2016-04-24 12 views
3

PHPの正方形画像から形状を切り取る方法はありますか?心のように同じ大きさで画像(Imagik/Gd)から任意の形状を切り取る

enter image description here

別の画像:

例、私は心臓の形でイメージを持っています。

最終画像:

enter image description here

だから私の質問は、二つの画像、または1枚の画像から、このような効果を作るためのPHPでの方法はありますか?

答えて

2

基本的には、ハートテンプレートの不透明度を車の画像にコピーしたいだけです。だから、コマンドラインで、あなたはどうなる:

convert motor.jpg heart.png -compose copyopacity -composite result.png 

enter image description here

そして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'); 
?> 
関連する問題