Image rotating not working with PNG alpha'd images

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply
mrBlaQ
Posts: 17
Joined: 2008-02-05T12:19:00-07:00

Image rotating not working with PNG alpha'd images

Post 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!
mrBlaQ
Posts: 17
Joined: 2008-02-05T12:19:00-07:00

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

Post 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
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

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

Post by el_supremo »

Not sure if this will help but try MagickSetBackgroundColor instead of MagickSetImageBackgroundColor.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
mrBlaQ
Posts: 17
Joined: 2008-02-05T12:19:00-07:00

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

Post 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!
Post Reply