note 73815 deleted from function.imagecreate by mazzanet
| From: | mazzanet@php.net | Date: | Mon, 12 Mar 2007 06:58:16 +0000 |
| Subject: | note 73815 deleted from function.imagecreate by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-124359@lists.php.net to get a copy of this message | ||
Note Submitter: Buckwheat469 at hotmail dot com
----
How to create a transparent Gif using PHP and imagecreate()...
$im = imagecreatefromstring($data);
$imageInfo['width'] = imagesx($im);
$imageInfo['height'] = imagesy($im);
//create the image
$dst = imagecreate($this->output_width, $this->output_height);
//get the transparent color value
$id = imagecolortransparent($im);
$imageInfo['transparent_color_id'] = $id;
$imageInfo['transparent_color_values'] = imagecolorsforindex($im, $id);
//set the transparent color value for the new image
$id = imagecolortransparent($dst,imagecolorallocatealpha ($dst,
$imageInfo['transparent_color_values']['red'],
$imageInfo['transparent_color_values']['green'],
$imageInfo['transparent_color_values']['blue'],
$imageInfo['transparent_color_values']['alpha']));
//copy the image to the new image
imagecopyresampled($dst,$im,0, 0,0, 0,
$this->output_width, $this->output_height, $imageInfo['width'],
$imageInfo['height']);
$im = $dst;
header('Content-Type: image/gif');
imagepng($im);
imagedestroy($im);