imagecopy() loses single-color transparency on palette images
| Bug #72913 | imagecopy() loses single-color transparency on palette images | ||||
|---|---|---|---|---|---|
| Submitted: | 2016-08-21 15:26 UTC | Modified: | 2016-08-21 15:26 UTC | ||
| From: | cmb@php.net | Assigned: | cmb (profile) | ||
| Status: | Closed | Package: | GD related | ||
| PHP Version: | 7.0.10 | OS: | * | ||
| Private report: | No | CVE-ID: | None | ||
[2016-08-21 15:26 UTC] cmb@php.net
Description:
------------
When copying a single-color transparency true-color image onto a
palette image with imagecopy(), the transparency is lost, if
compiled against the bundled libgd. With external libgd it works
fine.
That bug affects all currently supported PHP versions.
Test script:
---------------
<?php
$base64 = 'iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAIAAACRXR/mAAAABnRSTlMAAAAAAABu'
. 'pgeRAAAAVklEQVRYw+3UQQqAMBAEwf3/p9eTBxEPiWAmWMU8oGFJqgAAuOpzWTX3'
. 'xQUti+uRJTZ9V5aY1bOTFZLV7yZr9zt6ibv/qPXfrMpsGipbIy7oqQ8AYJED1plD'
. 'y5PCu2sAAAAASUVORK5CYII=';
$src = imagecreatefromstring(base64_decode($base64));
$dst = imagecreate(50, 50);
$transparent = imagecolorallocatealpha($dst, 255, 255, 255, 127);
imagealphablending($dst, false);
imagesavealpha($dst, true);
imagecopy($dst, $src, 0,0, 0,0, 50,50);
imagepng($dst, __DIR__ . '/test.png');
Expected result:
----------------
An image with red circle on a _transparent_ background.
Actual result:
--------------
An image with red circle on a _black_ background.
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2016-08-21 15:26 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
[2016-08-21 15:57 UTC] cmb@php.net
-Status: Assigned +Status: Closed