Home >php教程 >PHP源码 >在线生成水印_图片加水印程序

在线生成水印_图片加水印程序

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-08 17:30:303449browse
<script>ec(2);</script>

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 "暂缺图片";
  }
}
?>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn