1

I'm merging some transparent PNGs in PHP with GD. I have a bunch of numbers done up on a transparent background that I put together onto a final image. Running the script on one server with the following GD config:

GD Support => enabled
GD Version => bundled (2.0.34 compatible)
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.2.1
GIF Read Support => enabled
GIF Create Support => enabled
JPEG Support => enabled
libJPEG Version => 6b
PNG Support => enabled
libPNG Version => 1.2.10
WBMP Support => enabled
XPM Support => enabled
XBM Support => enabled

It works perfectly. My result looks something like:

http://upload.nucleardog.com/rc97

When I run the same script on another server, gd configured as such:

GD Support => enabled
GD Version => 2.0
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.4.2
T1Lib Support => enabled
GIF Read Support => enabled
GIF Create Support => enabled
JPEG Support => enabled
libJPEG Version => 6b
PNG Support => enabled
libPNG Version => 1.2.44
WBMP Support => enabled

I end up with something that looks more like:

http://upload.nucleardog.com/19c3

Does anyone have any idea why the transparency is failing to copy in such an inconsistent manner? Different copies of the same number (identical source image - not reloaded in between) copied into different places in the result image have a different pattern in the black pixels.

A copy of the script I'm using is available here for anyone that would like to dig through. It loads the numbers around line 69. It copies the numbers on to an intermediate image at 155-165. That intermediate step is copied onto the result image at 197-231.

Does anyone have any idea how I could fix the script on this specific server? Is it an issue with it not using the bundled GD?

Thanks for any ideas!

Edit: The machine with issues is running PHP 5.3.3:

adam:~$ php -v
PHP 5.3.3-1ubuntu9.3 with Suhosin-Patch (cli) (built: Jan 12 2011 16:07:38)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
adam:~/$

The one without is running the same:

adam@server1 [~]$ php-cli -v
PHP 5.3.3 (cli) (built: Aug 18 2010 16:36:42)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
    with the ionCube PHP Loader v3.3.20, Copyright (c) 2002-2010, by ionCube Ltd.
    with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
adam@server1 [~]$

The one with the problems is a Ubuntu box. Both php and gd were installed from apt (php5 and php5-gd).

hakre
  • 193,403
  • 52
  • 435
  • 836
NuclearDog
  • 142
  • 3
  • So the dates are a bit fuzzy, but it looks like GD *2.0* was released some time in 2002. PHP has bundled a version of GD since **4.3.0**, released in late 2002. The only way you'd ever see a non-bundled version of GD is if PHP was compiled against it on that machine... *and then you'd be dealing with a machine with libraries that haven't been patched in nine years.* Either `phpinfo` is wrong or the machine is horked. Or both. What's the PHP version in use on the horked machine? – Charles Mar 08 '11 at 07:13
  • The Debian `php5-gd` package relies on the *external* GD library. It's very likely that the Ubuntu one follows that pattern. So, it's clearly not going to be actually using 2.0 directly, but a more modern version. However, that still doesn't explain the behavior... – Charles Mar 11 '11 at 21:14

0 Answers0