DPX.pm 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #------------------------------------------------------------------------------
  2. # File: DPX.pm
  3. #
  4. # Description: Read DPX meta information
  5. #
  6. # Revisions: 2013-09-19 - P. Harvey created
  7. #
  8. # References: 1) http://www.cineon.com/ff_draft.php
  9. #------------------------------------------------------------------------------
  10. package Image::ExifTool::DPX;
  11. use strict;
  12. use vars qw($VERSION);
  13. use Image::ExifTool qw(:DataAccess :Utils);
  14. $VERSION = '1.02';
  15. # DPX tags
  16. %Image::ExifTool::DPX::Main = (
  17. PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
  18. GROUPS => { 0 => 'File', 1 => 'File', 2 => 'Image' },
  19. NOTES => 'Tags extracted from DPX (Digital Picture Exchange) images.',
  20. 0 => { Name => 'ByteOrder', Format => 'undef[4]', PrintConv => { SDPX => 'Big-endian', XPDS => 'Little-endian' } },
  21. 8 => { Name => 'HeaderVersion', Format => 'string[8]' },
  22. # 24 => { Name => 'GenericHeaderSize', Format => 'int32u' }, # = 1664
  23. # 28 => { Name => 'IndustryStandardHeaderSize', Format => 'int32u' }, # = 384
  24. 16 => { Name => 'DPXFileSize', Format => 'int32u' },
  25. 20 => { Name => 'DittoKey', Format => 'int32u', PrintConv => { 0 => 'Same', 1 => 'New' } },
  26. 36 => { Name => 'ImageFileName', Format => 'string[100]' },
  27. 136 => {
  28. Name => 'CreateDate',
  29. Format => 'string[24]',
  30. Groups => { 2 => 'Time' },
  31. ValueConv => '$val =~ s/(\d{4}:\d{2}:\d{2}):/$1 /; $val',
  32. PrintConv => '$self->ConvertDateTime($val)',
  33. },
  34. 160 => { Name => 'Creator', Format => 'string[100]', Groups => { 2 => 'Author' } },
  35. 260 => { Name => 'Project', Format => 'string[200]' },
  36. 460 => { Name => 'Copyright', Format => 'string[200]', Groups => { 2 => 'Author' } },
  37. 660 => { Name => 'EncryptionKey', Format => 'int32u', PrintConv => 'sprintf("%.8x",$val)' },
  38. 768 => {
  39. Name => 'Orientation',
  40. Format => 'int16u',
  41. PrintConv => {
  42. 0 => 'Horizontal (normal)',
  43. 1 => 'Mirror vertical',
  44. 2 => 'Mirror horizontal',
  45. 3 => 'Rotate 180',
  46. 4 => 'Mirror horizontal and rotate 270 CW',
  47. 5 => 'Rotate 90 CW',
  48. 6 => 'Rotate 270 CW',
  49. 7 => 'Mirror horizontal and rotate 90 CW',
  50. },
  51. },
  52. 770 => { Name => 'ImageElements', Format => 'int16u' },
  53. 772 => { Name => 'ImageWidth', Format => 'int32u' },
  54. 776 => { Name => 'ImageHeight', Format => 'int32u' },
  55. 780 => { Name => 'DataSign', Format => 'int32u', PrintConv => { 0 => 'Unsigned', 1 => 'Signed' } },
  56. 800 => {
  57. Name => 'ComponentsConfiguration',
  58. Format => 'int8u',
  59. PrintConv => {
  60. 0 => 'User-defined single component',
  61. 1 => 'Red (R)',
  62. 2 => 'Green (G)',
  63. 3 => 'Blue (B)',
  64. 4 => 'Alpha (matte)',
  65. 6 => 'Luminance (Y)',
  66. 7 => 'Chrominance (Cb, Cr, subsampled by two)',
  67. 8 => 'Depth (Z)',
  68. 9 => 'Composite video',
  69. 50 => 'R, G, B',
  70. 51 => 'R, G, B, Alpha',
  71. 52 => 'Alpha, B, G, R',
  72. 100 => 'Cb, Y, Cr, Y (4:2:2)',
  73. 101 => 'Cb, Y, A, Cr, Y, A (4:2:2:4)',
  74. 102 => 'Cb, Y, Cr (4:4:4)',
  75. 103 => 'Cb, Y, Cr, A (4:4:4:4)',
  76. 150 => 'User-defined 2 component element',
  77. 151 => 'User-defined 3 component element',
  78. 152 => 'User-defined 4 component element',
  79. 153 => 'User-defined 5 component element',
  80. 154 => 'User-defined 6 component element',
  81. 155 => 'User-defined 7 component element',
  82. 156 => 'User-defined 8 component element',
  83. },
  84. },
  85. 803 => { Name => 'BitDepth', Format => 'int8u' },
  86. 820 => { Name => 'ImageDescription', Format => 'string[32]' },
  87. 892 => { Name => 'Image2Description', Format => 'string[32]', RawConv => '$val=~/[^\xff]/ ? $val : undef' },
  88. 964 => { Name => 'Image3Description', Format => 'string[32]', RawConv => '$val=~/[^\xff]/ ? $val : undef' },
  89. 1036=> { Name => 'Image4Description', Format => 'string[32]', RawConv => '$val=~/[^\xff]/ ? $val : undef' },
  90. 1108=> { Name => 'Image5Description', Format => 'string[32]', RawConv => '$val=~/[^\xff]/ ? $val : undef' },
  91. 1180=> { Name => 'Image6Description', Format => 'string[32]', RawConv => '$val=~/[^\xff]/ ? $val : undef' },
  92. 1252=> { Name => 'Image7Description', Format => 'string[32]', RawConv => '$val=~/[^\xff]/ ? $val : undef' },
  93. 1324=> { Name => 'Image8Description', Format => 'string[32]', RawConv => '$val=~/[^\xff]/ ? $val : undef' },
  94. # 1408=> { Name => 'XOffset', Format => 'int32u' },
  95. # 1412=> { Name => 'YOffset', Format => 'int32u' },
  96. # 1416=> { Name => 'XCenter', Format => 'float' },
  97. # 1420=> { Name => 'YCenter', Format => 'float' },
  98. # 1424=> { Name => 'XOriginalSize', Format => 'int32u' },
  99. # 1428=> { Name => 'YOriginalSize', Format => 'int32u' },
  100. 1432=> { Name => 'SourceFileName', Format => 'string[100]' },
  101. 1532=> { Name => 'SourceCreateDate', Format => 'string[24]' },
  102. 1556=> { Name => 'InputDeviceName', Format => 'string[32]' },
  103. 1588=> { Name => 'InputDeviceSerialNumber', Format => 'string[32]' },
  104. # 1620=> { Name => 'AspectRatio', Format => 'int32u' },
  105. 1724 => { Name => 'FrameRate', Format => 'float' },
  106. 1732 => { Name => 'FrameID', Format => 'string[32]' },
  107. 1764 => { Name => 'SlateInformation', Format => 'string[100]' },
  108. 2048 => { Name => 'UserID', Format => 'string[32]' },
  109. );
  110. #------------------------------------------------------------------------------
  111. # Extract EXIF information from a DPX image
  112. # Inputs: 0) ExifTool object reference, 1) dirInfo reference
  113. # Returns: 1 on success, 0 if this wasn't a valid DPX file
  114. sub ProcessDPX($$)
  115. {
  116. my ($et, $dirInfo) = @_;
  117. my $raf = $$dirInfo{RAF};
  118. my $buff;
  119. # verify this is a valid DPX file
  120. return 0 unless $raf->Read($buff, 2080) == 2080;
  121. return 0 unless $buff =~ /^(SDPX|XPDS)/;
  122. SetByteOrder($1 eq 'SDPX' ? 'MM' : 'II');
  123. $et->SetFileType(); # set the FileType tag
  124. my $hdrLen = Get32u(\$buff,24) + Get32u(\$buff,28);
  125. $hdrLen == 2048 or $et->Warn("Unexpected DPX header length ($hdrLen)");
  126. my %dirInfo = (
  127. DataPt => \$buff,
  128. DirStart => 0,
  129. DirLen => length($buff),
  130. );
  131. my $tagTablePtr = GetTagTable('Image::ExifTool::DPX::Main');
  132. $et->ProcessDirectory(\%dirInfo, $tagTablePtr);
  133. return 1;
  134. }
  135. 1; # end
  136. __END__
  137. =head1 NAME
  138. Image::ExifTool::DPX - Read DPX meta information
  139. =head1 SYNOPSIS
  140. This module is used by Image::ExifTool
  141. =head1 DESCRIPTION
  142. This module contains definitions required by Image::ExifTool to read
  143. metadata from DPX (Digital Picture Exchange) images.
  144. =head1 AUTHOR
  145. Copyright 2003-2016, Phil Harvey (phil at owl.phy.queensu.ca)
  146. This library is free software; you can redistribute it and/or modify it
  147. under the same terms as Perl itself.
  148. =head1 REFERENCES
  149. =over 4
  150. =item L<http://www.cineon.com/ff_draft.php>
  151. =back
  152. =head1 SEE ALSO
  153. L<Image::ExifTool::TagNames/DPX Tags>,
  154. L<Image::ExifTool(3pm)|Image::ExifTool>
  155. =cut