ID: 38764 User updated by: markg852 at hotmail dot com Reported By: markg852 at hotmail dot com Status: Bogus Bug Type: GD related Operating System: Windows XP, linux PHP Version: 5.1.6 Assigned To: pajoye New Comment:
@ [EMAIL PROTECTED] i even tested the 6.0.0-dev snapshot and it still has the exact same issue. @ [EMAIL PROTECTED] tested your suggestion and the result is still exactly the same. and just to be sore.. i`m talking about the QUALITY!!! that`s just different.. just look at the image i supplied in the first image. Could this be a bug in GD itself (so not php`s fault) or in php_gd.dll ? Previous Comments: ------------------------------------------------------------------------ [2006-09-09 22:16:22] [EMAIL PROTECTED] doh, submit too quickly all you have to do: imagecolortransparent($thumb, 0); imagealphablending($thumb, false); the fist to set the bgd color, the second function to keep the alpha information while copying (no blend ops). ------------------------------------------------------------------------ [2006-09-09 22:13:18] [EMAIL PROTECTED] There is no bug. You copy an image to a another image. The destination image has no transparent color defined. True color images are "filled" with black by default, that's why you see black instead of the transparent color. short version: all you need to do is: ImageColorTransparent($thumb, 0); ------------------------------------------------------------------------ [2006-09-09 21:51:58] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows: http://snaps.php.net/win32/php5.2-win32-latest.zip ------------------------------------------------------------------------ [2006-09-09 21:47:45] markg852 at hotmail dot com The bug is in imagecopyresampled() AND imagecopyresized()!! ------------------------------------------------------------------------ [2006-09-09 21:45:27] markg852 at hotmail dot com Description: ------------ This bug can be found when trying to make a thumbnail from a url (example: http://promote.opera.com/logos/Opera5_t.png) the png isn`t even transperant anymore unless these 3 lines of code are also added: $background = imagecolorallocate($thumb, 0, 0, 0); ImageColorTransparent($thumb, $background); // make the new temp image all transparent imagealphablending($thumb, false); // turn off the alpha blending to keep the alpha channel i tried everything i could thing of but the quality stays different.. What the code below does is the following: 1. It downloaded the opera logo png image and makes a thumbnail of the URL!! 2. (after hitting F5) the code will make another thumbnail from the downloaded full scale image. 3. (after hitting F5 2nd time) the code will show both thumbnails and look at the quality difference!! and without the 3 lines posted above the "ugly" image has a black background!! Reproduce code: --------------- <?php // Error Reporting error_reporting(E_ALL); // File and new size if (file_exists('thumb_van_url.png') AND file_exists('thumb_van_path.png')) { echo '<img src="./thumb_van_url.png"></img>'; echo "Thumbnail made from URL"; echo '<img src="./thumb_van_path.png"></img>'; echo "This one is made from a PATH"; exit; } elseif (file_exists('./Opera5_t.png')) { $filename = 'Opera5_t.png'; $mid = 'van_path'; } else { $filename = 'http://promote.opera.com/logos/Opera5_t.png'; $mid = 'van_url'; imagepng(imagecreatefrompng('http://promote.opera.com/logos/Opera5_t.png'), 'Opera5_t.png'); } $percent = 0.1; // Get new sizes list($width, $height) = getimagesize($filename); $newwidth = $width * $percent; $newheight = $height * $percent; // Load $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefrompng($filename); $background = imagecolorallocate($thumb, 0, 0, 0); ImageColorTransparent($thumb, $background); // make the new temp image all transparent imagealphablending($thumb, false); // turn off the alpha blending to keep the alpha channel // Resize imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); // Output imagepng($thumb, 'thumb_' . $mid . '.png'); echo '<img src="./thumb_' . $mid . '.png"></img>'; // Content type // header('Content-type: image/png'); // readfile('thumb_' . $mid . '.png'); ?> Expected result: ---------------- http://img393.imageshack.us/img393/2796/uitkomstvc4.png ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38764&edit=1
