php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cmb@php.net
New email:
PHP Version: OS:

 

 [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 commitsRelated reports
 [2016-08-21 15:26 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2016-08-21 15:57 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d65adac2be2c9b32d9ad9bd00399c99d492502f5
Log: Fix #72913: imagecopy() loses single-color transparency on palette images
 [2016-08-21 15:57 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 [2016-10-17 10:09 UTC] bwoebi@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d65adac2be2c9b32d9ad9bd00399c99d492502f5
Log: Fix #72913: imagecopy() loses single-color transparency on palette images
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC