note 54118 added to function.imagefilltoborder
| From: | HenrikNyh at osu1 dot php dot net | Date: | Fri, 24 Jun 2005 08:26:36 +0000 |
| Subject: | note 54118 added to function.imagefilltoborder | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-90875@lists.php.net to get a copy of this message | ||
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
?>
----
Manual Page -- http://www.php.net/manual/en/function.imagefilltoborder.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54118
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54118&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54118&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54118&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54118&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54118&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54118&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54118&report=yes
Search -- http://master.php.net/manage/user-notes.php