Hello,
I am trying to use MagickWand to combine two images where one image contains color and the other contains a b/w alpha image. I want to output a transparent png. Is there currently a way to accomplish this? Any help would be appreciated.
Thanks.
Defining alpha
Re: Defining alpha
Here is the code I ended up with. Does exactly what I needed:
Solution found from: http://www.imagemagick.org/Usage/compose/#copyopacity
Code: Select all
$mgk_alpha=NewMagickWand();
MagickReadImage($mgk_alpha,'alpha.jpg');
MagickNegateImage($mgk_alpha, true);
MagickSetImageType($mgk_alpha, MW_GrayscaleType);
$mgk_color=NewMagickWand();
MagickReadImage($mgk_color,'color.jpg');
MagickSetImageFormat($mgk_color, "PNG");
$result = MagickCompositeImage($mgk_color, $mgk_alpha, MW_CopyOpacityCompositeOp, 0, 0);
header('Content-Type: image/png');
MagickEchoImageBlob( $mgk_color );