Bug #81321 [Opn->Nab]: incorrect image on save
| From: | cmb@php.net | Date: | Mon, 02 Aug 2021 08:36:47 +0000 |
| Subject: | Bug #81321 [Opn->Nab]: incorrect image on save | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-235521@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81321&edit=1
ID: 81321
Updated by: cmb@php.net
Reported by: andrei at anleaf dot com
Summary: incorrect image on save
-Status: Open
+Status: Not a bug
Type: Bug
-Package: *Graphics related
+Package: GD related
Operating System: CentOs 7.9
PHP Version: 7.4.22
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
You need to preserve the alpha channel explicitly by calling
imagesavealpha()[1], e.g.
<?php
$im = imagecreatefrompng("orig.png");
imagesavealpha($im, true);
imagepng("new.png");
?>
[1] <https://www.php.net/imagesavealpha>
Previous Comments:
------------------------------------------------------------------------
[2021-08-02 08:00:07] andrei at anleaf dot com
One more png with the problem
https://www.dropbox.com/s/1kuirhjgvnfcohs/logo_orig-2.png?dl=0
Its conversion result (wrong) is here
https://www.dropbox.com/s/98iklpacpm5ppot/logo-orig-2_new.png?dl=0
------------------------------------------------------------------------
[2021-08-01 21:30:16] andrei at anleaf dot com
Description:
------------
problem with opening and saving some png images using imagecreatefrompng() and then save it using
imagepng($image,$file).
Image opens OK but when saved, the resulting image has broken alpha channel.
Happens with some png images.
Input image to test is here https://www.dropbox.com/s/c6ne72bobrt2iz9/logo_orig.png?dl=0
Resulting image with problem is here https://www.dropbox.com/s/xs4b4bv6208hiua/logo_new.png?dl=0
Test script:
---------------
$im = imagecreatefrompng("logo_orig.png");
imagepng($im,"logo_new.png");
imagedestroy($im);
Expected result:
----------------
saved image should look the same as an input image
Actual result:
--------------
saved image is completely distorted.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81321&edit=1