note 30094 deleted from function.imagecolortransparent by cmb
| From: | cmb@php.net | Date: | Sun, 01 Dec 2019 08:43:37 +0000 |
| Subject: | note 30094 deleted from function.imagecolortransparent by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213315@lists.php.net to get a copy of this message | ||
Note Submitter: sandhawk at spies dot com
----
here's a little snippet of code that i got for getting images to overlay with
transparency(based off text overlay above).
$olay_img = imagecreatefromPNG("overlay.png); //NOTE I recomment you use png for this,
artifacts from jpeg images can look bad when you overlay them
$src_img = ImageCreateFromJPEG("image.jpg");
$src_w = ImageSX($src_img);
$src_h = ImageSY($src_img);
$can_img = imagecreatetruecolor($src_w, $src_h);
$black = ImageColorAllocate ($olay_img, 0, 0, 0);
ImageColorTransparent($olay_img, $black);
imagecopy($can_img, $src_img, 0,0,0,0, $src_w, $src_h);
imagecopymerge($can_img, $olay_img, 0,0,0,0, ImageSX($olay_img), ImageSY($olay_img),100);
//Imagecopy won't work, you must used imagecopymerge
ImageJPEG($can_img,'',100);
imagedestroy($src_img);
imagedestroy($olay_img);
imagedestroy($can_img);