开发者

Imagemagick command line in PHP

I've got the following two commands for imagemagick in the command line:

convert in.png container-mask.png +matte -compose CopyOpacity -composite  开发者_如何学JAVAout.png
composite container.png  out.png -compose multiply final.png

Those two commands include 3 files:

  • in.png: the file that should be masked
  • container-mask.png: the back/white mask of the areas of container.png where in.png should be visible
  • container.png image that includes the container for in.png, the one that has been masked in black/white with container-mask.png

Now the question is how to transpose this commands into PHP calls. I've played around quite a bit, but I can't make sense of the API at http://php.net/manual/en/book.imagick.php

Thanks and Bests, Charly


I've found the answer. Well, that was not too complicated after all:

$original = new Imagick("in.png");
$mask = new Imagick("container-mask.png");
$container = new Imagick("container.png");

$mask->setImageMatte(0);
$original->compositeImage($mask, Imagick::COMPOSITE_COPYOPACITY, 0, 0);
$container->compositeImage($original, Imagick::COMPOSITE_MULTIPLY, 0,0);
$container->setImageFormat( "png" );
echo $container;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜