【发布时间】:2016-08-17 19:48:55
【问题描述】:
有什么方法可以从 PHP 中的方形图像中切割出任何形状?
例如,我有一个心形的图像:
另一个与心脏大小相同的图像。
最终图像:
所以我的问题是 PHP 中有没有办法从两张图像或一张图像中产生这种效果?
【问题讨论】:
有什么方法可以从 PHP 中的方形图像中切割出任何形状?
例如,我有一个心形的图像:
另一个与心脏大小相同的图像。
最终图像:
所以我的问题是 PHP 中有没有办法从两张图像或一张图像中产生这种效果?
【问题讨论】:
您基本上只是想将心脏模板的不透明度复制到汽车图片中。所以,在命令行,你会这样做:
convert motor.jpg heart.png -compose copyopacity -composite result.png
在 PHP 中:
#!/usr/local/bin/php -f
<?php
$template=new Imagick('heart.png');
$image =new Imagick('motor.jpg');
# Copy alpha from template over car image
$image->compositeImage($template,imagick::COMPOSITE_COPYOPACITY,0,0);
$image->writeImage('result.png');
?>
【讨论】: