source: main/trunk/greenstone2/perllib/cpan/Image/ExifTool/DPX.pm@ 34921

Last change on this file since 34921 was 34921, checked in by anupama, 3 years ago

Committing the improvements to EmbeddedMetaPlugin's processing of Keywords vs other metadata fields. Keywords were literally stored as arrays of words rather than phrases in PDFs (at least in Diego's sample PDF), whereas other meta fields like Subjects and Creators stored them as arrays of phrases. To get both to work, Kathy updated EXIF to a newer version, to retrieve the actual EXIF values stored in the PDF. And Kathy and Dr Bainbridge came up with a new option that I added called apply_join_before_split_to_metafields that's a regex which can list the metadata fields to apply the join_before_split to and whcih previously always got applied to all metadata fields. Now it's applied to any *Keywords metafields by default, as that's the metafield we have experience of that behaves differently to the others, as it stores by word instead of phrases. Tested on Diego's sample PDF. Diego has double-checked it to works on his sample PDF too, setting the split char to ; and turning on the join_before_split and leaving apply_join_before_split_to_metafields at its default of .*Keywords. File changes are strings.properties for the tooltip, the plugin introducing the option and working with it and Kathy's EXIF updates affecting cpan/File and cpan/Image.

File size: 9.1 KB
Line 
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# 2) Harry Mallon private communication
10#------------------------------------------------------------------------------
11
12package Image::ExifTool::DPX;
13
14use strict;
15use vars qw($VERSION);
16use Image::ExifTool qw(:DataAccess :Utils);
17
18$VERSION = '1.05';
19
20# DPX tags
21%Image::ExifTool::DPX::Main = (
22 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
23 GROUPS => { 0 => 'File', 1 => 'File', 2 => 'Image' },
24 NOTES => 'Tags extracted from DPX (Digital Picture Exchange) images.',
25 0 => { Name => 'ByteOrder', Format => 'undef[4]', PrintConv => { SDPX => 'Big-endian', XPDS => 'Little-endian' } },
26 8 => { Name => 'HeaderVersion', Format => 'string[8]' },
27 # 24 => { Name => 'GenericHeaderSize', Format => 'int32u' }, # = 1664
28 # 28 => { Name => 'IndustryStandardHeaderSize', Format => 'int32u' }, # = 384
29 16 => { Name => 'DPXFileSize', Format => 'int32u' },
30 20 => { Name => 'DittoKey', Format => 'int32u', PrintConv => { 0 => 'Same', 1 => 'New' } },
31 36 => { Name => 'ImageFileName', Format => 'string[100]' },
32 136 => {
33 Name => 'CreateDate',
34 Format => 'string[24]',
35 Groups => { 2 => 'Time' },
36 ValueConv => '$val =~ s/(\d{4}:\d{2}:\d{2}):/$1 /; $val',
37 PrintConv => '$self->ConvertDateTime($val)',
38 },
39 160 => { Name => 'Creator', Format => 'string[100]', Groups => { 2 => 'Author' } },
40 260 => { Name => 'Project', Format => 'string[200]' },
41 460 => { Name => 'Copyright', Format => 'string[200]', Groups => { 2 => 'Author' } },
42 660 => { Name => 'EncryptionKey', Format => 'int32u', PrintConv => 'sprintf("%.8x",$val)' },
43 768 => {
44 Name => 'Orientation',
45 Format => 'int16u',
46 PrintConv => {
47 0 => 'Horizontal (normal)',
48 1 => 'Mirror vertical',
49 2 => 'Mirror horizontal',
50 3 => 'Rotate 180',
51 4 => 'Mirror horizontal and rotate 270 CW',
52 5 => 'Rotate 90 CW',
53 6 => 'Rotate 270 CW',
54 7 => 'Mirror horizontal and rotate 90 CW',
55 },
56 },
57 770 => { Name => 'ImageElements', Format => 'int16u' },
58 772 => { Name => 'ImageWidth', Format => 'int32u' },
59 776 => { Name => 'ImageHeight', Format => 'int32u' },
60 780 => { Name => 'DataSign', Format => 'int32u', PrintConv => { 0 => 'Unsigned', 1 => 'Signed' } },
61 800 => {
62 Name => 'ComponentsConfiguration',
63 Format => 'int8u',
64 PrintConv => {
65 0 => 'User-defined single component',
66 1 => 'Red (R)',
67 2 => 'Green (G)',
68 3 => 'Blue (B)',
69 4 => 'Alpha (matte)',
70 6 => 'Luminance (Y)',
71 7 => 'Chrominance (Cb, Cr, subsampled by two)',
72 8 => 'Depth (Z)',
73 9 => 'Composite video',
74 50 => 'R, G, B',
75 51 => 'R, G, B, Alpha',
76 52 => 'Alpha, B, G, R',
77 100 => 'Cb, Y, Cr, Y (4:2:2)',
78 101 => 'Cb, Y, A, Cr, Y, A (4:2:2:4)',
79 102 => 'Cb, Y, Cr (4:4:4)',
80 103 => 'Cb, Y, Cr, A (4:4:4:4)',
81 150 => 'User-defined 2 component element',
82 151 => 'User-defined 3 component element',
83 152 => 'User-defined 4 component element',
84 153 => 'User-defined 5 component element',
85 154 => 'User-defined 6 component element',
86 155 => 'User-defined 7 component element',
87 156 => 'User-defined 8 component element',
88 },
89 },
90 801 => { #2
91 Name => 'TransferCharacteristic',
92 Format => 'int8u',
93 PrintConv => {
94 0 => 'User-defined',
95 1 => 'Printing density',
96 2 => 'Linear',
97 3 => 'Logarithmic',
98 4 => 'Unspecified video',
99 5 => 'SMPTE 274M',
100 6 => 'ITU-R 704-4',
101 7 => 'ITU-R 601-5 system B or G (625)',
102 8 => 'ITU-R 601-5 system M (525)',
103 9 => 'Composite video (NTSC)',
104 10 => 'Composite video (PAL)',
105 11 => 'Z (depth) - linear',
106 12 => 'Z (depth) - homogeneous',
107 13 => 'SMPTE ADX',
108 14 => 'ITU-R 2020 NCL',
109 15 => 'ITU-R 2020 CL',
110 16 => 'IEC 61966-2-4 xvYCC',
111 17 => 'ITU-R 2100 NCL/PQ',
112 18 => 'ITU-R 2100 ICtCp/PQ',
113 19 => 'ITU-R 2100 NCL/HLG',
114 20 => 'ITU-R 2100 ICtCp/HLG',
115 21 => 'RP 431-2:2011 Gama 2.6',
116 22 => 'IEC 61966-2-1 sRGB',
117 },
118 },
119 802 => { #2
120 Name => 'ColorimetricSpecification',
121 Format => 'int8u',
122 PrintConv => {
123 0 => 'User-defined',
124 1 => 'Printing density',
125 4 => 'Unspecified video',
126 5 => 'SMPTE 274M',
127 6 => 'ITU-R 704-4',
128 7 => 'ITU-R 601-5 system B or G (625)',
129 8 => 'ITU-R 601-5 system M (525)',
130 9 => 'Composite video (NTSC)',
131 10 => 'Composite video (PAL)',
132 13 => 'SMPTE ADX',
133 14 => 'ITU-R 2020',
134 15 => 'P3D65',
135 16 => 'P3DCI',
136 17 => 'P3D60',
137 18 => 'ACES',
138 },
139 },
140 803 => { Name => 'BitDepth', Format => 'int8u' },
141 820 => { Name => 'ImageDescription', Format => 'string[32]' },
142 892 => { Name => 'Image2Description', Format => 'string[32]', RawConv => '$val=~/[^\xff]/ ? $val : undef' },
143 964 => { Name => 'Image3Description', Format => 'string[32]', RawConv => '$val=~/[^\xff]/ ? $val : undef' },
144 1036=> { Name => 'Image4Description', Format => 'string[32]', RawConv => '$val=~/[^\xff]/ ? $val : undef' },
145 1108=> { Name => 'Image5Description', Format => 'string[32]', RawConv => '$val=~/[^\xff]/ ? $val : undef' },
146 1180=> { Name => 'Image6Description', Format => 'string[32]', RawConv => '$val=~/[^\xff]/ ? $val : undef' },
147 1252=> { Name => 'Image7Description', Format => 'string[32]', RawConv => '$val=~/[^\xff]/ ? $val : undef' },
148 1324=> { Name => 'Image8Description', Format => 'string[32]', RawConv => '$val=~/[^\xff]/ ? $val : undef' },
149 # 1408=> { Name => 'XOffset', Format => 'int32u' },
150 # 1412=> { Name => 'YOffset', Format => 'int32u' },
151 # 1416=> { Name => 'XCenter', Format => 'float' },
152 # 1420=> { Name => 'YCenter', Format => 'float' },
153 # 1424=> { Name => 'XOriginalSize', Format => 'int32u' },
154 # 1428=> { Name => 'YOriginalSize', Format => 'int32u' },
155 1432=> { Name => 'SourceFileName', Format => 'string[100]' },
156 1532=> { Name => 'SourceCreateDate', Format => 'string[24]' },
157 1556=> { Name => 'InputDeviceName', Format => 'string[32]' },
158 1588=> { Name => 'InputDeviceSerialNumber', Format => 'string[32]' },
159 # 1620=> { Name => 'AspectRatio', Format => 'int32u' },
160 1724 => { Name => 'OriginalFrameRate',Format => 'float' },
161 1728 => { Name => 'ShutterAngle', Format => 'float', RawConv => '($val =~ /\d/ and $val !~ /nan/i) ? $val : undef' }, #2
162 1732 => { Name => 'FrameID', Format => 'string[32]' },
163 1764 => { Name => 'SlateInformation', Format => 'string[100]' },
164 1920 => { Name => 'TimeCode', Format => 'int32u' }, #2
165 1940 => { Name => 'FrameRate', Format => 'float', RawConv => '($val =~ /\d/ and $val !~ /nan/i) ? $val : undef' }, #2
166 1972 => { Name => 'Reserved5', Format => 'string[76]', Unknown => 1 },
167 2048 => { Name => 'UserID', Format => 'string[32]' },
168);
169
170#------------------------------------------------------------------------------
171# Extract EXIF information from a DPX image
172# Inputs: 0) ExifTool object reference, 1) dirInfo reference
173# Returns: 1 on success, 0 if this wasn't a valid DPX file
174sub ProcessDPX($$)
175{
176 my ($et, $dirInfo) = @_;
177 my $raf = $$dirInfo{RAF};
178 my $buff;
179
180 # verify this is a valid DPX file
181 return 0 unless $raf->Read($buff, 2080) == 2080;
182 return 0 unless $buff =~ /^(SDPX|XPDS)/;
183 SetByteOrder($1 eq 'SDPX' ? 'MM' : 'II');
184 $et->SetFileType(); # set the FileType tag
185 my $hdrLen = Get32u(\$buff,24) + Get32u(\$buff,28);
186 $hdrLen == 2048 or $et->Warn("Unexpected DPX header length ($hdrLen)");
187 my %dirInfo = (
188 DataPt => \$buff,
189 DirStart => 0,
190 DirLen => length($buff),
191 );
192 my $tagTablePtr = GetTagTable('Image::ExifTool::DPX::Main');
193 $et->ProcessDirectory(\%dirInfo, $tagTablePtr);
194
195 return 1;
196}
197
1981; # end
199
200__END__
201
202=head1 NAME
203
204Image::ExifTool::DPX - Read DPX meta information
205
206=head1 SYNOPSIS
207
208This module is used by Image::ExifTool
209
210=head1 DESCRIPTION
211
212This module contains definitions required by Image::ExifTool to read
213metadata from DPX (Digital Picture Exchange) images.
214
215=head1 AUTHOR
216
217Copyright 2003-2021, Phil Harvey (philharvey66 at gmail.com)
218
219This library is free software; you can redistribute it and/or modify it
220under the same terms as Perl itself.
221
222=head1 REFERENCES
223
224=over 4
225
226=item L<http://www.cineon.com/ff_draft.php>
227
228=back
229
230=head1 SEE ALSO
231
232L<Image::ExifTool::TagNames/DPX Tags>,
233L<Image::ExifTool(3pm)|Image::ExifTool>
234
235=cut
236
Note: See TracBrowser for help on using the repository browser.