php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51671 imagefill does not work correctly for small images
Submitted: 2010-04-27 09:22 UTC Modified: 2010-04-28 10:24 UTC
From: a dot schilder at gmx dot de Assigned: pajoye (profile)
Status: Closed Package: GD related
PHP Version: 5.3.2 OS: Windows XP SP3
Private report: No CVE-ID: None
 [2010-04-27 09:22 UTC] a dot schilder at gmx dot de
Description:
------------
I try to use imagefill() with an image that has a width of one pixel, but it does not work. For larger image it works as expected.

Test script:
---------------
// image 1
$image = imagecreatetruecolor(50, 50);
$white = imagecolorallocate($image, 255, 255, 255);
imagefill($image, 0, 0, $white);
imagegif($image, __DIR__ . '/50x50.gif');

// image 2
$image = imagecreatetruecolor(1, 50);
$white = imagecolorallocate($image, 255, 255, 255);
imagefill($image, 0, 0, $white);
imagegif($image, __DIR__ . '/1x50.gif');

Expected result:
----------------
1) White image, 50x50 pixel.

2) White image, 1x50 pixel.

Actual result:
--------------
1) White image, 50x50 pixel.

2) Image, 1x50 pixel, with the first two pixels (0/0, 1/0) in white, the rest in the default color (black).

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-27 09:52 UTC] pajoye@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: pajoye
 [2010-04-27 13:11 UTC] a dot schilder at gmx dot de
I also tested it with imagecreate() instead of imagecreatetruecolor() and then it worked. Although it's said in the docs that imagecreatetruecolor() does not work with gif images, that's not true - it works in all cases, except in this example (see also bug #51414 for this doc problem).

The code is taken from a class that creates an image and outputs it in different formats - so imagecreatetruecolor() has to be used, because the output format is not known on image creation.
 [2010-04-27 13:14 UTC] pajoye@php.net
-Status: Assigned +Status: Feedback
 [2010-04-27 13:14 UTC] pajoye@php.net
Which part of the doc says that you can't create gif from true color images?

As far as I remember the doc is about which buffer format is created when a script load a GIF image. imagecreatefromgif always returns a palette image.

Also this question is unrelated to this problem.
 [2010-04-27 19:57 UTC] a dot schilder at gmx dot de
I think you mean the doc of another function?

The doc for "imagecreatetruecolor" says "This function will not work with GIF file formats." in the notes section (see: http://php.net/manual/en/function.imagecreatetruecolor.php).

The note in the docs should be unrelated to this bug, because IMHO it doesn't make sense - but as I also mentioned, the problem disappeared after replacing "imagecreatetruecolor" with "imagecreate", so there seems to be a relation to the used function.
 [2010-04-27 20:40 UTC] pajoye@php.net
I removed the note in the doc.
 [2010-04-27 20:40 UTC] pajoye@php.net
-Status: Feedback +Status: Assigned
 [2010-04-28 10:23 UTC] pajoye@php.net
Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revision&revision=298693
Log: - Fix #51671, imagefill does not work correctly for small images
 [2010-04-28 10:24 UTC] pajoye@php.net
-Status: Assigned +Status: Closed
 [2010-04-28 10:24 UTC] pajoye@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 05:01:29 2024 UTC