Page 1 of 1

Image rotating not working with PNG alpha'd images

Posted: 2009-04-21T12:43:28-07:00
by mrBlaQ
Code that used to be working is no longer probably due to an upgrade of ImageMagick. I think....

I've have code to rotate PNG alpha transparency images. Where it used to correctly leave the excess 'new' areas transparent, it now leaves them as solid black. This picture would be the best example. I'm rotating two images and compositing them on a third red image.

Image

Both images have an alpha mask as you can see. The output image is png as well. I'm using the following code:

Code: Select all

MagickReadImage($wnd, $file);
MagickSetImageFormat($wnd, "png");
MagickSetImageType($wnd, MW_TrueColorMatteType);
			        
$transparentColor = NewPixelWand();
PixelSetColor($transparentColor, "none");
MagickSetImageBackgroundColor($wnd, $transparentColor);			        
MagickRotateImage($wnd, $transparentColor, $rotation);
If I do a...

Code: Select all

MagickWriteImage($wnd, "/usr/web/styleFlipGraphics/exports/thumb/test.png");
... right after the MagickRotateImage, I get the same black areas. So I know it's not a fault of my composite options.

Might anyone have an idea what could be causing this new problem?

Thanks!

Re: Image rotating not working with PNG alpha'd images

Posted: 2009-04-21T15:18:17-07:00
by mrBlaQ
It may help to have a more succinct example.

Here's the original image:
http://img220.imageshack.us/img220/7190/awesomex.png

The convert command I'm trying to emulate is:
convert awesome.png -matte -background none -rotate 30 rotate_trans.png
... and it's output is:
http://img87.imageshack.us/img87/5673/rotatetrans.png

What I get from my code, though, is:

http://img57.imageshack.us/img57/2808/output.png

Re: Image rotating not working with PNG alpha'd images

Posted: 2009-04-21T15:40:54-07:00
by el_supremo
Not sure if this will help but try MagickSetBackgroundColor instead of MagickSetImageBackgroundColor.

Pete

Re: Image rotating not working with PNG alpha'd images

Posted: 2009-04-21T15:41:17-07:00
by mrBlaQ
Hahahaha! Ok... So it was a version compatibility issue I guess. I had to upgrade from MagickWand 1.0.6 to 1.0.8 and ImageMagick from 6.5.0 to 6.5.1

I'm still puzzled on how a function who's syntax has remained unchanged could be effected by minor version updates. Nonetheless, my problem is solved!