source: gs2-extensions/parallel-building/trunk/src/perllib/cpan/Image/ExifTool/JPEG.pm@ 24626

Last change on this file since 24626 was 24626, checked in by jmt12, 13 years ago

An (almost) complete copy of the perllib directory from a (circa SEP2011) head checkout from Greenstone 2 trunk - in order to try and make merging in this extension a little easier later on (as there have been some major changes to buildcol.pl commited in the main trunk but not in the x64 branch)

File size: 17.8 KB
Line 
1#------------------------------------------------------------------------------
2# File: JPEG.pm
3#
4# Description: Definitions for uncommon JPEG segments
5#
6# Revisions: 10/06/2006 - P. Harvey Created
7#------------------------------------------------------------------------------
8
9package Image::ExifTool::JPEG;
10use strict;
11use vars qw($VERSION);
12use Image::ExifTool qw(:DataAccess :Utils);
13
14$VERSION = '1.13';
15
16sub ProcessScalado($$$);
17sub ProcessOcad($$$);
18
19# (this main JPEG table is for documentation purposes only)
20%Image::ExifTool::JPEG::Main = (
21 NOTES => 'This table lists information extracted by ExifTool from JPEG images.',
22 APP0 => [{
23 Name => 'JFIF',
24 Condition => '$$valPt =~ /^JFIF\0/',
25 SubDirectory => { TagTable => 'Image::ExifTool::JFIF::Main' },
26 }, {
27 Name => 'JFXX',
28 Condition => '$$valPt =~ /^JFXX\0\x10/',
29 SubDirectory => { TagTable => 'Image::ExifTool::JFIF::Extension' },
30 }, {
31 Name => 'CIFF',
32 Condition => '$$valPt =~ /^(II|MM).{4}HEAPJPGM/s',
33 SubDirectory => { TagTable => 'Image::ExifTool::CanonRaw::Main' },
34 }, {
35 Name => 'AVI1',
36 Condition => '$$valPt =~ /^AVI1/',
37 SubDirectory => { TagTable => 'Image::ExifTool::JPEG::AVI1' },
38 }, {
39 Name => 'Ocad',
40 Condition => '$$valPt =~ /^Ocad/',
41 SubDirectory => { TagTable => 'Image::ExifTool::JPEG::Ocad' },
42 }],
43 APP1 => [{
44 Name => 'EXIF',
45 Condition => '$$valPt =~ /^Exif\0/',
46 SubDirectory => { TagTable => 'Image::ExifTool::Exif::Main' },
47 }, {
48 Name => 'ExtendedXMP',
49 Condition => '$$valPt =~ m{^http://ns.adobe.com/xmp/extension/\0}',
50 SubDirectory => { TagTable => 'Image::ExifTool::XMP::Main' },
51 }, {
52 Name => 'XMP',
53 Condition => '$$valPt =~ /^http/ or $$valPt =~ /<exif:/',
54 SubDirectory => { TagTable => 'Image::ExifTool::XMP::Main' },
55 }, {
56 Name => 'QVCI',
57 Condition => '$$valPt =~ /^QVCI\0/',
58 SubDirectory => { TagTable => 'Image::ExifTool::Casio::QVCI' },
59 }],
60 APP2 => [{
61 Name => 'ICC_Profile',
62 Condition => '$$valPt =~ /^ICC_PROFILE\0/',
63 SubDirectory => { TagTable => 'Image::ExifTool::ICC_Profile::Main' },
64 }, {
65 Name => 'FPXR',
66 Condition => '$$valPt =~ /^FPXR\0/',
67 SubDirectory => { TagTable => 'Image::ExifTool::FlashPix::Main' },
68 }, {
69 Name => 'MPF',
70 Condition => '$$valPt =~ /^MPF\0/',
71 SubDirectory => { TagTable => 'Image::ExifTool::MPF::Main' },
72 }, {
73 Name => 'PreviewImage',
74 Condition => '$$valPt =~ /^\xff\xd8\xff\xdb/',
75 Notes => 'Samsung large preview',
76 }],
77 APP3 => [{
78 Name => 'Meta',
79 Condition => '$$valPt =~ /^(Meta|META|Exif)\0\0/',
80 SubDirectory => { TagTable => 'Image::ExifTool::Kodak::Meta' },
81 }, {
82 Name => 'Stim',
83 Condition => '$$valPt =~ /^Stim\0/',
84 SubDirectory => { TagTable => 'Image::ExifTool::Stim::Main' },
85 }, {
86 Name => 'PreviewImage', # (written by HP R837 and Samsung S1060)
87 Condition => '$$valPt =~ /^\xff\xd8\xff\xdb/',
88 Notes => 'Hewlett-Packard or Samsung preview image',
89 }],
90 APP4 => [{
91 Name => 'Scalado',
92 Condition => '$$valPt =~ /^SCALADO\0/',
93 SubDirectory => { TagTable => 'Image::ExifTool::JPEG::Scalado' },
94 }, {
95 Name => 'FPXR', # (non-standard location written by some HP models)
96 Condition => '$$valPt =~ /^FPXR\0/',
97 SubDirectory => { TagTable => 'Image::ExifTool::FlashPix::Main' },
98 }, {
99 Name => 'PreviewImage', # (written by S1060)
100 Notes => 'Continued Samsung preview from APP3',
101 }],
102 APP5 => {
103 Name => 'RMETA',
104 Condition => '$$valPt =~ /^RMETA\0/',
105 SubDirectory => { TagTable => 'Image::ExifTool::Ricoh::RMETA' },
106 },
107 APP6 => [{
108 Name => 'EPPIM',
109 Condition => '$$valPt =~ /^EPPIM\0/',
110 SubDirectory => { TagTable => 'Image::ExifTool::JPEG::EPPIM' },
111 }, {
112 Name => 'NITF',
113 Condition => '$$valPt =~ /^NTIF\0/',
114 SubDirectory => { TagTable => 'Image::ExifTool::JPEG::NITF' },
115 }, {
116 Name => 'HP_TDHD', # (written by R837)
117 Condition => '$$valPt =~ /^TDHD\x01\0\0\0/',
118 SubDirectory => { TagTable => 'Image::ExifTool::HP::TDHD' },
119 }],
120 APP8 => {
121 Name => 'SPIFF',
122 Condition => '$$valPt =~ /^SPIFF\0/',
123 SubDirectory => { TagTable => 'Image::ExifTool::JPEG::SPIFF' },
124 },
125 APP10 => {
126 Name => 'Comment',
127 Condition => '$$valPt =~ /^UNICODE\0/',
128 Notes => 'PhotoStudio Unicode comment',
129 },
130 APP12 => [{
131 Name => 'PictureInfo',
132 Condition => '$$valPt =~ /(\[picture info\]|Type=)/',
133 SubDirectory => { TagTable => 'Image::ExifTool::APP12::PictureInfo' },
134 }, {
135 Name => 'Ducky',
136 Condition => '$$valPt =~ /^Ducky/',
137 SubDirectory => { TagTable => 'Image::ExifTool::APP12::Ducky' },
138 }],
139 APP13 => [{
140 Name => 'Photoshop',
141 Condition => '$$valPt =~ /^(Photoshop 3.0\0|Adobe_Photoshop2.5)/',
142 SubDirectory => { TagTable => 'Image::ExifTool::Photoshop::Main' },
143 }, {
144 Name => 'Adobe_CM',
145 Condition => '$$valPt =~ /^Adobe_CM/',
146 SubDirectory => { TagTable => 'Image::ExifTool::JPEG::AdobeCM' },
147 }],
148 APP14 => {
149 Name => 'Adobe',
150 Condition => '$$valPt =~ /^Adobe/',
151 SubDirectory => { TagTable => 'Image::ExifTool::JPEG::Adobe' },
152 },
153 APP15 => {
154 Name => 'GraphicConverter',
155 Condition => '$$valPt =~ /^Q\s*(\d+)/',
156 SubDirectory => { TagTable => 'Image::ExifTool::JPEG::GraphConv' },
157 },
158 COM => {
159 Name => 'Comment',
160 # note: flag as writable for documentation, but it won't show up
161 # in the TagLookup as writable because there is no WRITE_PROC
162 Writable => 1,
163 },
164 SOF => {
165 Name => 'StartOfFrame',
166 SubDirectory => { TagTable => 'Image::ExifTool::JPEG::SOF' },
167 },
168 DQT => {
169 Name => 'DefineQuantizationTable',
170 Notes => 'used to calculate the Extra:JPEGDigest tag value',
171 },
172 Trailer => [{
173 Name => 'AFCP',
174 Condition => '$$valPt =~ /AXS(!|\*).{8}$/s',
175 SubDirectory => { TagTable => 'Image::ExifTool::AFCP::Main' },
176 }, {
177 Name => 'CanonVRD',
178 Condition => '$$valPt =~ /CANON OPTIONAL DATA\0.{44}$/s',
179 SubDirectory => { TagTable => 'Image::ExifTool::CanonVRD::Main' },
180 }, {
181 Name => 'FotoStation',
182 Condition => '$$valPt =~ /\xa1\xb2\xc3\xd4$/',
183 SubDirectory => { TagTable => 'Image::ExifTool::FotoStation::Main' },
184 }, {
185 Name => 'PhotoMechanic',
186 Condition => '$$valPt =~ /cbipcbbl$/',
187 SubDirectory => { TagTable => 'Image::ExifTool::PhotoMechanic::Main' },
188 }, {
189 Name => 'MIE',
190 Condition => q{
191 $$valPt =~ /~\0\x04\0zmie~\0\0\x06.{4}[\x10\x18]\x04$/s or
192 $$valPt =~ /~\0\x04\0zmie~\0\0\x0a.{8}[\x10\x18]\x08$/s
193 },
194 SubDirectory => { TagTable => 'Image::ExifTool::MIE::Main' },
195 }, {
196 Name => 'PreviewImage',
197 Condition => '$$valPt =~ /^\xff\xd8\xff/',
198 Writable => 1, # (for docs only)
199 }],
200);
201
202# EPPIM APP6 (Toshiba PrintIM) segment (ref PH, from PDR-M700 samples)
203%Image::ExifTool::JPEG::EPPIM = (
204 GROUPS => { 0 => 'APP6', 1 => 'EPPIM', 2 => 'Image' },
205 NOTES => q{
206 APP6 is used in by the Toshiba PDR-M700 to store a TIFF structure containing
207 PrintIM information.
208 },
209 0xc4a5 => {
210 Name => 'PrintIM',
211 # must set Writable here so this tag will be saved with MakerNotes option
212 Writable => 'undef',
213 Description => 'Print Image Matching',
214 SubDirectory => {
215 TagTable => 'Image::ExifTool::PrintIM::Main',
216 },
217 },
218);
219
220# SPIFF APP8 segment. Refs:
221# 1) http://www.fileformat.info/format/spiff/
222# 2) http://www.jpeg.org/public/spiff.pdf
223%Image::ExifTool::JPEG::SPIFF = (
224 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
225 GROUPS => { 0 => 'APP8', 1 => 'SPIFF', 2 => 'Image' },
226 NOTES => q{
227 This information is found in APP8 of SPIFF-style JPEG images (the "official"
228 yet rarely used JPEG file format standard: Still Picture Interchange File
229 Format). See L<http://www.jpeg.org/public/spiff.pdf> for the official
230 specification.
231 },
232 0 => {
233 Name => 'SPIFFVersion',
234 Format => 'int8u[2]',
235 PrintConv => '$val =~ tr/ /./; $val',
236 },
237 2 => {
238 Name => 'ProfileID',
239 PrintConv => {
240 0 => 'Not Specified',
241 1 => 'Continuous-tone Base',
242 2 => 'Continuous-tone Progressive',
243 3 => 'Bi-level Facsimile',
244 4 => 'Continuous-tone Facsimile',
245 },
246 },
247 3 => 'ColorComponents',
248 6 => {
249 Name => 'ImageHeight',
250 Notes => q{
251 at index 4 in specification, but there are 2 extra bytes here in my only
252 SPIFF sample, version 1.2
253 },
254 Format => 'int32u',
255 },
256 10 => {
257 Name => 'ImageWidth',
258 Format => 'int32u',
259 },
260 14 => {
261 Name => 'ColorSpace',
262 PrintConv => {
263 0 => 'Bi-level',
264 1 => 'YCbCr, ITU-R BT 709, video',
265 2 => 'No color space specified',
266 3 => 'YCbCr, ITU-R BT 601-1, RGB',
267 4 => 'YCbCr, ITU-R BT 601-1, video',
268 8 => 'Gray-scale',
269 9 => 'PhotoYCC',
270 10 => 'RGB',
271 11 => 'CMY',
272 12 => 'CMYK',
273 13 => 'YCCK',
274 14 => 'CIELab',
275 },
276 },
277 15 => 'BitsPerSample',
278 16 => {
279 Name => 'Compression',
280 PrintConv => {
281 0 => 'Uncompressed, interleaved, 8 bits per sample',
282 1 => 'Modified Huffman',
283 2 => 'Modified READ',
284 3 => 'Modified Modified READ',
285 4 => 'JBIG',
286 5 => 'JPEG',
287 },
288 },
289 17 => {
290 Name => 'ResolutionUnit',
291 PrintConv => {
292 0 => 'None',
293 1 => 'inches',
294 2 => 'cm',
295 },
296 },
297 18 => {
298 Name => 'YResolution',
299 Format => 'int32u',
300 },
301 22 => {
302 Name => 'XResolution',
303 Format => 'int32u',
304 },
305);
306
307# AdobeCM APP13 (no references)
308%Image::ExifTool::JPEG::AdobeCM = (
309 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
310 GROUPS => { 0 => 'APP13', 1 => 'AdobeCM', 2 => 'Image' },
311 NOTES => q{
312 The "Adobe_CM" APP13 segment presumably contains color management
313 information, but the meaning of the data is currently unknown. If anyone
314 has an idea about what this means, please let me know.
315 },
316 FORMAT => 'int16u',
317 0 => 'AdobeCMType',
318);
319
320# Adobe APP14 refs:
321# http://partners.adobe.com/public/developer/en/ps/sdk/5116.DCT_Filter.pdf
322# http://java.sun.com/j2se/1.5.0/docs/api/javax/imageio/metadata/doc-files/jpeg_metadata.html#color
323%Image::ExifTool::JPEG::Adobe = (
324 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
325 GROUPS => { 0 => 'APP14', 1 => 'Adobe', 2 => 'Image' },
326 NOTES => 'The "Adobe" APP14 segment stores image encoding information for DCT filters.',
327 FORMAT => 'int16u',
328 0 => 'DCTEncodeVersion',
329 1 => {
330 Name => 'APP14Flags0',
331 PrintConv => { BITMASK => {
332 15 => 'Encoded with Blend=1 downsampling'
333 } },
334 },
335 2 => {
336 Name => 'APP14Flags1',
337 PrintConv => { BITMASK => { } },
338 },
339 3 => {
340 Name => 'ColorTransform',
341 Format => 'int8u',
342 PrintConv => {
343 0 => 'Unknown (RGB or CMYK)',
344 1 => 'YCbCr',
345 2 => 'YCCK',
346 },
347 },
348);
349
350# GraphicConverter APP15 (ref PH)
351%Image::ExifTool::JPEG::GraphConv = (
352 GROUPS => { 0 => 'APP15', 1 => 'GraphConv', 2 => 'Image' },
353 NOTES => 'APP15 is used by GraphicConverter to store JPEG quality.',
354 'Q' => 'Quality',
355);
356
357# AVI1 APP0 segment (ref http://www.schnarff.com/file-formats/bmp/BMPDIB.TXT)
358%Image::ExifTool::JPEG::AVI1 = (
359 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
360 GROUPS => { 0 => 'APP0', 1 => 'AVI1', 2 => 'Image' },
361 NOTES => 'This information may be found in APP0 of JPEG image data from AVI videos.',
362 FIRST_ENTRY => 0,
363 0 => {
364 Name => 'InterleavedField',
365 PrintConv => {
366 0 => 'Not Interleaved',
367 1 => 'Odd',
368 2 => 'Even',
369 },
370 },
371);
372
373# Ocad APP0 segment (ref PH)
374%Image::ExifTool::JPEG::Ocad = (
375 PROCESS_PROC => \&ProcessOcad,
376 GROUPS => { 0 => 'APP0', 1 => 'Ocad', 2 => 'Image' },
377 FIRST_ENTRY => 0,
378 NOTES => q{
379 Tags extracted from the JPEG APP0 "Ocad" segment (found in Photobucket
380 images).
381 },
382 Rev => {
383 Name => 'OcadRevision',
384 Format => 'string[6]',
385 }
386);
387
388# NITF APP6 segment (National Imagery Transmission Format)
389# ref http://www.gwg.nga.mil/ntb/baseline/docs/n010697/bwcguide25aug98.pdf
390%Image::ExifTool::JPEG::NITF = (
391 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
392 GROUPS => { 0 => 'APP6', 1 => 'NITF', 2 => 'Image' },
393 NOTES => q{
394 Information in APP6 used by the National Imagery Transmission Format. See
395 L<http://www.gwg.nga.mil/ntb/baseline/docs/n010697/bwcguide25aug98.pdf> for
396 the official specification.
397 },
398 0 => {
399 Name => 'NITFVersion',
400 Format => 'int8u[2]',
401 ValueConv => 'sprintf("%d.%.2d", split(" ",$val))',
402 },
403 2 => {
404 Name => 'ImageFormat',
405 ValueConv => 'chr($val)',
406 PrintConv => { B => 'IMode B' },
407 },
408 3 => {
409 Name => 'BlocksPerRow',
410 Format => 'int16u',
411 },
412 5 => {
413 Name => 'BlocksPerColumn',
414 Format => 'int16u',
415 },
416 7 => {
417 Name => 'ImageColor',
418 PrintConv => { 0 => 'Monochrome' },
419 },
420 8 => 'BitDepth',
421 9 => {
422 Name => 'ImageClass',
423 PrintConv => {
424 0 => 'General Purpose',
425 4 => 'Tactical Imagery',
426 },
427 },
428 10 => {
429 Name => 'JPEGProcess',
430 PrintConv => {
431 1 => 'Baseline sequential DCT, Huffman coding, 8-bit samples',
432 4 => 'Extended sequential DCT, Huffman coding, 12-bit samples',
433 },
434 },
435 11 => 'Quality',
436 12 => {
437 Name => 'StreamColor',
438 PrintConv => { 0 => 'Monochrome' },
439 },
440 13 => 'StreamBitDepth',
441 14 => {
442 Name => 'Flags',
443 Format => 'int32u',
444 PrintConv => 'sprintf("0x%x", $val)',
445 },
446);
447
448# information written by Scalado software (PhotoFusion maybe?)
449%Image::ExifTool::JPEG::Scalado = (
450 GROUPS => { 0 => 'APP4', 1 => 'Scalado', 2 => 'Image' },
451 PROCESS_PROC => \&ProcessScalado,
452 TAG_PREFIX => 'Scalado',
453 FORMAT => 'int32s',
454 # I presume this was written by
455 NOTES => q{
456 Tags extracted from the JPEG APP4 "SCALADO" segment (presumably written by
457 Scalado mobile software, L<http://www.scalado.com/>).
458 },
459 SPMO => {
460 Name => 'DataLength',
461 Unkown => 1,
462 },
463 WDTH => {
464 Name => 'PreviewImageWidth',
465 ValueConv => '$val ? abs($val) : undef',
466 },
467 HGHT => {
468 Name => 'PreviewImageHeight',
469 ValueConv => '$val ? abs($val) : undef',
470 },
471 QUAL => {
472 Name => 'PreviewQuality',
473 ValueConv => '$val ? abs($val) : undef',
474 },
475 # tags not yet decoded with observed values:
476 # CHKH: 0, -9010
477 # CHKL: -2664, -12852
478 # CLEN: -1024
479 # CSPC: -2232593
480 # DATA: (+ve data length)
481 # HDEC: 0
482 # MAIN: 0
483 # SCI0: (+ve data length)
484 # SCX1: (+ve data length)
485 # WDEC: 0
486);
487
488#------------------------------------------------------------------------------
489# Extract information from the JPEG APP0 Ocad segment
490# Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
491# Returns: 1 on success
492sub ProcessOcad($$$)
493{
494 my ($exifTool, $dirInfo, $tagTablePtr) = @_;
495 my $dataPt = $$dirInfo{DataPt};
496 $exifTool->VerboseDir('APP0 Ocad', undef, length $$dataPt);
497 for (;;) {
498 last unless $$dataPt =~ /\$(\w+):([^\0\$]+)/g;
499 my ($tag, $val) = ($1, $2);
500 $val =~ s/(^\s+|\s+$)//g; # remove leading/trailing spaces
501 unless ($$tagTablePtr{$tag}) {
502 Image::ExifTool::AddTagToTable($tagTablePtr, $tag, { Name => "Ocad_$tag" });
503 }
504 $exifTool->HandleTag($tagTablePtr, $tag, $val);
505 }
506 return 1;
507}
508
509#------------------------------------------------------------------------------
510# Extract information from the JPEG APP4 SCALADO segment
511# Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
512# Returns: 1 on success
513sub ProcessScalado($$$)
514{
515 my ($exifTool, $dirInfo, $tagTablePtr) = @_;
516 my $dataPt = $$dirInfo{DataPt};
517 my $pos = 0;
518 my $end = length $$dataPt;
519 SetByteOrder('MM');
520 $exifTool->VerboseDir('APP4 SCALADO', undef, $end);
521 for (;;) {
522 last if $pos + 12 > $end;
523 my $tag = substr($$dataPt, $pos, 4);
524 my $unk = Get32u($dataPt, $pos + 4); # (what is this?)
525 $exifTool->HandleTag($tagTablePtr, $tag, undef,
526 DataPt => $dataPt,
527 Start => $pos + 8,
528 Size => 4,
529 Extra => ", unk $unk",
530 );
531 # shorten directory size by length of SPMO
532 $end -= Get32u($dataPt, $pos + 8) if $tag eq 'SPMO';
533 $pos += 12;
534 }
535 return 1;
536}
537
5381; # end
539
540__END__
541
542=head1 NAME
543
544Image::ExifTool::JPEG - Definitions for uncommon JPEG segments
545
546=head1 SYNOPSIS
547
548This module is used by Image::ExifTool
549
550=head1 DESCRIPTION
551
552This module contains definitions required by Image::ExifTool for some
553uncommon JPEG segments. For speed reasons, definitions for more common JPEG
554segments are included in the Image::ExifTool module itself.
555
556=head1 AUTHOR
557
558Copyright 2003-2011, Phil Harvey (phil at owl.phy.queensu.ca)
559
560This library is free software; you can redistribute it and/or modify it
561under the same terms as Perl itself.
562
563=head1 SEE ALSO
564
565L<Image::ExifTool::TagNames/JPEG Tags>,
566L<Image::ExifTool(3pm)|Image::ExifTool>
567
568=cut
569
Note: See TracBrowser for help on using the repository browser.