blib/lib/Imager/GIF.pm

filter: Statementstmt 28.3% 15 / 53 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 45.4% 5 / 11 Podpod 100% 4 / 4 totaltotal 28.9% 24 / 83 CC 10 SCAR 23.2
CC
10
Cov
22%
__ANON__
20.0
_mangle
20.0
read
6.0
CRAP 10.2
↑ Summary
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Imager;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 package Imager::GIF;
6 1 ▶use Carp 'croak';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # ABSTRACT: a handy module for animated GIF processing
9  
10 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
11 0 my ($class, @args) = @_;
12 0 bless { images => \@args }, $class;
13 }
14  
15 0 ▶sub read {
Subroutine read: not called CC=2 SCAR=17.9
Pod documented
16 0 my ($class, %args) = @_;
17 0 ▶ croak "No filename specified" unless $args{file};
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"file"} 0 0 0
18 0 my @images = Imager->read_multi(file => $args{file});
19 0 return Imager::GIF->new(@images);
20 }
21  
22 0 ▶sub write {
Subroutine write: not called CC=2 SCAR=17.9
Pod documented
23 0 my ($self, $file) = @_;
24 0 my $img = Imager->new;
25 0 ▶ $img->write_multi({ file => $file, type => 'gif' }, @{$self->{images}})
Branch: 1 branch
BranchTrueFalseTotal
$img->write_multi({"file", $file, "type", "gif"}, @{$$self{"images"};}) or die $img->errstr 0 0 0
26 or die $img->errstr;
27 }
28  
29 0 ▶sub scale {
Subroutine scale: not called CC=2 SCAR=17.9
Pod documented
30 0 my ($self, %args) = @_;
31 0 ▶ my $ratio = $args{scalefactor} // 1;
Condition0%0/2
$args{"scalefactor"} // 1
l!l
00
MC/DC0%0/1
$args{"scalefactor"} // 1
$args{"scalefactor"}
Truth table0%0/2
A
A= $args{"scalefactor"}
Aresult
11
00
32 0 ▶ $self->_mangle(sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
33 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 ▶ unless ($ratio) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ratio) 0 0 0
38 0 ▶ if (defined $args{xpixels}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"xpixels"}) 0 0 0
39 0 $ratio = $args{xpixels} / $w;
40 }
41 0 ▶ if (defined $args{ypixels}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"ypixels"}) 0 0 0
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 0 ▶sub _mangle {
Subroutine _mangle: not called CC=4 SCAR=30.0
56 0 my ($self, $action) = @_;
57 0 my @out;
58 0 for my $in (@{$self->{images}}) {
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 ▶ if ($in->tags(name => 'gif_local_map')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in->tags("name", "gif_local_map")) 0 0 0
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 1;
72  
73 __END__
↑ Summary