PrintIM.pm 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #------------------------------------------------------------------------------
  2. # File: PrintIM.pm
  3. #
  4. # Description: Read PrintIM meta information
  5. #
  6. # Revisions: 04/07/2004 - P. Harvey Created
  7. #------------------------------------------------------------------------------
  8. package Image::ExifTool::PrintIM;
  9. use strict;
  10. use vars qw($VERSION);
  11. use Image::ExifTool qw(:DataAccess);
  12. $VERSION = '1.07';
  13. sub ProcessPrintIM($$$);
  14. # PrintIM table (proprietary specification by Epson)
  15. %Image::ExifTool::PrintIM::Main = (
  16. PROCESS_PROC => \&ProcessPrintIM,
  17. GROUPS => { 0 => 'PrintIM', 1 => 'PrintIM', 2 => 'Printing' },
  18. PRINT_CONV => 'sprintf("0x%.8x", $val)',
  19. TAG_PREFIX => 'PrintIM',
  20. PrintIMVersion => { # values: 0100, 0250, 0260, 0300
  21. Description => 'PrintIM Version',
  22. PrintConv => undef,
  23. },
  24. # the following names are from http://www.kanzaki.com/ns/exif
  25. # but the decoding is unknown:
  26. # 9 => { Name => 'PIMContrast', Unknown => 1 }, #1
  27. # 10 => { Name => 'PIMBrightness', Unknown => 1 }, #1
  28. # 11 => { Name => 'PIMColorbalance', Unknown => 1 }, #1
  29. # 12 => { Name => 'PIMSaturation', Unknown => 1 }, #1
  30. # 13 => { Name => 'PIMSharpness', Unknown => 1 }, #1
  31. );
  32. #------------------------------------------------------------------------------
  33. # Process PrintIM IFD
  34. # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
  35. # Returns: 1 on success
  36. sub ProcessPrintIM($$$)
  37. {
  38. my ($et, $dirInfo, $tagTablePtr) = @_;
  39. my $dataPt = $$dirInfo{DataPt};
  40. my $offset = $$dirInfo{DirStart};
  41. my $size = $$dirInfo{DirLen};
  42. my $verbose = $et->Options('Verbose');
  43. unless ($size) {
  44. $et->Warn('Empty PrintIM data', 1);
  45. return 0;
  46. }
  47. unless ($size > 15) {
  48. $et->Warn('Bad PrintIM data');
  49. return 0;
  50. }
  51. unless (substr($$dataPt, $offset, 7) eq 'PrintIM') {
  52. $et->Warn('Invalid PrintIM header');
  53. return 0;
  54. }
  55. # check size of PrintIM block
  56. my $num = Get16u($dataPt, $offset + 14);
  57. if ($size < 16 + $num * 6) {
  58. # size is too big, maybe byte ordering is wrong
  59. ToggleByteOrder();
  60. $num = Get16u($dataPt, $offset + 14);
  61. if ($size < 16 + $num * 6) {
  62. $et->Warn('Bad PrintIM size');
  63. return 0;
  64. }
  65. }
  66. $verbose and $et->VerboseDir('PrintIM', $num);
  67. $et->HandleTag($tagTablePtr, 'PrintIMVersion', substr($$dataPt, $offset + 8, 4),
  68. DataPt => $dataPt,
  69. Start => $offset + 8,
  70. Size => 4,
  71. );
  72. my $n;
  73. for ($n=0; $n<$num; ++$n) {
  74. my $pos = $offset + 16 + $n * 6;
  75. my $tag = Get16u($dataPt, $pos);
  76. my $val = Get32u($dataPt, $pos + 2);
  77. $et->HandleTag($tagTablePtr, $tag, $val,
  78. Index => $n,
  79. DataPt => $dataPt,
  80. Start => $pos + 2,
  81. Size => 4,
  82. );
  83. }
  84. return 1;
  85. }
  86. 1; # end
  87. __END__
  88. =head1 NAME
  89. Image::ExifTool::PrintIM - Read PrintIM meta information
  90. =head1 SYNOPSIS
  91. This module is loaded automatically by Image::ExifTool when required.
  92. =head1 DESCRIPTION
  93. This module contains definitions required by Image::ExifTool to interpret
  94. Print Image Matching meta information.
  95. =head1 AUTHOR
  96. Copyright 2003-2016, Phil Harvey (phil at owl.phy.queensu.ca)
  97. This library is free software; you can redistribute it and/or modify it
  98. under the same terms as Perl itself.
  99. =head1 SEE ALSO
  100. L<Image::ExifTool::TagNames/PrintIM Tags>,
  101. L<Image::ExifTool(3pm)|Image::ExifTool>
  102. =cut