Bug #69734 [Fbk->Nab]: transparency sometimes works for PNGs

From: Date: Mon, 01 Jun 2015 15:27:41 +0000
Subject: Bug #69734 [Fbk->Nab]: transparency sometimes works for PNGs
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193050@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69734&edit=1 ID: 69734 Updated by: cmb@php.net Reported by: degnan dot 68k at gmail dot com Summary: transparency sometimes works for PNGs -Status: Feedback +Status: Not a bug Type: Bug Package: GD related Operating System: MacOS PHP Version: 5.4.41 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: degnan dot 68k at gmail dot com wrote: | The PNG file seems to have had bad header information, and I've | confirmed that it is not a PHP problem or GD problem. Previous Comments: ------------------------------------------------------------------------ [2015-05-31 14:53:03] cmb@php.net I can't access the second image (403 Forbidden). Please double-check the URL, and perhaps upload the image somewhere else. ------------------------------------------------------------------------ [2015-05-30 20:43:00] degnan dot 68k at gmail dot com 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. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69734&edit=1

« previous php.bugs (#193050) next »