PHP Developers Network
http://forums.devnetwork.net/

imagecolorset
http://forums.devnetwork.net/viewtopic.php?f=40&t=95473
Page 1 of 1

Author:  bubs81 [ Wed Feb 18, 2009 6:54 am ]
Post subject:  imagecolorset

Hi,

Can anyone see what is wring with this code?

Header("Content-type: image/jpg");
$imgname = "sketch.jpg";
$im = imagecreatefromjpeg($imgname);
$index = imagecolorclosest($im, 0,0,0); // get black
imagecolorset($im,$index,255,255,255); // set to white
imagepng($im);
imagedestroy($im);

I'm expecting the black color in the image to be replaced by white. All I get is the same image (looking un-edited). Any ideas?

Author:  greyhoundcode [ Wed Feb 18, 2009 3:06 pm ]
Post subject:  Re: imagecolorset

Not 100% about this but I suspect that it needs to be an indexed image, and perhaps the GD library is treating the image as true colour?

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/