Image/ExifTool/NikonCapture.pm

filter: Statementstmt 73.2% 107 / 146 Branchbran 55.8% 38 / 68 Conditioncond 38.1% 16 / 42 MC/DCmcdc 8.0% 2 / 25 Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 3 totaltotal 58.0% 169 / 291 CC 49 SCAR 36.4
CC
49
Cov
63%
WriteNikonCapture
45.3
ProcessNikonCaptureEditVersions
42.0
ProcessNikonCapture
35.4
CRAP 38.1
« Image/ExifTool/Red.pm ↑ Summary Image/ExifTool/iWork.pm »
1 #------------------------------------------------------------------------------
2 # File: NikonCapture.pm
3 #
4 # Description: Read/write Nikon Capture information
5 #
6 # Revisions: 11/08/2005 - P. Harvey Created
7 # 10/10/2008 - P. Harvey Updated for Capture NX 2
8 # 16/04/2011 - P. Harvey Decode NikonCaptureEditVersions
9 #
10 # References: 1) http://www.cybercom.net/~dcoffin/dcraw/
11 # IB) Iliah Borg private communication (LibRaw)
12 #------------------------------------------------------------------------------
13  
14 package Image::ExifTool::NikonCapture;
15  
16 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 8 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
18 8 ▶use Image::ExifTool qw(:DataAccess :Utils);
Subroutine BEGIN: called CC=1 SCAR=0.0
19 8 ▶use Image::ExifTool::Exif;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 8 $VERSION = '1.14';
22  
23 sub ProcessNikonCapture($$$);
24  
25 # common print conversions
26 8 my %offOn = ( 0 => 'Off', 1 => 'On' );
27 8 my %noYes = ( 0 => 'No', 1 => 'Yes' );
28 8 my %unsharpColor = (
29 0 => 'RGB',
30 1 => 'Red',
31 2 => 'Green',
32 3 => 'Blue',
33 4 => 'Yellow',
34 5 => 'Magenta',
35 6 => 'Cyan',
36 );
37  
38 # Nikon Capture data (ref PH)
39 8 %Image::ExifTool::NikonCapture::Main = (
40 PROCESS_PROC => \&ProcessNikonCapture,
41 WRITE_PROC => \&WriteNikonCapture,
42 CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
43 GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
44 NOTES => q{
45 This information is written by the Nikon Capture software in tag 0x0e01 of
46 the maker notes of NEF images.
47 },
48 # 0x007ddc9d contains contrast information
49 0x008ae85e => {
50 Name => 'LCHEditor',
51 Writable => 'int8u',
52 PrintConv => \%offOn,
53 },
54 0x0c89224b => {
55 Name => 'ColorAberrationControl',
56 Writable => 'int8u',
57 PrintConv => \%offOn,
58 },
59 0x116fea21 => {
60 Name => 'HighlightData',
61 SubDirectory => {
62 TagTable => 'Image::ExifTool::NikonCapture::HighlightData',
63 },
64 },
65 0x2175eb78 => {
66 Name => 'D-LightingHQ',
67 Writable => 'int8u',
68 PrintConv => \%offOn,
69 },
70 0x2fc08431 => {
71 Name => 'StraightenAngle',
72 Writable => 'double',
73 },
74 0x374233e0 => {
75 Name => 'CropData',
76 SubDirectory => {
77 TagTable => 'Image::ExifTool::NikonCapture::CropData',
78 },
79 },
80 0x39c456ac => {
81 Name => 'PictureCtrl',
82 SubDirectory => {
83 TagTable => 'Image::ExifTool::NikonCapture::PictureCtrl',
84 },
85 },
86 0x3cfc73c6 => {
87 Name => 'RedEyeData',
88 SubDirectory => {
89 TagTable => 'Image::ExifTool::NikonCapture::RedEyeData',
90 },
91 },
92 0x3d136244 => {
93 Name => 'EditVersionName',
94 Writable => 'string', # (null terminated)
95 },
96 # 0x3e726567 added when I rotated by 90 degrees
97 0x416391c6 => {
98 Name => 'QuickFix',
99 Writable => 'int8u',
100 PrintConv => \%offOn,
101 },
102 0x56a54260 => {
103 Name => 'Exposure',
104 SubDirectory => {
105 TagTable => 'Image::ExifTool::NikonCapture::Exposure',
106 },
107 },
108 0x5f0e7d23 => {
109 Name => 'ColorBooster',
110 Writable => 'int8u',
111 PrintConv => \%offOn,
112 },
113 0x6a6e36b6 => {
114 Name => 'D-LightingHQSelected',
115 Writable => 'int8u',
116 PrintConv => \%noYes,
117 },
118 0x753dcbc0 => {
119 Name => 'NoiseReduction',
120 Writable => 'int8u',
121 PrintConv => \%offOn,
122 },
123 0x76a43200 => {
124 Name => 'UnsharpMask',
125 Writable => 'int8u',
126 PrintConv => \%offOn,
127 },
128 0x76a43201 => {
129 Name => 'Curves',
130 Writable => 'int8u',
131 PrintConv => \%offOn,
132 },
133 0x76a43202 => {
134 Name => 'ColorBalanceAdj',
135 Writable => 'int8u',
136 PrintConv => \%offOn,
137 },
138 0x76a43203 => {
139 Name => 'AdvancedRaw',
140 Writable => 'int8u',
141 PrintConv => \%offOn,
142 },
143 0x76a43204 => {
144 Name => 'WhiteBalanceAdj',
145 Writable => 'int8u',
146 PrintConv => \%offOn,
147 },
148 0x76a43205 => {
149 Name => 'VignetteControl',
150 Writable => 'int8u',
151 PrintConv => \%offOn,
152 },
153 0x76a43206 => {
154 Name => 'FlipHorizontal',
155 Writable => 'int8u',
156 PrintConv => \%noYes,
157 },
158 0x76a43207 => { # rotation angle in degrees
159 Name => 'Rotation',
160 Writable => 'int16u',
161 },
162 0x083a1a25 => {
163 Name => 'HistogramXML',
164 Writable => 'undef',
165 Binary => 1,
166 AdjustSize => 4, # patch Nikon bug
167 },
168 0x84589434 => {
169 Name => 'BrightnessData',
170 SubDirectory => {
171 TagTable => 'Image::ExifTool::NikonCapture::Brightness',
172 },
173 },
174 # 0x88f55e48 - related to QuickFix
175 0x890ff591 => {
176 Name => 'D-LightingHQData',
177 SubDirectory => {
178 TagTable => 'Image::ExifTool::NikonCapture::DLightingHQ',
179 },
180 },
181 0x926f13e0 => {
182 Name => 'NoiseReductionData',
183 SubDirectory => {
184 TagTable => 'Image::ExifTool::NikonCapture::NoiseReduction',
185 },
186 },
187 0x9ef5f6e0 => {
188 Name => 'IPTCData',
189 SubDirectory => {
190 TagTable => 'Image::ExifTool::IPTC::Main',
191 },
192 },
193 # 0xa7264a72 - related to QuickFix
194 0xab5eca5e => {
195 Name => 'PhotoEffects',
196 Writable => 'int8u',
197 PrintConv => \%offOn,
198 },
199 0xac6bd5c0 => {
200 Name => 'VignetteControlIntensity',
201 Writable => 'int16s',
202 },
203 0xb0384e1e => {
204 Name => 'PhotoEffectsData',
205 SubDirectory => {
206 TagTable => 'Image::ExifTool::NikonCapture::PhotoEffects',
207 },
208 },
209 0xb999a36f => {
210 Name => 'ColorBoostData',
211 SubDirectory => {
212 TagTable => 'Image::ExifTool::NikonCapture::ColorBoost',
213 },
214 },
215 0xbf3c6c20 => {
216 Name => 'WBAdjData',
217 SubDirectory => {
218 TagTable => 'Image::ExifTool::NikonCapture::WBAdjData',
219 },
220 },
221 0xce5554aa => {
222 Name => 'D-LightingHS',
223 Writable => 'int8u',
224 PrintConv => \%offOn,
225 },
226 0xe2173c47 => {
227 Name => 'PictureControl',
228 Writable => 'int8u',
229 PrintConv => \%offOn,
230 },
231 0xe37b4337 => {
232 Name => 'D-LightingHSData',
233 SubDirectory => {
234 TagTable => 'Image::ExifTool::NikonCapture::DLightingHS',
235 },
236 },
237 0xe42b5161 => {
238 Name => 'UnsharpData',
239 SubDirectory => {
240 TagTable => 'Image::ExifTool::NikonCapture::UnsharpData',
241 },
242 },
243 0xe9651831 => {
244 Name => 'PhotoEffectHistoryXML',
245 Binary => 1,
246 Writable => 'undef',
247 },
248 0xfe28a44f => {
249 Name => 'AutoRedEye',
250 Writable => 'int8u',
251 PrintConv => \%offOn, # (have seen a value of 28 here for older software?)
252 },
253 0xfe443a45 => {
254 Name => 'ImageDustOff',
255 Writable => 'int8u',
256 PrintConv => \%offOn,
257 },
258 );
259  
260 8 %Image::ExifTool::NikonCapture::UnsharpData = (
261 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
262 WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
263 CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
264 WRITABLE => 1,
265 FORMAT => 'int8u',
266 FIRST_ENTRY => 0,
267 GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
268 0 => 'UnsharpCount',
269 19 => { Name => 'Unsharp1Color', Format => 'int16u', PrintConv => \%unsharpColor },
270 23 => { Name => 'Unsharp1Intensity', Format => 'int16u' },
271 25 => { Name => 'Unsharp1HaloWidth', Format => 'int16u' },
272 27 => 'Unsharp1Threshold',
273 46 => { Name => 'Unsharp2Color', Format => 'int16u', PrintConv => \%unsharpColor },
274 50 => { Name => 'Unsharp2Intensity', Format => 'int16u' },
275 52 => { Name => 'Unsharp2HaloWidth', Format => 'int16u' },
276 54 => 'Unsharp2Threshold',
277 73 => { Name => 'Unsharp3Color', Format => 'int16u', PrintConv => \%unsharpColor },
278 77 => { Name => 'Unsharp3Intensity', Format => 'int16u' },
279 79 => { Name => 'Unsharp3HaloWidth', Format => 'int16u' },
280 81 => 'Unsharp3Threshold',
281 100 => { Name => 'Unsharp4Color', Format => 'int16u', PrintConv => \%unsharpColor },
282 104 => { Name => 'Unsharp4Intensity', Format => 'int16u' },
283 106 => { Name => 'Unsharp4HaloWidth', Format => 'int16u' },
284 108 => 'Unsharp4Threshold',
285 # there could be more, but I grow bored of this... :P
286 );
287  
288 8 %Image::ExifTool::NikonCapture::DLightingHS = (
289 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
290 WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
291 CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
292 WRITABLE => 1,
293 FORMAT => 'int32u',
294 FIRST_ENTRY => 0,
295 GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
296 0 => 'D-LightingHSAdjustment',
297 1 => 'D-LightingHSColorBoost',
298 );
299  
300 8 %Image::ExifTool::NikonCapture::DLightingHQ = (
301 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
302 WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
303 CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
304 WRITABLE => 1,
305 FORMAT => 'int32u',
306 FIRST_ENTRY => 0,
307 GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
308 0 => 'D-LightingHQShadow',
309 1 => 'D-LightingHQHighlight',
310 2 => 'D-LightingHQColorBoost',
311 );
312  
313 8 %Image::ExifTool::NikonCapture::ColorBoost = (
314 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
315 WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
316 CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
317 WRITABLE => 1,
318 FORMAT => 'int8u',
319 FIRST_ENTRY => 0,
320 GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
321 0 => {
322 Name => 'ColorBoostType',
323 PrintConv => {
324 0 => 'Nature',
325 1 => 'People',
326 },
327 },
328 1 => {
329 Name => 'ColorBoostLevel',
330 Format => 'int32u',
331 },
332 );
333  
334 8 %Image::ExifTool::NikonCapture::WBAdjData = (
335 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
336 WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
337 CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
338 WRITABLE => 1,
339 FORMAT => 'int8u',
340 FIRST_ENTRY => 0,
341 GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
342 0x00 => {
343 Name => 'WBAdjRedBalance',
344 Format => 'double',
345 },
346 0x08 => {
347 Name => 'WBAdjBlueBalance',
348 Format => 'double',
349 },
350 0x10 => {
351 Name => 'WBAdjMode',
352 PrintConv => {
353 1 => 'Use Gray Point',
354 2 => 'Recorded Value',
355 3 => 'Use Temperature',
356 4 => 'Calculate Automatically',
357 5 => 'Auto2', #IB
358 6 => 'Underwater', #IB
359 7 => 'Auto1',
360 },
361 },
362 0x14 => { #IB
363 Name => 'WBAdjLighting',
364 Format => 'int16u',
365 PrintHex => 1,
366 PrintConv => {
367 0x000 => 'None',
368 0x100 => 'Incandescent',
369 0x200 => 'Daylight (direct sunlight)',
370 0x201 => 'Daylight (shade)',
371 0x202 => 'Daylight (cloudy)',
372 0x300 => 'Standard Fluorescent (warm white)',
373 0x301 => 'Standard Fluorescent (3700K)',
374 0x302 => 'Standard Fluorescent (cool white)',
375 0x303 => 'Standard Fluorescent (5000K)',
376 0x304 => 'Standard Fluorescent (daylight)',
377 0x305 => 'Standard Fluorescent (high temperature mercury vapor)',
378 0x400 => 'High Color Rendering Fluorescent (warm white)',
379 0x401 => 'High Color Rendering Fluorescent (3700K)',
380 0x402 => 'High Color Rendering Fluorescent (cool white)',
381 0x403 => 'High Color Rendering Fluorescent (5000K)',
382 0x404 => 'High Color Rendering Fluorescent (daylight)',
383 0x500 => 'Flash',
384 0x501 => 'Flash (FL-G1 filter)',
385 0x502 => 'Flash (FL-G2 filter)',
386 0x503 => 'Flash (TN-A1 filter)',
387 0x504 => 'Flash (TN-A2 filter)',
388 0x600 => 'Sodium Vapor Lamps',
389 # 0x1002 => seen for WBAdjMode modes of Underwater and Calculate Automatically
390 },
391 },
392 0x18 => {
393 Name => 'WBAdjTemperature',
394 Format => 'int16u',
395 },
396 0x25 => {
397 Name => 'WBAdjTint',
398 Format => 'int32s',
399 },
400 );
401  
402 8 %Image::ExifTool::NikonCapture::PhotoEffects = (
403 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
404 WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
405 CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
406 WRITABLE => 1,
407 FORMAT => 'int8u',
408 FIRST_ENTRY => 0,
409 GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
410 0 => {
411 Name => 'PhotoEffectsType',
412 PrintConv => {
413 0 => 'None',
414 1 => 'B&W',
415 2 => 'Sepia',
416 3 => 'Tinted',
417 },
418 },
419 4 => {
420 Name => 'PhotoEffectsRed',
421 Format => 'int16s',
422 },
423 6 => {
424 Name => 'PhotoEffectsGreen',
425 Format => 'int16s',
426 },
427 8 => {
428 Name => 'PhotoEffectsBlue',
429 Format => 'int16s',
430 },
431 );
432  
433 8 %Image::ExifTool::NikonCapture::Brightness = (
434 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
435 WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
436 CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
437 WRITABLE => 1,
438 FORMAT => 'int8u',
439 FIRST_ENTRY => 0,
440 GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
441 0 => {
442 Name => 'BrightnessAdj',
443 Format => 'double',
444 ValueConv => '$val * 50',
445 ValueConvInv => '$val / 50',
446 },
447 8 => {
448 Name => 'EnhanceDarkTones',
449 PrintConv => \%offOn,
450 },
451 );
452  
453 8 %Image::ExifTool::NikonCapture::NoiseReduction = (
454 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
455 WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
456 CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
457 WRITABLE => 1,
458 FORMAT => 'int8u',
459 FIRST_ENTRY => 0,
460 GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
461 0x04 => {
462 Name => 'EdgeNoiseReduction',
463 PrintConv => \%offOn,
464 },
465 0x05 => {
466 Name => 'ColorMoireReductionMode',
467 PrintConv => {
468 0 => 'Off',
469 1 => 'Low',
470 2 => 'Medium',
471 3 => 'High',
472 },
473 },
474 0x09 => {
475 Name => 'NoiseReductionIntensity',
476 Format => 'int32u',
477 },
478 0x0d => {
479 Name => 'NoiseReductionSharpness',
480 Format => 'int32u',
481 },
482 0x11 => {
483 Name => 'NoiseReductionMethod',
484 Format => 'int16u',
485 PrintConv => {
486 0 => 'Faster',
487 1 => 'Better Quality',
488 2 => 'Better Quality 2013',
489 },
490 },
491 0x15 => {
492 Name => 'ColorMoireReduction',
493 PrintConv => \%offOn,
494 },
495 0x17 => {
496 Name => 'NoiseReduction',
497 PrintConv => \%offOn,
498 },
499 0x18 => {
500 Name => 'ColorNoiseReductionIntensity',
501 Format => 'int32u',
502 },
503 0x1c => {
504 Name => 'ColorNoiseReductionSharpness',
505 Format => 'int32u',
506 },
507 );
508  
509 8 %Image::ExifTool::NikonCapture::CropData = (
510 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
511 WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
512 CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
513 WRITABLE => 1,
514 FORMAT => 'int8u',
515 FIRST_ENTRY => 0,
516 GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
517 0x1e => {
518 Name => 'CropLeft',
519 Format => 'double',
520 ValueConv => '$val / 2',
521 ValueConvInv => '$val * 2',
522 },
523 0x26 => {
524 Name => 'CropTop',
525 Format => 'double',
526 ValueConv => '$val / 2',
527 ValueConvInv => '$val * 2',
528 },
529 0x2e => {
530 Name => 'CropRight',
531 Format => 'double',
532 ValueConv => '$val / 2',
533 ValueConvInv => '$val * 2',
534 },
535 0x36 => {
536 Name => 'CropBottom',
537 Format => 'double',
538 ValueConv => '$val / 2',
539 ValueConvInv => '$val * 2',
540 },
541 0x8e => {
542 Name => 'CropOutputWidthInches',
543 Format => 'double',
544 },
545 0x96 => {
546 Name => 'CropOutputHeightInches',
547 Format => 'double',
548 },
549 0x9e => {
550 Name => 'CropScaledResolution',
551 Format => 'double',
552 },
553 0xae => {
554 Name => 'CropSourceResolution',
555 Format => 'double',
556 ValueConv => '$val / 2',
557 ValueConvInv => '$val * 2',
558 },
559 0xb6 => {
560 Name => 'CropOutputResolution',
561 Format => 'double',
562 },
563 0xbe => {
564 Name => 'CropOutputScale',
565 Format => 'double',
566 },
567 0xc6 => {
568 Name => 'CropOutputWidth',
569 Format => 'double',
570 },
571 0xce => {
572 Name => 'CropOutputHeight',
573 Format => 'double',
574 },
575 0xd6 => {
576 Name => 'CropOutputPixels',
577 Format => 'double',
578 },
579 );
580  
581 8 %Image::ExifTool::NikonCapture::PictureCtrl = (
582 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
583 WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
584 CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
585 WRITABLE => 1,
586 FORMAT => 'int8u',
587 FIRST_ENTRY => 0,
588 GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
589 0x00 => {
590 Name => 'PictureControlActive',
591 PrintConv => \%offOn,
592 },
593 0x13 => {
594 Name => 'PictureControlMode',
595 Format => 'string[16]',
596 },
597 # 0x29 changes with Hue and Sharpening
598 0x2a => {
599 Name => 'QuickAdjust',
600 ValueConv => '$val - 128',
601 ValueConvInv => '$val + 128',
602 },
603 0x2b => {
604 Name => 'SharpeningAdj',
605 ValueConv => '$val ? $val - 128 : "Auto"',
606 ValueConvInv => '$val=~/\d/ ? $val + 128 : 0',
607 },
608 0x2c => {
609 Name => 'ContrastAdj',
610 ValueConv => '$val ? $val - 128 : "Auto"',
611 ValueConvInv => '$val=~/\d/ ? $val + 128 : 0',
612 },
613 0x2d => {
614 Name => 'BrightnessAdj',
615 ValueConv => '$val ? $val - 128 : "Auto"', # no "Auto" mode (yet) for this setting
616 ValueConvInv => '$val=~/\d/ ? $val + 128 : 0',
617 },
618 0x2e => {
619 Name => 'SaturationAdj',
620 ValueConv => '$val ? $val - 128 : "Auto"',
621 ValueConvInv => '$val=~/\d/ ? $val + 128 : 0',
622 },
623 0x2f => {
624 Name => 'HueAdj',
625 ValueConv => '$val - 128',
626 ValueConvInv => '$val + 128',
627 },
628 # 0x37 changed from 0 to 2 when Picture Control is enabled (and no active DLighting)
629 );
630  
631 8 %Image::ExifTool::NikonCapture::RedEyeData = (
632 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
633 WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
634 CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
635 WRITABLE => 1,
636 FORMAT => 'int8u',
637 FIRST_ENTRY => 0,
638 GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
639 0 => {
640 Name => 'RedEyeCorrection',
641 PrintConv => {
642 0 => 'Off',
643 1 => 'Automatic',
644 2 => 'Click on Eyes',
645 },
646 },
647 );
648  
649 8 %Image::ExifTool::NikonCapture::Exposure = (
650 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
651 WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
652 CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
653 WRITABLE => 1,
654 FORMAT => 'int8u',
655 FIRST_ENTRY => 0,
656 GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
657 0x00 => {
658 Name => 'ExposureAdj',
659 Format => 'int16s',
660 ValueConv => '$val / 100',
661 ValueConvInv => '$val * 100',
662 },
663 0x12 => {
664 Name => 'ExposureAdj2',
665 Format => 'double',
666 PrintConv => 'sprintf("%.4f", $val)',
667 PrintConvInv => '$val',
668 },
669 0x24 => {
670 Name => 'ActiveD-Lighting',
671 PrintConv => \%offOn,
672 },
673 0x25 => {
674 Name => 'ActiveD-LightingMode',
675 PrintConv => {
676 0 => 'Unchanged',
677 1 => 'Off',
678 2 => 'Low',
679 3 => 'Normal',
680 4 => 'High',
681 6 => 'Extra High',
682 7 => 'Extra High 1',
683 8 => 'Extra High 2',
684 },
685 },
686 );
687  
688 8 %Image::ExifTool::NikonCapture::HighlightData = (
689 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
690 WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
691 CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
692 WRITABLE => 1,
693 FORMAT => 'int8s',
694 FIRST_ENTRY => 0,
695 GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
696 0 => 'ShadowProtection',
697 1 => 'SaturationAdj',
698 6 => 'HighlightProtection',
699 );
700  
701 #------------------------------------------------------------------------------
702 # write Nikon Capture data (ref 1)
703 # Inputs: 0) ExifTool object reference, 1) reference to directory information
704 # 2) pointer to tag table
705 # Returns: 1 on success
706 sub WriteNikonCapture($$$)
707 43 ▶{
Subroutine WriteNikonCapture: called CC=25 SCAR=38.1
Pod undocumented
708 43 my ($et, $dirInfo, $tagTablePtr) = @_;
709 43 ▶ $et or return 1; # allow dummy access to autoload this package
Branch: 1 branch
BranchTrueFalseTotal
$et or return 1 1 42 43
710  
711 # no need to edit this information unless necessary
712 1 ▶ unless ($$et{EDIT_DIRS}{MakerNotes} or $$et{EDIT_DIRS}{IPTC}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($et->{"EDIT_DIRS"}{"MakerNotes"} or $et->{"EDIT_DIRS"}{"IPTC"}) 0 1 1
Condition33%1/3
$et->{"EDIT_DIRS"}{"MakerNotes"} or $et->{"EDIT_DIRS"}{"IPTC"}
l!l&&r!l&&!r
100
MC/DC0%0/2
$et->{"EDIT_DIRS"}{"MakerNotes"} or $et->{"EDIT_DIRS"}{"IPTC"}
$et->{"EDIT_DIRS"}{"MakerNotes"} $et->{"EDIT_DIRS"}{"IPTC"}
Truth table33%1/3
A or B
A= $et->{"EDIT_DIRS"}{"MakerNotes"}B= $et->{"EDIT_DIRS"}{"IPTC"}
ABresult
1X1
011
000
713 0 return undef;
714 }
715 1 my $dataPt = $$dirInfo{DataPt};
716 1 my $dirStart = $$dirInfo{DirStart};
717 1 my $dirLen = $$dirInfo{DirLen};
718 1 ▶ if ($dirLen < 22) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dirLen < 22) 0 1 1
719 0 $et->Warn('Short Nikon Capture Data',1);
720 0 return undef;
721 }
722 # make sure the capture data is properly contained
723 1 SetByteOrder('II');
724 1 my $tagID = Get32u($dataPt, $dirStart);
725 # sometimes size includes 18 header bytes, and other times it doesn't (eg. ViewNX 2.1.1)
726 1 my $size = Get32u($dataPt, $dirStart + 18);
727 1 my $pad = $dirLen - $size - 18;
728 1 ▶ unless ($tagID == 0x7a86a940 and ($pad >= 0 or $pad == -18)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tagID == 2055645504 and $pad >= 0 || $pad == -18) 0 1 1
Condition33%2/6
$tagID == 2055645504 and $pad >= 0 || $pad == -18
!ll&&!rl&&r
001
$pad >= 0 or $pad == -18
l!l&&r!l&&!r
100
MC/DC0%0/3
$tagID == 2055645504 and $pad >= 0 || $pad == -18
$tagID == 2055645504 $pad >= 0 $pad == -18
Truth table25%1/4
A and B or C
A= $tagID == 2055645504B= $pad >= 0C= $pad == -18
ABCresult
0XX0
1000
11X1
1011
729 0 $et->Warn('Unrecognized Nikon Capture Data header');
730 0 return undef;
731 }
732 # determine if there is any data after this block
733 1 ▶ if ($pad > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pad > 0) { } 0 1 1
734 0 $pad = substr($$dataPt, $dirStart + 18 + $size, $pad);
735 0 $dirLen = $size + 18;
736 } else {
737 1 $pad = '';
738 }
739 1 my $outBuff = '';
740 1 my $pos;
741 1 my $newTags = $et->GetNewTagInfoHash($tagTablePtr);
742 1 my $dirEnd = $dirStart + $dirLen;
743  
744 # loop through all entries in the Nikon Capture data
745 1 ▶ for ($pos=$dirStart+22; $pos+22<$dirEnd; $pos+=22+$size) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos + 22 < $dirEnd) 50 1 51
746 50 $tagID = Get32u($dataPt, $pos);
747 50 $size = Get32u($dataPt, $pos + 18) - 4;
748 50 ▶ last if $size < 0 or $pos + 22 + $size > $dirEnd;
Branch: 1 branch
BranchTrueFalseTotal
if $size < 0 or $pos + 22 + $size > $dirEnd 0 50 50
Condition33%1/3
$size < 0 or $pos + 22 + $size > $dirEnd
l!l&&r!l&&!r
0050
MC/DC0%0/2
$size < 0 or $pos + 22 + $size > $dirEnd
$size < 0 $pos + 22 + $size > $dirEnd
Truth table33%1/3
A or B
A= $size < 0B= $pos + 22 + $size > $dirEnd
ABresult
1X1
011
000
749 50 my $tagInfo = $et->GetTagInfo($tagTablePtr, $tagID);
750 50 ▶ if ($tagInfo) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tagInfo) 32 18 50
751 32 my $newVal;
752 32 ▶ if ($$tagInfo{SubDirectory}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($tagInfo->{'SubDirectory'}) { } 12 20 32
elsif ($newTags->{$tagID}) { } 2 18 20
753 # rewrite the subdirectory
754 12 my %subdirInfo = (
755 DataPt => $dataPt,
756 DirStart => $pos + 22,
757 DirLen => $size,
758 );
759 12 my $subTable = GetTagTable($tagInfo->{SubDirectory}->{TagTable});
760 # ignore minor errors in IPTC since there is typically trailing garbage
761 12 my $oldSetting = $et->Options('IgnoreMinorErrors');
762 12 ▶ $$tagInfo{Name} =~ /IPTC/ and $et->Options(IgnoreMinorErrors => 1);
Branch: 1 branch
BranchTrueFalseTotal
$tagInfo->{"Name"} =~ /IPTC/ and $et->Options("IgnoreMinorErrors", 1) 1 11 12
763 # rewrite the directory
764 12 $newVal = $et->WriteDirectory(\%subdirInfo, $subTable);
765 # restore our original options
766 12 $et->Options(IgnoreMinorErrors => $oldSetting);
767 } elsif ($$newTags{$tagID}) {
768 # get new value for this tag if we are writing it
769 2 ▶ my $format = $$tagInfo{Format} || $$tagInfo{Writable};
Condition33%1/3
$tagInfo->{'Format'} || $tagInfo->{'Writable'}
l!l&&r!l&&!r
020
MC/DC0%0/2
$tagInfo->{'Format'} || $tagInfo->{'Writable'}
$tagInfo->{'Format'} $tagInfo->{'Writable'}
Truth table33%1/3
A || B
A= $tagInfo->{'Format'}B= $tagInfo->{'Writable'}
ABresult
1X1
011
000
770 2 my $oldVal = ReadValue($dataPt,$pos+22,$format,1,$size);
771 2 my $nvHash = $et->GetNewValueHash($tagInfo);
772 2 ▶ if ($et->IsOverwriting($nvHash, $oldVal)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($et->IsOverwriting($nvHash, $oldVal)) 2 0 2
773 2 my $val = $et->GetNewValue($tagInfo);
774 2 ▶ $newVal = WriteValue($val, $$tagInfo{Writable}) if defined $val;
Branch: 1 branch
BranchTrueFalseTotal
if defined $val 2 0 2
775 2 ▶ if (defined $newVal and length $newVal) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $newVal and length $newVal) { } 2 0 2
Condition33%1/3
defined $newVal and length $newVal
!ll&&!rl&&r
002
MC/DC0%0/2
defined $newVal and length $newVal
defined $newVal length $newVal
Truth table33%1/3
A and B
A= defined $newValB= length $newVal
ABresult
0X0
100
111
776 2 ++$$et{CHANGED};
777 } else {
778 0 undef $newVal;
779 0 $et->Warn("Can't delete $$tagInfo{Name}");
780 }
781 }
782 }
783 32 ▶ if (defined $newVal) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $newVal) 14 18 32
784 14 ▶ next unless length $newVal; # don't write zero length information
Branch: 1 branch
BranchTrueFalseTotal
unless length $newVal 0 14 14
785 # write the new value
786 14 $outBuff .= substr($$dataPt, $pos, 18);
787 14 $outBuff .= Set32u(length($newVal) + 4);
788 14 $outBuff .= $newVal;
789 14 next;
790 }
791 }
792 # rewrite the existing information
793 36 $outBuff .= substr($$dataPt, $pos, 22 + $size);
794 }
795 1 ▶ unless ($pos == $dirEnd) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pos == $dirEnd) 0 1 1
796 0 ▶ if ($pos == $dirEnd - 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos == $dirEnd - 4) { } 0 0 0
797 # it seems that sometimes (NX2) the main block size is wrong by 4 bytes
798 # (did they forget to include the size word?)
799 0 $outBuff .= substr($$dataPt, $pos, 4);
800 } else {
801 0 $et->Warn('Nikon Capture Data improperly terminated',1);
802 0 return undef;
803 }
804 }
805 # add the header and return the new directory
806 1 return substr($$dataPt, $dirStart, 18) .
807 Set32u(length($outBuff) + 4) .
808 $outBuff . $pad;
809 }
810  
811 #------------------------------------------------------------------------------
812 # process Nikon Capture data (ref 1)
813 # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
814 # Returns: 1 on success
815 sub ProcessNikonCaptureEditVersions($$$)
816 0 ▶{
Subroutine ProcessNikonCaptureEditVersions: not called CC=6 SCAR=37.4
Pod undocumented
817 0 my ($et, $dirInfo, $tagTablePtr) = @_;
818 0 my $dataPt = $$dirInfo{DataPt};
819 0 my $dirStart = $$dirInfo{DirStart};
820 0 my $dirLen = $$dirInfo{DirLen};
821 0 my $dirEnd = $dirStart + $dirLen;
822 0 my $verbose = $et->Options('Verbose');
823 0 SetByteOrder('II');
824 0 ▶ return 0 unless $dirLen > 4;
Branch: 1 branch
BranchTrueFalseTotal
unless $dirLen > 4 0 0 0
825 0 my $num = Get32u($dataPt, $dirStart);
826 0 my $pos = $dirStart + 4;
827 0 ▶ $verbose and $et->VerboseDir('NikonCaptureEditVersions', $num);
Branch: 1 branch
BranchTrueFalseTotal
$verbose and $et->VerboseDir("NikonCaptureEditVersions", $num) 0 0 0
828 0 ▶ while ($num) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num) 0 0 0
829 0 ▶ last if $pos + 4 > $dirEnd;
Branch: 1 branch
BranchTrueFalseTotal
if $pos + 4 > $dirEnd 0 0 0
830 0 my $len = Get32u($dataPt, $pos);
831 0 ▶ last if $pos + $len + 4 > $dirEnd;
Branch: 1 branch
BranchTrueFalseTotal
if $pos + $len + 4 > $dirEnd 0 0 0
832 0 my %dirInfo = (
833 DirName => 'NikonCapture',
834 Parent => 'NikonCaptureEditVersions',
835 DataPt => $dataPt,
836 DirStart => $pos + 4,
837 DirLen => $len,
838 );
839 0 $$et{DOC_NUM} = ++$$et{DOC_COUNT};
840 0 $et->ProcessDirectory(\%dirInfo, $tagTablePtr);
841 0 --$num;
842 0 $pos += $len + 4;
843 }
844 0 delete $$et{DOC_NUM};
845 0 return 1;
846 }
847  
848 #------------------------------------------------------------------------------
849 # process Nikon Capture data (ref 1)
850 # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
851 # Returns: 1 on success
852 sub ProcessNikonCapture($$$)
853 2 ▶{
Subroutine ProcessNikonCapture: called CC=20 SCAR=35.7
Pod undocumented
854 2 my ($et, $dirInfo, $tagTablePtr) = @_;
855 2 my $dataPt = $$dirInfo{DataPt};
856 2 my $dirStart = $$dirInfo{DirStart};
857 2 my $dirLen = $$dirInfo{DirLen};
858 2 my $dirEnd = $dirStart + $dirLen;
859 2 my $verbose = $et->Options('Verbose');
860 2 my $success = 0;
861 2 SetByteOrder('II');
862 2 ▶ $verbose and $et->VerboseDir('NikonCapture', 0, $dirLen);
Branch: 1 branch
BranchTrueFalseTotal
$verbose and $et->VerboseDir("NikonCapture", 0, $dirLen) 0 2 2
863 2 my $pos;
864 2 ▶ for ($pos=$dirStart+22; $pos+22<$dirEnd; ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos + 22 < $dirEnd) 100 2 102
865 100 my $tagID = Get32u($dataPt, $pos);
866 100 my $size = Get32u($dataPt, $pos + 18) - 4;
867 100 $pos += 22;
868 100 ▶ last if $size < 0 or $pos + $size > $dirEnd;
Branch: 1 branch
BranchTrueFalseTotal
if $size < 0 or $pos + $size > $dirEnd 0 100 100
Condition33%1/3
$size < 0 or $pos + $size > $dirEnd
l!l&&r!l&&!r
00100
MC/DC0%0/2
$size < 0 or $pos + $size > $dirEnd
$size < 0 $pos + $size > $dirEnd
Truth table33%1/3
A or B
A= $size < 0B= $pos + $size > $dirEnd
ABresult
1X1
011
000
869 100 my $tagInfo = $et->GetTagInfo($tagTablePtr, $tagID);
870 100 ▶ if ($tagInfo or $verbose) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tagInfo or $verbose) 64 36 100
Condition66%2/3
$tagInfo or $verbose
l!l&&r!l&&!r
64036
MC/DC50%1/2
$tagInfo or $verbose
$tagInfo $verbose
Truth table66%2/3
A or B
A= $tagInfoB= $verbose
ABresult
1X1
011
000
871 64 my ($format, $value);
872 # (note that Writable will be 0 for Unknown tags)
873 64 ▶ $tagInfo and $format = ($$tagInfo{Format} || $$tagInfo{Writable});
Branch: 1 branch
BranchTrueFalseTotal
$tagInfo and $format = $tagInfo->{"Format"} || $tagInfo->{"Writable"} 64 0 64
Condition66%2/3
$tagInfo->{'Format'} || $tagInfo->{'Writable'}
l!l&&r!l&&!r
04024
MC/DC50%1/2
$tagInfo->{'Format'} || $tagInfo->{'Writable'}
$tagInfo->{'Format'} $tagInfo->{'Writable'}
Truth table66%2/3
A || B
A= $tagInfo->{'Format'}B= $tagInfo->{'Writable'}
ABresult
1X1
011
000
874 # generate a reasonable default format type for short values
875 64 ▶ if (not $format and ($size == 1 or $size == 2 or $size == 4)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $format and $size == 1 || $size == 2 || $size == 4) 0 64 64
Condition44%4/9
not $format and $size == 1 || $size == 2 || $size == 4
!ll&&!rl&&r
40240
$size == 1 or $size == 2 or $size == 4
l!l&&r!l&&!r
0024
$size == 1 or $size == 2
l!l&&r!l&&!r
0024
MC/DC0%0/4
not $format and $size == 1 || $size == 2 || $size == 4
not $format $size == 1 $size == 2 $size == 4
Truth table40%2/5
not(A) and B or C or D
A= not $formatB= $size == 1C= $size == 2D= $size == 4
ABCDresult
0XXX0
10000
11XX1
101X1
10011
876 0 $format = 'int' . ($size * 8) . 'u';
877 }
878 64 ▶ if ($format) {
Branch: 2 branches
BranchTrueFalseTotal
if ($format) { } 40 24 64
elsif ($size == 1) { } 0 24 24
879 40 my $count = 1;
880 40 ▶ if ($format eq 'string' or $format eq 'undef') {
Branch: 1 branch
BranchTrueFalseTotal
if ($format eq "string" or $format eq "undef") 0 40 40
Condition33%1/3
$format eq "string" or $format eq "undef"
l!l&&r!l&&!r
0040
MC/DC0%0/2
$format eq "string" or $format eq "undef"
$format eq "string" $format eq "undef"
Truth table33%1/3
A or B
A= $format eq "string"B= $format eq "undef"
ABresult
1X1
011
000
881 # patch Nikon bug in size of some values (HistogramXML)
882 0 ▶ $size += $$tagInfo{AdjustSize} if $tagInfo and $$tagInfo{AdjustSize};
Branch: 1 branch
BranchTrueFalseTotal
if $tagInfo and $tagInfo->{"AdjustSize"} 0 0 0
Condition0%0/3
$tagInfo and $tagInfo->{"AdjustSize"}
!ll&&!rl&&r
000
MC/DC0%0/2
$tagInfo and $tagInfo->{"AdjustSize"}
$tagInfo $tagInfo->{"AdjustSize"}
Truth table0%0/3
A and B
A= $tagInfoB= $tagInfo->{"AdjustSize"}
ABresult
0X0
100
111
883 0 $count = $size;
884 }
885 40 $value = ReadValue($dataPt,$pos,$format,$count,$size);
886 } elsif ($size == 1) {
887 0 $value = substr($$dataPt, $pos, $size);
888 }
889 $et->HandleTag($tagTablePtr, $tagID, $value,
890 DataPt => $dataPt,
891 DataPos => $$dirInfo{DataPos},
892 Base => $$dirInfo{Base},
893 64 ▶ Start => $pos,
Branch: 1 branch
BranchTrueFalseTotal
$et->HandleTag($tagTablePtr, $tagID, $value, "DataPt", $dataPt, "DataPos", $dirInfo->{"DataPos"}, "Base", $dirInfo->{"Base"}, "Start", $pos, "Size", $size) and $success = 1 40 24 64
894 Size => $size,
895 ) and $success = 1;
896 }
897 100 $pos += $size;
898 }
899 2 return $success;
900 }
901  
902 8 1; # end
903  
904 __END__
« Image/ExifTool/Red.pm ↑ Summary Image/ExifTool/iWork.pm »