note 101611 deleted from function.imagecopymerge by danbrown
| From: | danbrown@php.net | Date: | Thu, 30 Dec 2010 16:06:36 +0000 |
| Subject: | note 101611 deleted from function.imagecopymerge by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-175334@lists.php.net to get a copy of this message | ||
Note Submitter: smalltux at yahoo dot com
----
Sina Salek suggested an excelent (yet simple) workaround for PNG images with alpha channel, but I
had to tune it a little bit more (the original code did not work properly for me):
function imagecopymerge_alpha($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h,
$opacity){
$w = imagesx($src_im);
$h = imagesy($src_im);
$cut = imagecreatetruecolor($src_w, $src_h);
imagecopy($cut, $dst_im, 0, 0, $dst_x, $dst_y, $src_w, $src_h);
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);
imagedestroy($cut);
}
This worked perfectly. I have a huge collection of movies and a catalogue maintained in PHP/MySQL. I
have a poster (jpg/giff/png file) for each movie. I got an idea to create a mosaic poster of all
Top#250 IMDB movies consisting of scaled down versions of individual posters. The only problem I had
was how to add watermark with an alpha channel. Now, it's solved. (Thanx, Sina!)
If you want to take a look, here is the final version of the poster created with PHP only
(5500x3200px). Yes, it's that huge:
http://www.luka.in.rs/poster.php