我对图像处理知之甚少,对所使用的术语更是知之甚少,所以请耐心等待。
Basically, I want to merge two images together where one of them will act as a mask. That image looks something like this:
Where the blue and yellow background are both transparent in reality.
该图像被用作常规照片的蒙版。照片中“突出”到圆圈之外的部分需要被“裁剪”(使其不可见),而内部仍然可见。
因此,蓝色区域中的所有内容都是不可见的,黄色区域中的所有内容都是可见的。
老实说,我不知道如何去做,所以任何帮助将不胜感激!
Edit:
我使用 Imagick 的 API 版本,而不是命令行版本
Edit:
为了了解我想要实现的目标,这里有一个例子。
The input images are thus:
This is the mask image, always the same
This is an example of a picture, dynamic
This is what the end result should look like
所以,最后,这应该可以满足您的需要:
原图:
不透明蒙版:
Overlay:
Output:
代码:
<?php
$base = new Imagick('U0R4F.png');
$mask = new Imagick('mask.png');
$over = new Imagick('3ulkM.png');
// Setting same size for all images
$base->resizeImage(274, 275, Imagick::FILTER_LANCZOS, 1);
// Copy opacity mask
$base->compositeImage($mask, Imagick::COMPOSITE_DSTIN, 0, 0, Imagick::CHANNEL_ALPHA);
// Add overlay
$base->compositeImage($over, Imagick::COMPOSITE_DEFAULT, 0, 0);
$base->writeImage('output.png');
header("Content-Type: image/png");
echo $base;
?>
我希望是现在!
注意:在您的示例中,您似乎缩小了基本图像的比例,而我没有(我的目标只是展示遮罩是如何完成的)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)