1#------------------------------------------------------------------------------ 2# File: PrintIM.pm 3# 4# Description: Read PrintIM meta information 5# 6# Revisions: 04/07/2004 - P. Harvey Created 7#------------------------------------------------------------------------------ 8 9package Image::ExifTool::PrintIM; 10 11use strict; 12use vars qw($VERSION); 13use Image::ExifTool qw(:DataAccess); 14 15$VERSION = '1.07'; 16 17sub ProcessPrintIM($$$); 18 19# PrintIM table (proprietary specification by Epson) 20%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 43sub ProcessPrintIM($$$) 44{ 45 my ($et, $dirInfo, $tagTablePtr) = @_; 46 my $dataPt = $$dirInfo{DataPt}; 47 my $offset = $$dirInfo{DirStart}; 48 my $size = $$dirInfo{DirLen}; 49 my $verbose = $et->Options('Verbose'); 50 51 unless ($size) { 52 $et->Warn('Empty PrintIM data', 1); 53 return 0; 54 } 55 unless ($size > 15) { 56 $et->Warn('Bad PrintIM data'); 57 return 0; 58 } 59 unless (substr($$dataPt, $offset, 7) eq 'PrintIM') { 60 $et->Warn('Invalid PrintIM header'); 61 return 0; 62 } 63 # check size of PrintIM block 64 my $num = Get16u($dataPt, $offset + 14); 65 if ($size < 16 + $num * 6) { 66 # size is too big, maybe byte ordering is wrong 67 ToggleByteOrder(); 68 $num = Get16u($dataPt, $offset + 14); 69 if ($size < 16 + $num * 6) { 70 $et->Warn('Bad PrintIM size'); 71 return 0; 72 } 73 } 74 $verbose and $et->VerboseDir('PrintIM', $num); 75 $et->HandleTag($tagTablePtr, 'PrintIMVersion', substr($$dataPt, $offset + 8, 4), 76 DataPt => $dataPt, 77 Start => $offset + 8, 78 Size => 4, 79 ); 80 my $n; 81 for ($n=0; $n<$num; ++$n) { 82 my $pos = $offset + 16 + $n * 6; 83 my $tag = Get16u($dataPt, $pos); 84 my $val = Get32u($dataPt, $pos + 2); 85 $et->HandleTag($tagTablePtr, $tag, $val, 86 Index => $n, 87 DataPt => $dataPt, 88 Start => $pos + 2, 89 Size => 4, 90 ); 91 } 92 return 1; 93} 94 95 961; # end 97 98__END__ 99 100=head1 NAME 101 102Image::ExifTool::PrintIM - Read PrintIM meta information 103 104=head1 SYNOPSIS 105 106This module is loaded automatically by Image::ExifTool when required. 107 108=head1 DESCRIPTION 109 110This module contains definitions required by Image::ExifTool to interpret 111Print Image Matching meta information. 112 113=head1 AUTHOR 114 115Copyright 2003-2021, Phil Harvey (philharvey66 at gmail.com) 116 117This library is free software; you can redistribute it and/or modify it 118under the same terms as Perl itself. 119 120=head1 SEE ALSO 121 122L<Image::ExifTool::TagNames/PrintIM Tags>, 123L<Image::ExifTool(3pm)|Image::ExifTool> 124 125=cut 126