note 101741 added to function.imagecopymerge
| From: | RalphVoigt at osu1 dot php dot net | Date: | Sat, 08 Jan 2011 12:44:23 +0000 |
| Subject: | note 101741 added to function.imagecopymerge | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175529@lists.php.net to get a copy of this message | ||
Thanks to Sina Salek for the simplified imagecopymerge_alpha function with support for alpha
channel.
However, there's a bug which causes it to work only for $src_x = $src_y = 0.
Also, inverting opacity is not necessary.
Here's the fixed version:
<?php
/**
* PNG ALPHA CHANNEL SUPPORT for imagecopymerge();
* by Sina Salek
*
* Bugfix by Ralph Voigt
**/
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 relevant section from background to the cut resource
imagecopy($cut, $dst_im, 0, 0, $dst_x, $dst_y, $src_w, $src_h);
// copying relevant section from watermark to the cut resource
imagecopy($cut, $src_im, 0, 0, $src_x, $src_y, $src_w, $src_h);
// insert cut resource to destination image
imagecopymerge($dst_im, $cut, $dst_x, $dst_y, 0, 0, $src_w, $src_h, $pct);
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 178.2.138.57
----
Manual Page -- http://www.php.net/manual/en/function.imagecopymerge.php
Edit -- https://master.php.net/note/edit/101741
Del: integrated -- https://master.php.net/note/delete/101741/integrated
Del: useless -- https://master.php.net/note/delete/101741/useless
Del: bad code -- https://master.php.net/note/delete/101741/bad+code
Del: spam -- https://master.php.net/note/delete/101741/spam
Del: non-english -- https://master.php.net/note/delete/101741/non-english
Del: in docs -- https://master.php.net/note/delete/101741/in+docs
Del: other reasons-- https://master.php.net/note/delete/101741
Reject -- https://master.php.net/note/reject/101741
Search -- https://master.php.net/manage/user-notes.php