Dear reader,
I would like to compose multiple PNG images (with transparency) on a background image with the blending mode set to Overlay. What is the most efficient way to do this? Is this possible with Imagick, or do I have to execute ImageMagick in a shell via exec()? I'd rather use Imagick because I've read it wins on performance over a shell execution.
I have used the compositeImage() command so far, which works fine but when you have 12 images to blend, you have to execute this command 12 times. I've read some documentation about this issue at http://imagemagick.org/Usage/layers/#compose but I can't seem to translate this shell code to Imagick.
Thanks in advance,
Ferenc
Efficiently blend multiple images into one image
Re: Efficiently blend multiple images into one image
Thanks for the quick reply and the references. I thought flattenImages did not support blending modes. I will look in to it. Thanks!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Efficiently blend multiple images into one image
I believe on common blend mode, but am not sure. In command line I think you can do that, but again not totally sure.
Re: Efficiently blend multiple images into one image
I have to deliver this site within a few weeks, so I'll stick to my current solution for now. I blend all images one by one like this:
I think using the convert method within a shell could be faster because you can run one command for multiple images. I've tried to achieve this by running ImageMagick with exec(), but I couldn't get it working. If there is an Imagick php command for this it would be awesome. First I'll stick to this method. Not the fastest, but it works!
Code: Select all
$imTopLeather = new Imagick($top_leather_url);
$imTopColor = new Imagick();
$imTopColor -> newImage(1000,450, $topColor);
$imTopColor -> compositeImage($imTopLeather, Imagick::COMPOSITE_COPYOPACITY, 0, 0);
$imTopLeather -> compositeImage($imTopColor, Imagick::COMPOSITE_OVERLAY, 0, 0);
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Efficiently blend multiple images into one image
exec() is just a PHP call and has nothing to do with Imagick.