php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20073 Anti-aliasing of text fails when writing it to trueColor image
Submitted: 2002-10-24 14:57 UTC Modified: 2002-10-25 11:06 UTC
From: millz at incogen dot com Assigned:
Status: Closed Package: GD related
PHP Version: 4.2.3 OS: Solaris 9
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: millz at incogen dot com
New email:
PHP Version: OS:

 

 [2002-10-24 14:57 UTC] millz at incogen dot com
Because of color-space issues that came up with using the simple 8-bit imageCreate() method, I have moved to using the imageCreateTrueColor() function.  

If I create and image using imageCreateTrueColor, and then try to write text onto it using ImageTTFText, the text will not be anti-aliased.  I have negated the color index being passed into ImageTTFText as an attempt to fix the issue, but there was no change.



Configure line
----------------
./configure --prefix=/homespace/geneport4/system/core/php --enable-wddx -enable-sigchild --enable-trans-sid 
--enable-inline-optimization --with-apxs=/homespace/geneport4/system/core/apache/bin/apxs --without-mysql --with-oci8 
--enable-track-vars --enable-gd-native-ttf --with-gd=/homespace/geneport4/system/core 
--with-freetype-dir=/homespace/geneport4/system/core --with-png-dir=/homespace/geneport4/system/core 
--with-zlib=/homespace/geneport4/system/core

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-25 01:19 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip



Use your original configure line, but don't pass '--with-gd' any path. (This will make it use the bundled GD library)

If this fails too, please provide a short example script
which can be used to reproduce this.

 [2002-10-25 09:54 UTC] millz at incogen dot com
OK, we downloaded and compiled the snapshot as recommended..

Then we made this test script and called it like this:

http://<SERVER>/php/testTrueColorImg.php?asd=test.png 

so that I.E would see the .png at the end of the URL (seems to help it understand that this is a png better sometimes)
-------
<?php

// create the image
$image = ImageCreateTrueColor(200,200);
$bg = ImageColorAllocate($image,0,0,0);
$tx = ImageColorAllocate($image,255,128,128);
$white = ImageColorAllocate ($image, 255, 255, 255);
ImageFilledRectangle($image,0,0,200,200,$bg);
//ImageString($image,3,70,90,"it works !",$tx);
ImageTTFText ($image, 20, 0, 10, 20,$white, "/homespace/geneport4/fonts/Arial.ttf","Testing...");
// send the image
header("content-type: image/png");
ImagePNG($image);
?>

-------
It seemed to help the text look a little better, but not as good as it does with an 8-bit image.  

Another note, the image appears to look better in IE 5.5 than it does in I.E. 6.0.sp1 but this may just be related to that fact that we tested this on different computers/monitors.
 [2002-10-25 09:59 UTC] millz at incogen dot com
I would also like to say that we found another way to bypass this issue.  

The color space problem comes up when we superimpose (imagecopy) different images together dynamically - we are adding button images to a 8-bit background image.  

We are able to avoid this issue by limiting the color table size for each image involved.  This solution should work for most cases.  

Still, problems would arise if:

1) we need to combine multiple images with non-overlapping, large color tables
2) the quality of the base image requires the full 256 colors to look decent
 [2002-10-25 11:06 UTC] rasmus@php.net
This stuff is all fixed in the bundled version of GD in PHP 4.3.  Use --with-gd  without any path when you build 4.3.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC