Reputation: 256
I want to change opacity of multiple images when i used setImageOpacity it work fine for all images but not with png images and when i used evaluateImage it is work fine for transparent images but not for other images. how can i used same method for all types of images if image is transparent or not this is the code
<?php
// Open the original image
$image = new Imagick();
$image->readImage(3.jpg);
// Open the watermark
$watermark = new Imagick();
$watermark->readImage(2.png);
$watermark->setImageOpacity(0.444);
//$watermark->evaluateImage(Imagick::EVALUATE_MULTIPLY, 0.0, Imagick::CHANNEL_ALPHA);
$watermark->rotateImage(new ImagickPixel('transparent'), 90);
// Overlay the watermark on the original image
$image->compositeImage($watermark, imagick::COMPOSITE_OVER, 20, 20);
// send the result to the browser
header("Content-Type: image/" . $image->getImageFormat());
echo $image;
Upvotes: 2
Views: 1419
Reputation: 125604
use if condition using getImageAlphaChannel() function
to detect if the image have any transparent
note :
This method is available if Imagick has been compiled against ImageMagick version 6.4.0 or newer.
Upvotes: 2