imagefill and imagefilltoborder not working for me
Posted: Fri Nov 16, 2007 12:20 pm
feyd | Please use
The result of that looks like this: laketest2.jpg
Second stab at code:
The result looks like this: laketest3.jpg
(It didn't matter whether I forced the border to black or picked the color from the image.)
Any suggestions? I know the border is solid because when I open the original in a program like Gimp and do a fill it works just fine.
TIA
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
So, here's the deal: I'm trying to fill an irregular shape with a color on the fly using php and gd. Pretty simple, no?
The starting image looks like this: [url=http://bozlax.is-a-geek.net/apache2-default/laketest.jpg]laketest.jpg[/url]
First stab at code is thusly:Code: Select all
#!/usr/bin/php
<?php
$im = imagecreatefromjpeg("laketest.jpg");
$blue = imagecolorallocate($im, 0, 0, 255);
imagefill($im, 168, 140, $blue);
imagejpeg($im, "laketest2.jpg");
imagedestroy($im);
?>Second stab at code:
Code: Select all
#!/usr/bin/php
<?php
$im = imagecreatefromjpeg("laketest.jpg");
// $border = imagecolorat($im, 258, 198); // should be black line
$border = imagecolorallocate($im, 0, 0, 0); // force to black
$blue = imagecolorallocate($im, 0, 0, 255);
imagefilltoborder($im, 168, 140, $border, $blue);
imagejpeg($im, "laketest3.jpg");
imagedestroy($im);
?>(It didn't matter whether I forced the border to black or picked the color from the image.)
Any suggestions? I know the border is solid because when I open the original in a program like Gimp and do a fill it works just fine.
TIA
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]