| 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'
MC/DC0%0/1
$args{'gravity'} || 'SouthWest'
$args{'gravity'}
Truth table0%0/2
A
A= $args{'gravity'}
| |||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | my $composite = $args{composite} || 'over'; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{'composite'} || 'over'
MC/DC0%0/1
$args{'composite'} || 'over'
$args{'composite'}
Truth table0%0/2
A
A= $args{'composite'}
| |||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | my $format = $args{format} || 'jpg'; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{'format'} || 'jpg'
MC/DC0%0/1
$args{'format'} || 'jpg'
$args{'format'}
Truth table0%0/2
A
A= $args{'format'}
| |||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | my $quality = $args{quality} || 100; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{'quality'} || 100
MC/DC0%0/1
$args{'quality'} || 100
$args{'quality'}
Truth table0%0/2
A
A= $args{'quality'}
| |||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | # Error Checking | ||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | if( !$source ){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 37 | 0 | carp "No source image specified"; | |||||||||||||||||||||||||||||||
| 38 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if( !$target ){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 42 | 0 | carp "No target image specified."; | |||||||||||||||||||||||||||||||
| 43 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if( !$output ){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 47 | 0 | carp "No output image specified."; | |||||||||||||||||||||||||||||||
| 48 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | # Debug Output | ||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | if( $self->{debug} ){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 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
Condition0%0/5
open(IMAGE, "<$source") || carp("Could not open source image: $source ($!)") && (return undef)
carp("Could not open source image: $source ($!)") and return undef
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 ($!)")
| |||||||||||||||||||||||||||||||||
| 70 | 0 | $err = $im_s->Read(file=>\*IMAGE); | |||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | die $err if $err; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 72 | 0 | close(IMAGE); | |||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | open(IMAGE,"<$target") or carp "Could not open target image: $target ($!)" and return undef; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
open(IMAGE, "<$target") || carp("Could not open target image: $target ($!)") && (return undef)
carp("Could not open target image: $target ($!)") and return undef
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 ($!)")
| |||||||||||||||||||||||||||||||||
| 75 | 0 | $err = $im_t->Read(file=>\*IMAGE); | |||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | die $err if $err; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | warn $@ and return undef; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||
| 93 | 0 | return 1; | |||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||
| 96 | 1; | ||||||||||||||||||||||||||||||||
| 97 | __END__ | ||||||||||||||||||||||||||||||||