Page 1 of 1

Problem with gd library's function imageColorSet()

Posted: Mon Apr 18, 2011 3:16 am
by Jilimay
Hello everyone,

I am currently working on a project and I would like to be able to replace colors by other in
some pictures.

I used the following code but it just does nothing, and I have no clue why. What do I get wrong ?

Code: Select all

$imgPath = "pictures/basic.png";
$myPicture = imageCreateFromPng($imgPath);
$index = imageColorat($myPicture, 5, 5);
imagecolorset ($myPicture, $index, 255, 0, 0);
imagepng($myPicture, $imgPath);

I also uploaded the picture I am trying to modify.

Thanks for reading.

Re: Problem with gd library's function imageColorSet()

Posted: Tue Apr 19, 2011 2:36 am
by Jilimay
Hello again,

I haven't found any solution to this issue, even if I believe the trick to be related with the
picture's resolution. But I found a way to bypass the problem, by using another function : bool imagefill ( resource $image , int $x , int $y , int $color ).

It basically acts like the paint's filling function, and allow me to do what I wanted to.

Hope it will help someone else :) !