|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-05-31 14:53 UTC] cmb@php.net
-Status: Open
+Status: Feedback
[2015-05-31 14:53 UTC] cmb@php.net
[2015-06-01 15:27 UTC] cmb@php.net
-Status: Feedback
+Status: Not a bug
-Assigned To:
+Assigned To: cmb
[2015-06-01 15:27 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 22 15:00:02 2025 UTC |
Description: ------------ Two PNG files handled the same way, and one works with transparency and the other does not. The included code cuts a transparent "hole" in each file, but only one has the red back ground show through. I'll be happy to look into patching it, but I need to confirm it's a problem. It show this behavior on all of my machines, but I cannot determine if it's a PHP or a libgd issue. Test script: --------------- <?php sometimesworks("https://maps.googleapis.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=12&size=400x400&maptype=hybrid", "google"); sometimesworks("https://lh4.googleusercontent.com/UQvV_dpBa3_rVf25pvLXKD3OwzF4FtPnHBHkzdWqjCQ5mlFqcFfId9echIgDMv_xYRRYzLaKEXphw7g=w2447-h1106", "myhouse"); function sometimesworks($p_image, $p_prefix) { $image_top =imagecreatefrompng($p_image); $brush = imagecolorallocate($image_top, 0, 0, 0); //create a black brush imagefilledpolygon($image_top, explode(",", "10,10, 120,22, 80,280, 200, 191"), 4, $brush); //fill a polygon imagecolortransparent($image_top, $brush); //turn the black to be transparent imagepng($image_top, './'.$p_prefix.'.transparent.png'); //save the file to confirm that it is working. //create a big red square $image_bottom = imagecreatetruecolor(imagesx($image_top), imagesy($image_top)); $red = imagecolorallocate($image_bottom, 255, 0, 0); imagefill($image_bottom, 0, 0, $red); imagepng($image_bottom, './'.$p_prefix.'.red.png'); //merge the top onto the bottom. $out = imagecreatetruecolor(imagesx($image_top), imagesy($image_top)); imagecopy($out, $image_bottom, 0, 0, 0, 0, imagesx($image_top), imagesy($image_top)); imagecopy($out, $image_top, 0, 0, 0, 0, imagesx($image_top), imagesy($image_top)); imagepng($out, './'.$p_prefix.'.out.png'); } Expected result: ---------------- Both files should have red seen through the alpha mask holes in the PNG images. Actual result: -------------- One file shows transparency, and the other does not; however, the code is identical as function. Only the files are different.