2009-09-14 82 views

回答

1

嘗試此(改編自sitepoint):

<?php 

header('content-type: image/jpeg'); 
$yourimagefile = 'something.jpg' // the image you're wanting to watermark 
$watermark = imagecreatefrompng('watermark.png'); // the watermark 
$watermark_width = imagesx($watermark); 
$watermark_height = imagesy($watermark); 
$image = imagecreatetruecolor($watermark_width, $watermark_height); 
$image = imagecreatefromjpeg($yourimagefile); 
$size = getimagesize($yourimagefile); 
$dest_x = $size[0] - $watermark_width - 5; 
$dest_y = $size[1] - $watermark_height - 5; 
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100); 
imagejpeg($image); 
imagedestroy($image); 
imagedestroy($watermark); 
+0

感謝羅傑。它的工作原理.. – Fero 2009-09-14 11:22:21

+2

我會強烈建議WideImage對於這樣的事情:http://wideimage.sourceforge.net/tutorials/watermarkmerge/ – deceze 2009-09-14 11:26:29

5
+0

我愛你,即使你可以給他更多的鏈接形式SO ^^ – 2009-09-14 11:23:31

+1

而現在:***傳奇繼續***! (順便提一句,電視節目致敬+1和研究表明你的觀點。) – 2009-09-14 11:24:05