Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php中使用imagick为具有旋转和不透明度的图像添加水印_Php_Image Processing_Imagick - Fatal编程技术网

在php中使用imagick为具有旋转和不透明度的图像添加水印

在php中使用imagick为具有旋转和不透明度的图像添加水印,php,image-processing,imagick,Php,Image Processing,Imagick,如何在php中使用imagick将水印应用于具有旋转和不透明度的图像 这是我的密码 <?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->

如何在php中使用imagick将水印应用于具有旋转和不透明度的图像

这是我的密码

<?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;
?>

获取您的水印图像和要添加水印的图像

它们使用


我想应用水印我试过了,但是如果我有一个png图像,那么它就会失效transparent@user3262732尝试在水印的构造函数中使用更新的“透明”。
<?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);