note 99523 deleted from function.imagecopymerge by danbrown

From: Date: Sat, 21 Aug 2010 18:10:26 +0000
Subject: note 99523 deleted from function.imagecopymerge by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-171919@lists.php.net to get a copy of this message
Note Submitter: Aron Schatz (aronschatz at aselabs dot com) ---- In regard to: Sina Salek 09-Aug-2009 08:26: The function for merging with alpha works, but there is no need to invert the opacity. There are some extra things in the function that can be removed as well. <?php /** * PNG ALPHA CHANNEL SUPPORT for imagecopymerge(); * This is a function like imagecopymerge but it handle alpha channel well!!! **/ function imagecopymerge_alpha($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct) { // creating a cut resource $cut = imagecreatetruecolor($src_w, $src_h); // copying that section of the background to the cut imagecopy($cut, $dst_im, 0, 0, $dst_x, $dst_y, $src_w, $src_h); // placing the watermark now imagecopy($cut, $src_im, 0, 0, $src_x, $src_y, $src_w, $src_h); imagecopymerge($dst_im, $cut, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct); return true; } ?> What the function does is copy the part of the original image with the merge and place the merge with full opacity which respected the alpha channel. Then this new image (original cut + merged) with properly merged into the original image with the correct opacity.

« previous php.notes (#171919) next »