合并透明 PNG 会导致黑点不一致

发布于 2024-10-20 22:30:30 字数 2397 浏览 1 评论 0原文

我正在将 PHP 中的一些透明 PNG 与 GD 合并。我在透明背景上完成了一堆数字,然后将它们放在一起形成最终图像。使用以下 GD 配置在一台服务器上运行脚本:

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

它运行良好。我的结果看起来像:

http://upload.nucleardog.com/rc97

当我运行相同的脚本时在另一台服务器上,gd 配置如下:

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

我最终得到的结果看起来更像是:

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

有谁知道为什么透明度无法以如此不一致的方式复制?复制到结果图像中不同位置的相同数量的不同副本(相同的源图像 - 之间未重新加载)在黑色像素中具有不同的图案。

任何想要深入研究的人都可以在此处获取我正在使用的脚本的副本。它加载第 69 行周围的数字。它将数字复制到 155-165 处的中间图像上。该中间步骤被复制到 197-231 处的结果图像上。

有谁知道如何修复该特定服务器上的脚本?不使用捆绑的GD有问题吗?

感谢您的任何想法!

编辑: 有问题的机器正在运行 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:~/$

没有问题的机器运行相同:

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 [~]$

有问题的机器是 Ubuntu 机器。 php 和 gd 都是从 apt 安装的(php5 和 php5-gd)。

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).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文