Image-DeAnim
view release on metacpan or search on metacpan
my $bytes = 3 * 2**($size+1);
return &safe_read($bytes);
}
sub get_image {
my $id_bytes = &safe_read(9);
my $block = $id_bytes;
my ($id_info, $id_flag) = unpack("A8 C", $id_bytes);
if ($id_flag & 0x80) {
$block .= &get_colormap($id_flag & 0x07);
}
$block .= &safe_read(1); # LZW minimum code size
$block .= &get_data_block;
return $block;
}
1;
__END__
=head1 NAME
Image::DeAnim - create static GIF file from animated GIF
=head1 SYNOPSIS
use Image::DeAnim;
open(G,"animated.gif") or die;
undef $/;
$gif = <G>;
$newgif = Image::DeAnim::gif(\$gif);
print $$newgif;
# Using HTTP::Response
if ($self -> content_type eq 'image/gif') {
my $gif = $self -> content;
$self -> content (${&Image::DeAnim::gif(\$gif)});
}
=head1 DESCRIPTION
Image::DeAnim::gif takes a reference to a scalar conatining a GIF
image, and returns a scalar reference to a filtered GIF image. If the
input is an animated GIF, the output will be a static GIF of the last
frame of the animation. If the input is already a static GIF, the
output file should be (mostly) identical.
Image::DeAnim is intended for use with a HTTP proxy server, in order to
de-animate GIFs before they reach the browser window.
=head1 BUGS
Currently only outputs last frame. Options for first/other shouldn't
be too difficult, though.
If the last image of the animation is not the same size as the first,
the remaining image is blacked out (no overlay). It doesn't bother
me, but it may for others.
Doesn't work with cached animations, although as images work their way
out of the cache, this shouldn't be a problem.
Not very Perl-ish; can probably use lots of fixing, and better
documentation. OO in place of references seems to be the next logical
step.
=head1 AUTHOR
Ken MacFarlane, <ksm+cpan@universal.dca.net>
=head1 COPYRIGHT
Copyright 1999. This program may be distributed under the Perl
Artistic License.
=cut
( run in 0.984 second using v1.01-cache-2.11-cpan-140bd7fdf52 )