在线生成水印_图片加水印程序
<?php
printbreviaryImg("image/img.gif", "ss", "35", "22");
function PrintBreviaryImg($spathimg, $photoname, $simgwidth, $simgheight) {
if (file_exists($spathimg)) {
$size = GetImageSize($spathimg);
switch ($size[2]) {
case 1:
$origImg = @ImageCreateFromGIF($spathimg);
break;
case 2:
$origImg = @imagecreatefromjpeg($spathimg);
break;
case 3:
$origImg = @ImageCreateFromPNG($spathimg);
break;
}
//生成缩略图
$simgsize = GetImgSize($simgwidth, $simgheight, $size[0], $size[1]);
if (function_exists("imagecopyresampled")) {
$im = imagecreatetruecolor($simgsize['width'], $simgsize['height']);
imagecopyresampled($im, $origImg, 0, 0, 0, 0, $simgsize['width'], $simgsize['height'], $size[0], $size[1]);
} else {
$im = imagecreate($simgwidth, $simgheight);
imagecopyresized($im, $origImg, 0, 0, 0, 0, $simgwidth, $simgwidth, $simgsize['width'], $simgsize['height']);
}
//添加水印
$dstX = $simgsize['width'] - 10;
$dstY = $simgsize['height'] - 10;
$string = "[url=http://www.gd.com.cn]www.gd.com.cn[/url]";
$clo = imagecolorallocate($im, 255, 255, 255);
imagettftext($im, 48, 0, $dstX, $dstY, $clo, '../../fonts/arialbd.ttf', $string);
//添加水印
/*
$logoImage = ImageCreateFromGif('image/img.gif');
$logoW = ImageSX($logoImage);
$logoH = ImageSY($logoImage);
$dstX = -($simgsize['width']-$logoW);
$dstY = -($simgsize['height']-$logoH);
imagecopymerge($im, $logoImage, 0, 0, 0, 0, $logoW, $logoH,30);
*/
Imagejpeg($im, $photoname);
} else {
echo "暂缺图片";
}
}教程链接:http://www.phprm.com/code/f10ff44085311134441e50c1e911a020.html
随意转载~但请保留教程地址★