php使用imagick给图片加水印的方法
<?php
$image = new Imagick();
$image->readImage("original.jpg");
$watermark = new Imagick();
$watermark->readImage("/data/mark.png");
// how big are the images?
$iWidth = $image->getImageWidth();
$iHeight = $image->getImageHeight();
$wWidth = $watermark->getImageWidth();
$wHeight = $watermark->getImageHeight();
if ($iHeight < $wHeight || $iWidth < $wWidth) {
// resize the watermark
$watermark->scaleImage($iWidth, $iHeight);
// get new size
$wWidth = $watermark->getImageWidth();
$wHeight = $watermark->getImageHeight();
}
// calculate the position
$x = ($iWidth – $wWidth);
$y = ($iHeight – $wHeight);
$image->compositeImage($watermark, imagick::COMPOSITE_OVER, $x, $y);
header("Content-Type: image/" . $image->getImageFormat());
echo $image;
?>
您可能感兴趣的文章:
php使用imagick给图片加水印的方法
使用Imagick绘图 文字换行 生成二维码例子
Laravel中如何给图片加水印?
php添加imagick扩展的方法
php 图片处理类(附实例)
php 文件上传类与图片处理类的实现代码
超级好用的php文件上传类(上传、缩略图、水印)
Windows php5.6安装Imagick库的方法详解
简单的php图片上传自动给图片加水印
php在新浪云中使用imagick的方法