Image/ExifTool/PrintIM.pm

filter: Statementstmt 80.9% 34 / 42 Branchbran 71.4% 10 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 78.6% 48 / 61 CC 8 SCAR 19.5
CC
8
Cov
79%
ProcessPrintIM
9.3
BEGIN
1.0
BEGIN
1.0
CRAP 7.0
« Image/ExifTool/Shortcuts.pm ↑ Summary Image/ExifTool/ZISRAW.pm »
1 #------------------------------------------------------------------------------
2 # File: PrintIM.pm
3 #
4 # Description: Read PrintIM meta information
5 #
6 # Revisions: 04/07/2004 - P. Harvey Created
7 #------------------------------------------------------------------------------
8  
9 package Image::ExifTool::PrintIM;
10  
11 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 18 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 18 ▶use Image::ExifTool qw(:DataAccess);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 18 $VERSION = '1.07';
16  
17 sub ProcessPrintIM($$$);
18  
19 # PrintIM table (proprietary specification by Epson)
20 18 %Image::ExifTool::PrintIM::Main = (
21 PROCESS_PROC => \&ProcessPrintIM,
22 GROUPS => { 0 => 'PrintIM', 1 => 'PrintIM', 2 => 'Printing' },
23 PRINT_CONV => 'sprintf("0x%.8x", $val)',
24 TAG_PREFIX => 'PrintIM',
25 PrintIMVersion => { # values: 0100, 0250, 0260, 0300
26 Description => 'PrintIM Version',
27 PrintConv => undef,
28 },
29 # the following names are from http://www.kanzaki.com/ns/exif
30 # but the decoding is unknown:
31 # 9 => { Name => 'PIMContrast', Unknown => 1 }, #1
32 # 10 => { Name => 'PIMBrightness', Unknown => 1 }, #1
33 # 11 => { Name => 'PIMColorbalance', Unknown => 1 }, #1
34 # 12 => { Name => 'PIMSaturation', Unknown => 1 }, #1
35 # 13 => { Name => 'PIMSharpness', Unknown => 1 }, #1
36 );
37  
38  
39 #------------------------------------------------------------------------------
40 # Process PrintIM IFD
41 # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
42 # Returns: 1 on success
43 sub ProcessPrintIM($$$)
44 67 ▶{
Subroutine ProcessPrintIM: called CC=8 SCAR=22.3
Pod undocumented
45 67 my ($et, $dirInfo, $tagTablePtr) = @_;
46 67 my $dataPt = $$dirInfo{DataPt};
47 67 my $offset = $$dirInfo{DirStart};
48 67 my $size = $$dirInfo{DirLen};
49 67 my $verbose = $et->Options('Verbose');
50  
51 67 ▶ unless ($size) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($size) 0 67 67
52 0 $et->Warn('Empty PrintIM data', 1);
53 0 return 0;
54 }
55 67 ▶ unless ($size > 15) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($size > 15) 0 67 67
56 0 $et->Warn('Bad PrintIM data');
57 0 return 0;
58 }
59 67 ▶ unless (substr($$dataPt, $offset, 7) eq 'PrintIM') {
Branch: 1 branch
BranchTrueFalseTotal
unless (substr($$dataPt, $offset, 7) eq "PrintIM") 0 67 67
60 0 $et->Warn('Invalid PrintIM header');
61 0 return 0;
62 }
63 # check size of PrintIM block
64 67 my $num = Get16u($dataPt, $offset + 14);
65 67 ▶ if ($size < 16 + $num * 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($size < 16 + $num * 6) 1 66 67
66 # size is too big, maybe byte ordering is wrong
67 1 ToggleByteOrder();
68 1 $num = Get16u($dataPt, $offset + 14);
69 1 ▶ if ($size < 16 + $num * 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($size < 16 + $num * 6) 0 1 1
70 0 $et->Warn('Bad PrintIM size');
71 0 return 0;
72 }
73 }
74 67 ▶ $verbose and $et->VerboseDir('PrintIM', $num);
Branch: 1 branch
BranchTrueFalseTotal
$verbose and $et->VerboseDir("PrintIM", $num) 1 66 67
75 67 $et->HandleTag($tagTablePtr, 'PrintIMVersion', substr($$dataPt, $offset + 8, 4),
76 DataPt => $dataPt,
77 Start => $offset + 8,
78 Size => 4,
79 );
80 67 my $n;
81 67 ▶ for ($n=0; $n<$num; ++$n) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n < $num) 681 67 748
82 681 my $pos = $offset + 16 + $n * 6;
83 681 my $tag = Get16u($dataPt, $pos);
84 681 my $val = Get32u($dataPt, $pos + 2);
85 681 $et->HandleTag($tagTablePtr, $tag, $val,
86 Index => $n,
87 DataPt => $dataPt,
88 Start => $pos + 2,
89 Size => 4,
90 );
91 }
92 67 return 1;
93 }
94  
95  
96 18 1; # end
97  
98 __END__
« Image/ExifTool/Shortcuts.pm ↑ Summary Image/ExifTool/ZISRAW.pm »