Bug #55545 [NEW]: imagettftext() antialiasing depends on color allocation order
| From: | phpbugs at exaseb dot de | Date: | Wed, 31 Aug 2011 03:27:58 +0000 |
| Subject: | Bug #55545 [NEW]: imagettftext() antialiasing depends on color allocation order | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-163168@lists.php.net to get a copy of this message | ||
From:
Operating system: Windows XP, 32bit
PHP version: 5.3.8
Package: GD related
Bug Type: Bug
Bug description:imagettftext() antialiasing depends on color allocation order
Description:
------------
GD version: bundled (2.0.34 compatible)
Using a negative $color parameter for imagettftext() does not produce
antialiased text if the image is created with imagecreate() (as opposed to
imagecreatetruecolor()) and the text color is the first color allocated.
I have not looked into this but I suppose the first color recieves an index
of 0, thus a test for <0 always fails and antialiasing is never used. Using
a negative color index is a really awful hack. imagettftext() should
receive an additional parameter instead.
Test script:
---------------
<?php
$im = imagecreate(210, 50);
$background_color = imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 255, 255, 255);
imagefilledrectangle($im, 0, 0, 209, 49, $background_color);
imagettftext($im, 20, 0, 10, 20, -$text_color, "arial.ttf",
"Antialiasing");
imagetruecolortopalette($im, FALSE, 255);
imagepng($im, "as_intended.png");
imagedestroy($im);
$im = imagecreate(210, 50);
$text_color = imagecolorallocate($im, 255, 255, 255);
$background_color = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 209, 49, $background_color);
imagettftext($im, 20, 0, 10, 20, -$text_color, "arial.ttf",
"Antialiasing");
imagetruecolortopalette($im, FALSE, 255);
imagepng($im, "not_as_intended.png");
imagedestroy($im);
?>
Expected result:
----------------
The script should produce two identical PNG images with not antialiased
text.
Actual result:
--------------
The image as_intended.png shows the expected result whereas
not_as_intended.png shows antialiased text where the text should not be
antialiased.
--
Edit bug report at https://bugs.php.net/bug.php?id=55545&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=55545&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=55545&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=55545&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=55545&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55545&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=55545&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=55545&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=55545&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=55545&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=55545&r=support
Expected behavior: https://bugs.php.net/fix.php?id=55545&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=55545&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=55545&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=55545&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=55545&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=55545&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=55545&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=55545&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=55545&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=55545&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=55545&r=mysqlcfg