I have spent some rather frustrating days converting ImageMagick code into PerlMagick and am now successfully able to convert a simple JPEG into the following transparent PNG:
Unfortunately for use on our website I now need to convert it to a GIF on a solid background as per:
The ImageMagick command is simplicity itself:
Code: Select all
convert a.png -background LightSteelBlue -flatten a_overlay.gif
However I am struggling to convert this into PerlMagick. My code currently looks like this:
Code: Select all
use Image::Magick;
my $gif = new Image::Magick;
$x = $gif->Read(filename=>'png:test.png');
warn "$x" if "$x";
$x = $gif->Flatten(background => 'LightSteelBlue');
warn "$x" if "$x";
$x = $gif->Write(filename=>'gif:test.gif');
warn "$x" if "$x";
This fails with "Usage: Flatten(ref)" on both the following systems:
- Windows XP / ActiveState 5.8.8 / ImageMagick 6.3.3
- Debian Linux / Perl 5.8.4 / ImageMagick 6.3.3
I have searched all documentation, forums, Google etc, but without success. I have even considered sticking with the PNG format and have gone through the whole "PNG in IE" fun and games; however I haven't resolved the basic problem that the PNG files are just too big. I have tried the various options to reduce file size (compress, depth, colors, quality) but the only one that seems to have any significant success in bringing down the size seems to be colors 256, which I feel is just too brutal, and in any case does not appear to be recognised by PerlMagick.
I am at the hair-tearing stage, so any assistance anyone is able to provide would be much appreciated.
Thank you.
Chris Roberts