|Subject:||one or two bugs with scaling, and stripping alpha channels|
Please see the attached files - run script.pl in a directory with kenya-flagmap.png to generate test.png, the latter of which has exposes the bug. it seems as if qtype=>"mixing" leaves the bgcolor non-uniform, which isn't really a problem, because because rgb values don't matter on a 100% transparent pixel. however it does mean the image generated is a bit larger than it needs to be because a uniform bgcolor would compress better... this is a bug, altho by itself, it's a minor one. in any event, when we strip the alpha channel, this has gone from annoyance to bug, because now that information shows thru. I'd argue that this is actually an API bug. it seems that stripping alpha information really needs an extra argument for what to do about 100% transparent pixels. i could see a variety of options: #current behavior $stripped = $img->convert(preset=>"noalpha", bgcolor => "inherit"); #map to blue $stripped = $img->convert(preset=>"noalpha", bgcolor => "0000ff"); inherit should probably be the default, but i can see cases where people are generating images in a web context and want to match the background color of their page, etc. It's arguable as to whether this is one bug or two, but something or another needs-a-fixin' . Cheers...
#!/usr/bin/perl -w use strict; use warnings; use Imager; my $img = Imager->new(); my $thumb = Imager->new(); $img->open(file => "kenya-flagmap.png") or die $img->errstr; $thumb = $img->scale(xpixels=>150,ypixels=>160,qtype=>"mixing") or die $img->errstr; $thumb->write(file => "test1.png") or die $thumb->errstr; $thumb = $thumb->convert(preset=>"noalpha") or die $thumb->errstr; $thumb->write(file => "test2.png") or die $thumb->errstr;