php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20451 imagepstext generates weird images since PHP 4.3.0-pre1
Submitted: 2002-11-15 17:08 UTC Modified: 2002-12-03 21:47 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: fdsoft at pganet dot com Assigned:
Status: Closed Package: GD related
PHP Version: 4.3.0RC1 OS: Red Hat Linux 7.3
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: fdsoft at pganet dot com
New email:
PHP Version: OS:

 

 [2002-11-15 17:08 UTC] fdsoft at pganet dot com
I use the GD extension to generate .png images automatically for displaying text with a specific Type1 font, using the imagepstext function.

PHP 4.2.x generates these images perfectly, while using PHP 4.3.0-pre1 and -pre2 results in some really weird output.

Here are some examples to show the difference:
http://web.axelero.hu/fdsoft/temp/images.html

There actually seems to be two seperate problems:
- the characters are not lined up properly any more
- anti-aliasing produces weird output (most pronounced when the resulting image is viewed in IE 6, less ugly but still noticeable in Mozilla)

The anti-aliasing problem pretty much goes away if I recompile PHP 4.3.0-pre2 to use my old GD 1.8.4 (from the Red Hat rpms) instead of PHP's built-in version of GD.

The php code in question:

<code>
$fonthandle=@imagepsloadfont(FONT_PATH.$font);
imagepsencodefont($fonthandle, FONT_PATH.'IsoLatin1.enc');

$im = imagecreate($imgwidth, $imgheight);
$background_color = imagecolorallocate ($im, $background[0], $background[1], $background[2]);
imagecolortransparent($im, $background_color);
$text_color = imagecolorallocate ($im, 
	$color[0], $color[1], $color[2]);
imagepstext($im, $txt, $fonthandle, $size, $text_color, $background_color,$x, $y, 0, 0, 0, 16);
imagepng($im);
</code>



Finally my php configure options:

<code>
--host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --target=i386-redhat-linux-gnu --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --prefix=/usr --with-config-file-path=/etc --with-exec-dir=/usr/bin --enable-force-cgi-redirect --disable-debug --enable-dbg=shared --with-dbg-profiler --enable-pic --disable-rpath --enable-inline-optimization --with-bz2 --with-db3 --with-curl=/usr/local --with-freetype-dir=/usr --with-png-dir=/usr --with-gd=shared --enable-gd-native-ttf --with-ttf --with-t1lib
--with-gettext=shared --with-ncurses --with-iconv=shared --with-jpeg-dir=/usr --with-openssl --with-png --with-regex=system --with-expat-dir=/usr --with-zlib --with-layout=GNU --enable-bcmath --enable-exif --enable-ftp
--enable-sockets --enable-sysvsem --enable-sysvshm --enable-discard-path --enable-track-vars --enable-trans-sid
--enable-wddx --enable-exif --enable-memory-limit --enable-bcmath --enable-shmop --enable-versioning --enable-calendar --enable-dbx --enable-dio --enable-mcal --with-readline  --with-mysql=shared,/usr --with-sybase-ct=shared,/usr/local --with-pgsql=shared --with-unixODBC=shared --with-interbase=shared,/opt/interbase
--with-imap=shared --with-imap-ssl --with-kerberos=/usr/kerberos --with-zip=shared --with-pspell=shared --with-ming=shared --with-pdflib=shared --with-pear=/usr/share/pear --with-apxs=/usr/sbin/apxs
</code>

The '--with-gd=shared' option was changed to '--with-gd=shared,/usr' to produce the "without built-in GD" output.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-15 21:18 UTC] sniper@php.net
Can you please provide a complete and working example script? This one you added does not work.

--Jani

 [2002-11-15 23:03 UTC] fdsoft at pganet dot com
Yes, certainly, here's the whole code and the font in question:

http://web.axelero.hu/fdsoft/temp/fonttest.zip

There are some really ugly calculations and a brute force way of determining the size of the would-be image in the code, since imagepsbbox function didn't quite work well either. At least that was the case with PHP 4.2.x, and since I added this workaround, I've yet to re-check that in 4.3.0.

Now for this weird output problem I can't figure out a workaround, and this was absolutely perfect with PHP 4.2.x., hence my bug report.
It's likely that the fonts I use are of low quality or buggy or both; but that doesn't change the fact that this was working nicely with the older versions.

Thanks
 [2002-11-15 23:06 UTC] fdsoft at pganet dot com
I forgot to mention that I use t1lib 1.3.1 from the following address to enable the imageps* functions in the gd extension (--with-t1lib configure option):

ftp://sunsite.unc.edu/pub/Linux/libs/graphics/t1lib-1.3.1.tar.gz
 [2002-11-16 13:44 UTC] fdsoft at pganet dot com
Reopening the report
 [2002-11-18 15:07 UTC] fdsoft at pganet dot com
Verified that the problem still exists in PHP 4.3.0RC1.
 [2002-12-03 21:47 UTC] pajoye@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Hello,

I have downloaded your script (which is bugged, the path to the font is wrong generated, removed +1 :) ), I do not see any problem with the font (except the fact, as you said, it s an ugly font). I compared the result with a font viewer as well as a paint program, no problem occurs. Tests made with RC2, RC1 and HEAD.

pierre
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 13:01:33 2025 UTC