ID: 33914 User updated by: me at thomaskeller dot biz Reported By: me at thomaskeller dot biz -Status: Bogus +Status: Open Bug Type: GD related Operating System: Linux 2.4 shared hosting PHP Version: 4.3.11 Assigned To: pajoye New Comment:
I have already provided a sample script, which is available on http://thomaskeller.biz/work/php/PHP_GIF/image.php, the source for this file is http://thomaskeller.biz/work/php/PHP_GIF/image.phps [0]. The test image which fails to be scaled is http://thomaskeller.biz/work/php/PHP_GIF/rose.gif As you can see here [0] the problematic code seems to be (shortened): <?php $idx = imagecolortransparent($im_src); if ($idx > -1) // transparent color found? { list($r, $g, $b) = imagecolorsforindex($im_src,$idx); $transColor = imagecolorexact($im_target, $r, $g, $b); imagecolortransparent($im_target, $transColor); } ?> where I try to receive the index of the transparent color of the original image, then find the rgb value of this color and finally create a new color on the target image using the rgb value and set it as transparent color. Previous Comments: ------------------------------------------------------------------------ [2005-07-29 17:19:21] [EMAIL PROTECTED] Provide a sample (and little) script and the images causing your problem may help. For what you said, the "random" color may in fact be the background. You have to set the transparent color yourself to the dest image. Short version, it's not a bug as far as I can tell now. I keep this bug to bogus, if you have a reproducable script with one image, turn it back to open. ------------------------------------------------------------------------ [2005-07-29 13:36:34] me at thomaskeller dot biz So, is this a bug in GD and you guys are not responsible or is it me or... a small sentence below the auto responder may have helped. ------------------------------------------------------------------------ [2005-07-29 10:47:50] [EMAIL PROTECTED] Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. ------------------------------------------------------------------------ [2005-07-29 02:37:12] me at thomaskeller dot biz Description: ------------ Following use case: Uploaded images should be shrinked to a certain size according to our guidelines. Works with jpeg/ png (not palette based) images without a problem, problems arise when used palette based (8bit) images. Resizing via imagecopyresampled/ imagecopyresize works only for images WITHOUT a transparency color set properly. If a transparency color is set in the image, the value of this color is just ignored and a random background color is applied to the "transparent" area. It makes no difference if the image is outputted as gif or 8bit png. If imagecopyresampled/imagecopyresized is called with the same width/height for the source and the target image, the transparency keeps intact. Reproduce code: --------------- I've setuped a few things on a test server: PHPInfo: http://thomaskeller.biz/work/php/PHP_GIF/info.php Testfile: http://thomaskeller.biz/work/php/PHP_GIF/image.php Testfile (Source): http://thomaskeller.biz/work/php/PHP_GIF/image.phps image.php loads http://thomaskeller.biz/work/php/PHP_GIF/rose.gif by default, but you can load an own gif file via URL like image.php?filename=http://your.server.com/file.gif The loaded image is per default resized to its double width/ height. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33914&edit=1