开发者

Merging Transparent PNGs results in inconsistent black dots

开发者 https://www.devze.com 2023-02-15 16:39 出处:网络
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 follo

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开发者_JAVA技巧.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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号