|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2021-08-01 21:30 UTC] 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. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 23:00:02 2025 UTC |
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>