A noter la presence d'un channel alpha dans le antialiasing du texte (fonctionne avec imagettf par exemple):
<?php $stamp = imagecreatefrompng('stamp.png'); $im = imagecreatefromjpeg('photo.jpeg'); $marge_right = 10; $marge_bottom = 10; $sx = imagesx($stamp); $sy = imagesy($stamp); imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp)); imagepng($im, "photo_stamp.png");
Ici l'image "stamp" est créée via GD afin de demontrer comment fonctionne imagecopymerge. Aucun channel alpha n'est utilisé.
<?php $stamp = imagecreatetruecolor(100, 70); imagefilledrectangle($stamp, 0,0, 99, 99, 0x0000FF); imagefilledrectangle($stamp, 9,9, 90,60, 0xFFFFFF); $im = imagecreatefromjpeg('photo.jpeg'); imagestring($stamp, 5, 20, 20, "libGD", 0x0000FF); imagestring($stamp, 3, 20, 40, "(c) 2007-8", 0x0000FF); $marge_right = 10; $marge_bottom = 10; $sx = imagesx($stamp); $sy = imagesy($stamp); imagecopymerge($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp), 50); imagepng($im, "photo_stamp_2.png");