There are two graphic files. First file - JPG background image
The second file is a PNG with a figure in the center with a black border around the contour.
Question: How to combine two files with transparency preservation? The background from the first file should be placed inside the shape on the second file (see an example).
Images:
PNG file - profiles.in.ua/tmp/sample2.jpg
JPG file - profiles.in.ua/tmp/sample1.png
I try to do this:
$ mask = new Imagick (realpath ('mask.png'));
$ pattern = new Imagick (realpath ('pattern.jpg'));
$ pattern-> resizeImage ($ mask-> width, $ mask-> height, Imagick :: FILTER_LANCZOS, 1);
$ pattern-> compositeImage ($ mask, Imagick :: COMPOSITE_ATOP, 0, 0);
header ("Content-Type: image / png");
echo $ pattern-> getImageBlob ();
$ mask-> destroy ();
$ pattern-> destroy ();
