I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2007-08-27 00:06:37-07 by tonyc in response to 5958
Re: Convering ico to gif makes background black

Hi,

Unfortunately Imager doesn't apply the mask from the image to the color data, which results in the black background.

I'll look at changing that for 0.60, since the current behaviour is confusing.

In the meantime, I've included a simple program that will apply the mask to the image. You could adapt this for use in your code.

#!perl -w use strict; use Imager; my $in = shift; my $out = shift or die "Usage: $0 input output\n"; my $im = Imager->new; $im->read(file => $in) or die "Cannot read $in:", $im->errstr; my $format = $im->tags(name => 'i_format'); $format =~ /^(ico|cur)$/ or die "Input not a ico or cure image\n"; my $mask = $im->tags(name => "${format}_mask"); # Imager always uses * for the 1s # add an alpha channel $im = $im->convert(preset => 'addalpha'); my @mask = split /\n/, $mask; shift @mask; # lose the key for my $y (0 .. $im->getheight() - 1) { my $m = shift @mask; for my $x (0 .. $im->getwidth() - 1 ) { if (substr($m, $x, 1) eq '*') { my $c = $im->getpixel(x => $x, 'y' => $y); $im->setpixel(x => $x, 'y' => $y, color => Imager::Color->new(($c->rgba)[0,1,2], 0)); } } } $im->write(file => $out) or die "Cannot write $out: ", $im->errstr;
Direct Responses: Write a response