note 77733 deleted from function.imagecolortransparent by cmb

From: Date: Sun, 01 Dec 2019 08:50:40 +0000
Subject: note 77733 deleted from function.imagecolortransparent by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213325@lists.php.net to get a copy of this message
Note Submitter: kevinoe at gmail ---- To resize a transparent image into a thumbnail while keeping its transparency. The quality of the thumbnail is pretty bad though.. but it is transparent. $image = ImageCreateFromGIF('transparentimage.gif'); $img_width = ImagesX($image); $img_height = ImagesY($image); $new_width = '100'; $new_height = ($new_width * $img_height) / $img_width; $resized = imagecreatetruecolor($new_width, $new_height); $colorTransparent = imagecolortransparent($image); imagepalettecopy($image, $resized); imagefill($resized, 0, 0, $colorTransparent); imagecolortransparent($resized, $colorTransparent); imagetruecolortopalette($resized, true, 256); imagecopyresized($resized, $image, 0, 0, 0, 0, $new_width, $new_height, $img_width, $img_height);

« previous php.notes (#213325) next »