gradient across a folder of images

images php coding issues or problems here.

Moderators: macek, egami, gesf

Veux
New php-forum User
New php-forum User
Posts: 1
Joined: Thu Jun 16, 2011 1:03 pm

gradient across a folder of images

Postby Veux » Thu Jun 16, 2011 1:10 pm

I am looking to apply a color tint across a series of thumbnails.

For example, 50 images which transition from red to blue from 1-50.
Can anyone set me in the right path?

Tacticious
New php-forum User
New php-forum User
Posts: 4
Joined: Mon Jun 27, 2011 1:06 pm

Re: gradient across a folder of images

Postby Tacticious » Mon Jun 27, 2011 2:57 pm

Untested. You'll need to tweak it to suit your directory/file structure. Change your height and width as well.

Code: Select all

//SET THIS!
//How visible will the tint be?
//In this case, 25%
$pct = 25;

$height = 32
$width = 32;

for($i=0;$i<=50;$i++){
    //The thumbnail
    $original = imagecreatefromjpg("images/image" . $i . ".jpg");

    //Initialize the overlay tint
    $overlay = imagecreatetruecolor($width, $height);

    //Increment integer
    $inc = 255 / 50;

    //Fade
    $red = 255 - ($inc * $i);
    $blue = $inc;

    $original = imagecopymerge($original, $overlay, 0, 0, 0, 0, $width, $height, $pct);
}


Return to “PHP coding => Images”

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest