Page 1 of 1

Defining alpha

Posted: 2007-08-18T16:47:59-07:00
by ophiuci
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.

Re: Defining alpha

Posted: 2007-08-19T18:42:56-07:00
by ophiuci
Here is the code I ended up with. Does exactly what I needed:

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 );
Solution found from: http://www.imagemagick.org/Usage/compose/#copyopacity

Solved

Posted: 2008-02-19T16:11:55-07:00
by mrBlaQ
wait, I'm replying to the wrong thread....