note 44134 added to function.imagecopyresampled

From: Date: Thu, 15 Jul 2004 21:09:49 +0000
Subject: note 44134 added to function.imagecopyresampled
Groups: php.notes 
Request: Send a blank email to php-notes+get-73328@lists.php.net to get a copy of this message
In add to all the posts that describes how to create thumbnails: If you are trying to resample a png image with its transparency you need to do this workaround: <? ... $t_im = imageCreateTrueColor($t_wd,$t_ht); imageAntiAlias($t_im,true); imagealphablending($t_im, false); imagesavealpha($t_im,true); $transparent = imagecolorallocatealpha($t_im, 255, 255, 255, 0); for($x=0;$x<$t_wd;$x++) { for($y=0;$y<$t_ht;$y++) { imageSetPixel( $t_im, $x, $y, $transparent ); } } imageCopyResampled($t_im, $o_im, 0, 0, 0, 0, $t_wd, $t_ht, $o_wd, $o_ht); imagePNG($t_im, $image_name); ... ?> The alphablending must be off so the imagesavealpha can be true. The double FORs is need to fix the problem with imagefill function that not support colors with alpha setted. It is TO SLOWLIER than imagefill, but do a nice work with static images. Take a look and enjoy the nice result. (this workaround needs the gd2 library) [s] Pigmeu ---- Manual Page -- http://www.php.net/manual/en/function.imagecopyresampled.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+44134 Delete -- http://master.php.net/manage/user-notes.php?action=delete+44134&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+44134&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#73328) next »