| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
59801
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
37
|
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
3
|
1
|
|
|
1
|
|
24
|
use 5.010; |
|
|
1
|
|
|
|
|
8
|
|
|
|
1
|
|
|
|
|
37
|
|
|
4
|
1
|
|
|
1
|
|
1430
|
use Imager; |
|
|
1
|
|
|
|
|
123483
|
|
|
|
1
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
|
|
package Imager::GIF; |
|
6
|
1
|
|
|
1
|
|
124
|
use Carp 'croak'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
642
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: a handy module for animated GIF processing |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
|
11
|
0
|
|
|
0
|
1
|
|
my ($class, @args) = @_; |
|
12
|
0
|
|
|
|
|
|
bless { images => \@args }, $class; |
|
13
|
|
|
|
|
|
|
} |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub read { |
|
16
|
0
|
|
|
0
|
1
|
|
my ($class, %args) = @_; |
|
17
|
0
|
0
|
|
|
|
|
croak "No filename specified" unless $args{file}; |
|
18
|
0
|
|
|
|
|
|
my @images = Imager->read_multi(file => $args{file}); |
|
19
|
0
|
|
|
|
|
|
return Imager::GIF->new(@images); |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub write { |
|
23
|
0
|
|
|
0
|
1
|
|
my ($self, $file) = @_; |
|
24
|
0
|
|
|
|
|
|
my $img = Imager->new; |
|
25
|
0
|
0
|
|
|
|
|
$img->write_multi({ file => $file, type => 'gif' }, @{$self->{images}}) |
|
|
0
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
or die $img->errstr; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub scale { |
|
30
|
0
|
|
|
0
|
1
|
|
my ($self, %args) = @_; |
|
31
|
0
|
|
0
|
|
|
|
my $ratio = $args{scalefactor} // 1; |
|
32
|
|
|
|
|
|
|
$self->_mangle(sub { |
|
33
|
0
|
|
|
0
|
|
|
my $img = shift; |
|
34
|
0
|
|
|
|
|
|
my $ret = $img->scale(%args, qtype => 'mixing'); |
|
35
|
0
|
|
|
|
|
|
my $h = $img->tags(name => 'gif_screen_height'); |
|
36
|
0
|
|
|
|
|
|
my $w = $img->tags(name => 'gif_screen_width'); |
|
37
|
0
|
0
|
|
|
|
|
unless ($ratio) { |
|
38
|
0
|
0
|
|
|
|
|
if (defined $args{xpixels}) { |
|
39
|
0
|
|
|
|
|
|
$ratio = $args{xpixels} / $w; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
0
|
0
|
|
|
|
|
if (defined $args{ypixels}) { |
|
42
|
0
|
|
|
|
|
|
$ratio = $args{ypixels} / $h; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
} |
|
45
|
0
|
|
|
|
|
|
$ret->settag(name => 'gif_left', |
|
46
|
|
|
|
|
|
|
value => int($ratio * $img->tags(name => 'gif_left'))); |
|
47
|
0
|
|
|
|
|
|
$ret->settag(name => 'gif_top', |
|
48
|
|
|
|
|
|
|
value => int($ratio * $img->tags(name => 'gif_top'))); |
|
49
|
0
|
|
|
|
|
|
$ret->settag(name => 'gif_screen_width', value => int($ratio * $w)); |
|
50
|
0
|
|
|
|
|
|
$ret->settag(name => 'gif_screen_height', value => int($ratio * $h)); |
|
51
|
0
|
|
|
|
|
|
return $ret; |
|
52
|
0
|
|
|
|
|
|
}); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _mangle { |
|
56
|
0
|
|
|
0
|
|
|
my ($self, $action) = @_; |
|
57
|
0
|
|
|
|
|
|
my @out; |
|
58
|
0
|
|
|
|
|
|
for my $in (@{$self->{images}}) { |
|
|
0
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $mangled = $action->($in); |
|
60
|
0
|
|
|
|
|
|
for my $tag (qw/gif_delay gif_user_input gif_loop gif_disposal/) { |
|
61
|
0
|
|
|
|
|
|
$mangled->settag(name => $tag, value => $in->tags(name => $tag)); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
0
|
0
|
|
|
|
|
if ($in->tags(name => 'gif_local_map')) { |
|
64
|
0
|
|
|
|
|
|
$mangled->settag(name => 'gif_local_map', value => 1); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
0
|
|
|
|
|
|
push @out, $mangled; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
0
|
|
|
|
|
|
return Imager::GIF->new(@out); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |