文字水印:
$w = 80;
$h = 20;
$im = imagecreatetruecolor($w,$h);
$textcolor = imagecolorallocate($im, 123, 12, 255);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $grey); //画一矩形并填充
// 把字符串写在图像左上角
imagestring($im, 3, 2, 3, "hello world!", $textcolor);
// 输出图像
header("content-type: image/jpeg");
imagejpeg($im);
imagedestroy($im);
图片水印
$groundimg = "dsc05940.jpeg";
$groundinfo = getimagesize($groundimg);
$ground_w = $groundinfo[0];
//print_r($groundinfo);
$ground_h = $groundinfo[1];
switch($groundinfo[2]){
case 1:
$ground_im = imagecreatefromgif($groundimg);
break;
case 2:
$ground_im = imagecreatefromjpeg($groundimg);
break;
case 3:
$ground_im = imagecreatefrompng($groundimg);
break;
}
$waterimg = "dsc05949.jpeg";
$imginfo =getimagesize($waterimg);
$water_w = $imginfo[0];
$water_w = $imginfo[1];
switch($imginfo[2]){
case 1:
$water_im = imagecreatefromgif($waterimg);
break;
case 2:
$water_im = imagecreatefromjpeg($waterimg);
break;
case 3:
$water_im = imagecreatefrompng($waterimg);
break;
}
imagecopy($ground_im,$water_im,100,100,0,0,500,500);
header("content-type: image/jpeg");
imagejpeg($ground_im);
合并图片php提供了很多函数:例如:imagecopymerge,imagecopyresized
如对本文有疑问,
点击进行留言回复!!
相关文章:
-
-
-
-
-
-
-
-
-
-
管理后台无限级菜单
管理后台菜单遍历很久就想做一个通用的管理后台出来,一直太懒没做,今天开始粗略搞了一下,只是先把框架搭建好,菜单栏...
[阅读全文]
-
桥接模式学习总结
桥接模式引言假如一个系统需要加入报表模块,主要的开发点是数据的获取和报表的显示方式。数据的获取可能是从系统数据库...
[阅读全文]
网友评论