note 54118 deleted from function.imagefilltoborder by cmb

From: Date: Sun, 04 Aug 2019 12:23:29 +0000
Subject: note 54118 deleted from function.imagefilltoborder by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211819@lists.php.net to get a copy of this message
Note Submitter: Henrik Nyh ---- Reply to pritm (.a.t.) mail (.d.0.t.) ru below. I had a similar problem and solved it thus: I had to reduce the number of colors on the image I was using. It appeared to be a black and white map, but contained about 50 shades of almost black and almost white. I reduced this to two colors only (also going from JPG to GIF) so that the borders as well as the areas to be filled each were of a consistent shade. Additionally, it did not work when I specified border colors as black (0,0,0), even though they seem to be of this exact shade in the map file. Instead, I used ImageColorAt() to pick the border color, and now everything seems to work. Image: http://henrik.nyh.se/dump/map/europe.gif In action: http://henrik.nyh.se/dump/map/map.html Source: <?php $map = "europe.gif"; $img = ImageCreateFromGIF($map); // Colors $border = ImageColorAt ($img, 416, 111); // Get color of borders - apparently (0,0,0) won't work $red = ImageColorAllocate($img, 255, 0, 0); $green = ImageColorAllocate($img, 0, 255, 0); // Fill ImageFillToBorder($img, 440, 100, $border, $red); // Sweden ImageFillToBorder($img, 250, 290, $border, $green); // Great Britain // Output image as PNG header("Content-type: image/png"); ImagePNG($img); ImageDestroy($img); // Free memoryu ?>

« previous php.notes (#211819) next »