note 40474 deleted from function.imagecolortransparent by cmb
| From: | cmb@php.net | Date: | Sun, 01 Dec 2019 08:44:11 +0000 |
| Subject: | note 40474 deleted from function.imagecolortransparent by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213316@lists.php.net to get a copy of this message | ||
Note Submitter: shelley_hina at yahoo dot com
----
It took me a while to figure this out. I added visual web thumbnail preview graphic from http://www.thumbshots.org and http://www.thumbshots.com to my customer sites to visualize web
pages. Then I needed to create a small blank transparent PNG image if the thumbshot is not
available. You can do this easily using imagecolortransparent function. It came out really nice and
fast. It's very cool stuff and highly recommended library for all your web site needs!
// Use GD library to create transparent color PNG image of the pixel size
$ImgGD = imagecreate(120, 90);
$ImgWhite = imagecolorallocate($ImgGD, 255, 255, 255);
imagefill($ImgGD, 0, 0, $ImgWhite);
imagecolortransparent($ImgGD, $ImgWhite);
// Capture STDOUT to buffer
ob_start();
imagepng($ImgGD);
$Image = ob_get_contents();
ob_end_clean();
// Remember to free your memory
imagedestroy($ImgGD);
// Print image to web browser.
print $Image