note 44134 deleted from function.imagecopyresampled by cmb

From: Date: Wed, 12 Oct 2016 15:43:19 +0000
Subject: note 44134 deleted from function.imagecopyresampled by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-206857@lists.php.net to get a copy of this message
Note Submitter: ---- 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

« previous php.notes (#206857) next »