lib/Image/TIFF.pm

filter: Statementstmt 87.4% 167 / 191 Branchbran 77.0% 77 / 100 Conditioncond 73.1% 30 / 41 MC/DCmcdc 48.0% 12 / 25 Subroutinesub 100% 16 / 16 Podpod 0.0% 0 / 10 totaltotal 78.8% 302 / 383 CC 72 SCAR 37.7
CC
72
Cov
83%
add_fields
68.7
new
11.2
exif_tagname
3.0
CRAP 43.6
« lib/Image/Info/GIF.pm ↑ Summary lib/Image/Info/PNG.pm »
1 package Image::TIFF;
2  
3 # Copyright 1999-2001, Gisle Aas.
4 # Copyright 2006, 2007 Tels
5 #
6 # This library is free software; you can redistribute it and/or
7 # modify it under the same terms as Perl v5.8.8 itself.
8  
9 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 12 our $VERSION = '1.12';
12  
13 12 my @types = (
14 [ "BYTE", "C1", 1],
15 [ "ASCII", "A1", 1],
16 [ "SHORT", "n1", 2],
17 [ "LONG", "N1", 4],
18 [ "RATIONAL", "N2", 8],
19 [ "SBYTE", "c1", 1],
20 [ "UNDEFINED", "a1", 1],
21 [ "SSHORT", "n1", 2],
22 [ "SLONG", "N1", 4],
23 [ "SRATIONAL", "N2", 8],
24 [ "FLOAT", "f1", 4], # XXX 4-byte IEEE format
25 [ "DOUBLE", "d1", 8], # XXX 8-byte IEEE format
26 # XXX TODO:
27 # [ "IFD", "??", ?], # See ExifTool
28 );
29  
30 12 my %nikon1_tags = (
31 0x0003 => "Quality",
32 0x0004 => "ColorMode",
33 0x0005 => "ImageAdjustment",
34 0x0006 => "CCDSensitivity",
35 0x0007 => "Whitebalance",
36 0x0008 => "Focus",
37 0x000A => "DigitalZoom",
38 0x000B => "Converter",
39 );
40  
41 12 my %nikon2_tags = (
42 0x0001 => "NikonVersion",
43 0x0002 => "ISOSetting",
44 0x0003 => "ColorMode",
45 0x0004 => "Quality",
46 0x0005 => "Whitebalance",
47 0x0006 => "ImageSharpening",
48 0x0007 => "FocusMode",
49 0x0008 => "FlashSetting",
50 0x0009 => "FlashMetering",
51 0x000B => "WBAdjustment",
52 0x000F => "ISOSelection",
53 0x0080 => "ImageAdjustment",
54 0x0082 => "AuxiliaryLens",
55 0x0084 => "Lens",
56 0x0085 => "ManualFocusDistance",
57 0x0086 => "DigitalZoom",
58 0x0088 => { __TAG__ => "AFFocusPosition",
59 pack("xCxx",0) => "Center",
60 pack("xCxx",1) => "Top",
61 pack("xCxx",2) => "Bottom",
62 pack("xCxx",3) => "Left",
63 pack("xCxx",4) => "Right",
64 },
65 0x008d => "ColorMode",
66 0x0090 => "FlashType",
67 0x0095 => "NoiseReduction",
68 0x0010 => "DataDump",
69 );
70  
71 12 my %olympus_tags = (
72 0x0200 => "SpecialMode",
73 0x0201 => { __TAG__ => "JpegQual", 0 => "SQ", 1 => "HQ", 2 => "SHQ" },
74 0x0202 => { __TAG__ => "Macro", 0 => "Normal", 1 => "Macro" },
75 0x0204 => "DigiZoom",
76 0x0207 => "SoftwareRelease",
77 0x0208 => "PictInfo",
78 0x0209 => "CameraID",
79 0x0f00 => "DataDump",
80 );
81  
82 12 my %fujifilm_tags = (
83 0x0000 => "Version",
84 0x1000 => "Quality",
85 0x1001 => { __TAG__ => "Sharpness",
86 1 => "Very Soft",
87 2 => "Soft",
88 3 => "Normal",
89 4 => "Hard",
90 5 => "Very Hard",
91 },
92 0x1002 => { __TAG__ => "WhiteBalance",
93 0 => "Auto",
94 256 => "Daylight",
95 512 => "Cloudy",
96 768 => "DaylightColor-fluorescence",
97 769 => "DaywhiteColor-fluorescence",
98 770 => "White-fluorescence",
99 1024 => "Incandenscense",
100 3840 => "Custom white balance",
101 },
102 0x1003 => { __TAG__ => "Color", 0 => "Normal", 256 => "High", 512 => "Low" },
103 0x1004 => { __TAG__ => "Tone" , 0 => "Normal", 256 => "High", 512 => "Low" },
104 0x1010 => { __TAG__ => "FlashMode", 0 => "Auto", 1 => "On", 2 => "Off", 3 => "Red-eye reduction" },
105 0x1011 => "FlashStrength",
106 0x1020 => { __TAG__ => "Macro", 0 => "Off", 1 => "On"},
107 0x1021 => { __TAG__ => "FocusMode", 0 => "Auto", 1 => "Manual" },
108 0x1030 => { __TAG__ => "SlowSync", 0 => "Off", 1 => "On"},
109 0x1031 => { __TAG__ => "PictureMode",
110 0 => "Auto",
111 1 => "Portrait",
112 2 => "Landscape",
113 4 => "Sports",
114 5 => "Night",
115 6 => "Program AE",
116 256 => "Aperture priority",
117 512 => "Shutter priority",
118 768 => "Manual",
119 },
120 0x1100 => { __TAG__ => "AutoBracketing", 0 => "Off", 1 => "On"},
121 0x1300 => { __TAG__ => "BlurWarning", 0 => "No", 1 => "Yes"},
122 0x1301 => { __TAG__ => "FocusWarning", 0 => "No", 1 => "Yes"},
123 0x1302 => { __TAG__ => "AEWarning", 0 => "No", 1 => "Yes"},
124 );
125  
126 12 my %casio_tags = (
127 0x0001 => { __TAG__ => "RecordingMode",
128 1 => "SingleShutter",
129 2 => "Panorama",
130 3 => "Night scene",
131 4 => "Portrait",
132 5 => "Landscape",
133 },
134 0x0002 => { __TAG__ => "Quality", 1 => "Economy", 2 => "Normal", 3 => "Fine" },
135 0x0003 => { __TAG__ => "FocusingMode",
136 2 => "Macro",
137 3 => "Auto",
138 4 => "Manual",
139 5 => "Infinity",
140 },
141 0x0004 => { __TAG__ => "FlashMode", 1 => "Auto", 2 => "On", 3 => "Off", 4 => "Red-eye reduction" },
142 0x0005 => { __TAG__ => "FlashIntensity", 11 => "Weak", 13 => "Normal", 15 => "Strong" },
143 0x0006 => "ObjectDistance",
144 0x0007 => { __TAG__ => "WhiteBalance",
145 1 => "Auto",
146 2 => "Tungsten",
147 3 => "Daylight",
148 4 => "Fluorescent",
149 5 => "Shade",
150 129 => "Manual",
151 },
152 0x000a => { __TAG__ => "DigitalZoom", 65536 => "Off", 65537 => "2X" },
153 0x000b => { __TAG__ => "Sharpness", 0 => "Normal", 1 => "Soft", 2 => "Hard" },
154 0x000c => { __TAG__ => "Contrast" , 0 => "Normal", 1 => "Low", 2 => "High" },
155 0x000d => { __TAG__ => "Saturation", 0 => "Normal", 1 => "Low", 2 => "High" },
156 0x0014 => { __TAG__ => "CCDSensitivity",
157 64 => "Normal",
158 125 => "+1.0",
159 250 => "+2.0",
160 244 => "+3.0",
161 80 => "Normal",
162 100 => "High",
163 },
164 );
165  
166 12 my %canon_0x0001_tags = (
167 0 => { __TAG__ => "MacroMode", 1 => "Macro", 2 => "Normal" },
168 1 => "SelfTimer",
169 2 => { __TAG__ => "Quality", 2 => "Normal", 3 => "Fine", 5 => "SuperFine" },
170 3 => 'Tag-0x0001-03',
171 4 => { __TAG__ => 'FlashMode',
172 0 => 'Flash Not Fired',
173 1 => 'Auto',
174 2 => 'On',
175 3 => 'Red-Eye Reduction',
176 4 => 'Slow Synchro',
177 5 => 'Auto + Red-Eye Reduction',
178 6 => 'On + Red-Eye Reduction',
179 16 => 'External Flash'
180 },
181 5 => { __TAG__ => 'ContinuousDriveMode', 0 => 'Single Or Timer', 1 => 'Continuous' },
182 6 => 'Tag-0x0001-06',
183 7 => { __TAG__ => 'FocusMode',
184 0 => 'One-Shot',
185 1 => 'AI Servo',
186 2 => 'AI Focus',
187 3 => 'MF',
188 4 => 'Single',
189 5 => 'Continuous',
190 6 => 'MF'
191 },
192 8 => 'Tag-0x0001-08',
193 9 => 'Tag-0x0001-09',
194 10 => { __TAG__ => 'ImageSize', 0 => 'Large', 1 => 'Medium', 2 => 'Small' },
195 11 => { __TAG__ => 'EasyShootingMode',
196 0 => 'Full Auto',
197 1 => 'Manual',
198 2 => 'Landscape',
199 3 => 'Fast Shutter',
200 4 => 'Slow Shutter',
201 5 => 'Night',
202 6 => 'B&W',
203 7 => 'Sepia',
204 8 => 'Portrait',
205 9 => 'Sports',
206 10 => 'Macro/Close-Up',
207 11 => 'Pan Focus'
208 },
209 12 => { __TAG__ => 'DigitalZoom', 0 => 'None', 1 => '2x', 2 => '4x' },
210 13 => { __TAG__ => 'Contrast', 0xFFFF => 'Low', 0 => 'Normal', 1 => 'High' },
211 14 => { __TAG__ => 'Saturation', 0xFFFF => 'Low', 0 => 'Normal', 1 => 'High' },
212 15 => { __TAG__ => 'Sharpness', 0xFFFF => 'Low', 0 => 'Normal', 1 => 'High' },
213 16 => { __TAG__ => 'ISO',
214 0 => 'See ISOSpeedRatings Tag',
215 15 => 'Auto',
216 16 => '50',
217 17 => '100',
218 18 => '200',
219 19 => '400'
220 },
221 17 => { __TAG__ => 'MeteringMode', 3 => 'Evaluative', 4 => 'Partial', 5 => 'Center-Weighted' },
222 18 => { __TAG__ => 'FocusType',
223 0 => 'Manual',
224 1 => 'Auto',
225 3 => 'Close-Up (Macro)',
226 8 => 'Locked (Pan Mode)'
227 },
228 19 => { __TAG__ => 'AFPointSelected',
229 0x3000 => 'None { __TAG__ => MF)',
230 0x3001 => 'Auto-Selected',
231 0x3002 => 'Right',
232 0x3003 => 'Center',
233 0x3004 => 'Left'
234 },
235 20 => { __TAG__ => 'ExposureMode',
236 0 => 'Easy Shooting',
237 1 => 'Program',
238 2 => 'Tv-priority',
239 3 => 'Av-priority',
240 4 => 'Manual',
241 5 => 'A-DEP'
242 },
243 21 => 'Tag-0x0001-21',
244 22 => 'Tag-0x0001-22',
245 23 => 'LongFocalLengthOfLensInFocalUnits',
246 24 => 'ShortFocalLengthOfLensInFocalUnits',
247 25 => 'FocalUnitsPerMM',
248 26 => 'Tag-0x0001-26',
249 27 => 'Tag-0x0001-27',
250 28 => { __TAG__ => 'FlashActivity', 0 => 'Did Not Fire', 1 => 'Fired' },
251 29 => { __TAG__ => 'FlashDetails',
252 14 => 'External E-TTL',
253 13 => 'Internal Flash',
254 11 => 'FP Sync Used',
255 7 => '2nd ("Rear")-Curtain Sync Used',
256 4 => 'FP Sync Enabled'
257 },
258 30 => 'Tag-0x0001-30',
259 31 => 'Tag-0x0001-31',
260 32 => { __TAG__ => 'FocusMode', 0 => 'Single', 1 => 'Continuous' },
261 );
262  
263 12 my %canon_0x0004_tags = (
264 7 => { __TAG__ => 'WhiteBalance',
265 0 => 'Auto',
266 1 => 'Sunny',
267 2 => 'Cloudy',
268 3 => 'Tungsten',
269 4 => 'Fluorescent',
270 5 => 'Flash',
271 6 => 'Custom'
272 },
273 9 => 'SequenceNumber',
274 14 => 'AFPointUsed',
275 15 => { __TAG__ => 'FlashBias',
276 0xFFC0 => '-2 EV',
277 0xFFCC => '-1.67 EV',
278 0xFFD0 => '-1.50 EV',
279 0xFFD4 => '-1.33 EV',
280 0xFFE0 => '-1 EV',
281 0xFFEC => '-0.67 EV',
282 0xFFF0 => '-0.50 EV',
283 0xFFF4 => '-0.33 EV',
284 0x0000 => '0 EV',
285 0x000C => '0.33 EV',
286 0x0010 => '0.50 EV',
287 0x0014 => '0.67 EV',
288 0x0020 => '1 EV',
289 0x002C => '1.33 EV',
290 0x0030 => '1.50 EV',
291 0x0034 => '1.67 EV',
292 0x0040 => '2 EV',
293 },
294 19 => 'SubjectDistance'
295 );
296  
297  
298 12 my %canon_tags = (
299 0x0001 => { __TAG__ => "Custom_0x0001", __ARRAYOFFSET__ => \%canon_0x0001_tags },
300 0x0004 => { __TAG__ => "Custom_0x0004", __ARRAYOFFSET__ => \%canon_0x0004_tags },
301 0x0006 => "ImageType",
302 0x0007 => "FirmwareVersion",
303 0x0008 => "ImageNumber",
304 0x0009 => "OwnerName",
305 0x000c => "SerialNumber",
306 );
307  
308 # see http://www.compton.nu/panasonic.html
309  
310 12 my %panasonic_tags = (
311 0x0001 => { __TAG__ => "ImageQuality",
312 2 => 'High',
313 3 => 'Normal',
314 6 => 'Very High', #3 (Leica)
315 7 => 'Raw', #3 (Leica)
316 },
317 0x0002 => "FirmwareVersion",
318 0x0003 => { __TAG__ => "WhiteBalance",
319 1 => 'Auto',
320 2 => 'Daylight',
321 3 => 'Cloudy',
322 4 => 'Halogen',
323 5 => 'Manual',
324 8 => 'Flash',
325 10 => 'Black & White', #3 (Leica)
326 },
327 0x0007 => { __TAG__ => "FocusMode",
328 1 => 'Auto',
329 2 => 'Manual',
330 5 => 'Auto, Continuous',
331 4 => 'Auto, Focus button',
332 },
333 0x000f => { __TAG__ => "SpotMode",
334 # XXX TODO: does not decode properly
335 "0,1" => 'On',
336 "0,16" => 'Off',
337 },
338 0x001a => { __TAG__ => "ImageStabilizer",
339 2 => 'On, Mode 1',
340 3 => 'Off',
341 4 => 'On, Mode 2',
342 },
343 0x001c => { __TAG__ => "MacroMode",
344 1 => 'On',
345 2 => 'Off',
346 },
347 0x001f => { __TAG__ => "ShootingMode",
348 1 => 'Normal',
349 2 => 'Portrait',
350 3 => 'Scenery',
351 4 => 'Sports',
352 5 => 'Night Portrait',
353 6 => 'Program',
354 7 => 'Aperture Priority',
355 8 => 'Shutter Priority',
356 9 => 'Macro',
357 11 => 'Manual',
358 13 => 'Panning',
359 18 => 'Fireworks',
360 19 => 'Party',
361 20 => 'Snow',
362 21 => 'Night Scenery',
363 },
364 0x0020 => { __TAG__ => "Audio",
365 1 => 'Yes',
366 2 => 'No',
367 },
368 0x0021 => "DataDump",
369 0x0022 => "Panasonic 0x0022",
370 0x0023 => "WhiteBalanceBias",
371 0x0024 => "FlashBias",
372 0x0025 => "SerialNumber",
373 0x0026 => "Panasonic 0x0026",
374 0x0027 => "Panasonic 0x0027",
375 0x0028 => { __TAG__ => "ColorEffect",
376 1 => 'Off',
377 2 => 'Warm',
378 3 => 'Cool',
379 4 => 'Black & White',
380 5 => 'Sepia',
381 },
382 0x0029 => "Panasonic 0x0029",
383 0x002a => { __TAG__ => "BurstMode",
384 0 => 'Off',
385 1 => 'Low/High Quality',
386 2 => 'Infinite',
387 },
388 0x002b => "ImageSequenceNumber",
389 0x002c => { __TAG__ => "Contrast",
390 0 => 'Normal',
391 1 => 'Low',
392 2 => 'High',
393 0x100 => 'Low', # Leica
394 0x110 => 'Normal', # Leica
395 0x120 => 'High', # Leica
396 },
397 0x002d => { __TAG__ => "NoiseReduction",
398 0 => 'Standard',
399 1 => 'Low',
400 2 => 'High',
401 },
402 0x002e => { __TAG__ => "SelfTimer",
403 1 => 'Off',
404 2 => '10s',
405 3 => '2s',
406 },
407 0x002f => "Panasonic 0x002f",
408 0x0030 => "Panasonic 0x0030",
409 0x0031 => "Panasonic 0x0031",
410 0x0032 => "Panasonic 0x0032",
411 );
412  
413 # format:
414 # "Make Model" => [ Offset, 'Tag_prefix', ptr to tags ]
415 # Offset is either 0, or a positive number of Bytes.
416 # Offset -1 or -2 means a kludge for Fuji or Nikon
417  
418 12 my %makernotes = (
419 "NIKON CORPORATION NIKON D1" => [0, 'NikonD1', \%nikon2_tags],
420 "NIKON CORPORATION NIKON D70" => [-2, 'NikonD1', \%nikon2_tags],
421 "NIKON CORPORATION NIKON D100" => [-2, 'NikonD1', \%nikon2_tags],
422  
423 # For the following manufacturers we simple discard the model and always
424 # decode the MakerNote in the same manner. This makes it work with all
425 # models, even yet unreleased ones. (That's better than the very limited
426 # list of models we previously had)
427  
428 "CANON" => [0, 'Canon', \%canon_tags],
429 'PANASONIC' => [12, 'Panasonic', \%panasonic_tags],
430 "FUJIFILM" => [-1, 'FinePix', \%fujifilm_tags],
431 "CASIO" => [0, 'Casio', \%casio_tags],
432 "OLYMPUS" => [8, 'Olympus', \%olympus_tags],
433 );
434  
435 BEGIN
436 12 ▶ {
Subroutine BEGIN: called CC=3 SCAR=11.0
437 # add some Nikon cameras
438 12 for my $model (qw/E700 E800 E900 E900S E910 E950/)
439 {
440 72 $makernotes{'NIKON ' . $model} = [8, 'CoolPix', \%nikon1_tags];
441 }
442 12 for my $model (qw/E880 E990 E995/)
443 {
444 36 $makernotes{'NIKON ' . $model} = [0, 'CoolPix', \%nikon2_tags];
445 }
446 }
447  
448 12 my %exif_intr_tags = (
449 0x1 => "InteroperabilityIndex",
450 0x2 => "InteroperabilityVersion",
451 0x1000 => "RelatedImageFileFormat",
452 0x1001 => "RelatedImageWidth",
453 0x1002 => "RelatedImageLength",
454 );
455  
456 # Tag decode helpers
457 sub components_configuration_decoder;
458 sub file_source_decoder;
459 sub scene_type_decoder;
460  
461 12 my %exif_tags = (
462 0x828D => "CFARepeatPatternDim",
463 0x828E => "CFAPattern",
464 0x828F => "BatteryLevel",
465 0x8298 => "Copyright",
466 0x829A => "ExposureTime",
467 0x829D => "FNumber",
468 0x83BB => "IPTC/NAA",
469 0x8769 => "ExifOffset",
470 0x8773 => "InterColorProfile",
471 0x8822 => { __TAG__ => "ExposureProgram",
472 0 => "unknown",
473 1 => "Manual",
474 2 => "Program",
475 3 => "Aperture priority",
476 4 => "Shutter priority",
477 5 => "Program creative",
478 6 => "Program action",
479 7 => "Portrait",
480 8 => "Landscape",
481 # 9 .. 255 reserved
482 },
483 0x8824 => "SpectralSensitivity",
484 0x8827 => "ISOSpeedRatings",
485 0x8828 => "OECF",
486 0x9000 => "ExifVersion",
487 0x9003 => "DateTimeOriginal",
488 0x9004 => "DateTimeDigitized",
489 0x9101 => { __TAG__ => "ComponentsConfiguration",
490 DECODER => \&components_configuration_decoder,
491 },
492 0x9102 => "CompressedBitsPerPixel",
493 0x9201 => "ShutterSpeedValue",
494 0x9202 => "ApertureValue",
495 0x9203 => "BrightnessValue",
496 0x9204 => "ExposureBiasValue",
497 0x9205 => "MaxApertureValue",
498 0x9206 => "SubjectDistance",
499 0x9207 => { __TAG__ => "MeteringMode",
500 0 => "unknown",
501 1 => "Average",
502 2 => "CenterWeightedAverage",
503 3 => "Spot",
504 4 => "MultiSpot",
505 5 => "Pattern",
506 6 => "Partial",
507 # 7 .. 254 reserved in EXIF 1.2
508 255 => "other",
509 },
510 0x9208 => { __TAG__ => "LightSource",
511 0 => "unknown",
512 1 => "Daylight",
513 2 => "Fluorescent",
514 3 => "Tungsten",
515 4 => "Flash",
516 # 5 .. 8 reserved in EXIF 2.2
517 9 => "Fine weather",
518 10 => "Cloudy weather",
519 11 => "Shade",
520 12 => "Daylight fluorescent (D 5700-7100K)",
521 13 => "Day white fluorescent (N 4600-5400K)",
522 14 => "Cool white fluorescent (W 3900-4500K)",
523 15 => "White fluorescent (WW 3200-3700K)",
524 17 => "Standard light A",
525 18 => "Standard light B",
526 19 => "Standard light C",
527 20 => "D55",
528 21 => "D65",
529 22 => "D75",
530 23 => "D50",
531 24 => "ISO studio tungesten",
532 # 25 .. 254 reserved in EXIF 2.2
533 255 => "other light source",
534 },
535 0x9209 => { __TAG__ => "Flash",
536 0x0000 => "Flash did not fire",
537 0x0001 => "Flash fired",
538 0x0005 => "Strobe return light not detected",
539 0x0007 => "Strobe return light detected",
540 0x0009 => "Flash fired, compulsory flash mode",
541 0x000D => "Flash fired, compulsory flash mode, return light not detected",
542 0x000F => "Flash fired, compulsory flash mode, return light detected",
543 0x0010 => "Flash did not fire, compulsory flash mode",
544 0x0018 => "Flash did not fire, auto mode",
545 0x0019 => "Flash fired, auto mode",
546 0x001D => "Flash fired, auto mode, return light not detected",
547 0x001F => "Flash fired, auto mode, return light detected",
548 0x0020 => "No flash function",
549 0x0041 => "Flash fired, red-eye reduction mode",
550 0x0045 => "Flash fired, red-eye reduction mode, return light not detected",
551 0x0047 => "Flash fired, red-eye reduction mode, return light detected",
552 0x0049 => "Flash fired, compulsory flash mode, red-eye reduction mode",
553 0x004D => "Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",
554 0x004F => "Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",
555 0x0059 => "Flash fired, auto mode, red-eye reduction mode",
556 0x005D => "Flash fired, auto mode, return light not detected, red-eye reduction mode",
557 0x005F => "Flash fired, auto mode, return light detected, red-eye reduction mode"
558 },
559 0x920A => "FocalLength",
560 0x9214 => "SubjectArea",
561 0x927C => "MakerNote",
562 0x9286 => "UserComment",
563 0x9290 => "SubSecTime",
564 0x9291 => "SubSecTimeOriginal",
565 0x9292 => "SubSecTimeDigitized",
566 0xA000 => "FlashPixVersion",
567 0xA001 => "ColorSpace",
568 0xA002 => "ExifImageWidth",
569 0xA003 => "ExifImageLength",
570 0xA004 => "RelatedAudioFile",
571 0xA005 => {__TAG__ => "InteroperabilityOffset",
572 __SUBIFD__ => \%exif_intr_tags,
573 },
574 0xA20B => "FlashEnergy", # 0x920B in TIFF/EP
575 0xA20C => "SpatialFrequencyResponse", # 0x920C - -
576 0xA20E => "FocalPlaneXResolution", # 0x920E - -
577 0xA20F => "FocalPlaneYResolution", # 0x920F - -
578 0xA210 => { __TAG__ => "FocalPlaneResolutionUnit", # 0x9210 - -
579 1 => "pixels",
580 2 => "dpi",
581 3 => "dpcm",
582 },
583 0xA214 => "SubjectLocation", # 0x9214 - -
584 0xA215 => "ExposureIndex", # 0x9215 - -
585 0xA217 => {__TAG__ => "SensingMethod",
586 1 => "Not defined",
587 2 => "One-chip color area sensor",
588 3 => "Two-chip color area sensor",
589 4 => "Three-chip color area sensor",
590 5 => "Color sequential area sensor",
591 7 => "Trilinear sensor",
592 8 => "Color sequential linear sensor"
593 },
594 0xA300 => {__TAG__ => "FileSource",
595 DECODER => \&file_source_decoder,
596 },
597 0xA301 => {__TAG__ => "SceneType",
598 DECODER => \&scene_type_decoder,
599 },
600 0xA302 => "CFAPattern",
601 0xA401 => {__TAG__ => "CustomRendered",
602 0 => "Normal process",
603 1 => "Custom process"
604 },
605 0xA402 => {__TAG__ => "ExposureMode",
606 0 => "Auto exposure",
607 1 => "Manual exposure",
608 2 => "Auto bracket"
609 },
610 0xA403 => {__TAG__ => "WhiteBalance",
611 0 => "Auto white balance",
612 1 => "Manual white balance"
613 },
614 0xA404 => "DigitalZoomRatio",
615 0xA405 => "FocalLengthIn35mmFilm",
616 0xA406 => {__TAG__ => "SceneCaptureType",
617 0 => "Standard",
618 1 => "Landscape",
619 2 => "Portrait",
620 3 => "Night Scene"
621 },
622 0xA407 => {__TAG__ => "GainControl",
623 0 => "None",
624 1 => "Low gain up",
625 2 => "High gain up",
626 3 => "Low gain down",
627 4 => "High gain down"
628 },
629 0xA408 => {__TAG__ => "Contrast",
630 0 => "Normal",
631 1 => "Soft",
632 2 => "Hard"
633 },
634 0xA409 => {__TAG__ => "Saturation",
635 0 => "Normal",
636 1 => "Low saturation",
637 2 => "High saturation"
638 },
639 0xA40A => {__TAG__ => "Sharpness",
640 0 => "Normal",
641 1 => "Soft",
642 2 => "Hard"
643 },
644 0xA40B => "DeviceSettingDescription",
645 0xA40C => {__TAG__ => "SubjectDistanceRange",
646 0 => "Unknown",
647 1 => "Macro",
648 2 => "Close view",
649 3 => "Distant view"
650 },
651 0xA420 => "ImageUniqueID",
652 );
653  
654 12 my %gps_tags = (
655 0x0000 => 'GPSVersionID',
656 0x0001 => 'GPSLatitudeRef',
657 0x0002 => 'GPSLatitude',
658 0x0003 => 'GPSLongitudeRef',
659 0x0004 => 'GPSLongitude',
660 0x0005 => 'GPSAltitudeRef',
661 0x0006 => 'GPSAltitude',
662 0x0007 => 'GPSTimeStamp',
663 0x0008 => 'GPSSatellites',
664 0x0009 => 'GPSStatus',
665 0x000A => 'GPSMeasureMode',
666 0x000B => 'GPSDOP',
667 0x000C => 'GPSSpeedRef',
668 0x000D => 'GPSSpeed',
669 0x000E => 'GPSTrackRef',
670 0x000F => 'GPSTrack',
671 0x0010 => 'GPSImgDirectionRef',
672 0x0011 => 'GPSImgDirection',
673 0x0012 => 'GPSMapDatum',
674 0x0013 => 'GPSDestLatitudeRef',
675 0x0014 => 'GPSDestLatitude',
676 0x0015 => 'GPSDestLongitudeRef',
677 0x0016 => 'GPSDestLongitude',
678 0x0017 => 'GPSDestBearingRef',
679 0x0018 => 'GPSDestBearing',
680 0x0019 => 'GPSDestDistanceRef',
681 0x001A => 'GPSDestDistance',
682 0x001B => 'GPSProcessingMethod',
683 0x001C => 'GPSAreaInformation',
684 0x001D => 'GPSDateStamp',
685 0x001E => 'GPSDifferential',
686 );
687  
688 12 my %tiff_tags = (
689 254 => { __TAG__ => "NewSubfileType",
690 1 => "ReducedResolution",
691 2 => "SinglePage",
692 4 => "TransparencyMask",
693 },
694 255 => { __TAG__ => "SubfileType",
695 1 => "FullResolution",
696 2 => "ReducedResolution",
697 3 => "SinglePage",
698 },
699 256 => "width",
700 257 => "height",
701 258 => "BitsPerSample",
702 259 => { __TAG__ => "Compression",
703 1 => "PackBytes",
704 2 => "CCITT Group3",
705 3 => "CCITT T4",
706 4 => "CCITT T6",
707 5 => "LZW",
708 6 => "JPEG",
709 7 => "JPEG DCT",
710 8 => "Deflate (Adobe)",
711 32766 => "NeXT 2-bit RLE",
712 32771 => "#1 w/ word alignment",
713 32773 => "PackBits (Macintosh RLE)",
714 32809 => "ThunderScan RLE",
715 32895 => "IT8 CT w/padding",
716 32896 => "IT8 Linework RLE",
717 32897 => "IT8 Monochrome picture",
718 32898 => "IT8 Binary line art",
719 32908 => "Pixar companded 10bit LZW",
720 32909 => "Pixar companded 11bit ZIP",
721 32946 => "Deflate",
722 },
723 262 => { __TAG__ => "PhotometricInterpretation",
724 0 => "WhiteIsZero",
725 1 => "BlackIsZero",
726 2 => "RGB",
727 3 => "RGB Palette",
728 4 => "Transparency Mask",
729 5 => "CMYK",
730 6 => "YCbCr",
731 8 => "CIELab",
732 },
733 263 => { __TAG__ => "Threshholding",
734 1 => "NoDithering",
735 2 => "OrderedDither",
736 3 => "Randomized",
737 },
738 266 => { __TAG__ => "FillOrder",
739 1 => "LowInHigh",
740 2 => "HighInLow",
741 },
742 269 => "DocumentName",
743 270 => "ImageDescription",
744 271 => "Make",
745 272 => "Model",
746 273 => "StripOffsets",
747 274 => { __TAG__ => "Orientation",
748 1 => "top_left",
749 2 => "top_right",
750 3 => "bot_right",
751 4 => "bot_left",
752 5 => "left_top",
753 6 => "right_top",
754 7 => "right_bot",
755 8 => "left_bot",
756 },
757 277 => "SamplesPerPixel",
758 278 => "RowsPerStrip",
759 279 => "StripByteCounts",
760 282 => "XResolution",
761 283 => "YResolution",
762 284 => {__TAG__ => "PlanarConfiguration",
763 1 => "Chunky", 2 => "Planar",
764 },
765 296 => {__TAG__ => "ResolutionUnit",
766 1 => "pixels", 2 => "dpi", 3 => "dpcm",
767 },
768 297 => "PageNumber",
769 301 => "TransferFunction",
770 305 => "Software",
771 306 => "DateTime",
772 315 => "Artist",
773 316 => "Host",
774 318 => "WhitePoint",
775 319 => "PrimaryChromaticities",
776 320 => "ColorMap",
777 513 => "JPEGInterchangeFormat",
778 514 => "JPEGInterchangeFormatLength",
779 529 => "YCbCrCoefficients",
780 530 => "YCbCrSubSampling",
781 531 => "YCbCrPositioning",
782 532 => "ReferenceBlackWhite",
783 33432 => "Copyright",
784 34665 => { __TAG__ => "ExifOffset",
785 __SUBIFD__ => \%exif_tags,
786 },
787 34853 => { __TAG__ => "GPSInfo",
788 __SUBIFD__ => \%gps_tags,
789 },
790 );
791  
792  
793 sub new
794 18 ▶{
Subroutine new: called CC=9 SCAR=24.2
Pod undocumented
795 18 my $class = shift;
796 18 my $source = shift;
797  
798 18 ▶ if (!ref($source)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $source) 0 18 18
799 0 local(*F);
800 0 ▶ open(F, $source) || return;
Branch: 1 branch
BranchTrueFalseTotal
open F, $source or return 0 0 0
801 0 binmode(F);
802 0 $source = \*F;
803 }
804  
805 18 ▶ if (ref($source) ne "SCALAR") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $source ne "SCALAR") 0 18 18
806 # XXX should really only read the file on demand
807 0 local($/); # slurp mode
808 0 my $data = <$source>;
809 0 $source = \$data;
810 }
811  
812 18 my $self = bless { source => $source }, $class;
813  
814 18 for ($$source) {
815 18 my $byte_order = substr($_, 0, 2);
816 18 $self->{little_endian} = ($byte_order eq "II");
817 18 $self->{version} = $self->unpack("n", substr($_, 2, 2));
818  
819 18 my $ifd = $self->unpack("N", substr($_, 4, 4));
820 18 ▶ while ($ifd) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ifd) 33 0 33
821 33 push(@{$self->{ifd}}, $ifd);
822 33 my($num_fields) = $self->unpack("x$ifd n", $_);
823  
824 33 my $substr_ifd = substr($_, $ifd + 2 + $num_fields*12, 4);
825 33 ▶ last unless defined $substr_ifd; # bad TIFF header, eg: substr idx > length($substr_ifd)
Branch: 1 branch
BranchTrueFalseTotal
unless defined $substr_ifd 1 32 33
826  
827 32 my $next_ifd = $self->unpack("N", $substr_ifd);
828  
829 # guard against (bug #26127)
830 32 ▶ $next_ifd = 0 if $next_ifd > length($_);
Branch: 1 branch
BranchTrueFalseTotal
if $next_ifd > length $_ 0 32 32
831 # guard against looping ifd (bug #26130)
832 32 ▶ if ($next_ifd <= $ifd) {
Branch: 1 branch
BranchTrueFalseTotal
if ($next_ifd <= $ifd) 17 15 32
833 # bad TIFF header - would cause a loop or strange results
834 17 last;
835 }
836 15 $ifd = $next_ifd;
837 }
838 }
839  
840 18 $self;
841 }
842  
843 sub unpack
844 1836 ▶{
Subroutine unpack: called CC=2 SCAR=6.9
Pod undocumented
845 1836 my $self = shift;
846 1836 my $template = shift;
847 1836 ▶ if ($self->{little_endian}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"little_endian"}) 1803 33 1836
848 1803 $template =~ tr/nN/vV/;
849 }
850 #print "UNPACK $template\n";
851 1836 CORE::unpack($template, $_[0]);
852 }
853  
854 sub num_ifds
855 18 ▶{
Subroutine num_ifds: called CC=1 SCAR=0.0
Pod undocumented
856 18 my $self = shift;
857 18 scalar @{$self->{ifd}};
858 }
859  
860 sub ifd
861 33 ▶{
Subroutine ifd: called CC=2 SCAR=6.9
Pod undocumented
862 33 my $self = shift;
863 33 ▶ my $num = shift || 0;
Condition100%2/2
shift() || 0
l!l
1518
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
864 33 my @ifd;
865  
866 33 $self->add_fields($self->{ifd}[$num], \@ifd);
867 }
868  
869 sub tagname
870 71 ▶{
Subroutine tagname: called CC=2 SCAR=7.6
Pod undocumented
871 71 ▶ $tiff_tags{$_[1]} || sprintf "Tag-0x%04x",$_[1];
Branch: 1 branch
BranchTrueFalseTotal
$tiff_tags{$_[1]} or sprintf "Tag-0x%04x", $_[1] 0 71 71
872 }
873  
874 sub exif_tagname
875 203 ▶{
Subroutine exif_tagname: called CC=3 SCAR=11.1
Pod undocumented
876 203 ▶ $tiff_tags{$_[1]} || $exif_tags{$_[1]} || sprintf "Tag-0x%04x",$_[1];
Branch: 1 branch
BranchTrueFalseTotal
$tiff_tags{$_[1]} or $exif_tags{$_[1]} or sprintf "Tag-0x%04x", $_[1] 196 7 203
Condition66%2/3
$tiff_tags{$_[1]} or $exif_tags{$_[1]}
l!l&&r!l&&!r
19607
MC/DC50%1/2
$tiff_tags{$_[1]} or $exif_tags{$_[1]}
$tiff_tags{$_[1]} $exif_tags{$_[1]}
Truth table66%2/3
A or B
A= $tiff_tags{$_[1]}B= $exif_tags{$_[1]}
ABresult
1X1
011
000
877 }
878  
879 sub add_fields
880 71 ▶{
Subroutine add_fields: called CC=53 SCAR=42.3
Pod undocumented
881 71 my($self, $offset, $ifds, $tags, $voff_plus) = @_;
882 71 ▶ return unless $offset;
Branch: 1 branch
BranchTrueFalseTotal
unless $offset 0 71 71
883 # guard against finding the same offset twice (bug #29088)
884 71 ▶ return if $self->{seen_offset}{$offset}++;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"seen_offset"}{$offset}++ 0 71 71
885 71 ▶ $tags ||= \%tiff_tags;
Condition100%2/2
$tags ||= \%tiff_tags
l!l
3833
MC/DC100%1/1
$tags ||= \%tiff_tags
$tags
Truth table100%2/2
A
A= $tags
Aresult
11
00
886  
887 71 for (${$self->{source}}) { # alias as $_
888 71 ▶ last if $offset > length($_) - 2; # bad offset
Branch: 1 branch
BranchTrueFalseTotal
if $offset > length($_) - 2 1 70 71
889 70 my $entries = $self->unpack("x$offset n", $_);
890 70 my $max_entries = int((length($_) - $offset - 2) / 12);
891 # print "ENTRIES $entries $max_entries\n";
892 70 ▶ if ($entries > $max_entries) {
Branch: 1 branch
BranchTrueFalseTotal
if ($entries > $max_entries) 8 62 70
893 # Hmmm, something smells bad here... parsing garbage
894 8 $entries = $max_entries;
895 8 last;
896 }
897 FIELD:
898 62 for my $i (0 .. $entries-1) {
899 813 my $entry_offset = 2 + $offset + $i*12;
900 813 my($tag, $type, $count, $voff) =
901 $self->unpack("nnNN", substr($_, $entry_offset, 12));
902 #print STDERR "TAG $tag $type $count $voff\n";
903  
904 813 ▶ if ($type == 0 || $type > @types) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type == 0 or $type > @types) 2 811 813
Condition100%3/3
$type == 0 or $type > @types
l!l&&r!l&&!r
11811
MC/DC100%2/2
$type == 0 or $type > @types
$type == 0 $type > @types
Truth table100%3/3
A or B
A= $type == 0B= $type > @types
ABresult
1X1
011
000
905 # unknown type code might indicate that we are parsing garbage
906 2 print STDERR "# Ignoring unknown type code $type\n";
907 2 next;
908 }
909  
910 # extract type information
911 811 my($tmpl, $vlen);
912 811 ($type, $tmpl, $vlen) = @{$types[$type-1]};
913  
914 811 ▶ die "Undefined type while parsing" unless $type;
Branch: 1 branch
BranchTrueFalseTotal
unless $type 0 811 811
915  
916 811 ▶ if ($count * $vlen <= 4) {
Branch: 2 branches
BranchTrueFalseTotal
if ($count * $vlen <= 4) { } 439 372 811
elsif ($voff + $count * $vlen > length $_) { } 0 372 372
917 439 $voff = $entry_offset + 8;
918 }
919 elsif ($voff + $count * $vlen > length($_)) {
920 # offset points outside of string, corrupt entry ignore
921 0 print STDERR "# ignoring offset pointer outside of string\n";
922 0 next;
923 }
924 else {
925 372 ▶ $voff += $voff_plus || 0;
Condition50%1/2
$voff_plus || 0
l!l
0372
MC/DC0%0/1
$voff_plus || 0
$voff_plus
Truth table50%1/2
A
A= $voff_plus
Aresult
11
00
926 }
927  
928 811 $tmpl =~ s/(\d+)$/$count*$1/e;
929  
930 811 my @v = $self->unpack("x$voff $tmpl", $_);
931  
932 811 ▶ if ($type =~ /^S(SHORT|LONG|RATIONAL)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type =~ /^S(SHORT|LONG|RATIONAL)/) 45 766 811
933 45 ▶ my $max = 2 ** ($1 eq "SHORT" ? 15 : 31);
Branch: 1 branch
BranchTrueFalseTotal
$1 eq 'SHORT' ? : 4 41 45
934 45 ▶ $v[0] -= ($max * 2) if $v[0] >= $max;
Branch: 1 branch
BranchTrueFalseTotal
if $v[0] >= $max 4 41 45
935 }
936  
937 811 ▶ my $val = (@v > 1) ? \@v : $v[0];
Branch: 1 branch
BranchTrueFalseTotal
@v > 1 ? : 222 589 811
938 811 ▶ if ($type =~ /^S?RATIONAL$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type =~ /^S?RATIONAL$/) 193 618 811
939 193 ▶ if (ref $val) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $val) { } 193 0 193
940 193 bless $val, "Image::TIFF::Rational";
941 } else {
942 0 print STDERR "# invalid rational value\n";
943 0 $val = undef;
944 }
945 }
946  
947 811 ▶ if ($type eq 'ASCII' || $type eq 'UNDEFINED')
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "ASCII" or $type eq "UNDEFINED") 236 575 811
Condition100%3/3
$type eq "ASCII" or $type eq "UNDEFINED"
l!l&&r!l&&!r
124112575
MC/DC100%2/2
$type eq "ASCII" or $type eq "UNDEFINED"
$type eq "ASCII" $type eq "UNDEFINED"
Truth table100%3/3
A or B
A= $type eq "ASCII"B= $type eq "UNDEFINED"
ABresult
1X1
011
000
948 {
949 236 ▶ if ($val =~ /\0[^\0]+\z/)
Branch: 1 branch
BranchTrueFalseTotal
if ($val =~ /\0[^\0]+\z/) { } 14 222 236
950 {
951 # cut out the first "ASCII\0" and take the remaining text
952 # (fix bug #29243 parsing of UserComment)
953 # XXX TODO: this needs to handle UNICODE, too:
954 14 $val =~ /\0([^\0]+)/;
955 14 ▶ $val = '' . ($1 || '');
Condition50%1/2
$1 || ''
l!l
140
MC/DC0%0/1
$1 || ''
$1
Truth table50%1/2
A
A= $1
Aresult
11
00
956 }
957 else
958 {
959 # avoid things like "Foo\x00\x00\x00" by removing trailing nulls
960 # this needs to handle UNICODE, too:
961 222 $val =~ /^([^\0]*)/;
962 222 ▶ $val = '' . ($1 || '');
Condition100%2/2
$1 || ''
l!l
21111
MC/DC100%1/1
$1 || ''
$1
Truth table100%2/2
A
A= $1
Aresult
11
00
963 }
964 }
965  
966 811 ▶ $tag = $tags->{$tag} || $self->tagname($tag);
Condition66%2/3
$tags->{$tag} || $self->tagname($tag)
l!l&&r!l&&!r
740710
MC/DC0%0/2
$tags->{$tag} || $self->tagname($tag)
$tags->{$tag} $self->tagname($tag)
Truth table66%2/3
A || B
A= $tags->{$tag}B= $self->tagname($tag)
ABresult
1X1
011
000
967  
968 811 ▶ if ($tag eq 'MakerNote')
Branch: 1 branch
BranchTrueFalseTotal
if ($tag eq "MakerNote") 16 795 811
969 {
970 16 ▶ my $maker = uc($self->{Make} || '');
Condition100%2/2
$self->{'Make'} || ''
l!l
133
MC/DC100%1/1
$self->{'Make'} || ''
$self->{'Make'}
Truth table100%2/2
A
A= $self->{'Make'}
Aresult
11
00
971 16 ▶ $maker =~ /^([A-Z]+)/; $maker = $1 || ''; # "OLYMPUS ..." > "OLYMPUS"
Condition50%1/2
$1 || ''
l!l
160
MC/DC0%0/1
$1 || ''
$1
Truth table50%1/2
A
A= $1
Aresult
11
00
972  
973 # if 'Panasonic' doesn't exist, try 'Panasonic DMC-FZ5'
974 6 ▶ $maker = join " ", grep { defined && m/\S/ } $self->{Make}, $self->{Model}
Condition33%1/3
defined $_ && /\S/
!ll&&!rl&&r
600
MC/DC0%0/2
defined $_ && /\S/
defined $_ /\S/
Truth table33%1/3
A && B
A= defined $_B= /\S/
ABresult
0X0
100
111
975 16 ▶ unless exists $makernotes{$maker};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $makernotes{$maker} 3 13 16
976  
977 16 ▶ if (exists $makernotes{$maker}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $makernotes{$maker}) 13 3 16
978 13 my ($ifd_off, $tag_prefix, $sub) = @{$makernotes{$maker}};
979  
980 #print STDERR "# Decoding Makernotes from $maker\n";
981  
982 13 $self->{tag_prefix} = $tag_prefix;
983 13 ▶ if ($ifd_off == -1 && length($val) >= 12) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ifd_off == -1 and length $val >= 12) { } 0 13 13
elsif ($ifd_off == -2) { } 0 13 13
Condition66%2/3
$ifd_off == -1 and length $val >= 12
!ll&&!rl&&r
580
MC/DC0%0/2
$ifd_off == -1 and length $val >= 12
$ifd_off == -1 length $val >= 12
Truth table66%2/3
A and B
A= $ifd_off == -1B= length $val >= 12
ABresult
0X0
100
111
984 # fuji kludge - http://www.butaman.ne.jp/~tsuruzoh/Computer/Digicams/exif-e.html#APP4
985 0 my $save_endian = $self->{little_endian};
986 0 $self->{little_endian} = 1;
987 0 $ifd_off = $self->unpack("N", substr($val, 8, 4));
988 0 $self->add_fields($voff+$ifd_off, $ifds, $sub, $voff);
989 0 $self->{little_endian} = $save_endian;
990 } elsif ($ifd_off == -2) {
991 # Nikon D70/D100 kludge -- word "Nikon" and 5
992 # bytes of data is tacked to the front of MakerNote;
993 # all EXIF offsets are relative to MakerNote section
994 0 my ($nikon_voff);
995 0 $nikon_voff = 0;
996 0 ▶ if (substr($val, 0, 5) eq 'Nikon') {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($val, 0, 5) eq "Nikon") 0 0 0
997 0 $nikon_voff = $voff+10;
998 }
999 #print "IFD_OFF $ifd_off NIKON_VOFF $nikon_voff\n";
1000 0 $self->add_fields($voff+18, $ifds, $sub, $nikon_voff);
1001 } else {
1002 13 $self->add_fields($voff+$ifd_off, $ifds, $sub)
1003 }
1004 13 delete $self->{tag_prefix};
1005 13 next FIELD;
1006 }
1007 }
1008  
1009 798 ▶ if (ref($tag)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $tag) 233 565 798
1010 233 ▶ die "Assert" unless ref($tag) eq "HASH";
Branch: 1 branch
BranchTrueFalseTotal
unless ref $tag eq "HASH" 0 233 233
1011 233 ▶ if (my $sub = $tag->{__SUBIFD__}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $sub = $tag->{"__SUBIFD__"}) 25 208 233
1012 25 ▶ next if $val < 0 || $val > length($_);
Branch: 1 branch
BranchTrueFalseTotal
if $val < 0 or $val > length $_ 0 25 25
Condition33%1/3
$val < 0 or $val > length $_
l!l&&r!l&&!r
0025
MC/DC0%0/2
$val < 0 or $val > length $_
$val < 0 $val > length $_
Truth table33%1/3
A or B
A= $val < 0B= $val > length $_
ABresult
1X1
011
000
1013 #print "SUBIFD $tag->{__TAG__} $val ", length($_), "\n";
1014 25 $self->add_fields($val, $ifds, $sub);
1015 25 next FIELD;
1016 }
1017 208 ▶ if (my $sub = $tag->{__ARRAYOFFSET__}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $sub = $tag->{"__ARRAYOFFSET__"}) 2 206 208
1018 2 ▶ my $prefix; $prefix = $tag = $self->{tag_prefix} . '-' if $self->{tag_prefix};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tag_prefix"} 2 0 2
1019 2 ▶ for (my $i=0; $i < @$val; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$val) 82 2 84
1020 82 ▶ if ( exists($sub->{$i}) )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $sub->{$i}) 38 44 82
1021 38 ▶ { if ( ref($sub->{$i}) eq "HASH" && exists($sub->{$i}->{__TAG__}) )
Branch: 1 branch
BranchTrueFalseTotal
if (ref $sub->{$i} eq 'HASH' and exists $sub->{$i}{'__TAG__'}) { } 21 17 38
Condition66%2/3
ref $sub->{$i} eq "HASH" and exists $sub->{$i}{"__TAG__"}
!ll&&!rl&&r
17021
MC/DC50%1/2
ref $sub->{$i} eq "HASH" and exists $sub->{$i}{"__TAG__"}
ref $sub->{$i} eq "HASH" exists $sub->{$i}{"__TAG__"}
Truth table66%2/3
A and B
A= ref $sub->{$i} eq "HASH"B= exists $sub->{$i}{"__TAG__"}
ABresult
0X0
100
111
1022 21 ▶ { if ( exists($sub->{$i}->{$val->[$i]}) )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $sub->{$i}{$val->[$i]}) { } 13 8 21
1023 {
1024 push @$ifds, [ $prefix . $sub->{$i}->{__TAG__}, $type, $count,
1025 13 $sub->{$i}->{$val->[$i]} ];
1026 }
1027 else
1028 {
1029 8 push @$ifds, [ $prefix . $sub->{$i}->{__TAG__}, $type, $count,
1030 "Unknown (" . $val->[$i] . ")" ];
1031 }
1032 }
1033 else
1034 17 { push @$ifds, [ $prefix . $sub->{$i}, $type, $count, $val->[$i] ]; }
1035 }
1036 }
1037 2 next FIELD;
1038 }
1039 #hack for UNDEFINED values, they all have different
1040 #meanings depending on tag
1041 206 ▶ $val = &{$tag->{DECODER}}($self,$val) if defined($tag->{DECODER});
Branch: 1 branch
BranchTrueFalseTotal
if defined $tag->{"DECODER"} 41 165 206
1042 206 ▶ $val = $tag->{$val} if exists $tag->{$val};
Branch: 1 branch
BranchTrueFalseTotal
if exists $tag->{$val} 165 41 206
1043 206 $tag = $tag->{__TAG__};
1044 }
1045  
1046 771 ▶ $tag = $self->{tag_prefix} . '-' . $tag if $self->{tag_prefix};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"tag_prefix"} 67 704 771
1047  
1048 #if ( $val =~ m/ARRAY/ ) { $val = join(', ',@$val); }
1049 771 push @$ifds, [ $tag, $type, $count, $val ];
1050  
1051 771 ▶ $self->{$tag} = $val if ($tag eq 'Make' or $tag eq 'Model');
Branch: 1 branch
BranchTrueFalseTotal
if $tag eq "Make" or $tag eq "Model" 26 745 771
Condition100%3/3
$tag eq "Make" or $tag eq "Model"
l!l&&r!l&&!r
1313745
MC/DC100%2/2
$tag eq "Make" or $tag eq "Model"
$tag eq "Make" $tag eq "Model"
Truth table100%3/3
A or B
A= $tag eq "Make"B= $tag eq "Model"
ABresult
1X1
011
000
1052 }
1053 }
1054  
1055 71 $ifds;
1056 }
1057  
1058 sub components_configuration_decoder
1059 16 ▶{
Subroutine components_configuration_decoder: called CC=2 SCAR=7.0
Pod undocumented
1060 16 my $self = shift;
1061 16 my $val = shift;
1062 16 my $rv = "";
1063 16 my %v = (
1064 0 => undef,
1065 1 => 'Y',
1066 2 => 'Cb',
1067 3 => 'Cr',
1068 4 => 'R',
1069 5 => 'G',
1070 6 => 'B',
1071 );
1072 16 ▶return join ( '', map { $v{$_} if defined($v{$_}) } $self->unpack('c4',$val) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $v{$_} 48 0 48
1073 }
1074  
1075 sub file_source_decoder
1076 13 ▶{
Subroutine file_source_decoder: called CC=2 SCAR=7.2
Pod undocumented
1077 13 my $self = shift;
1078 13 my $val = shift;
1079 13 my %v = (
1080 3 => "(DSC) Digital Still Camera",
1081 );
1082 13 $val = $self->unpack('c',$val);
1083 13 ▶ return $v{$val} if $v{$val};
Branch: 1 branch
BranchTrueFalseTotal
if $v{$val} 13 0 13
1084 0 "Other";
1085 }
1086  
1087 sub scene_type_decoder
1088 12 ▶{
Subroutine scene_type_decoder: called CC=2 SCAR=7.2
Pod undocumented
1089 12 my $self = shift;
1090 12 my $val = shift;
1091 12 my %v = (
1092 1 => "Directly Photographed Image",
1093 );
1094 12 $val = $self->unpack('c',$val);
1095 12 ▶ return $v{$val} if $v{$val};
Branch: 1 branch
BranchTrueFalseTotal
if $v{$val} 12 0 12
1096 0 "Other";
1097 }
1098  
1099 package Image::TIFF::Rational;
1100  
1101 12 ▶use overload '""' => \&as_string,
Subroutine BEGIN: called CC=1 SCAR=0.0
1102 '0+' => \&as_float,
1103 12 fallback => 1;
1104  
1105 22 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
1106 22 my($class, $a, $b) = @_;
1107 22 bless [$a, $b], $class;
1108 }
1109  
1110 89 ▶sub as_string {
Subroutine as_string: called CC=1 SCAR=0.0
1111 89 my $self = shift;
1112 #warn "@$self";
1113 89 "$self->[0]/$self->[1]";
1114 }
1115  
1116 84 ▶sub as_float {
Subroutine as_float: called CC=2 SCAR=7.6
1117 84 my $self = shift;
1118  
1119 # We check here because some stupid cameras (Samsung Digimax 200)
1120 # use rationals with 0 denominator (found in thumbnail resolution spec).
1121 84 ▶ if ($self->[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->[1]) { } 84 0 84
1122 84 return $self->[0] / $self->[1];
1123 }
1124 else {
1125 0 return $self->[0];
1126 }
1127 }
1128  
1129 12 1;
« lib/Image/Info/GIF.pm ↑ Summary lib/Image/Info/PNG.pm »