| 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
| |||||||||||
| 52 | 0 | $et->Warn('Empty PrintIM data', 1); | |||||||||
| 53 | 0 | return 0; | |||||||||
| 54 | } | ||||||||||
| 55 | 67 | ▶ | unless ($size > 15) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | 0 | $et->Warn('Bad PrintIM data'); | |||||||||
| 57 | 0 | return 0; | |||||||||
| 58 | } | ||||||||||
| 59 | 67 | ▶ | unless (substr($$dataPt, $offset, 7) eq 'PrintIM') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 70 | 0 | $et->Warn('Bad PrintIM size'); | |||||||||
| 71 | 0 | return 0; | |||||||||
| 72 | } | ||||||||||
| 73 | } | ||||||||||
| 74 | 67 | ▶ | $verbose and $et->VerboseDir('PrintIM', $num); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 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__ | ||||||||||