(none) imager-devel
/ help / lists / applications / search /
 

Re: scaling animated GIFs

From: Tony Cook (
16932@xyz.molar.is)
Date: Mon 18 Jun 2007 - 00:01:42 GMT


On Sat, Jun 16, 2007 at 01:39:54PM +0200, Bernhard Graf wrote:
> Tony Cook wrote:
>
> > In most cases I expect you'll just need to copy gif_delay:
>
> Well, meanwhile I came to the conclusion that I'd better copy or convert
> all tags to the scaled image.
>
> > my @in = Imager->read_multi(file => $infile, type => 'gif')
> > or die Imager->errstr;
> > my @out;
> > for my $i (@in) {
> > my $out = $i->scale(xpixels => 60, ypixels => 60, type=>'min');
> > $out->settag(gif_delay => $i->tags(name=>'gif_delay'));
> > push @out, out;
> > }
> > Imager->write_multi({file => $outfile, type => 'gif'}, @out)
> > or die Imager->errstr;
>
> Now I stumbled across another problem: Transparency is lost.

You appear to have discovered how to generate a transparent gif. I'll
take a look at changing this behaviour to the default (which is mostly
for backwards compatibility.)

> There is a tag, that tells which color is to be regarded as transparent.
> In my example GIF tag `gif_trans_color' is "color(255,255,255,0)".
> When I open source and result GIF files in GIMP I see that all areas
> that are (255,255,255) in the original are turned into (254,254,254) in
> the scaled result.
> Also after scaling the pallete has only 64 entries instead of 256 in the
> source GIF image, so I think, `gif_trans_index' which is 255 is wrong.

gif_trans_index is ignored when writing, since in most cases Imager is
generating a new palette.

In your case, the palette required to render the scaled image is 64 or
fewer colors.

I'll take a look at why that color isn't coming through correctly,
though with transparency enabled it should come through transparent.

Tony