note 99523 added to function.imagecopymerge

From: Date: Sat, 21 Aug 2010 18:04:40 +0000
Subject: note 99523 added to function.imagecopymerge
Groups: php.notes 
Request: Send a blank email to php-notes+get-171918@lists.php.net to get a copy of this message
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. ---- Server IP: 208.69.120.55 Probable Submitter: 68.44.179.233 ---- Manual Page -- http://www.php.net/manual/en/function.imagecopymerge.php Edit -- https://master.php.net/note/edit/99523 Del: integrated -- https://master.php.net/note/delete/99523/integrated Del: useless -- https://master.php.net/note/delete/99523/useless Del: bad code -- https://master.php.net/note/delete/99523/bad+code Del: spam -- https://master.php.net/note/delete/99523/spam Del: non-english -- https://master.php.net/note/delete/99523/non-english Del: in docs -- https://master.php.net/note/delete/99523/in+docs Del: other reasons-- https://master.php.net/note/delete/99523 Reject -- https://master.php.net/note/reject/99523 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#171918) next »