|
文字水印:
[U]复制代码[/U] 代码如下:
$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";
$($waterImg);
$water_w = $[0];
$water_w = $[1];
switch($[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
您可能感兴趣的文章:用来给图片加水印的PHP类php上传图片并给图片打上透明水印的代码超级好用的一个php上传图片类(随机名,缩略图,加水印)PHP 透明水印生成代码php加水印的代码(支持半透明透明打水印,支持png透明背景)php文字水印和php图片水印实现代码(二种加水印方法)ThinkPHP水印功能实现修复PNG透明水印并增加JPEG图片质量可调整php给图片添加文字水印方法汇总功能强大的PHP图片处理类(水印、透明度、旋转)php使用imagecopymerge()函数创建半透明水印
|
|