Bug #53154 [Opn->Ver]: Zero-height rectangle has whiskers

From: Date: Sun, 28 Jun 2015 20:15:09 +0000
Subject: Bug #53154 [Opn->Ver]: Zero-height rectangle has whiskers
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193973@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=53154&edit=1

 ID:                 53154
 Updated by:         cmb@php.net
 Reported by:        lbayuk at users dot sourceforge dot net
 Summary:            Zero-height rectangle has whiskers
-Status:             Open
+Status:             Verified
 Type:               Bug
 Package:            GD related
-Operating System:   Linux
+Operating System:   *
-PHP Version:        5.3.3
+PHP Version:        5.6.10
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

> Verified still there in PHP-5.6.10

Thanks for the reminder. :)

The issue is caused by two strange assignments[1] in the bundled
libgd. Interestingly this code has changed in libgd already two
years ago[2]. I can't find any regression when removing these two
assignments, but I'm puzzled why they're there in the first place.

[1] <http://lxr.php.net/xref/PHP_TRUNK/ext/gd/libgd/gd.c#2096>
[2] <https://github.com/libgd/libgd/commit/a3016ad01b762aa81534ed99ee2af976d45b800a>


Previous Comments:
------------------------------------------------------------------------
[2015-06-22 21:36:45] lbayuk at users dot sourceforge dot net

Verified still there in PHP-5.6.10

------------------------------------------------------------------------
[2010-10-25 21:31:01] lbayuk at users dot sourceforge dot net

Description:
------------
Using imagerectangle() to draw a rectangle that happens to have zero height results in a horizontal
line with small 'whiskers' at the ends. The whiskers extend up and down 1 pixel from the
line. This looks weird. This only happens with unit line thickness. It does not happen with zero
width rectangles, nor with imagefilledrectangle().

Note: Using PHP-bundled GD library.

Test script:
---------------
<?php
$img = imagecreate(400, 200);
$white = imagecolorallocate($img, 255, 255, 255);
$black = imagecolorallocate($img, 0, 0, 0);
$red = imagecolorallocate($img, 255, 0, 0);
imagestring($img, 4, 5, 5, "RECTANGLES", $black);
imagestring($img, 4, 150, 5, "Filled", $black);
imagestring($img, 4, 300, 5, "Unfilled", $black);
imagestring($img, 4, 5, 75, "Height=0", $black);
imagestring($img, 4, 5, 145, "Width=0", $black);
imagefilledrectangle($img, 150, 95, 200, 95, $black);
imagerectangle($img, 300, 95, 350, 95, $black);
imagefilledrectangle($img, 175, 125, 175, 175, $black);
imagerectangle($img, 325, 125, 325, 175, $black);
imageellipse($img, 325, 95, 90, 50, $red); // Circle the bad one
imagepng($img);

Expected result:
----------------
In all 4 cases, a single line should be drawn.

Actual result:
--------------
The upper right case (zero height, unfilled rectangle) has whiskers at the ends.


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=53154&edit=1


Thread (9 messages)

« previous php.bugs (#193973) next »