note 92787 added to function.imagecopymerge
| From: | SinaSalek at osu1 dot php dot net | Date: | Sun, 09 Aug 2009 08:26:56 +0000 |
| Subject: | note 92787 added to function.imagecopymerge | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-159226@lists.php.net to get a copy of this message | ||
I've just checked PHP's issue tracker and a core developer says that this function was
never meant to support alpha channel! and they refused to commit the provided patch! so ridicules
Anyway i tried rodrigo's workaround and it worked quite well, thanks rodrigo for sharing it.
I came up with another idea which is much faster than his solution, (it may need a little bit more
memory)
Hope it helps someone.
You can find me here : you can find me here http://sina.salek.ws/en/contact
<?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){
$opacity=$pct;
// getting the watermark width
$w = imagesx($src_im);
// getting the watermark height
$h = imagesy($src_im);
// 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);
// inverting the opacity
$opacity = 100 - $opacity;
// 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, $opacity);
}
?>
----
Server IP: 79.132.192.3
Probable Submitter: 84.47.225.66
----
Manual Page -- http://www.php.net/manual/en/function.imagecopymerge.php
Edit -- https://master.php.net/note/edit/92787
Del: integrated -- https://master.php.net/note/delete/92787/integrated
Del: useless -- https://master.php.net/note/delete/92787/useless
Del: bad code -- https://master.php.net/note/delete/92787/bad+code
Del: spam -- https://master.php.net/note/delete/92787/spam
Del: non-english -- https://master.php.net/note/delete/92787/non-english
Del: in docs -- https://master.php.net/note/delete/92787/in+docs
Del: other reasons-- https://master.php.net/note/delete/92787
Reject -- https://master.php.net/note/reject/92787
Search -- https://master.php.net/manage/user-notes.php