Possible bug in imagefill()
[email protected] (Joe Lencioni) Wed, 3 Mar 2010 13:22:32 -0600
| Newsgroups | php.gd.devel |
|---|---|
| Message-ID | <[email protected]> |
I noticed some strange behavior today with GD on one of my systems. We are
using PHP 5.3.1 on Linux. phpinfo() tells me that our version of GD is "bundled
(2.0.34 compatible)".
Here's the problem: when creating an image that is less than 4 pixels wide
and filling it with a color, only the top 2 rows of pixels are filled with
the desired color (see attached images).
This code produces the bad image for me:
<?php
$im = imagecreatetruecolor(3, 100);
$red = imagecolorallocate($im, 255, 0, 0);
imagefill($im, 0, 0, $red);
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
This code produces the image that is correctly filled:
<?php
$im = imagecreatetruecolor(4, 100);
$red = imagecolorallocate($im, 255, 0, 0);
imagefill($im, 0, 0, $red);
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
I tested this using imagejpeg() and imagegif() and the results are
effectively the same. In the meantime, I switched to using
imagefilledrectangle() instead of imagefill().
I don't know if this is helpful information, but this seems to work fine on
PHP 5.1.2 on Linux with GD bundled (2.0.28 compatible).
Please let me know if you need any more information or if there is anything
I can do to help.
Thanks!
Joe