Author Topic: GD Newbie Question  (Read 411 times)

0 Members and 1 Guest are viewing this topic.

Offline VikRTopic starter

  • Irregular
  • Posts: 21
    • View Profile
GD Newbie Question
« on: March 15, 2010, 05:00:56 PM »
This is my first time using GD. I've got an image with a transparent background. All the other pixels are the identical color (#8bc4ed). I want to replace all those pixels with a given color, say #CCC5AC. Here's my code that doesn't work yet:

$filepath $_SERVER['DOCUMENT_ROOT'] . "/images/source_image.gif"
$image imagecreatefromgif($filepath); 

$indexToSearchFor imagecolorat($image30); 
imagecolorset($image$indexToSearchFor204197172); 

$filepath $_SERVER['DOCUMENT_ROOT'] . "/images/target.gif"
imagegif ($image,  $filepath);


The output image is identical to the input image - no color is replaced.

What is the correct way to do this?

Here is a link to the image I'm trying to change in case you can tell anything from it: http://www.generalwebapps.com/images/header_2_selected.gif.

Thanks very much to all in advance for any info!