1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| <?php
$src="aaa.png";
$info = getimagesize($src);
$type = image_type_to_extension($info[2], false);
$fun = "imagecreatefrom" . $type;
$image = $fun($src); $top= $info[0]/2-($info[0]/4); $left= $info[1]/2;
$font = "D:\phpstudy_pro\WWW\jianti.ttf";
$content = "水印内容刘浩鹏";
$color = imagecolorallocatealpha($image,255,48,48, 0);
imagettftext($image, 90, 40, $left,$top, $color, $font, $content); imagettftext($image, 90, 40, $left,$top+250, $color, $font, $content);
$fun = "image" . $type;
$imgPathName = "aaa.png";
$fun($image, $imgPathName);
imagedestroy($image); ?>
|