IPS IPS - 5 months ago 16x
PHP Question

Cut any shape from image ( Imagik/Gd)

Is there any way to cut any shape from square image in PHP ?

Example, I have image with heart shape:

enter image description here

Another image in same size like heart.

Final image:

enter image description here

So my question is there way in PHP to make such effect from two images, or one image ?


You basically just want to copy the opacity of the heart template into the car picture. So, at the command-line, you would do:

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

enter image description here

And in PHP:

#!/usr/local/bin/php -f
   $template=new Imagick('heart.png');
   $image   =new Imagick('motor.jpg');

   # Copy alpha from template over car image