Issue
I guess I should be able to use GD to brighten or darken an image in PHP but don't find any info on it. Isn't that possible?
Solution
You can use the imagefilter
function provided by PHP5 and up.
bool imagefilter ( resource $image , int $filtertype [, int $arg1 [, int $arg2 [, int $arg3 [, int $arg4 ]]]] )
You should be using the IMG_FILTER_BRIGHTNESS
with a value from -255
to 255
to brighten/darken the image.
Example from the manual
<?php
$im = imagecreatefrompng('sean.png');
if($im && imagefilter($im, IMG_FILTER_BRIGHTNESS, 20))
{
echo 'Image brightness changed.';
imagepng($im, 'sean.png');
imagedestroy($im);
}
else
{
echo 'Image brightness change failed.';
}
?>
Answered By - Murf Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.