如何使用PHP將圖片應用於上傳的圖片?如何在使用PHP上傳的圖片中應用水印
例LINK:http://www.kitebeaches.com/kitesurf/uploadPicture/NIRVANA_Club_Village.html
如何使用PHP將圖片應用於上傳的圖片?如何在使用PHP上傳的圖片中應用水印
例LINK:http://www.kitebeaches.com/kitesurf/uploadPicture/NIRVANA_Club_Village.html
嘗試此(改編自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);
此前關於SO:
我愛你,即使你可以給他更多的鏈接形式SO ^^ – 2009-09-14 11:23:31
而現在:***傳奇繼續***! (順便提一句,電視節目致敬+1和研究表明你的觀點。) – 2009-09-14 11:24:05
感謝羅傑。它的工作原理.. – Fero 2009-09-14 11:22:21
我會強烈建議WideImage對於這樣的事情:http://wideimage.sourceforge.net/tutorials/watermarkmerge/ – deceze 2009-09-14 11:26:29