May I introduce myself and the task: I run a private website about model railroading and railway prototypes with lots of 4 bit images in proper quality. There's a resize function for these images (for visitors with sight issues). Example: English introduction (currently, the script is set to "scale").
Since most modern browsers use the (censored) bicubic interpolation when raster graphics are output at a size that differs from the original even if it's an integer magnifying factor (2x), I use IM (Perl layer in between) on a local Server (IM 6.4.1) and at the ISP. There's a caching algorithm, too.
Here's the essential part of the code:
Code: Select all
my ($inimage, $xlimage);
$inimage = new Image::Magick;
$inimage->Read($root.$imgfile);
$xlimage = $inimage->Clone();
$xlimage->Resize(width => $nNewWd, height => $nNewHt, blur => 0);
$xlimage->Write($root.$xlfile);
$imgfile = $xlfile;
undef($inimage);
undef($xlimage);
This works - and worked - perfectly fine, but PNG images with 4 bit (16 colours) and a transparency colour turned out to be fully black after the resize. If I turn "blur => 0" off, the transparency is maintained, and also scale works fine, but of course, the 16M colours image are too huge, and the images w/o blur => 0 look more than ugly.
Here is one of the images that turn out to cause problems:
Could anybody please help a more or less IM noob? And yes, I spent hours searching at Google and used the forum search, too.
Thanks in advance!
Best regards, Thomas