PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Feb 23, 2018 10:55 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: imagecolorset
PostPosted: Wed Feb 18, 2009 6:54 am 
Offline
Forum Newbie

Joined: Thu Jan 15, 2009 8:22 am
Posts: 4
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?


Top
 Profile  
 
 Post subject: Re: imagecolorset
PostPosted: Wed Feb 18, 2009 3:06 pm 
Offline
Forum Regular
User avatar

Joined: Mon Feb 11, 2008 5:22 am
Posts: 613
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group