2014-06-20 37 views
0

使用imagick图像哪能应用水印到旋转和不透明度在PHP中使用imagick图像水印旋转和不透明度在PHP

这是我的代码

<?php 
$image = new Imagick(); 
$image->readImage(realpath('C:\xampp\htdocs\imagick\3.jpg')); 

$watermark = new Imagick(); 
$watermark->readImage(realpath('C:\xampp\htdocs\imagick\1.png')); 

$image->compositeImage($watermark, imagick::COMPOSITE_OVER, 0, 0); 

header("Content-Type: image/" . $image->getImageFormat()); 
echo $image; 
?> 
+0

我想申请水印 – user3262732

回答

0

让你的水印图像和你想要添加的图像。

它们合并使用它们PHP ImageCopy function

<?php 
// Load the stamp and the photo to apply the watermark to 
$watermark= imagecreatefrompng('stamp.png'); 
$im = imagecreatefromjpeg('photo.jpeg'); 

// Set the margins for the stamp and get the height/width of the stamp image 
$marge_right = 10; 
$marge_bottom = 10; 
$sx = imagesx($watermark); 
$sy = imagesy($watermark); 

// Copy the stamp image onto our photo using the margin offsets and the photo 
// width to calculate positioning of the stamp. 
imagecopy($im, $watermark, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($watermark), imagesy($watermark)); 

// Output and free memory 
header('Content-type: image/png'); 
imagepng($im); 
imagedestroy($im); 
?> 

应该做的伎俩..

在你的榜样,你是唯一缺少的旋转图像。

$imagick->rotateImage(new ImagickPixel('transparent'), -13.55); 

Imagick.rotateImage

+1

感谢,但我想做到这一点使用imagick不GD – user3262732

+0

而复你已经有一个例子! – Pogrindis

+0

@ user3262732更新答案与旋转.. – Pogrindis