> I have a map of the world with all countries. I have > 250 maps of the same size as png where only one > country is black, rest is transp. > Now I neeed to set this country color to blue or red > to indicate a special spot. > I just don't want to save the same map double or tripple.
Good! Makes much more sense. Call this like <img src='country.php?cty=germany&col=255,0,0'> (functions in bold you will have to write yourself) ====== country.php =========== <?php Header("Content-type: image/png"); $mapURL = '\images\countrymask\'.MAKESAFE($cty); // load image $img = ImageCreateFromPNG($mapURL.$mapname) or MAKEDEFAULTIMAGE(); // parse new desired color $newcolor = split(',', $col); // find black $oldcolor = ImageColorResolve($img, 0, 0, 0); // change to new color ImageColorSet($img, $oldcolor, $newcolor[0], $newcolor[1], $newcolor[2]); // ... and return result ImagePNG($img); ?> Note that depending on how much this gets used, it may indeed be better (faster, less computationally intensive) in the long run to use multiple image copies, ie country_red.png, country_blu.png etc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php