COMPOSITE_MULTIPLY ignores alpha channel of src
Posted: 2010-07-09T16:49:41-07:00
It appears that compositeImage() using imagick::COMPOSITE_MULTIPLY sometimes disregards the alpha channel of the source (overlaid) image.
The only way I've gotten it to retain the alpha channel for the source (overlaid) image is to first save the overlay image to disk, open it in Photoshop and re-save it.
Has anyone found a way around this?
Thanks.
The only way I've gotten it to retain the alpha channel for the source (overlaid) image is to first save the overlay image to disk, open it in Photoshop and re-save it.
Has anyone found a way around this?
Thanks.
Code: Select all
$grip = new Imagick('grip.png');
$overlay = new Imagick();
$overlay->newImage($grip->getimagewidth(),$grip->getimageheight(), 'blue');
$overlayMask = new Imagick('mask.gif');
$overlay->compositeImage($overlayMask, imagick::COMPOSITE_COPYOPACITY, 0, 0);
$grip->compositeImage($overlay, imagick::COMPOSITE_MULTIPLY, 0, 0);
$overlayMask->setImageFormat( "png" );
$overlayMask->writeImage( 'tmp/test-overlayMask.png' );
$overlay->setImageFormat( "png" );
$overlay->writeImage( 'tmp/test-overlay.png' );
$grip->setImageFormat( "png" );
$grip->writeImage( 'tmp/test-grip.png' );