I am using the following code to mask one image on another image. On output, it gives me an image with Black background.
But I need a white background or a transparent background.
Following is the code that I am using to mask one image over another.
<?PHP
$destination_path = getcwd().DIRECTORY_SEPARATOR;
$im1="image1.png";
$im2="image2.png";
$i1="$destination_path$im1";
$i2="$destination_path$im2";
$base = new Imagick($i1);
$mask = new Imagick($i2);
// Setting same size for all images
$base->resizeImage(274, 275, Imagick::FILTER_LANCZOS, 1);
// Copy opacity mask
$base->compositeImage($mask, Imagick::COMPOSITE_DSTIN, 0, 0, Imagick::CHANNEL_ALPHA);
$base->writeImage('output.png');
header("Content-Type: image/png");
echo $base;
?>