note 85038 added to function.imagecopyresampled
| From: | crash at osu1 dot php dot net | Date: | Tue, 12 Aug 2008 13:49:49 +0000 |
| Subject: | note 85038 added to function.imagecopyresampled | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143396@lists.php.net to get a copy of this message | ||
The suggestion of converting a gif to a png to retain transparency was useful. However the steps
used to maintain the transparency work for a gif as well, so the conversion step is not necessary.
Just do everything the same, and save as a gif anyway. i.e.
<?php
$g_iw is new image width
$g_ih is new image height
$img_src=imagecreatefromgif($g_srcfile);
$img_dst=imagecreatetruecolor($g_iw,$g_ih);
//preserve alpha
imagecolortransparent($img_dst, imagecolorallocate($img_dst, 0, 0, 0));
imagealphablending($img_dst, false);
imagesavealpha($img_dst, true);
imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $g_iw, $g_ih, $g_is[0], $g_is[1]);
imagegif($img_dst, $g_dstfile);
imagedestroy($img_dst);
?>
----
Server IP: 92.48.74.199
Probable Submitter: 82.26.197.45
----
Manual Page -- http://www.php.net/manual/en/function.imagecopyresampled.php
Edit -- https://master.php.net/note/edit/85038
Del: integrated -- https://master.php.net/note/delete/85038/integrated
Del: useless -- https://master.php.net/note/delete/85038/useless
Del: bad code -- https://master.php.net/note/delete/85038/bad+code
Del: spam -- https://master.php.net/note/delete/85038/spam
Del: non-english -- https://master.php.net/note/delete/85038/non-english
Del: in docs -- https://master.php.net/note/delete/85038/in+docs
Del: other reasons-- https://master.php.net/note/delete/85038
Reject -- https://master.php.net/note/reject/85038
Search -- https://master.php.net/manage/user-notes.php