【问题标题】:Cut any shape from image ( Imagik/Gd)从图像中剪切任何形状(Imagik/Gd)
【发布时间】:2016-08-17 19:48:55
【问题描述】:

有什么方法可以从 PHP 中的方形图像中切割出任何形状?

例如,我有一个心形的图像:

另一个与心脏大小相同的图像。

最终图像:

所以我的问题是 PHP 中有没有办法从两张图像或一张图像中产生这种效果?

【问题讨论】:

    标签: php image gd imagick


    【解决方案1】:

    您基本上只是想将心脏模板的不透明度复制到汽车图片中。所以,在命令行,你会这样做:

    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');
    ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-10-02
      • 2012-07-30
      • 1970-01-01
      • 2018-12-24
      • 1970-01-01
      • 1970-01-01
      • 2018-09-30
      相关资源
      最近更新 更多