Filter/ExifOrientation.pm

filter: Statementstmt 70.5% 24 / 34 Branchbran 10.0% 1 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 60.7% 31 / 51 CC 6 SCAR 24.3
CC
6
Cov
57%
exif_orientation
20.0
BEGIN
1.0
BEGIN
1.0
CRAP 11.4
↑ Summary ExifOrientation.pm »
1 package Imager::Filter::ExifOrientation;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 our $VERSION = '0.01';
5  
6 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Imager::ExifOrientation;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Image::ExifTool ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 Imager->register_filter(
11 type => 'exif_orientation',
12 callsub => \&exif_orientation,
13 defaults => {
14 path => undef,
15 exif => undef,
16 data => undef,
17 orientation => undef,
18 },
19 callseq => ['image'],
20 );
21  
22 16 ▶sub exif_orientation {
Subroutine exif_orientation: called CC=6 SCAR=30.0
Pod undocumented
23 16 my %args = @_;
24  
25 16 my $orientation;
26  
27 16 ▶ if ($args{orientation}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{'orientation'}) { } 16 0 16
28 16 $orientation = $args{orientation};
29 } else {
30 0 my $exif;
31 0 ▶ if ($args{exif}) {
Branch: 3 branches
BranchTrueFalseTotal
if ($args{'exif'}) { } 0 0 0
elsif ($args{'data'}) { } 0 0 0
elsif ($args{'path'}) { } 0 0 0
32 0 $exif = $args{exif};
33 0 $orientation = Imager::ExifOrientation->get_orientation_by_exiftool($exif);
34 } elsif ($args{data}) {
35 0 $exif = Image::ExifTool::ImageInfo(\$args{data});
36 0 $orientation = Imager::ExifOrientation->get_orientation_by_exiftool($exif);
37 } elsif ($args{path}) {
38 0 $exif = Image::ExifTool::ImageInfo($args{path});
39 0 $orientation = Imager::ExifOrientation->get_orientation_by_exiftool($exif);
40 } else {
41 0 $orientation = $args{imager}->tags(name => 'exif_orientation');
42 0 ▶ return unless defined $orientation; # there is no orientation information
Branch: 1 branch
BranchTrueFalseTotal
unless defined $orientation 0 0 0
43 }
44 }
45  
46 my $img = Imager::ExifOrientation->_rotate(
47 16 $args{imager}, $orientation
48 );
49  
50 16 $args{imager}->{IMG} = $img->{IMG};
51 }
52  
53 1 1;
54 __END__
↑ Summary ExifOrientation.pm »