Bug #66005 [NEW]: imagecopy does not support 1bit transparency on truecolor images

From: Date: Wed, 30 Oct 2013 18:41:32 +0000
Subject: Bug #66005 [NEW]: imagecopy does not support 1bit transparency on truecolor images
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182504@lists.php.net to get a copy of this message
From: andreas dot ringlstetter at gmail dot com Operating system: Linux 3.11.6-1-ARCH x86_64 PHP version: 5.5.5 Package: GD related Bug Type: Bug Bug description:imagecopy does not support 1bit transparency on truecolor images Description: ------------ --- From manual page: http://www.php.net/function.imagecopy --- imagecopy() fails to copy transparency from truecolor images if only transparent color is present, but no full alpha channel. It works as expected for pure palette images and images with full 32bit color depth, but not for the default mixed 24bit + transparency. imagecopymerge() with 100% handles this transparency type correct. Same test was successful on an outdated 5.4.6-1ubuntu1.4. GD Support enabled GD Version bundled (2.1.0 compatible) FreeType Support enabled FreeType Linkage with freetype FreeType Version 2.5.0 GIF Read Support enabled GIF Create Support enabled JPEG Support enabled libJPEG Version 8 PNG Support enabled libPNG Version 1.6.5 WBMP Support enabled XBM Support enabled WebP Support enabled Test script: --------------- <?php // Create target image $dest = imagecreatetruecolor(150, 50); // Fill with transparency $transparent = imagecolorallocatealpha($dest, 255, 255, 255, 127); imagealphablending($dest, false); imagefill($dest, 1, 1, $transparent); imagesavealpha($dest, true); imageistruecolor($dest); // true imagecolortransparent($dest); // == -1 // Palette image with transparent color $png_palette = imagecreatefromstring(base64_decode('iVBORw0KGgoAAAANSUhEUgAAADIAAAAyAgMAAABjUWAiAAAACVBMVEUAAAD/AAD///9nGWQeAAAAAXRSTlMAQObYZgAAAEFJREFUKM9jYBimIASZIxoagOAwhoaGInisQJ4DksJQJKWoPCAnNIQYHsgChBX4eMSbiddlqH5A9R+q39HCZWgDAFxFGyOrmguhAAAAAElFTkSuQmCCPHP')); imageistruecolor($png_palette); // false imagecolortransparent($png_palette); // != -1 // 24 bit with transparent color $png_24 = imagecreatefromstring(base64_decode('iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAIAAACRXR/mAAAABnRSTlMAAAAAAABupgeRAAAAVklEQVRYw+3UQQqAMBAEwf3/p9eTBxEPiWAmWMU8oGFJqgAAuOpzWTX3xQUti+uRJTZ9V5aY1bOTFZLV7yZr9zt6ibv/qPXfrMpsGipbIy7oqQ8AYJED1plDy5PCu2sAAAAASUVORK5CYII=')); imageistruecolor($png_24); // true imagecolortransparent($png_24); // != -1 // 32 bit with full alpha channel $png_full = imagecreatefromstring(base64_decode('iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAXklEQVRo3u3XMQrAIBBFwb3/pU2VwiJNIvjdzMD2PlBwqwAAAGajatxz9OGf5viA+KA3EXExXyKiYlqErIiIiBGSFLIyYmuMkO7Xy2MX4ovS/ONoH7Eh/m1nBwCASBe3VYeVaAy8PwAAAABJRU5ErkJggg==')); imageistruecolor($png_full); // true imageistruecolor($png_full); // == -1 imagecopy($dest, $png_palette, 0, 0, 0, 0, 50, 50); imagecopy($dest, $png_24, 50, 0, 0, 0, 50, 50); imagecopy($dest, $png_full, 100, 0, 0, 0, 50, 50); imagepng($dest, 'out.png'); Expected result: ---------------- 3 red circles on transparent background, same as in the source images. Actual result: -------------- Middle circle has black background, transparent color was ignored on truecolor image. -- Edit bug report at https://bugs.php.net/bug.php?id=66005&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66005&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66005&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66005&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=66005&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=66005&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=66005&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=66005&r=needscript Try newer version: https://bugs.php.net/fix.php?id=66005&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=66005&r=support Expected behavior: https://bugs.php.net/fix.php?id=66005&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=66005&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=66005&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=66005&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66005&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=66005&r=dst IIS Stability: https://bugs.php.net/fix.php?id=66005&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=66005&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=66005&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=66005&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=66005&r=mysqlcfg

« previous php.bugs (#182504) next »