I wonder if anyone out there knows if the following is a bug or 'feature'. I've found that when loading in a gif with a transparent background (Such as this
http://www.phrenetic.org/images/rabbit_tattoo.gif), if I resize the image and then change it's format to a jpeg, the outputted image's transparent background is converted to black. If I don't resize, it stays white. Very odd. Is there a way to stop this from happening?
Here's an example of what I'm doing
Code: Select all
$mwh = NewMagickWand();
MagickReadImage($mwh, 'rabbit_tattoo.gif');
MagickResizeImage($mwh, 369, 501, MW_LanczosFilter, 0.5);
MagickSetFormat($mwh, 'jpeg');
header('Content-type: ' . MagickGetMimeType($mwh));
MagickEchoImageBlob($mwh);
If I comment out the resize line then the image (as a jpeg) will be displayed correctly with the white background. If the resize is left in, then it comes out as black.
I've also tried setting the background colour to red in the hopes that even when outputting the image as a GIF, the transparent colour will fall through to the red, but this doesn't seem to have any effect either. E.g.
Code: Select all
$pwh = NewPixelWand('#ff0000');
MagickSetImageBackgroundColor($mwh, $pwh);
Any ideas? Or does this sound like a bug that I should maybe submit to the developers?