| 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
| |||||||||||||||||||
| 28 | 16 | $orientation = $args{orientation}; | |||||||||||||||||
| 29 | } else { | ||||||||||||||||||
| 30 | 0 | my $exif; | |||||||||||||||||
| 31 | 0 | ▶ | if ($args{exif}) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 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
| |||||||||||||||||||
| 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__ | ||||||||||||||||||