blib/lib/Image/Magick/Brand.pm

filter: Statementstmt 15.7% 9 / 57 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 50.0% 3 / 6 Podpod n/a totaltotal 11.0% 12 / 109 CC 17 SCAR 54.7
CC
17
Cov
9%
brand
306.0
new
2.0
debug
2.0
CRAP 236.8
↑ Summary
1 package Image::Magick::Brand;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 require Image::Magick;
8  
9 our $VERSION = '0.01';
10  
11 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
12 0 my $class = shift;
13 0 my $self = bless {}, $class;
14 }
15  
16 0 ▶sub debug {
Subroutine debug: not called CC=1 SCAR=6.9
17 0 my $self = shift;
18 0 $self->{debug} = shift;
19 }
20  
21 0 ▶sub brand {
Subroutine brand: not called CC=17 SCAR=57.2
22 0 my ($self, %args) = @_;
23
24 # Required Parameters
25 0 my $source = $args{source};
26 0 my $target = $args{target};
27 0 my $output = $args{output};
28
29 # Optional Parameters
30 0 ▶ my $gravity = $args{gravity} || 'SouthWest';
Condition0%0/2
$args{'gravity'} || 'SouthWest'
l!l
00
MC/DC0%0/1
$args{'gravity'} || 'SouthWest'
$args{'gravity'}
Truth table0%0/2
A
A= $args{'gravity'}
Aresult
11
00
31 0 ▶ my $composite = $args{composite} || 'over';
Condition0%0/2
$args{'composite'} || 'over'
l!l
00
MC/DC0%0/1
$args{'composite'} || 'over'
$args{'composite'}
Truth table0%0/2
A
A= $args{'composite'}
Aresult
11
00
32 0 ▶ my $format = $args{format} || 'jpg';
Condition0%0/2
$args{'format'} || 'jpg'
l!l
00
MC/DC0%0/1
$args{'format'} || 'jpg'
$args{'format'}
Truth table0%0/2
A
A= $args{'format'}
Aresult
11
00
33 0 ▶ my $quality = $args{quality} || 100;
Condition0%0/2
$args{'quality'} || 100
l!l
00
MC/DC0%0/1
$args{'quality'} || 100
$args{'quality'}
Truth table0%0/2
A
A= $args{'quality'}
Aresult
11
00
34  
35 # Error Checking
36 0 ▶ if( !$source ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($source) 0 0 0
37 0 carp "No source image specified";
38 0 return undef;
39 }
40
41 0 ▶ if( !$target ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($target) 0 0 0
42 0 carp "No target image specified.";
43 0 return undef;
44 }
45  
46 0 ▶ if( !$output ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($output) 0 0 0
47 0 carp "No output image specified.";
48 0 return undef;
49 }
50  
51 # Debug Output
52 0 ▶ if( $self->{debug} ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"}) 0 0 0
53 0 warn "Source : $source\n";
54 0 warn "Target : $target\n";
55 0 warn "Output : $output\n";
56 0 warn "Gravity : $gravity\n";
57 0 warn "Composite : $composite\n";
58 0 warn "Quality : $quality\n";
59 0 warn "Format : $format\n";
60 }
61
62 0 eval {
63  
64 0 my $im_s = new Image::Magick;
65 0 my $im_t = new Image::Magick;
66  
67 0 my $err;
68
69 0 ▶ open(IMAGE,"<$source") or carp "Could not open source image: $source ($!)" and return undef;
Branch: 1 branch
BranchTrueFalseTotal
open IMAGE, "<$source" or carp("Could not open source image: $source ($!)") and return undef 0 0 0
Condition0%0/5
open(IMAGE, "<$source") || carp("Could not open source image: $source ($!)") && (return undef)
l!l&&r!l&&!r
000
carp("Could not open source image: $source ($!)") and return undef
!ll
00
MC/DC0%0/2
open(IMAGE, "<$source") || carp("Could not open source image: $source ($!)") && (return undef)
open(IMAGE, "<$source") carp("Could not open source image: $source ($!)")
Truth table0%0/3
A || B
A= open(IMAGE, "<$source")B= carp("Could not open source image: $source ($!)")
ABresult
1X1
011
000
70 0 $err = $im_s->Read(file=>\*IMAGE);
71 0 ▶ die $err if $err;
Branch: 1 branch
BranchTrueFalseTotal
if $err 0 0 0
72 0 close(IMAGE);
73  
74 0 ▶ open(IMAGE,"<$target") or carp "Could not open target image: $target ($!)" and return undef;
Branch: 1 branch
BranchTrueFalseTotal
open IMAGE, "<$target" or carp("Could not open target image: $target ($!)") and return undef 0 0 0
Condition0%0/5
open(IMAGE, "<$target") || carp("Could not open target image: $target ($!)") && (return undef)
l!l&&r!l&&!r
000
carp("Could not open target image: $target ($!)") and return undef
!ll
00
MC/DC0%0/2
open(IMAGE, "<$target") || carp("Could not open target image: $target ($!)") && (return undef)
open(IMAGE, "<$target") carp("Could not open target image: $target ($!)")
Truth table0%0/3
A || B
A= open(IMAGE, "<$target")B= carp("Could not open target image: $target ($!)")
ABresult
1X1
011
000
75 0 $err = $im_t->Read(file=>\*IMAGE);
76 0 ▶ die $err if $err;
Branch: 1 branch
BranchTrueFalseTotal
if $err 0 0 0
77 0 close(IMAGE);
78  
79 0 $im_s->Set( quality => $quality );
80 0 $im_t->Set( quality => $quality );
81  
82 0 $im_t->Composite( image => $im_s,
83 composite => 'over',
84 gravity => $gravity );
85
86 0 $im_t->Write("$format:$output");
87 };
88  
89 0 ▶ if( $@ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
90 0 ▶ warn $@ and return undef;
Branch: 1 branch
BranchTrueFalseTotal
warn $@ and return undef 0 0 0
91 }
92
93 0 return 1;
94 }
95  
96 1;
97 __END__
↑ Summary