note 101611 added to function.imagecopymerge

From: Date: Thu, 30 Dec 2010 09:53:53 +0000
Subject: note 101611 added to function.imagecopymerge
Groups: php.notes 
Request: Send a blank email to php-notes+get-175325@lists.php.net to get a copy of this message
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 ---- Server IP: 69.147.83.197 Probable Submitter: 194.247.199.194 ---- Manual Page -- http://www.php.net/manual/en/function.imagecopymerge.php Edit -- https://master.php.net/note/edit/101611 Del: integrated -- https://master.php.net/note/delete/101611/integrated Del: useless -- https://master.php.net/note/delete/101611/useless Del: bad code -- https://master.php.net/note/delete/101611/bad+code Del: spam -- https://master.php.net/note/delete/101611/spam Del: non-english -- https://master.php.net/note/delete/101611/non-english Del: in docs -- https://master.php.net/note/delete/101611/in+docs Del: other reasons-- https://master.php.net/note/delete/101611 Reject -- https://master.php.net/note/reject/101611 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#175325) next »