Bug #66005 [Opn->Ana]: imagecopy does not support 1bit transparency on truecolor images

From: Date: Sun, 21 Aug 2016 13:34:25 +0000
Subject: Bug #66005 [Opn->Ana]: imagecopy does not support 1bit transparency on truecolor images
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203451@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66005&edit=1 ID: 66005 Updated by: cmb@php.net Reported by: andreas dot ringlstetter at gmail dot com Summary: imagecopy does not support 1bit transparency on truecolor images -Status: Open +Status: Analyzed Type: Bug Package: GD related Operating System: Linux 3.11.6-1-ARCH x86_64 PHP Version: 5.5.5 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: This bug had been fixed in libgd as of 2.1.0-alpha1[1], but the fix had not been propagated to PHP's bundled libgd. [1] <https://github.com/libgd/libgd/commit/daac285c> Previous Comments: ------------------------------------------------------------------------ [2013-10-30 18:41:32] andreas dot ringlstetter at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=66005&edit=1

« previous php.bugs (#203451) next »