2013-09-30 45 views
-4

请在这里附上我的网站名称附加的任何PHP脚本,以便用户从我的网站下载任何图片或图像时,我的网站名称将被附加在那里,就像百叶窗是如何做到的。请帮忙!谢谢!在图片或图片上附上网站名称

+2

对不起,我们这里不提供脚本的建议。提问前请先看[问]。 –

+0

尝试玩php图像功能和gd库 – Lab

回答

1

您应该使用php watermark函数。

中心定位水印

<?php 
// Load the stamp and the photo to apply the watermark to 
$stamp = imagecreatefrompng('stampimg.png'); 
$im = imagecreatefrompng('mainimage.png'); 

// Set the margins for the stamp and get the height/width of the stamp image 
$marge_right = 10; 
$marge_bottom = 10; 
$sx = imagesx($stamp); 
$sy = imagesy($stamp); 

$imgx = imagesx($im); 
$imgy = imagesy($im); 
$centerX=round($imgx/2); 
$centerY=round($imgy/2); 

// Copy the stamp image onto our photo using the margin offsets and the photo 
// width to calculate positioning of the stamp. 
imagecopy($im, $stamp, $centerX, $centerY, 0, 0, imagesx($stamp), imagesy($stamp)); 

// Output and free memory 
header('Content-type: image/png'); 
imagepng($im); 
imagedestroy($im); 
?>