Colorize an image in PHP

Description

The following code shows how to colorize an image.

Example


<?php//from  w ww  .  j  av a  2 s. com
$im = imagecreatefrompng('test.png');

/* R, G, B, so 0, 255, 0 is green */
if($im && imagefilter($im, IMG_FILTER_COLORIZE, 0, 255, 0))
{
    echo 'Image successfully shaded green.';

    imagepng($im, 'philip.png');
    imagedestroy($im);
}
else
{
    echo 'Green shading failed.';
}
?>

The code above generates the following result.

Colorize an image in PHP




















Home »
  PHP Tutorial »
    Image »




Color
Create
Font
Operation
Shape
Text