File Coverage

blib/lib/Image/ExifTool/Nikon.pm
Criterion Covered Total %
statement 165 397 41.5
branch 59 232 25.4
condition 22 102 21.5
subroutine 15 27 55.5
pod 0 21 0.0
total 261 779 33.5


line stmt bran cond sub pod time code
1             #------------------------------------------------------------------------------
2             # File: Nikon.pm
3             #
4             # Description: Nikon EXIF maker notes tags
5             #
6             # Revisions: 12/09/2003 - P. Harvey Created
7             # 05/17/2004 - P. Harvey Added information from Joseph Heled
8             # 09/21/2004 - P. Harvey Changed tag 2 to ISOUsed & added PrintConv
9             # 12/01/2004 - P. Harvey Added default PRINT_CONV
10             # 01/01/2005 - P. Harvey Decode preview image and preview IFD
11             # 03/35/2005 - T. Christiansen additions
12             # 05/10/2005 - P. Harvey Decode encrypted lens data
13             # [ongoing] - P. Harvey Constantly decoding new information
14             #
15             # References: 1) http://park2.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html
16             # 2) Joseph Heled private communication (tests with D70)
17             # 3) Thomas Walter private communication (tests with Coolpix 5400)
18             # 4) http://www.cybercom.net/~dcoffin/dcraw/
19             # 5) Brian Ristuccia private communication (tests with D70)
20             # 6) Danek Duvall private communication (tests with D70)
21             # 7) Tom Christiansen private communication (tests with D70)
22             # 8) Robert Rottmerhusen private communication
23             # 9) http://members.aol.com/khancock/pilot/nbuddy/
24             # 10) Werner Kober private communication (D2H, D2X, D100, D70, D200, D90)
25             # 11) http://www.rottmerhusen.com/objektives/lensid/thirdparty.html
26             # 12) http://libexif.sourceforge.net/internals/mnote-olympus-tag_8h-source.html
27             # 13) Roger Larsson private communication (tests with D200)
28             # 14) http://homepage3.nifty.com/kamisaka/makernote/makernote_nikon.htm (2007/09/15)
29             # 15) http://tomtia.plala.jp/DigitalCamera/MakerNote/index.asp
30             # 16) Jeffrey Friedl private communication (D200 with firmware update)
31             # 17) http://www.wohlberg.net/public/software/photo/nstiffexif/
32             # and Brendt Wohlberg private communication
33             # 18) Anonymous user private communication (D70, D200, D2x)
34             # 19) Bruce Stevens private communication
35             # 20) Vladimir Sauta private communication (D80)
36             # 21) Gregor Dorlars private communication (D300)
37             # 22) Tanel Kuusk private communication
38             # 23) Alexandre Naaman private communication (D3)
39             # 24) Geert De Soete private communication
40             # 26) Bozi (http://www.cpanforum.com/posts/8983)
41             # 27) Jens Kriese private communication
42             # 28) Warren Hatch private communication (D3v2.00 with SB-800 and SB-900)
43             # 29) Anonymous contribution 2011/05/25 (D700, D7000)
44             # 30) https://exiftool.org/forum/index.php/topic,3833.30.html
45             # 31) Michael Relt private communication
46             # 32) Stefan https://exiftool.org/forum/index.php/topic,4494.0.html
47             # 34) Stewart Bennett private communication (D4S, D810)
48             # 35) David Puschel private communication
49             # 36) Hayo Baann (forum10207)
50             # 37) Tom Lachecki, private communication
51             # 38) https://github.com/exiftool/exiftool/pull/40 (and forum10893)
52             # 39) Stefan Grube private communication (Z9)
53             # IB) Iliah Borg private communication (LibRaw)
54             # JD) Jens Duttke private communication
55             # NJ) Niels Kristian Bech Jensen private communication
56             #------------------------------------------------------------------------------
57              
58             package Image::ExifTool::Nikon;
59              
60 27     27   5878 use strict;
  27         83  
  27         1096  
61 27     27   156 use vars qw($VERSION %nikonLensIDs %nikonTextEncoding);
  27         72  
  27         1700  
62 27     27   192 use Image::ExifTool qw(:DataAccess :Utils);
  27         79  
  27         6322  
63 27     27   1501 use Image::ExifTool::Exif;
  27         81  
  27         841  
64 27     27   736 use Image::ExifTool::GPS;
  27         69  
  27         710  
65 27     27   11191 use Image::ExifTool::XMP;
  27         416  
  27         762403  
66              
67             $VERSION = '4.13';
68              
69             sub LensIDConv($$$);
70             sub ProcessNikonAVI($$$);
71             sub ProcessNikonMOV($$$);
72             sub FormatString($);
73             sub ProcessNikonCaptureEditVersions($$$);
74             sub PrintAFPoints($$);
75             sub PrintAFPointsInv($$);
76             sub PrintAFPointsGrid($$);
77             sub PrintAFPointsGridInv($$$);
78             sub GetAFPointGrid($$;$);
79              
80             # nikon lens ID numbers (ref 8/11)
81             %nikonLensIDs = (
82             Notes => q{
83             The Nikon LensID is constructed as a Composite tag from the raw hex values
84             of 8 other tags: LensIDNumber, LensFStops, MinFocalLength, MaxFocalLength,
85             MaxApertureAtMinFocal, MaxApertureAtMaxFocal, MCUVersion and LensType, in
86             that order. Multiple lenses with the same LensID are differentiated by
87             decimal values in the list below. The user-defined "Lenses" list may be
88             used to specify the lens for ExifTool to choose in these cases (see the
89             L for details).
90             },
91             OTHER => \&LensIDConv,
92             # Note: Sync this list with Robert's Perl version at
93             # http://www.rottmerhusen.com/objektives/lensid/files/exif/fmountlens.p.txt
94             # (hex digits must be uppercase in keys below)
95             '01 58 50 50 14 14 02 00' => 'AF Nikkor 50mm f/1.8',
96             '01 58 50 50 14 14 05 00' => 'AF Nikkor 50mm f/1.8',
97             '02 42 44 5C 2A 34 02 00' => 'AF Zoom-Nikkor 35-70mm f/3.3-4.5',
98             '02 42 44 5C 2A 34 08 00' => 'AF Zoom-Nikkor 35-70mm f/3.3-4.5',
99             '03 48 5C 81 30 30 02 00' => 'AF Zoom-Nikkor 70-210mm f/4',
100             '04 48 3C 3C 24 24 03 00' => 'AF Nikkor 28mm f/2.8',
101             '05 54 50 50 0C 0C 04 00' => 'AF Nikkor 50mm f/1.4',
102             '06 54 53 53 24 24 06 00' => 'AF Micro-Nikkor 55mm f/2.8',
103             '07 40 3C 62 2C 34 03 00' => 'AF Zoom-Nikkor 28-85mm f/3.5-4.5',
104             '08 40 44 6A 2C 34 04 00' => 'AF Zoom-Nikkor 35-105mm f/3.5-4.5',
105             '09 48 37 37 24 24 04 00' => 'AF Nikkor 24mm f/2.8',
106             '0A 48 8E 8E 24 24 03 00' => 'AF Nikkor 300mm f/2.8 IF-ED',
107             '0A 48 8E 8E 24 24 05 00' => 'AF Nikkor 300mm f/2.8 IF-ED N',
108             '0B 48 7C 7C 24 24 05 00' => 'AF Nikkor 180mm f/2.8 IF-ED',
109             '0D 40 44 72 2C 34 07 00' => 'AF Zoom-Nikkor 35-135mm f/3.5-4.5',
110             '0E 48 5C 81 30 30 05 00' => 'AF Zoom-Nikkor 70-210mm f/4',
111             '0F 58 50 50 14 14 05 00' => 'AF Nikkor 50mm f/1.8 N',
112             '10 48 8E 8E 30 30 08 00' => 'AF Nikkor 300mm f/4 IF-ED',
113             '11 48 44 5C 24 24 08 00' => 'AF Zoom-Nikkor 35-70mm f/2.8',
114             '11 48 44 5C 24 24 15 00' => 'AF Zoom-Nikkor 35-70mm f/2.8', #Jakob Dettner
115             '12 48 5C 81 30 3C 09 00' => 'AF Nikkor 70-210mm f/4-5.6',
116             '13 42 37 50 2A 34 0B 00' => 'AF Zoom-Nikkor 24-50mm f/3.3-4.5',
117             '14 48 60 80 24 24 0B 00' => 'AF Zoom-Nikkor 80-200mm f/2.8 ED',
118             '15 4C 62 62 14 14 0C 00' => 'AF Nikkor 85mm f/1.8',
119             '17 3C A0 A0 30 30 0F 00' => 'Nikkor 500mm f/4 P ED IF',
120             '17 3C A0 A0 30 30 11 00' => 'Nikkor 500mm f/4 P ED IF',
121             '18 40 44 72 2C 34 0E 00' => 'AF Zoom-Nikkor 35-135mm f/3.5-4.5 N',
122             '1A 54 44 44 18 18 11 00' => 'AF Nikkor 35mm f/2',
123             '1B 44 5E 8E 34 3C 10 00' => 'AF Zoom-Nikkor 75-300mm f/4.5-5.6',
124             '1C 48 30 30 24 24 12 00' => 'AF Nikkor 20mm f/2.8',
125             '1D 42 44 5C 2A 34 12 00' => 'AF Zoom-Nikkor 35-70mm f/3.3-4.5 N',
126             '1E 54 56 56 24 24 13 00' => 'AF Micro-Nikkor 60mm f/2.8',
127             '1F 54 6A 6A 24 24 14 00' => 'AF Micro-Nikkor 105mm f/2.8',
128             '20 48 60 80 24 24 15 00' => 'AF Zoom-Nikkor 80-200mm f/2.8 ED',
129             '21 40 3C 5C 2C 34 16 00' => 'AF Zoom-Nikkor 28-70mm f/3.5-4.5',
130             '22 48 72 72 18 18 16 00' => 'AF DC-Nikkor 135mm f/2',
131             '23 30 BE CA 3C 48 17 00' => 'Zoom-Nikkor 1200-1700mm f/5.6-8 P ED IF',
132             '24 48 60 80 24 24 1A 02' => 'AF Zoom-Nikkor 80-200mm f/2.8D ED',
133             '25 48 44 5C 24 24 1B 02' => 'AF Zoom-Nikkor 35-70mm f/2.8D',
134             '25 48 44 5C 24 24 3A 02' => 'AF Zoom-Nikkor 35-70mm f/2.8D',
135             '25 48 44 5C 24 24 52 02' => 'AF Zoom-Nikkor 35-70mm f/2.8D',
136             '26 40 3C 5C 2C 34 1C 02' => 'AF Zoom-Nikkor 28-70mm f/3.5-4.5D',
137             '27 48 8E 8E 24 24 1D 02' => 'AF-I Nikkor 300mm f/2.8D IF-ED',
138             '27 48 8E 8E 24 24 F1 02' => 'AF-I Nikkor 300mm f/2.8D IF-ED + TC-14E',
139             '27 48 8E 8E 24 24 E1 02' => 'AF-I Nikkor 300mm f/2.8D IF-ED + TC-17E',
140             '27 48 8E 8E 24 24 F2 02' => 'AF-I Nikkor 300mm f/2.8D IF-ED + TC-20E',
141             '28 3C A6 A6 30 30 1D 02' => 'AF-I Nikkor 600mm f/4D IF-ED',
142             '28 3C A6 A6 30 30 F1 02' => 'AF-I Nikkor 600mm f/4D IF-ED + TC-14E',
143             '28 3C A6 A6 30 30 E1 02' => 'AF-I Nikkor 600mm f/4D IF-ED + TC-17E',
144             '28 3C A6 A6 30 30 F2 02' => 'AF-I Nikkor 600mm f/4D IF-ED + TC-20E',
145             '2A 54 3C 3C 0C 0C 26 02' => 'AF Nikkor 28mm f/1.4D',
146             '2B 3C 44 60 30 3C 1F 02' => 'AF Zoom-Nikkor 35-80mm f/4-5.6D',
147             '2C 48 6A 6A 18 18 27 02' => 'AF DC-Nikkor 105mm f/2D',
148             '2D 48 80 80 30 30 21 02' => 'AF Micro-Nikkor 200mm f/4D IF-ED',
149             '2E 48 5C 82 30 3C 22 02' => 'AF Nikkor 70-210mm f/4-5.6D',
150             '2E 48 5C 82 30 3C 28 02' => 'AF Nikkor 70-210mm f/4-5.6D',
151             '2F 48 30 44 24 24 29 02.1' => 'AF Zoom-Nikkor 20-35mm f/2.8D IF',
152             '30 48 98 98 24 24 24 02' => 'AF-I Nikkor 400mm f/2.8D IF-ED',
153             '30 48 98 98 24 24 F1 02' => 'AF-I Nikkor 400mm f/2.8D IF-ED + TC-14E',
154             '30 48 98 98 24 24 E1 02' => 'AF-I Nikkor 400mm f/2.8D IF-ED + TC-17E',
155             '30 48 98 98 24 24 F2 02' => 'AF-I Nikkor 400mm f/2.8D IF-ED + TC-20E',
156             '31 54 56 56 24 24 25 02' => 'AF Micro-Nikkor 60mm f/2.8D',
157             '32 54 6A 6A 24 24 35 02.1' => 'AF Micro-Nikkor 105mm f/2.8D',
158             '33 48 2D 2D 24 24 31 02' => 'AF Nikkor 18mm f/2.8D',
159             '34 48 29 29 24 24 32 02' => 'AF Fisheye Nikkor 16mm f/2.8D',
160             '35 3C A0 A0 30 30 33 02' => 'AF-I Nikkor 500mm f/4D IF-ED',
161             '35 3C A0 A0 30 30 F1 02' => 'AF-I Nikkor 500mm f/4D IF-ED + TC-14E',
162             '35 3C A0 A0 30 30 E1 02' => 'AF-I Nikkor 500mm f/4D IF-ED + TC-17E',
163             '35 3C A0 A0 30 30 F2 02' => 'AF-I Nikkor 500mm f/4D IF-ED + TC-20E',
164             '36 48 37 37 24 24 34 02' => 'AF Nikkor 24mm f/2.8D',
165             '37 48 30 30 24 24 36 02' => 'AF Nikkor 20mm f/2.8D',
166             '38 4C 62 62 14 14 37 02' => 'AF Nikkor 85mm f/1.8D',
167             '3A 40 3C 5C 2C 34 39 02' => 'AF Zoom-Nikkor 28-70mm f/3.5-4.5D',
168             '3B 48 44 5C 24 24 3A 02' => 'AF Zoom-Nikkor 35-70mm f/2.8D N',
169             '3C 48 60 80 24 24 3B 02' => 'AF Zoom-Nikkor 80-200mm f/2.8D ED', #NJ
170             '3D 3C 44 60 30 3C 3E 02' => 'AF Zoom-Nikkor 35-80mm f/4-5.6D',
171             '3E 48 3C 3C 24 24 3D 02' => 'AF Nikkor 28mm f/2.8D',
172             '3F 40 44 6A 2C 34 45 02' => 'AF Zoom-Nikkor 35-105mm f/3.5-4.5D',
173             '41 48 7C 7C 24 24 43 02' => 'AF Nikkor 180mm f/2.8D IF-ED',
174             '42 54 44 44 18 18 44 02' => 'AF Nikkor 35mm f/2D',
175             '43 54 50 50 0C 0C 46 02' => 'AF Nikkor 50mm f/1.4D',
176             '44 44 60 80 34 3C 47 02' => 'AF Zoom-Nikkor 80-200mm f/4.5-5.6D',
177             '45 40 3C 60 2C 3C 48 02' => 'AF Zoom-Nikkor 28-80mm f/3.5-5.6D',
178             '46 3C 44 60 30 3C 49 02' => 'AF Zoom-Nikkor 35-80mm f/4-5.6D N',
179             '47 42 37 50 2A 34 4A 02' => 'AF Zoom-Nikkor 24-50mm f/3.3-4.5D',
180             '48 48 8E 8E 24 24 4B 02' => 'AF-S Nikkor 300mm f/2.8D IF-ED',
181             '48 48 8E 8E 24 24 F1 02' => 'AF-S Nikkor 300mm f/2.8D IF-ED + TC-14E',
182             '48 48 8E 8E 24 24 E1 02' => 'AF-S Nikkor 300mm f/2.8D IF-ED + TC-17E',
183             '48 48 8E 8E 24 24 F2 02' => 'AF-S Nikkor 300mm f/2.8D IF-ED + TC-20E',
184             '49 3C A6 A6 30 30 4C 02' => 'AF-S Nikkor 600mm f/4D IF-ED',
185             '49 3C A6 A6 30 30 F1 02' => 'AF-S Nikkor 600mm f/4D IF-ED + TC-14E',
186             '49 3C A6 A6 30 30 E1 02' => 'AF-S Nikkor 600mm f/4D IF-ED + TC-17E',
187             '49 3C A6 A6 30 30 F2 02' => 'AF-S Nikkor 600mm f/4D IF-ED + TC-20E',
188             '4A 54 62 62 0C 0C 4D 02' => 'AF Nikkor 85mm f/1.4D IF',
189             '4B 3C A0 A0 30 30 4E 02' => 'AF-S Nikkor 500mm f/4D IF-ED',
190             '4B 3C A0 A0 30 30 F1 02' => 'AF-S Nikkor 500mm f/4D IF-ED + TC-14E',
191             '4B 3C A0 A0 30 30 E1 02' => 'AF-S Nikkor 500mm f/4D IF-ED + TC-17E',
192             '4B 3C A0 A0 30 30 F2 02' => 'AF-S Nikkor 500mm f/4D IF-ED + TC-20E',
193             '4C 40 37 6E 2C 3C 4F 02' => 'AF Zoom-Nikkor 24-120mm f/3.5-5.6D IF',
194             '4D 40 3C 80 2C 3C 62 02' => 'AF Zoom-Nikkor 28-200mm f/3.5-5.6D IF',
195             '4E 48 72 72 18 18 51 02' => 'AF DC-Nikkor 135mm f/2D',
196             '4F 40 37 5C 2C 3C 53 06' => 'IX-Nikkor 24-70mm f/3.5-5.6',
197             '50 48 56 7C 30 3C 54 06' => 'IX-Nikkor 60-180mm f/4-5.6',
198             '53 48 60 80 24 24 57 02' => 'AF Zoom-Nikkor 80-200mm f/2.8D ED',
199             '53 48 60 80 24 24 60 02' => 'AF Zoom-Nikkor 80-200mm f/2.8D ED',
200             '54 44 5C 7C 34 3C 58 02' => 'AF Zoom-Micro Nikkor 70-180mm f/4.5-5.6D ED',
201             '54 44 5C 7C 34 3C 61 02' => 'AF Zoom-Micro Nikkor 70-180mm f/4.5-5.6D ED',
202             '56 48 5C 8E 30 3C 5A 02' => 'AF Zoom-Nikkor 70-300mm f/4-5.6D ED',
203             '59 48 98 98 24 24 5D 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED',
204             '59 48 98 98 24 24 F1 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED + TC-14E',
205             '59 48 98 98 24 24 E1 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED + TC-17E',
206             '59 48 98 98 24 24 F2 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED + TC-20E',
207             '5A 3C 3E 56 30 3C 5E 06' => 'IX-Nikkor 30-60mm f/4-5.6',
208             '5B 44 56 7C 34 3C 5F 06' => 'IX-Nikkor 60-180mm f/4.5-5.6',
209             '5D 48 3C 5C 24 24 63 02' => 'AF-S Zoom-Nikkor 28-70mm f/2.8D IF-ED',
210             '5E 48 60 80 24 24 64 02' => 'AF-S Zoom-Nikkor 80-200mm f/2.8D IF-ED',
211             '5F 40 3C 6A 2C 34 65 02' => 'AF Zoom-Nikkor 28-105mm f/3.5-4.5D IF',
212             '60 40 3C 60 2C 3C 66 02' => 'AF Zoom-Nikkor 28-80mm f/3.5-5.6D', #(http://www.exif.org/forum/topic.asp?TOPIC_ID=16)
213             '61 44 5E 86 34 3C 67 02' => 'AF Zoom-Nikkor 75-240mm f/4.5-5.6D',
214             '63 48 2B 44 24 24 68 02' => 'AF-S Nikkor 17-35mm f/2.8D IF-ED',
215             '64 00 62 62 24 24 6A 02' => 'PC Micro-Nikkor 85mm f/2.8D',
216             '65 44 60 98 34 3C 6B 0A' => 'AF VR Zoom-Nikkor 80-400mm f/4.5-5.6D ED',
217             '66 40 2D 44 2C 34 6C 02' => 'AF Zoom-Nikkor 18-35mm f/3.5-4.5D IF-ED',
218             '67 48 37 62 24 30 6D 02' => 'AF Zoom-Nikkor 24-85mm f/2.8-4D IF',
219             '68 42 3C 60 2A 3C 6E 06' => 'AF Zoom-Nikkor 28-80mm f/3.3-5.6G',
220             '69 48 5C 8E 30 3C 6F 06' => 'AF Zoom-Nikkor 70-300mm f/4-5.6G',
221             '6A 48 8E 8E 30 30 70 02' => 'AF-S Nikkor 300mm f/4D IF-ED',
222             '6B 48 24 24 24 24 71 02' => 'AF Nikkor ED 14mm f/2.8D',
223             '6D 48 8E 8E 24 24 73 02' => 'AF-S Nikkor 300mm f/2.8D IF-ED II',
224             '6E 48 98 98 24 24 74 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED II',
225             '6F 3C A0 A0 30 30 75 02' => 'AF-S Nikkor 500mm f/4D IF-ED II',
226             '70 3C A6 A6 30 30 76 02' => 'AF-S Nikkor 600mm f/4D IF-ED II',
227             '72 48 4C 4C 24 24 77 00' => 'Nikkor 45mm f/2.8 P',
228             '74 40 37 62 2C 34 78 06' => 'AF-S Zoom-Nikkor 24-85mm f/3.5-4.5G IF-ED',
229             '75 40 3C 68 2C 3C 79 06' => 'AF Zoom-Nikkor 28-100mm f/3.5-5.6G',
230             '76 58 50 50 14 14 7A 02' => 'AF Nikkor 50mm f/1.8D',
231             '77 48 5C 80 24 24 7B 0E' => 'AF-S VR Zoom-Nikkor 70-200mm f/2.8G IF-ED',
232             '78 40 37 6E 2C 3C 7C 0E' => 'AF-S VR Zoom-Nikkor 24-120mm f/3.5-5.6G IF-ED',
233             '79 40 3C 80 2C 3C 7F 06' => 'AF Zoom-Nikkor 28-200mm f/3.5-5.6G IF-ED',
234             '7A 3C 1F 37 30 30 7E 06.1' => 'AF-S DX Zoom-Nikkor 12-24mm f/4G IF-ED',
235             '7B 48 80 98 30 30 80 0E' => 'AF-S VR Zoom-Nikkor 200-400mm f/4G IF-ED',
236             '7D 48 2B 53 24 24 82 06' => 'AF-S DX Zoom-Nikkor 17-55mm f/2.8G IF-ED',
237             '7F 40 2D 5C 2C 34 84 06' => 'AF-S DX Zoom-Nikkor 18-70mm f/3.5-4.5G IF-ED',
238             '80 48 1A 1A 24 24 85 06' => 'AF DX Fisheye-Nikkor 10.5mm f/2.8G ED',
239             '81 54 80 80 18 18 86 0E' => 'AF-S VR Nikkor 200mm f/2G IF-ED',
240             '82 48 8E 8E 24 24 87 0E' => 'AF-S VR Nikkor 300mm f/2.8G IF-ED',
241             '83 00 B0 B0 5A 5A 88 04' => 'FSA-L2, EDG 65, 800mm F13 G',
242             '89 3C 53 80 30 3C 8B 06' => 'AF-S DX Zoom-Nikkor 55-200mm f/4-5.6G ED',
243             '8A 54 6A 6A 24 24 8C 0E' => 'AF-S VR Micro-Nikkor 105mm f/2.8G IF-ED', #10
244             # when the TC-20 III 2x teleconverter is used with the above lens, the following have been observed:
245             # 8A 4D 6A 6A 24 24 8C 0E
246             # 8A 4E 6A 6A 24 24 8C 0E
247             # 8A 50 6A 6A 24 24 8C 0E
248             # 8A 51 6A 6A 24 24 8C 0E
249             # 8A 52 6A 6A 24 24 8C 0E
250             # 8A 53 6A 6A 24 24 8C 0E
251             # 8A 54 6A 6A 24 24 8C 0E (same as without the TC)
252             '8B 40 2D 80 2C 3C 8D 0E' => 'AF-S DX VR Zoom-Nikkor 18-200mm f/3.5-5.6G IF-ED',
253             '8B 40 2D 80 2C 3C FD 0E' => 'AF-S DX VR Zoom-Nikkor 18-200mm f/3.5-5.6G IF-ED [II]', #20
254             '8C 40 2D 53 2C 3C 8E 06' => 'AF-S DX Zoom-Nikkor 18-55mm f/3.5-5.6G ED',
255             '8D 44 5C 8E 34 3C 8F 0E' => 'AF-S VR Zoom-Nikkor 70-300mm f/4.5-5.6G IF-ED', #10
256             '8F 40 2D 72 2C 3C 91 06' => 'AF-S DX Zoom-Nikkor 18-135mm f/3.5-5.6G IF-ED',
257             '90 3B 53 80 30 3C 92 0E' => 'AF-S DX VR Zoom-Nikkor 55-200mm f/4-5.6G IF-ED',
258             '92 48 24 37 24 24 94 06' => 'AF-S Zoom-Nikkor 14-24mm f/2.8G ED',
259             '93 48 37 5C 24 24 95 06' => 'AF-S Zoom-Nikkor 24-70mm f/2.8G ED',
260             '94 40 2D 53 2C 3C 96 06' => 'AF-S DX Zoom-Nikkor 18-55mm f/3.5-5.6G ED II', #10 (D40)
261             '95 4C 37 37 2C 2C 97 02' => 'PC-E Nikkor 24mm f/3.5D ED',
262             '95 00 37 37 2C 2C 97 06' => 'PC-E Nikkor 24mm f/3.5D ED', #JD
263             '96 48 98 98 24 24 98 0E' => 'AF-S VR Nikkor 400mm f/2.8G ED',
264             '97 3C A0 A0 30 30 99 0E' => 'AF-S VR Nikkor 500mm f/4G ED',
265             '98 3C A6 A6 30 30 9A 0E' => 'AF-S VR Nikkor 600mm f/4G ED',
266             '99 40 29 62 2C 3C 9B 0E' => 'AF-S DX VR Zoom-Nikkor 16-85mm f/3.5-5.6G ED',
267             '9A 40 2D 53 2C 3C 9C 0E' => 'AF-S DX VR Zoom-Nikkor 18-55mm f/3.5-5.6G',
268             '9B 54 4C 4C 24 24 9D 02' => 'PC-E Micro Nikkor 45mm f/2.8D ED',
269             '9B 00 4C 4C 24 24 9D 06' => 'PC-E Micro Nikkor 45mm f/2.8D ED',
270             '9C 54 56 56 24 24 9E 06' => 'AF-S Micro Nikkor 60mm f/2.8G ED',
271             '9D 54 62 62 24 24 9F 02' => 'PC-E Micro Nikkor 85mm f/2.8D',
272             '9D 00 62 62 24 24 9F 06' => 'PC-E Micro Nikkor 85mm f/2.8D',
273             '9E 40 2D 6A 2C 3C A0 0E' => 'AF-S DX VR Zoom-Nikkor 18-105mm f/3.5-5.6G ED', #PH/10
274             '9F 58 44 44 14 14 A1 06' => 'AF-S DX Nikkor 35mm f/1.8G', #27
275             'A0 54 50 50 0C 0C A2 06' => 'AF-S Nikkor 50mm f/1.4G',
276             'A1 40 18 37 2C 34 A3 06' => 'AF-S DX Nikkor 10-24mm f/3.5-4.5G ED',
277             'A1 40 2D 53 2C 3C CB 86' => 'AF-P DX Nikkor 18-55mm f/3.5-5.6G', #30
278             'A2 48 5C 80 24 24 A4 0E' => 'AF-S Nikkor 70-200mm f/2.8G ED VR II',
279             'A3 3C 29 44 30 30 A5 0E' => 'AF-S Nikkor 16-35mm f/4G ED VR',
280             'A4 54 37 37 0C 0C A6 06' => 'AF-S Nikkor 24mm f/1.4G ED',
281             'A5 40 3C 8E 2C 3C A7 0E' => 'AF-S Nikkor 28-300mm f/3.5-5.6G ED VR',
282             'A6 48 8E 8E 24 24 A8 0E' => 'AF-S Nikkor 300mm f/2.8G IF-ED VR II',
283             'A7 4B 62 62 2C 2C A9 0E' => 'AF-S DX Micro Nikkor 85mm f/3.5G ED VR',
284             'A8 48 80 98 30 30 AA 0E' => 'AF-S Zoom-Nikkor 200-400mm f/4G IF-ED VR II', #https://exiftool.org/forum/index.php/topic,3218.msg15495.html#msg15495
285             'A9 54 80 80 18 18 AB 0E' => 'AF-S Nikkor 200mm f/2G ED VR II',
286             'AA 3C 37 6E 30 30 AC 0E' => 'AF-S Nikkor 24-120mm f/4G ED VR',
287             'AC 38 53 8E 34 3C AE 0E' => 'AF-S DX Nikkor 55-300mm f/4.5-5.6G ED VR',
288             'AD 3C 2D 8E 2C 3C AF 0E' => 'AF-S DX Nikkor 18-300mm f/3.5-5.6G ED VR',
289             'AE 54 62 62 0C 0C B0 06' => 'AF-S Nikkor 85mm f/1.4G',
290             'AF 54 44 44 0C 0C B1 06' => 'AF-S Nikkor 35mm f/1.4G',
291             'B0 4C 50 50 14 14 B2 06' => 'AF-S Nikkor 50mm f/1.8G',
292             'B1 48 48 48 24 24 B3 06' => 'AF-S DX Micro Nikkor 40mm f/2.8G', #27
293             'B2 48 5C 80 30 30 B4 0E' => 'AF-S Nikkor 70-200mm f/4G ED VR', #35
294             'B3 4C 62 62 14 14 B5 06' => 'AF-S Nikkor 85mm f/1.8G',
295             'B4 40 37 62 2C 34 B6 0E' => 'AF-S Zoom-Nikkor 24-85mm f/3.5-4.5G IF-ED VR', #30
296             'B5 4C 3C 3C 14 14 B7 06' => 'AF-S Nikkor 28mm f/1.8G', #30
297             'B6 3C B0 B0 3C 3C B8 0E' => 'AF-S VR Nikkor 800mm f/5.6E FL ED',
298             'B6 3C B0 B0 3C 3C B8 4E' => 'AF-S VR Nikkor 800mm f/5.6E FL ED', #PH
299             'B7 44 60 98 34 3C B9 0E' => 'AF-S Nikkor 80-400mm f/4.5-5.6G ED VR',
300             'B8 40 2D 44 2C 34 BA 06' => 'AF-S Nikkor 18-35mm f/3.5-4.5G ED',
301             'A0 40 2D 74 2C 3C BB 0E' => 'AF-S DX Nikkor 18-140mm f/3.5-5.6G ED VR', #PH
302             'A1 54 55 55 0C 0C BC 06' => 'AF-S Nikkor 58mm f/1.4G', #IB
303             'A1 48 6E 8E 24 24 DB 4E' => 'AF-S Nikkor 120-300mm f/2.8E FL ED SR VR', #28
304             'A2 40 2D 53 2C 3C BD 0E' => 'AF-S DX Nikkor 18-55mm f/3.5-5.6G VR II',
305             'A4 40 2D 8E 2C 40 BF 0E' => 'AF-S DX Nikkor 18-300mm f/3.5-6.3G ED VR',
306             'A5 4C 44 44 14 14 C0 06' => 'AF-S Nikkor 35mm f/1.8G ED', #35 ("ED" ref 11)
307             'A6 48 98 98 24 24 C1 0E' => 'AF-S Nikkor 400mm f/2.8E FL ED VR',
308             'A7 3C 53 80 30 3C C2 0E' => 'AF-S DX Nikkor 55-200mm f/4-5.6G ED VR II', #IB
309             'A8 48 8E 8E 30 30 C3 4E' => 'AF-S Nikkor 300mm f/4E PF ED VR', #35
310             'A8 48 8E 8E 30 30 C3 0E' => 'AF-S Nikkor 300mm f/4E PF ED VR', #30
311             'A9 4C 31 31 14 14 C4 06' => 'AF-S Nikkor 20mm f/1.8G ED', #30
312             'AA 48 37 5C 24 24 C5 4E' => 'AF-S Nikkor 24-70mm f/2.8E ED VR',
313             'AA 48 37 5C 24 24 C5 0E' => 'AF-S Nikkor 24-70mm f/2.8E ED VR',
314             'AB 3C A0 A0 30 30 C6 4E' => 'AF-S Nikkor 500mm f/4E FL ED VR',
315             'AC 3C A6 A6 30 30 C7 4E' => 'AF-S Nikkor 600mm f/4E FL ED VR', #PH
316             'AD 48 28 60 24 30 C8 4E' => 'AF-S DX Nikkor 16-80mm f/2.8-4E ED VR',
317             'AD 48 28 60 24 30 C8 0E' => 'AF-S DX Nikkor 16-80mm f/2.8-4E ED VR', #PH
318             'AE 3C 80 A0 3C 3C C9 4E' => 'AF-S Nikkor 200-500mm f/5.6E ED VR', #PH
319             'AE 3C 80 A0 3C 3C C9 0E' => 'AF-S Nikkor 200-500mm f/5.6E ED VR',
320             'A0 40 2D 53 2C 3C CA 8E' => 'AF-P DX Nikkor 18-55mm f/3.5-5.6G', #Yang You pvt communication
321             'A0 40 2D 53 2C 3C CA 0E' => 'AF-P DX Nikkor 18-55mm f/3.5-5.6G VR', #PH
322             'AF 4C 37 37 14 14 CC 06' => 'AF-S Nikkor 24mm f/1.8G ED', #IB
323             'A2 38 5C 8E 34 40 CD 86' => 'AF-P DX Nikkor 70-300mm f/4.5-6.3G VR', #PH
324             'A3 38 5C 8E 34 40 CE 8E' => 'AF-P DX Nikkor 70-300mm f/4.5-6.3G ED VR',
325             'A3 38 5C 8E 34 40 CE 0E' => 'AF-P DX Nikkor 70-300mm f/4.5-6.3G ED',
326             'A4 48 5C 80 24 24 CF 4E' => 'AF-S Nikkor 70-200mm f/2.8E FL ED VR',
327             'A4 48 5C 80 24 24 CF 0E' => 'AF-S Nikkor 70-200mm f/2.8E FL ED VR',
328             'A5 54 6A 6A 0C 0C D0 46' => 'AF-S Nikkor 105mm f/1.4E ED', #IB
329             'A5 54 6A 6A 0C 0C D0 06' => 'AF-S Nikkor 105mm f/1.4E ED', #IB
330             'A6 48 2F 2F 30 30 D1 46' => 'PC Nikkor 19mm f/4E ED',
331             'A6 48 2F 2F 30 30 D1 06' => 'PC Nikkor 19mm f/4E ED',
332             'A7 40 11 26 2C 34 D2 46' => 'AF-S Fisheye Nikkor 8-15mm f/3.5-4.5E ED',
333             'A7 40 11 26 2C 34 D2 06' => 'AF-S Fisheye Nikkor 8-15mm f/3.5-4.5E ED',
334             'A8 38 18 30 34 3C D3 8E' => 'AF-P DX Nikkor 10-20mm f/4.5-5.6G VR', #Yang You pvt communication
335             'A8 38 18 30 34 3C D3 0E' => 'AF-P DX Nikkor 10-20mm f/4.5-5.6G VR',
336             'A9 48 7C 98 30 30 D4 4E' => 'AF-S Nikkor 180-400mm f/4E TC1.4 FL ED VR', #IB
337             'A9 48 7C 98 30 30 D4 0E' => 'AF-S Nikkor 180-400mm f/4E TC1.4 FL ED VR',
338             'AA 48 88 A4 3C 3C D5 4E' => 'AF-S Nikkor 180-400mm f/4E TC1.4 FL ED VR + 1.4x TC', #IB
339             'AA 48 88 A4 3C 3C D5 0E' => 'AF-S Nikkor 180-400mm f/4E TC1.4 FL ED VR + 1.4x TC',
340             'AB 44 5C 8E 34 3C D6 CE' => 'AF-P Nikkor 70-300mm f/4.5-5.6E ED VR',
341             'AB 44 5C 8E 34 3C D6 0E' => 'AF-P Nikkor 70-300mm f/4.5-5.6E ED VR',
342             'AB 44 5C 8E 34 3C D6 4E' => 'AF-P Nikkor 70-300mm f/4.5-5.6E ED VR', #IB
343             'AC 54 3C 3C 0C 0C D7 46' => 'AF-S Nikkor 28mm f/1.4E ED',
344             'AC 54 3C 3C 0C 0C D7 06' => 'AF-S Nikkor 28mm f/1.4E ED',
345             'AD 3C A0 A0 3C 3C D8 0E' => 'AF-S Nikkor 500mm f/5.6E PF ED VR',
346             'AD 3C A0 A0 3C 3C D8 4E' => 'AF-S Nikkor 500mm f/5.6E PF ED VR',
347             '01 00 00 00 00 00 02 00' => 'TC-16A',
348             '01 00 00 00 00 00 08 00' => 'TC-16A',
349             '00 00 00 00 00 00 F1 0C' => 'TC-14E [II] or Sigma APO Tele Converter 1.4x EX DG or Kenko Teleplus PRO 300 DG 1.4x',
350             '00 00 00 00 00 00 F2 18' => 'TC-20E [II] or Sigma APO Tele Converter 2x EX DG or Kenko Teleplus PRO 300 DG 2.0x',
351             '00 00 00 00 00 00 E1 12' => 'TC-17E II',
352             'FE 47 00 00 24 24 4B 06' => 'Sigma 4.5mm F2.8 EX DC HSM Circular Fisheye', #JD
353             '26 48 11 11 30 30 1C 02' => 'Sigma 8mm F4 EX Circular Fisheye',
354             '79 40 11 11 2C 2C 1C 06' => 'Sigma 8mm F3.5 EX Circular Fisheye', #JD
355             'DB 40 11 11 2C 2C 1C 06' => 'Sigma 8mm F3.5 EX DG Circular Fisheye', #30
356             'DC 48 19 19 24 24 4B 06' => 'Sigma 10mm F2.8 EX DC HSM Fisheye',
357             'C2 4C 24 24 14 14 4B 06' => 'Sigma 14mm F1.8 DG HSM | A', #IB
358             '48 48 24 24 24 24 4B 02' => 'Sigma 14mm F2.8 EX Aspherical HSM',
359             '02 3F 24 24 2C 2C 02 00' => 'Sigma 14mm F3.5',
360             '26 48 27 27 24 24 1C 02' => 'Sigma 15mm F2.8 EX Diagonal Fisheye',
361             'EA 48 27 27 24 24 1C 02' => 'Sigma 15mm F2.8 EX Diagonal Fisheye', #30
362             '26 58 31 31 14 14 1C 02' => 'Sigma 20mm F1.8 EX DG Aspherical RF',
363             '79 54 31 31 0C 0C 4B 06' => 'Sigma 20mm F1.4 DG HSM | A', #Rolf Probst
364             '26 58 37 37 14 14 1C 02' => 'Sigma 24mm F1.8 EX DG Aspherical Macro',
365             'E1 58 37 37 14 14 1C 02' => 'Sigma 24mm F1.8 EX DG Aspherical Macro',
366             '02 46 37 37 25 25 02 00' => 'Sigma 24mm F2.8 Super Wide II Macro',
367             '7E 54 37 37 0C 0C 4B 06' => 'Sigma 24mm F1.4 DG HSM | A', #30
368             '26 58 3C 3C 14 14 1C 02' => 'Sigma 28mm F1.8 EX DG Aspherical Macro',
369             '48 54 3E 3E 0C 0C 4B 06' => 'Sigma 30mm F1.4 EX DC HSM',
370             'F8 54 3E 3E 0C 0C 4B 06' => 'Sigma 30mm F1.4 EX DC HSM', #JD
371             '91 54 44 44 0C 0C 4B 06' => 'Sigma 35mm F1.4 DG HSM', #30
372             'DE 54 50 50 0C 0C 4B 06' => 'Sigma 50mm F1.4 EX DG HSM',
373             '88 54 50 50 0C 0C 4B 06' => 'Sigma 50mm F1.4 DG HSM | A',
374             '02 48 50 50 24 24 02 00' => 'Sigma Macro 50mm F2.8', #https://exiftool.org/forum/index.php/topic,4027.0.html
375             '32 54 50 50 24 24 35 02' => 'Sigma Macro 50mm F2.8 EX DG',
376             'E3 54 50 50 24 24 35 02' => 'Sigma Macro 50mm F2.8 EX DG', #https://exiftool.org/forum/index.php/topic,3215.0.html
377             '79 48 5C 5C 24 24 1C 06' => 'Sigma Macro 70mm F2.8 EX DG', #JD
378             '9B 54 62 62 0C 0C 4B 06' => 'Sigma 85mm F1.4 EX DG HSM',
379             'C8 54 62 62 0C 0C 4B 46' => 'Sigma 85mm F1.4 DG HSM | A', #JamiBradley
380             'C8 54 62 62 0C 0C 4B 06' => 'Sigma 85mm F1.4 DG HSM | A', #KennethCochran
381             '02 48 65 65 24 24 02 00' => 'Sigma Macro 90mm F2.8',
382             '32 54 6A 6A 24 24 35 02.2' => 'Sigma Macro 105mm F2.8 EX DG', #JD
383             'E5 54 6A 6A 24 24 35 02' => 'Sigma Macro 105mm F2.8 EX DG',
384             '97 48 6A 6A 24 24 4B 0E' => 'Sigma Macro 105mm F2.8 EX DG OS HSM',
385             '48 48 76 76 24 24 4B 06' => 'Sigma APO Macro 150mm F2.8 EX DG HSM',
386             'F5 48 76 76 24 24 4B 06' => 'Sigma APO Macro 150mm F2.8 EX DG HSM', #24
387             '99 48 76 76 24 24 4B 0E' => 'Sigma APO Macro 150mm F2.8 EX DG OS HSM', #(Christian Hesse)
388             '48 4C 7C 7C 2C 2C 4B 02' => 'Sigma APO Macro 180mm F3.5 EX DG HSM',
389             '48 4C 7D 7D 2C 2C 4B 02' => 'Sigma APO Macro 180mm F3.5 EX DG HSM',
390             'F4 4C 7C 7C 2C 2C 4B 02' => 'Sigma APO Macro 180mm F3.5 EX DG HSM', #Bruno
391             '94 48 7C 7C 24 24 4B 0E' => 'Sigma APO Macro 180mm F2.8 EX DG OS HSM', #MichaelTapes (HSM from ref 8)
392             '48 54 8E 8E 24 24 4B 02' => 'Sigma APO 300mm F2.8 EX DG HSM',
393             'FB 54 8E 8E 24 24 4B 02' => 'Sigma APO 300mm F2.8 EX DG HSM', #26
394             '26 48 8E 8E 30 30 1C 02' => 'Sigma APO Tele Macro 300mm F4',
395             '02 2F 98 98 3D 3D 02 00' => 'Sigma APO 400mm F5.6',
396             '26 3C 98 98 3C 3C 1C 02' => 'Sigma APO Tele Macro 400mm F5.6',
397             '02 37 A0 A0 34 34 02 00' => 'Sigma APO 500mm F4.5', #19
398             '48 44 A0 A0 34 34 4B 02' => 'Sigma APO 500mm F4.5 EX HSM',
399             'F1 44 A0 A0 34 34 4B 02' => 'Sigma APO 500mm F4.5 EX DG HSM',
400             '02 34 A0 A0 44 44 02 00' => 'Sigma APO 500mm F7.2',
401             '02 3C B0 B0 3C 3C 02 00' => 'Sigma APO 800mm F5.6',
402             '48 3C B0 B0 3C 3C 4B 02' => 'Sigma APO 800mm F5.6 EX HSM',
403             '9E 38 11 29 34 3C 4B 06' => 'Sigma 8-16mm F4.5-5.6 DC HSM',
404             'A1 41 19 31 2C 2C 4B 06' => 'Sigma 10-20mm F3.5 EX DC HSM',
405             '48 3C 19 31 30 3C 4B 06' => 'Sigma 10-20mm F4-5.6 EX DC HSM',
406             'F9 3C 19 31 30 3C 4B 06' => 'Sigma 10-20mm F4-5.6 EX DC HSM', #JD
407             '48 38 1F 37 34 3C 4B 06' => 'Sigma 12-24mm F4.5-5.6 EX DG Aspherical HSM',
408             'F0 38 1F 37 34 3C 4B 06' => 'Sigma 12-24mm F4.5-5.6 EX DG Aspherical HSM',
409             '96 38 1F 37 34 3C 4B 06' => 'Sigma 12-24mm F4.5-5.6 II DG HSM', #Jurgen Sahlberg
410             'CA 3C 1F 37 30 30 4B 46' => 'Sigma 12-24mm F4 DG HSM | A', #github issue#101
411             'C1 48 24 37 24 24 4B 46' => 'Sigma 14-24mm F2.8 DG HSM | A', #30
412             '26 40 27 3F 2C 34 1C 02' => 'Sigma 15-30mm F3.5-4.5 EX DG Aspherical DF',
413             '48 48 2B 44 24 30 4B 06' => 'Sigma 17-35mm F2.8-4 EX DG Aspherical HSM',
414             '26 54 2B 44 24 30 1C 02' => 'Sigma 17-35mm F2.8-4 EX Aspherical',
415             '9D 48 2B 50 24 24 4B 0E' => 'Sigma 17-50mm F2.8 EX DC OS HSM',
416             '8F 48 2B 50 24 24 4B 0E' => 'Sigma 17-50mm F2.8 EX DC OS HSM', #http://dev.exiv2.org/boards/3/topics/1747
417             '7A 47 2B 5C 24 34 4B 06' => 'Sigma 17-70mm F2.8-4.5 DC Macro Asp. IF HSM',
418             '7A 48 2B 5C 24 34 4B 06' => 'Sigma 17-70mm F2.8-4.5 DC Macro Asp. IF HSM',
419             '7F 48 2B 5C 24 34 1C 06' => 'Sigma 17-70mm F2.8-4.5 DC Macro Asp. IF',
420             '8E 3C 2B 5C 24 30 4B 0E' => 'Sigma 17-70mm F2.8-4 DC Macro OS HSM | C',
421             'A0 48 2A 5C 24 30 4B 0E' => 'Sigma 17-70mm F2.8-4 DC Macro OS HSM', #https://exiftool.org/forum/index.php/topic,5170.0.html
422             '8B 4C 2D 44 14 14 4B 06' => 'Sigma 18-35mm F1.8 DC HSM', #30/NJ
423             '26 40 2D 44 2B 34 1C 02' => 'Sigma 18-35mm F3.5-4.5 Aspherical',
424             '26 48 2D 50 24 24 1C 06' => 'Sigma 18-50mm F2.8 EX DC',
425             '7F 48 2D 50 24 24 1C 06' => 'Sigma 18-50mm F2.8 EX DC Macro', #NJ
426             '7A 48 2D 50 24 24 4B 06' => 'Sigma 18-50mm F2.8 EX DC Macro',
427             'F6 48 2D 50 24 24 4B 06' => 'Sigma 18-50mm F2.8 EX DC Macro',
428             'A4 47 2D 50 24 34 4B 0E' => 'Sigma 18-50mm F2.8-4.5 DC OS HSM',
429             '26 40 2D 50 2C 3C 1C 06' => 'Sigma 18-50mm F3.5-5.6 DC',
430             '7A 40 2D 50 2C 3C 4B 06' => 'Sigma 18-50mm F3.5-5.6 DC HSM',
431             '26 40 2D 70 2B 3C 1C 06' => 'Sigma 18-125mm F3.5-5.6 DC',
432             'CD 3D 2D 70 2E 3C 4B 0E' => 'Sigma 18-125mm F3.8-5.6 DC OS HSM',
433             '26 40 2D 80 2C 40 1C 06' => 'Sigma 18-200mm F3.5-6.3 DC',
434             'FF 40 2D 80 2C 40 4B 06' => 'Sigma 18-200mm F3.5-6.3 DC', #30
435             '7A 40 2D 80 2C 40 4B 0E' => 'Sigma 18-200mm F3.5-6.3 DC OS HSM',
436             'ED 40 2D 80 2C 40 4B 0E' => 'Sigma 18-200mm F3.5-6.3 DC OS HSM', #JD
437             '90 40 2D 80 2C 40 4B 0E' => 'Sigma 18-200mm F3.5-6.3 II DC OS HSM', #JohnHelour
438             '89 30 2D 80 2C 40 4B 0E' => 'Sigma 18-200mm F3.5-6.3 DC Macro OS HS | C', #JoeSchonberg
439             'A5 40 2D 88 2C 40 4B 0E' => 'Sigma 18-250mm F3.5-6.3 DC OS HSM',
440             # LensFStops varies with FocalLength for this lens (ref 2):
441             '92 2C 2D 88 2C 40 4B 0E' => 'Sigma 18-250mm F3.5-6.3 DC Macro OS HSM', #2
442             '87 2C 2D 8E 2C 40 4B 0E' => 'Sigma 18-300mm F3.5-6.3 DC Macro HSM', #30
443             # '92 2C 2D 88 2C 40 4B 0E' (250mm)
444             # '92 2B 2D 88 2C 40 4B 0E' (210mm)
445             # '92 2C 2D 88 2C 40 4B 0E' (185mm)
446             # '92 2D 2D 88 2C 40 4B 0E' (155mm)
447             # '92 2E 2D 88 2C 40 4B 0E' (130mm)
448             # '92 2F 2D 88 2C 40 4B 0E' (105mm)
449             # '92 30 2D 88 2C 40 4B 0E' (90mm)
450             # '92 32 2D 88 2C 40 4B 0E' (75mm)
451             # '92 33 2D 88 2C 40 4B 0E' (62mm)
452             # '92 35 2D 88 2C 40 4B 0E' (52mm)
453             # '92 37 2D 88 2C 40 4B 0E' (44mm)
454             # '92 39 2D 88 2C 40 4B 0E' (38mm)
455             # '92 3A 2D 88 2C 40 4B 0E' (32mm)
456             # '92 3E 2D 88 2C 40 4B 0E' (22mm)
457             # '92 40 2D 88 2C 40 4B 0E' (18mm)
458             '26 48 31 49 24 24 1C 02' => 'Sigma 20-40mm F2.8',
459             '7B 48 37 44 18 18 4B 06' => 'Sigma 24-35mm F2.0 DG HSM | A', #30
460             '02 3A 37 50 31 3D 02 00' => 'Sigma 24-50mm F4-5.6 UC',
461             '26 48 37 56 24 24 1C 02' => 'Sigma 24-60mm F2.8 EX DG',
462             'B6 48 37 56 24 24 1C 02' => 'Sigma 24-60mm F2.8 EX DG',
463             'A6 48 37 5C 24 24 4B 06' => 'Sigma 24-70mm F2.8 IF EX DG HSM', #JD
464             'C9 48 37 5C 24 24 4B 4E' => 'Sigma 24-70mm F2.8 DG OS HSM | A', #30
465             '26 54 37 5C 24 24 1C 02' => 'Sigma 24-70mm F2.8 EX DG Macro',
466             '67 54 37 5C 24 24 1C 02' => 'Sigma 24-70mm F2.8 EX DG Macro',
467             'E9 54 37 5C 24 24 1C 02' => 'Sigma 24-70mm F2.8 EX DG Macro',
468             '26 40 37 5C 2C 3C 1C 02' => 'Sigma 24-70mm F3.5-5.6 Aspherical HF',
469             '8A 3C 37 6A 30 30 4B 0E' => 'Sigma 24-105mm F4 DG OS HSM', #IB
470             '26 54 37 73 24 34 1C 02' => 'Sigma 24-135mm F2.8-4.5',
471             '02 46 3C 5C 25 25 02 00' => 'Sigma 28-70mm F2.8',
472             '26 54 3C 5C 24 24 1C 02' => 'Sigma 28-70mm F2.8 EX',
473             '26 48 3C 5C 24 24 1C 06' => 'Sigma 28-70mm F2.8 EX DG',
474             '79 48 3C 5C 24 24 1C 06' => 'Sigma 28-70mm F2.8 EX DG', #30 ("D" removed)
475             '26 48 3C 5C 24 30 1C 02' => 'Sigma 28-70mm F2.8-4 DG',
476             '02 3F 3C 5C 2D 35 02 00' => 'Sigma 28-70mm F3.5-4.5 UC',
477             '26 40 3C 60 2C 3C 1C 02' => 'Sigma 28-80mm F3.5-5.6 Mini Zoom Macro II Aspherical',
478             '26 40 3C 65 2C 3C 1C 02' => 'Sigma 28-90mm F3.5-5.6 Macro',
479             '26 48 3C 6A 24 30 1C 02' => 'Sigma 28-105mm F2.8-4 Aspherical',
480             '26 3E 3C 6A 2E 3C 1C 02' => 'Sigma 28-105mm F3.8-5.6 UC-III Aspherical IF',
481             '26 40 3C 80 2C 3C 1C 02' => 'Sigma 28-200mm F3.5-5.6 Compact Aspherical Hyperzoom Macro',
482             '26 40 3C 80 2B 3C 1C 02' => 'Sigma 28-200mm F3.5-5.6 Compact Aspherical Hyperzoom Macro',
483             '26 3D 3C 80 2F 3D 1C 02' => 'Sigma 28-300mm F3.8-5.6 Aspherical',
484             '26 41 3C 8E 2C 40 1C 02' => 'Sigma 28-300mm F3.5-6.3 DG Macro',
485             'E6 41 3C 8E 2C 40 1C 02' => 'Sigma 28-300mm F3.5-6.3 DG Macro', #https://exiftool.org/forum/index.php/topic,3301.0.html
486             '26 40 3C 8E 2C 40 1C 02' => 'Sigma 28-300mm F3.5-6.3 Macro',
487             '02 3B 44 61 30 3D 02 00' => 'Sigma 35-80mm F4-5.6',
488             '02 40 44 73 2B 36 02 00' => 'Sigma 35-135mm F3.5-4.5 a',
489             'CC 4C 50 68 14 14 4B 06' => 'Sigma 50-100mm F1.8 DC HSM | A', #30
490             '7A 47 50 76 24 24 4B 06' => 'Sigma 50-150mm F2.8 EX APO DC HSM',
491             'FD 47 50 76 24 24 4B 06' => 'Sigma 50-150mm F2.8 EX APO DC HSM II',
492             '98 48 50 76 24 24 4B 0E' => 'Sigma 50-150mm F2.8 EX APO DC OS HSM', #30
493             '48 3C 50 A0 30 40 4B 02' => 'Sigma 50-500mm F4-6.3 EX APO RF HSM',
494             '9F 37 50 A0 34 40 4B 0E' => 'Sigma 50-500mm F4.5-6.3 DG OS HSM', #16
495             '26 3C 54 80 30 3C 1C 06' => 'Sigma 55-200mm F4-5.6 DC',
496             '7A 3B 53 80 30 3C 4B 06' => 'Sigma 55-200mm F4-5.6 DC HSM',
497             '48 54 5C 80 24 24 4B 02' => 'Sigma 70-200mm F2.8 EX APO IF HSM',
498             '7A 48 5C 80 24 24 4B 06' => 'Sigma 70-200mm F2.8 EX APO DG Macro HSM II',
499             'EE 48 5C 80 24 24 4B 06' => 'Sigma 70-200mm F2.8 EX APO DG Macro HSM II', #JD
500             '9C 48 5C 80 24 24 4B 0E' => 'Sigma 70-200mm F2.8 EX DG OS HSM', #Rolando Ruzic
501             'BB 48 5C 80 24 24 4B 4E' => 'Sigma 70-200mm F2.8 DG OS HSM | S', #forum13207
502             '02 46 5C 82 25 25 02 00' => 'Sigma 70-210mm F2.8 APO', #JD
503             '02 40 5C 82 2C 35 02 00' => 'Sigma APO 70-210mm F3.5-4.5',
504             '26 3C 5C 82 30 3C 1C 02' => 'Sigma 70-210mm F4-5.6 UC-II',
505             '02 3B 5C 82 30 3C 02 00' => 'Sigma Zoom-K 70-210mm F4-5.6', #30
506             '26 3C 5C 8E 30 3C 1C 02' => 'Sigma 70-300mm F4-5.6 DG Macro',
507             '56 3C 5C 8E 30 3C 1C 02' => 'Sigma 70-300mm F4-5.6 APO Macro Super II',
508             'E0 3C 5C 8E 30 3C 4B 06' => 'Sigma 70-300mm F4-5.6 APO DG Macro HSM', #22
509             'A3 3C 5C 8E 30 3C 4B 0E' => 'Sigma 70-300mm F4-5.6 DG OS',
510             '02 37 5E 8E 35 3D 02 00' => 'Sigma 75-300mm F4.5-5.6 APO',
511             '02 3A 5E 8E 32 3D 02 00' => 'Sigma 75-300mm F4.0-5.6',
512             '77 44 61 98 34 3C 7B 0E' => 'Sigma 80-400mm F4.5-5.6 EX OS',
513             '77 44 60 98 34 3C 7B 0E' => 'Sigma 80-400mm F4.5-5.6 APO DG D OS',
514             '48 48 68 8E 30 30 4B 02' => 'Sigma APO 100-300mm F4 EX IF HSM',
515             'F3 48 68 8E 30 30 4B 02' => 'Sigma APO 100-300mm F4 EX IF HSM',
516             '26 45 68 8E 34 42 1C 02' => 'Sigma 100-300mm F4.5-6.7 DL', #30
517             '48 54 6F 8E 24 24 4B 02' => 'Sigma APO 120-300mm F2.8 EX DG HSM',
518             '7A 54 6E 8E 24 24 4B 02' => 'Sigma APO 120-300mm F2.8 EX DG HSM',
519             'FA 54 6E 8E 24 24 4B 02' => 'Sigma APO 120-300mm F2.8 EX DG HSM', #https://exiftool.org/forum/index.php/topic,2787.0.html
520             'CF 38 6E 98 34 3C 4B 0E' => 'Sigma APO 120-400mm F4.5-5.6 DG OS HSM',
521             'C3 34 68 98 38 40 4B 4E' => 'Sigma 100-400mm F5-6.3 DG OS HSM | C', #JR (017)
522             '8D 48 6E 8E 24 24 4B 0E' => 'Sigma 120-300mm F2.8 DG OS HSM Sports',
523             '26 44 73 98 34 3C 1C 02' => 'Sigma 135-400mm F4.5-5.6 APO Aspherical',
524             'CE 34 76 A0 38 40 4B 0E' => 'Sigma 150-500mm F5-6.3 DG OS APO HSM', #JD
525             '81 34 76 A6 38 40 4B 0E' => 'Sigma 150-600mm F5-6.3 DG OS HSM | S', #Jaap Voets
526             '82 34 76 A6 38 40 4B 0E' => 'Sigma 150-600mm F5-6.3 DG OS HSM | C',
527             'C4 4C 73 73 14 14 4B 46' => 'Sigma 135mm F1.8 DG HSM | A', #forum3833
528             '26 40 7B A0 34 40 1C 02' => 'Sigma APO 170-500mm F5-6.3 Aspherical RF',
529             'A7 49 80 A0 24 24 4B 06' => 'Sigma APO 200-500mm F2.8 EX DG',
530             '48 3C 8E B0 3C 3C 4B 02' => 'Sigma APO 300-800mm F5.6 EX DG HSM',
531             'D2 3C 8E B0 3C 3C 4B 02' => 'Sigma APO 300-800mm F5.6 EX DG HSM', #forum10942
532             #
533             '00 47 25 25 24 24 00 02' => 'Tamron SP AF 14mm f/2.8 Aspherical (IF) (69E)',
534             'C8 54 44 44 0D 0D DF 46' => 'Tamron SP 35mm f/1.4 Di USD (F045)', #IB
535             'E8 4C 44 44 14 14 DF 0E' => 'Tamron SP 35mm f/1.8 Di VC USD (F012)', #35
536             'E7 4C 4C 4C 14 14 DF 0E' => 'Tamron SP 45mm f/1.8 Di VC USD (F013)',
537             'F4 54 56 56 18 18 84 06' => 'Tamron SP AF 60mm f/2.0 Di II Macro 1:1 (G005)', #24
538             'E5 4C 62 62 14 14 C9 4E' => 'Tamron SP 85mm f/1.8 Di VC USD (F016)', #30
539             '1E 5D 64 64 20 20 13 00' => 'Tamron SP AF 90mm f/2.5 (52E)',
540             '20 5A 64 64 20 20 14 00' => 'Tamron SP AF 90mm f/2.5 Macro (152E)',
541             '22 53 64 64 24 24 E0 02' => 'Tamron SP AF 90mm f/2.8 Macro 1:1 (72E)',
542             '32 53 64 64 24 24 35 02' => 'Tamron SP AF 90mm f/2.8 [Di] Macro 1:1 (172E/272E)',
543             'F8 55 64 64 24 24 84 06' => 'Tamron SP AF 90mm f/2.8 Di Macro 1:1 (272NII)',
544             'F8 54 64 64 24 24 DF 06' => 'Tamron SP AF 90mm f/2.8 Di Macro 1:1 (272NII)',
545             'FE 54 64 64 24 24 DF 0E' => 'Tamron SP 90mm f/2.8 Di VC USD Macro 1:1 (F004)', #Jurgen Sahlberg
546             'E4 54 64 64 24 24 DF 0E' => 'Tamron SP 90mm f/2.8 Di VC USD Macro 1:1 (F017)', #Rolf Probst
547             '00 4C 7C 7C 2C 2C 00 02' => 'Tamron SP AF 180mm f/3.5 Di Model (B01)',
548             '21 56 8E 8E 24 24 14 00' => 'Tamron SP AF 300mm f/2.8 LD-IF (60E)',
549             '27 54 8E 8E 24 24 1D 02' => 'Tamron SP AF 300mm f/2.8 LD-IF (360E)',
550             'E1 40 19 36 2C 35 DF 4E' => 'Tamron 10-24mm f/3.5-4.5 Di II VC HLD (B023)',
551             'F6 3F 18 37 2C 34 84 06' => 'Tamron SP AF 10-24mm f/3.5-4.5 Di II LD Aspherical (IF) (B001)',
552             'F6 3F 18 37 2C 34 DF 06' => 'Tamron SP AF 10-24mm f/3.5-4.5 Di II LD Aspherical (IF) (B001)', #30
553             '00 36 1C 2D 34 3C 00 06' => 'Tamron SP AF 11-18mm f/4.5-5.6 Di II LD Aspherical (IF) (A13)',
554             'E9 48 27 3E 24 24 DF 0E' => 'Tamron SP 15-30mm f/2.8 Di VC USD (A012)', #IB
555             'CA 48 27 3E 24 24 DF 4E' => 'Tamron SP 15-30mm f/2.8 Di VC USD G2 (A041)', #IB
556             'EA 40 29 8E 2C 40 DF 0E' => 'Tamron 16-300mm f/3.5-6.3 Di II VC PZD (B016)', # (removed AF designation, ref 37)
557             '07 46 2B 44 24 30 03 02' => 'Tamron SP AF 17-35mm f/2.8-4 Di LD Aspherical (IF) (A05)',
558             'CB 3C 2B 44 24 31 DF 46' => 'Tamron 17-35mm f/2.8-4 Di OSD (A037)', #IB
559             '00 53 2B 50 24 24 00 06' => 'Tamron SP AF 17-50mm f/2.8 XR Di II LD Aspherical (IF) (A16)', #PH
560             '7C 54 2B 50 24 24 00 06' => 'Tamron SP AF 17-50mm f/2.8 XR Di II LD Aspherical (IF) (A16)', #PH (https://github.com/Exiv2/exiv2/issues/1155)
561             '00 54 2B 50 24 24 00 06' => 'Tamron SP AF 17-50mm f/2.8 XR Di II LD Aspherical (IF) (A16NII)',
562             'FB 54 2B 50 24 24 84 06' => 'Tamron SP AF 17-50mm f/2.8 XR Di II LD Aspherical (IF) (A16NII)', #https://exiftool.org/forum/index.php/topic,3787.0.html
563             'F3 54 2B 50 24 24 84 0E' => 'Tamron SP AF 17-50mm f/2.8 XR Di II VC LD Aspherical (IF) (B005)',
564             '00 3F 2D 80 2B 40 00 06' => 'Tamron AF 18-200mm f/3.5-6.3 XR Di II LD Aspherical (IF) (A14)',
565             '00 3F 2D 80 2C 40 00 06' => 'Tamron AF 18-200mm f/3.5-6.3 XR Di II LD Aspherical (IF) Macro (A14)',
566             'EC 3E 3C 8E 2C 40 DF 0E' => 'Tamron 28-300mm f/3.5-6.3 Di VC PZD A010', #30
567             '00 40 2D 80 2C 40 00 06' => 'Tamron AF 18-200mm f/3.5-6.3 XR Di II LD Aspherical (IF) Macro (A14NII)', #NJ
568             'FC 40 2D 80 2C 40 DF 06' => 'Tamron AF 18-200mm f/3.5-6.3 XR Di II LD Aspherical (IF) Macro (A14NII)', #PH (NC)
569             'E6 40 2D 80 2C 40 DF 0E' => 'Tamron 18-200mm f/3.5-6.3 Di II VC (B018)', #Tanel (removed AF designation, ref 37)
570             '00 40 2D 88 2C 40 62 06' => 'Tamron AF 18-250mm f/3.5-6.3 Di II LD Aspherical (IF) Macro (A18)',
571             '00 40 2D 88 2C 40 00 06' => 'Tamron AF 18-250mm f/3.5-6.3 Di II LD Aspherical (IF) Macro (A18NII)', #JD
572             'F5 40 2C 8A 2C 40 40 0E' => 'Tamron AF 18-270mm f/3.5-6.3 Di II VC LD Aspherical (IF) Macro (B003)',
573             'F0 3F 2D 8A 2C 40 DF 0E' => 'Tamron AF 18-270mm f/3.5-6.3 Di II VC PZD (B008)',
574             'E0 40 2D 98 2C 41 DF 4E' => 'Tamron 18-400mm f/3.5-6.3 Di II VC HLD (B028)', # (removed AF designation, ref 37)
575             '07 40 2F 44 2C 34 03 02' => 'Tamron AF 19-35mm f/3.5-4.5 (A10)',
576             '07 40 30 45 2D 35 03 02.1' => 'Tamron AF 19-35mm f/3.5-4.5 (A10)',
577             '00 49 30 48 22 2B 00 02' => 'Tamron SP AF 20-40mm f/2.7-3.5 (166D)',
578             '0E 4A 31 48 23 2D 0E 02' => 'Tamron SP AF 20-40mm f/2.7-3.5 (166D)',
579             'FE 48 37 5C 24 24 DF 0E' => 'Tamron SP 24-70mm f/2.8 Di VC USD (A007)', #24
580             'CE 47 37 5C 25 25 DF 4E' => 'Tamron SP 24-70mm f/2.8 Di VC USD G2 (A032)', #forum9110
581             '45 41 37 72 2C 3C 48 02' => 'Tamron SP AF 24-135mm f/3.5-5.6 AD Aspherical (IF) Macro (190D)',
582             '33 54 3C 5E 24 24 62 02' => 'Tamron SP AF 28-75mm f/2.8 XR Di LD Aspherical (IF) Macro (A09)',
583             'FA 54 3C 5E 24 24 84 06' => 'Tamron SP AF 28-75mm f/2.8 XR Di LD Aspherical (IF) Macro (A09NII)', #JD
584             'FA 54 3C 5E 24 24 DF 06' => 'Tamron SP AF 28-75mm f/2.8 XR Di LD Aspherical (IF) Macro (A09NII)',
585             '10 3D 3C 60 2C 3C D2 02' => 'Tamron AF 28-80mm f/3.5-5.6 Aspherical (177D)',
586             '45 3D 3C 60 2C 3C 48 02' => 'Tamron AF 28-80mm f/3.5-5.6 Aspherical (177D)',
587             '00 48 3C 6A 24 24 00 02' => 'Tamron SP AF 28-105mm f/2.8 LD Aspherical IF (176D)',
588             '4D 3E 3C 80 2E 3C 62 02' => 'Tamron AF 28-200mm f/3.8-5.6 XR Aspherical (IF) Macro (A03N)',
589             '0B 3E 3D 7F 2F 3D 0E 00' => 'Tamron AF 28-200mm f/3.8-5.6 (71D)',
590             '0B 3E 3D 7F 2F 3D 0E 02' => 'Tamron AF 28-200mm f/3.8-5.6D (171D)',
591             '12 3D 3C 80 2E 3C DF 02' => 'Tamron AF 28-200mm f/3.8-5.6 AF Aspherical LD (IF) (271D)',
592             '4D 41 3C 8E 2B 40 62 02' => 'Tamron AF 28-300mm f/3.5-6.3 XR Di LD Aspherical (IF) (A061)',
593             '4D 41 3C 8E 2C 40 62 02' => 'Tamron AF 28-300mm f/3.5-6.3 XR LD Aspherical (IF) (185D)',
594             'F9 40 3C 8E 2C 40 40 0E' => 'Tamron AF 28-300mm f/3.5-6.3 XR Di VC LD Aspherical (IF) Macro (A20)',
595             'C9 3C 44 76 25 31 DF 4E' => 'Tamron 35-150mm f/2.8-4 Di VC OSD (A043)', #30
596             '00 47 53 80 30 3C 00 06' => 'Tamron AF 55-200mm f/4-5.6 Di II LD (A15)',
597             'F7 53 5C 80 24 24 84 06' => 'Tamron SP AF 70-200mm f/2.8 Di LD (IF) Macro (A001)',
598             'FE 53 5C 80 24 24 84 06' => 'Tamron SP AF 70-200mm f/2.8 Di LD (IF) Macro (A001)',
599             'F7 53 5C 80 24 24 40 06' => 'Tamron SP AF 70-200mm f/2.8 Di LD (IF) Macro (A001)',
600             # 'FE 54 5C 80 24 24 DF 0E' => 'Tamron SP AF 70-200mm f/2.8 Di VC USD (A009)',
601             'FE 54 5C 80 24 24 DF 0E' => 'Tamron SP 70-200mm f/2.8 Di VC USD (A009)', #NJ
602             'E2 47 5C 80 24 24 DF 4E' => 'Tamron SP 70-200mm f/2.8 Di VC USD G2 (A025)', #forum9549
603             '69 48 5C 8E 30 3C 6F 02' => 'Tamron AF 70-300mm f/4-5.6 LD Macro 1:2 (572D/772D)',
604             '69 47 5C 8E 30 3C 00 02' => 'Tamron AF 70-300mm f/4-5.6 Di LD Macro 1:2 (A17N)',
605             '00 48 5C 8E 30 3C 00 06' => 'Tamron AF 70-300mm f/4-5.6 Di LD Macro 1:2 (A17NII)', #JD
606             'F1 47 5C 8E 30 3C DF 0E' => 'Tamron SP 70-300mm f/4-5.6 Di VC USD (A005)',
607             'CF 47 5C 8E 31 3D DF 0E' => 'Tamron SP 70-300mm f/4-5.6 Di VC USD (A030)', #forum9773
608             'CC 44 68 98 34 41 DF 0E' => 'Tamron 100-400mm f/4.5-6.3 Di VC USD', #30
609             'EB 40 76 A6 38 40 DF 0E' => 'Tamron SP AF 150-600mm f/5-6.3 VC USD (A011)',
610             'E3 40 76 A6 38 40 DF 4E' => 'Tamron SP 150-600mm f/5-6.3 Di VC USD G2', #30
611             'E3 40 76 A6 38 40 DF 0E' => 'Tamron SP 150-600mm f/5-6.3 Di VC USD G2 (A022)', #forum3833
612             '20 3C 80 98 3D 3D 1E 02' => 'Tamron AF 200-400mm f/5.6 LD IF (75D)',
613             '00 3E 80 A0 38 3F 00 02' => 'Tamron SP AF 200-500mm f/5-6.3 Di LD (IF) (A08)',
614             '00 3F 80 A0 38 3F 00 02' => 'Tamron SP AF 200-500mm f/5-6.3 Di (A08)',
615             #
616             '00 40 2B 2B 2C 2C 00 02' => 'Tokina AT-X 17 AF PRO (AF 17mm f/3.5)',
617             '00 47 44 44 24 24 00 06' => 'Tokina AT-X M35 PRO DX (AF 35mm f/2.8 Macro)',
618             '00 54 68 68 24 24 00 02' => 'Tokina AT-X M100 AF PRO D (AF 100mm f/2.8 Macro)',
619             '27 48 8E 8E 30 30 1D 02' => 'Tokina AT-X 304 AF (AF 300mm f/4.0)',
620             '00 54 8E 8E 24 24 00 02' => 'Tokina AT-X 300 AF PRO (AF 300mm f/2.8)',
621             '12 3B 98 98 3D 3D 09 00' => 'Tokina AT-X 400 AF SD (AF 400mm f/5.6)',
622             '00 40 18 2B 2C 34 00 06' => 'Tokina AT-X 107 AF DX Fisheye (AF 10-17mm f/3.5-4.5)',
623             '00 48 1C 29 24 24 00 06' => 'Tokina AT-X 116 PRO DX (AF 11-16mm f/2.8)',
624             '7A 48 1C 29 24 24 7E 06' => 'Tokina AT-X 116 PRO DX II (AF 11-16mm f/2.8)',
625             '80 48 1C 29 24 24 7A 06' => 'Tokina atx-i 11-16mm F2.8 CF', #exiv2 issue 1078
626             '7A 48 1C 30 24 24 7E 06' => 'Tokina AT-X 11-20 F2.8 PRO DX (AF 11-20mm f/2.8)',
627             '8B 48 1C 30 24 24 85 06' => 'Tokina AT-X 11-20 F2.8 PRO DX (AF 11-20mm f/2.8)', #forum12687
628             '00 3C 1F 37 30 30 00 06' => 'Tokina AT-X 124 AF PRO DX (AF 12-24mm f/4)',
629             '7A 3C 1F 37 30 30 7E 06.2' => 'Tokina AT-X 124 AF PRO DX II (AF 12-24mm f/4)',
630             '7A 3C 1F 3C 30 30 7E 06' => 'Tokina AT-X 12-28 PRO DX (AF 12-28mm f/4)',
631             '00 48 29 3C 24 24 00 06' => 'Tokina AT-X 16-28 AF PRO FX (AF 16-28mm f/2.8)',
632             '00 48 29 50 24 24 00 06' => 'Tokina AT-X 165 PRO DX (AF 16-50mm f/2.8)',
633             '00 40 2A 72 2C 3C 00 06' => 'Tokina AT-X 16.5-135 DX (AF 16.5-135mm F3.5-5.6)',
634             '00 3C 2B 44 30 30 00 06' => 'Tokina AT-X 17-35 F4 PRO FX (AF 17-35mm f/4)',
635             '2F 40 30 44 2C 34 29 02.2' => 'Tokina AF 193 (AF 19-35mm f/3.5-4.5)',
636             '2F 48 30 44 24 24 29 02.2' => 'Tokina AT-X 235 AF PRO (AF 20-35mm f/2.8)',
637             '2F 40 30 44 2C 34 29 02.1' => 'Tokina AF 235 II (AF 20-35mm f/3.5-4.5)',
638             '00 48 37 5C 24 24 00 06' => 'Tokina AT-X 24-70 F2.8 PRO FX (AF 24-70mm f/2.8)',
639             '00 40 37 80 2C 3C 00 02' => 'Tokina AT-X 242 AF (AF 24-200mm f/3.5-5.6)',
640             '25 48 3C 5C 24 24 1B 02.1' => 'Tokina AT-X 270 AF PRO II (AF 28-70mm f/2.6-2.8)',
641             '25 48 3C 5C 24 24 1B 02.2' => 'Tokina AT-X 287 AF PRO SV (AF 28-70mm f/2.8)',
642             '07 48 3C 5C 24 24 03 00' => 'Tokina AT-X 287 AF (AF 28-70mm f/2.8)',
643             '07 47 3C 5C 25 35 03 00' => 'Tokina AF 287 SD (AF 28-70mm f/2.8-4.5)',
644             '07 40 3C 5C 2C 35 03 00' => 'Tokina AF 270 II (AF 28-70mm f/3.5-4.5)',
645             '00 48 3C 60 24 24 00 02' => 'Tokina AT-X 280 AF PRO (AF 28-80mm f/2.8)',
646             '25 44 44 8E 34 42 1B 02' => 'Tokina AF 353 (AF 35-300mm f/4.5-6.7)',
647             '00 48 50 72 24 24 00 06' => 'Tokina AT-X 535 PRO DX (AF 50-135mm f/2.8)',
648             '00 3C 5C 80 30 30 00 0E' => 'Tokina AT-X 70-200 F4 FX VCM-S (AF 70-200mm f/4)',
649             '00 48 5C 80 30 30 00 0E' => 'Tokina AT-X 70-200 F4 FX VCM-S (AF 70-200mm f/4)',
650             '12 44 5E 8E 34 3C 09 00' => 'Tokina AF 730 (AF 75-300mm F4.5-5.6)',
651             '14 54 60 80 24 24 0B 00' => 'Tokina AT-X 828 AF (AF 80-200mm f/2.8)',
652             '24 54 60 80 24 24 1A 02' => 'Tokina AT-X 828 AF PRO (AF 80-200mm f/2.8)',
653             '24 44 60 98 34 3C 1A 02' => 'Tokina AT-X 840 AF-II (AF 80-400mm f/4.5-5.6)',
654             '00 44 60 98 34 3C 00 02' => 'Tokina AT-X 840 D (AF 80-400mm f/4.5-5.6)',
655             '14 48 68 8E 30 30 0B 00' => 'Tokina AT-X 340 AF (AF 100-300mm f/4)',
656             '8C 48 29 3C 24 24 86 06' => 'Tokina opera 16-28mm F2.8 FF', #30
657             #
658             '06 3F 68 68 2C 2C 06 00' => 'Cosina AF 100mm F3.5 Macro',
659             '07 36 3D 5F 2C 3C 03 00' => 'Cosina AF Zoom 28-80mm F3.5-5.6 MC Macro',
660             '07 46 3D 6A 25 2F 03 00' => 'Cosina AF Zoom 28-105mm F2.8-3.8 MC',
661             '12 36 5C 81 35 3D 09 00' => 'Cosina AF Zoom 70-210mm F4.5-5.6 MC Macro',
662             '12 39 5C 8E 34 3D 08 02' => 'Cosina AF Zoom 70-300mm F4.5-5.6 MC Macro',
663             '12 3B 68 8D 3D 43 09 02' => 'Cosina AF Zoom 100-300mm F5.6-6.7 MC Macro',
664             #
665             '12 38 69 97 35 42 09 02' => 'Promaster Spectrum 7 100-400mm F4.5-6.7',
666             #
667             '00 40 31 31 2C 2C 00 00' => 'Voigtlander Color Skopar 20mm F3.5 SLII Aspherical',
668             '00 48 3C 3C 24 24 00 00' => 'Voigtlander Color Skopar 28mm F2.8 SL II',
669             '00 54 48 48 18 18 00 00' => 'Voigtlander Ultron 40mm F2 SLII Aspherical',
670             '00 54 55 55 0C 0C 00 00' => 'Voigtlander Nokton 58mm F1.4 SLII',
671             '00 40 64 64 2C 2C 00 00' => 'Voigtlander APO-Lanthar 90mm F3.5 SLII Close Focus',
672             '07 40 30 45 2D 35 03 02.2' => 'Voigtlander Ultragon 19-35mm F3.5-4.5 VMV', #NJ
673             '71 48 64 64 24 24 00 00' => 'Voigtlander APO-Skopar 90mm F2.8 SL IIs', #30
674             'FD 00 50 50 18 18 DF 00' => 'Voigtlander APO-Lanthar 50mm F2 Aspherical', #35
675             #
676             '00 40 2D 2D 2C 2C 00 00' => 'Carl Zeiss Distagon T* 3.5/18 ZF.2',
677             '00 48 27 27 24 24 00 00' => 'Carl Zeiss Distagon T* 2.8/15 ZF.2', #MykytaKozlov
678             '00 48 32 32 24 24 00 00' => 'Carl Zeiss Distagon T* 2.8/21 ZF.2',
679             '00 54 38 38 18 18 00 00' => 'Carl Zeiss Distagon T* 2/25 ZF.2',
680             '00 54 3C 3C 18 18 00 00' => 'Carl Zeiss Distagon T* 2/28 ZF.2',
681             '00 54 44 44 0C 0C 00 00' => 'Carl Zeiss Distagon T* 1.4/35 ZF.2',
682             '00 54 44 44 18 18 00 00' => 'Carl Zeiss Distagon T* 2/35 ZF.2',
683             '00 54 50 50 0C 0C 00 00' => 'Carl Zeiss Planar T* 1.4/50 ZF.2',
684             '00 54 50 50 18 18 00 00' => 'Carl Zeiss Makro-Planar T* 2/50 ZF.2',
685             '00 54 62 62 0C 0C 00 00' => 'Carl Zeiss Planar T* 1.4/85 ZF.2',
686             '00 54 68 68 18 18 00 00' => 'Carl Zeiss Makro-Planar T* 2/100 ZF.2',
687             '00 54 72 72 18 18 00 00' => 'Carl Zeiss Apo Sonnar T* 2/135 ZF.2',
688             '00 54 53 53 0C 0C 00 00' => 'Zeiss Otus 1.4/55', #IB
689             '01 54 62 62 0C 0C 00 00' => 'Zeiss Otus 1.4/85',
690             '03 54 68 68 0C 0C 00 00' => 'Zeiss Otus 1.4/100', #IB
691             '52 54 44 44 18 18 00 00' => 'Zeiss Milvus 35mm f/2',
692             '53 54 50 50 0C 0C 00 00' => 'Zeiss Milvus 50mm f/1.4', #IB
693             '54 54 50 50 18 18 00 00' => 'Zeiss Milvus 50mm f/2 Macro',
694             '55 54 62 62 0C 0C 00 00' => 'Zeiss Milvus 85mm f/1.4', #IB
695             '56 54 68 68 18 18 00 00' => 'Zeiss Milvus 100mm f/2 Macro',
696             #
697             '00 54 56 56 30 30 00 00' => 'Coastal Optical Systems 60mm 1:4 UV-VIS-IR Macro Apo',
698             #
699             'BF 4E 26 26 1E 1E 01 04' => 'Irix 15mm f/2.4 Firefly', #30
700             'BF 3C 1B 1B 30 30 01 04' => 'Irix 11mm f/4 Firefly', #30
701             #
702             '4A 40 11 11 2C 0C 4D 02' => 'Samyang 8mm f/3.5 Fish-Eye CS',
703             '4A 48 24 24 24 0C 4D 02.1' => 'Samyang 10mm f/2.8 ED AS NCS CS',
704             '4A 48 1E 1E 24 0C 4D 02' => 'Samyang 12mm f/2.8 ED AS NCS Fish-Eye', #Jurgen Sahlberg
705             '4A 48 24 24 24 0C 4D 02.2' => 'Samyang AE 14mm f/2.8 ED AS IF UMC', #https://exiftool.org/forum/index.php/topic,3150.0.html
706             '4A 4C 24 24 1E 6C 4D 06' => 'Samyang 14mm f/2.4 Premium',
707             '4A 54 29 29 18 0C 4D 02' => 'Samyang 16mm f/2.0 ED AS UMC CS', #Jon Bloom (by email)
708             '4A 60 36 36 0C 0C 4D 02' => 'Samyang 24mm f/1.4 ED AS UMC',
709             '4A 60 44 44 0C 0C 4D 02' => 'Samyang 35mm f/1.4 AS UMC',
710             '4A 60 62 62 0C 0C 4D 02' => 'Samyang AE 85mm f/1.4 AS IF UMC', #https://exiftool.org/forum/index.php/topic,2888.0.html
711             #
712             '9A 4C 50 50 14 14 9C 06' => 'Yongnuo YN50mm F1.8N',
713             '9F 48 48 48 24 24 A1 06' => 'Yongnuo YN40mm F2.8N', #30
714             '9F 54 68 68 18 18 A2 06' => 'Yongnuo YN100mm F2N', #30
715             #
716             '02 40 44 5C 2C 34 02 00' => 'Exakta AF 35-70mm 1:3.5-4.5 MC',
717             #
718             '07 3E 30 43 2D 35 03 00' => 'Soligor AF Zoom 19-35mm 1:3.5-4.5 MC',
719             '03 43 5C 81 35 35 02 00' => 'Soligor AF C/D Zoom UMCS 70-210mm 1:4.5',
720             '12 4A 5C 81 31 3D 09 00' => 'Soligor AF C/D Auto Zoom+Macro 70-210mm 1:4-5.6 UMCS',
721             '12 36 69 97 35 42 09 00' => 'Soligor AF Zoom 100-400mm 1:4.5-6.7 MC',
722             #
723             '00 00 00 00 00 00 00 01' => 'Manual Lens No CPU',
724             #
725             '00 00 48 48 53 53 00 01' => 'Loreo 40mm F11-22 3D Lens in a Cap 9005', #PH
726             '00 47 10 10 24 24 00 00' => 'Fisheye Nikkor 8mm f/2.8 AiS',
727             '00 47 3C 3C 24 24 00 00' => 'Nikkor 28mm f/2.8 AiS', #35
728             # '00 54 44 44 0C 0C 00 00' => 'Nikkor 35mm f/1.4 AiS', comment out in favour of Zeiss with same ID because this lens is rare (requires CPU upgrade)
729             '00 57 50 50 14 14 00 00' => 'Nikkor 50mm f/1.8 AI', #35
730             '00 48 50 50 18 18 00 00' => 'Nikkor H 50mm f/2',
731             '00 48 68 68 24 24 00 00' => 'Series E 100mm f/2.8',
732             '00 4C 6A 6A 20 20 00 00' => 'Nikkor 105mm f/2.5 AiS',
733             '00 48 80 80 30 30 00 00' => 'Nikkor 200mm f/4 AiS',
734             '00 40 11 11 2C 2C 00 00' => 'Samyang 8mm f/3.5 Fish-Eye',
735             '00 58 64 64 20 20 00 00' => 'Soligor C/D Macro MC 90mm f/2.5',
736             '4A 58 30 30 14 0C 4D 02' => 'Rokinon 20mm f/1.8 ED AS UMC', #30
737             #
738             'A0 56 44 44 14 14 A2 06' => 'Sony FE 35mm F1.8', #IB (Techart adapter)
739             'A0 37 5C 8E 34 3C A2 06' => 'Sony FE 70-300mm F4.5-5.6 G OSS', #IB (Techart adapter)
740             );
741              
742             # text encoding used in LocationInfo (ref PH)
743             %nikonTextEncoding = (
744             0 => 'n/a',
745             1 => 'UTF8',
746             # UTF16 is a guess here: it could also be Unicode or JIS,
747             # but I chose UTF16 due to the similarity with the QuickTime stringEncoding
748             2 => 'UTF16',
749             );
750              
751             # flash firmware decoding (ref JD)
752             my %flashFirmware = (
753             '0 0' => 'n/a',
754             '1 1' => '1.01 (SB-800 or Metz 58 AF-1)',
755             '1 3' => '1.03 (SB-800)',
756             '2 1' => '2.01 (SB-800)',
757             '2 4' => '2.04 (SB-600)',
758             '2 5' => '2.05 (SB-600)',
759             '3 1' => '3.01 (SU-800 Remote Commander)',
760             '4 1' => '4.01 (SB-400)',
761             '4 2' => '4.02 (SB-400)',
762             '4 4' => '4.04 (SB-400)',
763             '5 1' => '5.01 (SB-900)',
764             '5 2' => '5.02 (SB-900)',
765             '6 1' => '6.01 (SB-700)', #https://exiftool.org/forum/index.php/topic,5034.0.html
766             '7 1' => '7.01 (SB-910)', #PH
767             '14 3' => '14.03 (SB-5000)', #28
768             OTHER => sub {
769             my ($val, $inv) = @_;
770             return sprintf('%d.%.2d (Unknown model)', split(' ', $val)) unless $inv;
771             return "$1 $2" if $val =~ /(\d+)\.(\d+)/;
772             return '0 0';
773             },
774             );
775              
776             # flash Guide Number (GN) distance settings (ref 28)
777             my %flashGNDistance = (
778             0 => 0, 19 => '2.8 m',
779             1 => '0.1 m', 20 => '3.2 m',
780             2 => '0.2 m', 21 => '3.6 m',
781             3 => '0.3 m', 22 => '4.0 m',
782             4 => '0.4 m', 23 => '4.5 m',
783             5 => '0.5 m', 24 => '5.0 m',
784             6 => '0.6 m', 25 => '5.6 m',
785             7 => '0.7 m', 26 => '6.3 m',
786             8 => '0.8 m', 27 => '7.1 m',
787             9 => '0.9 m', 28 => '8.0 m',
788             10 => '1.0 m', 29 => '9.0 m',
789             11 => '1.1 m', 30 => '10.0 m',
790             12 => '1.3 m', 31 => '11.0 m',
791             13 => '1.4 m', 32 => '13.0 m',
792             14 => '1.6 m', 33 => '14.0 m',
793             15 => '1.8 m', 34 => '16.0 m',
794             16 => '2.0 m', 35 => '18.0 m',
795             17 => '2.2 m', 36 => '20.0 m',
796             18 => '2.5 m', 255 => 'n/a',
797             );
798              
799             # flash color filter values (ref 28)
800             my %flashColorFilter = (
801             0x00 => 'None',
802             1 => 'FL-GL1 or SZ-2FL Fluorescent', # (green) (SZ model ref PH)
803             2 => 'FL-GL2',
804             9 => 'TN-A1 or SZ-2TN Incandescent', # (orange) (SZ model ref PH)
805             10 => 'TN-A2',
806             65 => 'Red',
807             66 => 'Blue',
808             67 => 'Yellow',
809             68 => 'Amber',
810             );
811              
812             # flash control mode values (ref JD)
813             my %flashControlMode = (
814             0x00 => 'Off',
815             0x01 => 'iTTL-BL',
816             0x02 => 'iTTL',
817             0x03 => 'Auto Aperture',
818             0x04 => 'Automatic', #28
819             0x05 => 'GN (distance priority)', #28 (Guide Number, but called "GN" in manual)
820             0x06 => 'Manual',
821             0x07 => 'Repeating Flash',
822             );
823              
824             my %activeDLightingZ7 = (
825             0 => 'Off',
826             2 => 'Low',
827             3 => 'Normal',
828             4 => 'High',
829             5 => 'Extra High',
830             );
831              
832             my %flashControlModeZ7 = (
833             0 => 'TTL',
834             1 => 'Auto External Flash',
835             2 => 'GN (distance priority)',
836             3 => 'Manual',
837             4 => 'Repeating Flash',
838             );
839              
840             my %flashRemoteControlZ7 = (
841             0 => 'Group',
842             1 => 'Quick Wireless',
843             2 => 'Remote Repeating',
844             );
845              
846             my %flashWirelessOptionZ7 = (
847             0 => 'Off',
848             1 => 'Optical AWL',
849             2 => 'Optical/Radio AWL',
850             3 => 'Radio AWL',
851             );
852              
853             my %focusModeZ7 = (
854             0 => 'Manual',
855             1 => 'AF-S',
856             2 => 'AF-C',
857             4 => 'AF-F', # full frame
858             );
859              
860             my %infoZSeries = (
861             Condition => '$$self{Model} =~ /^NIKON Z (5|50|6|6_2|7|7_2|fc|9)\b/i',
862             Notes => 'Z Series cameras thru December 2021',
863             );
864             my %iSOAutoHiLimitZ7 = (
865             0 => 'ISO 64',
866             1 => 'ISO 80',
867             2 => 'ISO 100',
868             3 => 'ISO 125',
869             4 => 'ISO 160',
870             5 => 'ISO 200',
871             6 => 'ISO 250',
872             7 => 'ISO 320',
873             8 => 'ISO 400',
874             9 => 'ISO 500',
875             10 => 'ISO 640',
876             11 => 'ISO 800',
877             12 => 'ISO 1000',
878             13 => 'ISO 1250',
879             14 => 'ISO 1600',
880             15 => 'ISO 2000',
881             16 => 'ISO 2500',
882             17 => 'ISO 3200',
883             18 => 'ISO 4000',
884             19 => 'ISO 5000',
885             20 => 'ISO 6400',
886             21 => 'ISO 8000',
887             22 => 'ISO 10000',
888             23 => 'ISO 12800',
889             24 => 'ISO 16000',
890             25 => 'ISO 20000',
891             26 => 'ISO 25600',
892             27 => 'ISO Hi 0.3',
893             28 => 'ISO Hi 0.7',
894             29 => 'ISO Hi 1.0',
895             32 => 'ISO Hi 2.0',
896             );
897              
898             my %meteringModeZ7 = (
899             0 => 'Matrix',
900             1 => 'Center',
901             2 => 'Spot',
902             3 => 'Highlight'
903             );
904              
905             my %movieFrameRateZ7 = (
906             0 => '120p',
907             1 => '100p',
908             2 => '60p',
909             3 => '50p',
910             4 => '30p',
911             5 => '25p',
912             6 => '24p',
913             );
914              
915             my %offLowNormalHighZ7 = (
916             0 => 'Off',
917             1 => 'Low',
918             2 => 'Normal',
919             3 => 'High',
920             );
921              
922             my %movieFrameSizeZ9 = (
923             1 => '1920x1080',
924             2 => '3840x2160',
925             3 => '7680x4320',
926             );
927              
928             my %subjectDetectionZ9 = (
929             0 => 'Off',
930             1 => 'Auto',
931             2 => 'People',
932             3 => 'Animals',
933             4 => 'Vehicles',
934             );
935              
936             my %vRModeZ9 = (
937             0 => 'Off',
938             1 => 'Normal',
939             2 => 'Sport',
940             );
941              
942             my %retouchValues = ( #PH
943             0 => 'None',
944             3 => 'B & W',
945             4 => 'Sepia',
946             5 => 'Trim',
947             6 => 'Small Picture',
948             7 => 'D-Lighting',
949             8 => 'Red Eye',
950             9 => 'Cyanotype',
951             10 => 'Sky Light',
952             11 => 'Warm Tone',
953             12 => 'Color Custom',
954             13 => 'Image Overlay',
955             14 => 'Red Intensifier',
956             15 => 'Green Intensifier',
957             16 => 'Blue Intensifier',
958             17 => 'Cross Screen',
959             18 => 'Quick Retouch',
960             19 => 'NEF Processing',
961             23 => 'Distortion Control',
962             25 => 'Fisheye',
963             26 => 'Straighten',
964             29 => 'Perspective Control',
965             30 => 'Color Outline',
966             31 => 'Soft Filter',
967             32 => 'Resize', #31
968             33 => 'Miniature Effect',
969             34 => 'Skin Softening', # (S9200)
970             35 => 'Selected Frame', #31 (frame exported from MOV)
971             37 => 'Color Sketch', #31
972             38 => 'Selective Color', # (S9200)
973             39 => 'Glamour', # (S3500)
974             40 => 'Drawing', # (S9200)
975             44 => 'Pop', # (S3500)
976             45 => 'Toy Camera Effect 1', # (S3500)
977             46 => 'Toy Camera Effect 2', # (S3500)
978             47 => 'Cross Process (red)', # (S3500)
979             48 => 'Cross Process (blue)', # (S3500)
980             49 => 'Cross Process (green)', # (S3500)
981             50 => 'Cross Process (yellow)', # (S3500)
982             51 => 'Super Vivid', # (S3500)
983             52 => 'High-contrast Monochrome', # (S3500)
984             53 => 'High Key', # (S3500)
985             54 => 'Low Key', # (S3500)
986             );
987              
988             # AF point indices for models with 51 focus points, eg. D3 (ref JD/PH)
989             # A1 A2 A3 A4 A5 A6 A7 A8 A9
990             # B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11
991             # C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11
992             # D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11
993             # E1 E2 E3 E4 E5 E6 E7 E8 E9
994             my %afPoints51 = (
995             1 => 'C6', 11 => 'C5', 21 => 'C9', 31 => 'C11',41 => 'A2', 51 => 'D1',
996             2 => 'B6', 12 => 'B5', 22 => 'B9', 32 => 'B11',42 => 'D3',
997             3 => 'A5', 13 => 'A4', 23 => 'A8', 33 => 'D11',43 => 'E2',
998             4 => 'D6', 14 => 'D5', 24 => 'D9', 34 => 'C4', 44 => 'C2',
999             5 => 'E5', 15 => 'E4', 25 => 'E8', 35 => 'B4', 45 => 'B2',
1000             6 => 'C7', 16 => 'C8', 26 => 'C10',36 => 'A3', 46 => 'A1',
1001             7 => 'B7', 17 => 'B8', 27 => 'B10',37 => 'D4', 47 => 'D2',
1002             8 => 'A6', 18 => 'A7', 28 => 'A9', 38 => 'E3', 48 => 'E1',
1003             9 => 'D7', 19 => 'D8', 29 => 'D10',39 => 'C3', 49 => 'C1',
1004             10 => 'E6', 20 => 'E7', 30 => 'E9', 40 => 'B3', 50 => 'B1',
1005             );
1006              
1007             # AF point indices for models with 39 focus points, eg. D7000 (ref 29)
1008             # A1 A2 A3
1009             # B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11
1010             # C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11
1011             # D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11
1012             # E1 E2 E3
1013             my %afPoints39 = (
1014             1 => 'C6', 11 => 'C5', 21 => 'D9', 31 => 'C3',
1015             2 => 'B6', 12 => 'B5', 22 => 'C10',32 => 'B3',
1016             3 => 'A2', 13 => 'A1', 23 => 'B10',33 => 'D3',
1017             4 => 'D6', 14 => 'D5', 24 => 'D10',34 => 'C2',
1018             5 => 'E2', 15 => 'E1', 25 => 'C11',35 => 'B2',
1019             6 => 'C7', 16 => 'C8', 26 => 'B11',36 => 'D2',
1020             7 => 'B7', 17 => 'B8', 27 => 'D11',37 => 'C1',
1021             8 => 'A3', 18 => 'D8', 28 => 'C4', 38 => 'B1',
1022             9 => 'D7', 19 => 'C9', 29 => 'B4', 39 => 'D1',
1023             10 => 'E3', 20 => 'B9', 30 => 'D4',
1024             );
1025              
1026             # AF point indices for models with 105 focus points, eg. D6 (ref 28)
1027             # - 7 rows (A-G) with 15 columns (1-15), center is D8
1028             my %afPoints105 = (
1029             1 => 'D8', 28 => 'G7', 55 => 'F13', 82 => 'E4',
1030             2 => 'C8', 29 => 'D6', 56 => 'G13', 83 => 'F4',
1031             3 => 'B8', 30 => 'C6', 57 => 'D14', 84 => 'G4',
1032             4 => 'A8', 31 => 'B6', 58 => 'C14', 85 => 'D3',
1033             5 => 'E8', 32 => 'A6', 59 => 'B14', 86 => 'C3',
1034             6 => 'F8', 33 => 'E6', 60 => 'A14', 87 => 'B3',
1035             7 => 'G8', 34 => 'F6', 61 => 'E14', 88 => 'A3',
1036             8 => 'D9', 35 => 'G6', 62 => 'F14', 89 => 'E3',
1037             9 => 'C9', 36 => 'D11', 63 => 'G14', 90 => 'F3',
1038             10 => 'B9', 37 => 'C11', 64 => 'D15', 91 => 'G3',
1039             11 => 'A9', 38 => 'B11', 65 => 'C15', 92 => 'D2',
1040             12 => 'E9', 39 => 'A11', 66 => 'B15', 93 => 'C2',
1041             13 => 'F9', 40 => 'E11', 67 => 'A15', 94 => 'B2',
1042             14 => 'G9', 41 => 'F11', 68 => 'E15', 95 => 'A2',
1043             15 => 'D10', 42 => 'G11', 69 => 'F15', 96 => 'E2',
1044             16 => 'C10', 43 => 'D12', 70 => 'G15', 97 => 'F2',
1045             17 => 'B10', 44 => 'C12', 71 => 'D5', 98 => 'G2',
1046             18 => 'A10', 45 => 'B12', 72 => 'C5', 99 => 'D1',
1047             19 => 'E10', 46 => 'A12', 73 => 'B5', 100 => 'C1',
1048             20 => 'F10', 47 => 'E12', 74 => 'A5', 101 => 'B1',
1049             21 => 'G10', 48 => 'F12', 75 => 'E5', 102 => 'A1',
1050             22 => 'D7', 49 => 'G12', 76 => 'F5', 103 => 'E1',
1051             23 => 'C7', 50 => 'D13', 77 => 'G5', 104 => 'F1',
1052             24 => 'B7', 51 => 'C13', 78 => 'D4', 105 => 'G1',
1053             25 => 'A7', 52 => 'B13', 79 => 'C4',
1054             26 => 'E7', 53 => 'A13', 80 => 'B4',
1055             27 => 'F7', 54 => 'E13', 81 => 'A4',
1056             );
1057              
1058             # AF point indices for models with 135 focus points, eg. 1J1 (ref PH)
1059             # - 9 rows (A-I) with 15 columns (1-15), center is E8
1060             # - odd columns, columns 2 and 14, and the remaining corner points are
1061             # not used in 41-point mode
1062             my %afPoints135 = (
1063             1 => 'E8', 28 => 'E10', 55 => 'E13', 82 => 'E6', 109 => 'E3',
1064             2 => 'D8', 29 => 'D10', 56 => 'D13', 83 => 'D6', 110 => 'D3',
1065             3 => 'C8', 30 => 'C10', 57 => 'C13', 84 => 'C6', 111 => 'C3',
1066             4 => 'B8', 31 => 'B10', 58 => 'B13', 85 => 'B6', 112 => 'B3',
1067             5 => 'A8', 32 => 'A10', 59 => 'A13', 86 => 'A6', 113 => 'A3',
1068             6 => 'F8', 33 => 'F10', 60 => 'F13', 87 => 'F6', 114 => 'F3',
1069             7 => 'G8', 34 => 'G10', 61 => 'G13', 88 => 'G6', 115 => 'G3',
1070             8 => 'H8', 35 => 'H10', 62 => 'H13', 89 => 'H6', 116 => 'H3',
1071             9 => 'I8', 36 => 'I10', 63 => 'I13', 90 => 'I6', 117 => 'I3',
1072             10 => 'E9', 37 => 'E11', 64 => 'E14', 91 => 'E5', 118 => 'E2',
1073             11 => 'D9', 38 => 'D11', 65 => 'D14', 92 => 'D5', 119 => 'D2',
1074             12 => 'C9', 39 => 'C11', 66 => 'C14', 93 => 'C5', 120 => 'C2',
1075             13 => 'B9', 40 => 'B11', 67 => 'B14', 94 => 'B5', 121 => 'B2',
1076             14 => 'A9', 41 => 'A11', 68 => 'A14', 95 => 'A5', 122 => 'A2',
1077             15 => 'F9', 42 => 'F11', 69 => 'F14', 96 => 'F5', 123 => 'F2',
1078             16 => 'G9', 43 => 'G11', 70 => 'G14', 97 => 'G5', 124 => 'G2',
1079             17 => 'H9', 44 => 'H11', 71 => 'H14', 98 => 'H5', 125 => 'H2',
1080             18 => 'I9', 45 => 'I11', 72 => 'I14', 99 => 'I5', 126 => 'I2',
1081             19 => 'E7', 46 => 'E12', 73 => 'E15', 100 => 'E4', 127 => 'E1',
1082             20 => 'D7', 47 => 'D12', 74 => 'D15', 101 => 'D4', 128 => 'D1',
1083             21 => 'C7', 48 => 'C12', 75 => 'C15', 102 => 'C4', 129 => 'C1',
1084             22 => 'B7', 49 => 'B12', 76 => 'B15', 103 => 'B4', 130 => 'B1',
1085             23 => 'A7', 50 => 'A12', 77 => 'A15', 104 => 'A4', 131 => 'A1',
1086             24 => 'F7', 51 => 'F12', 78 => 'F15', 105 => 'F4', 132 => 'F1',
1087             25 => 'G7', 52 => 'G12', 79 => 'G15', 106 => 'G4', 133 => 'G1',
1088             26 => 'H7', 53 => 'H12', 80 => 'H15', 107 => 'H4', 134 => 'H1',
1089             27 => 'I7', 54 => 'I12', 81 => 'I15', 108 => 'I4', 135 => 'I1',
1090             );
1091              
1092             # AF point indices for models with 153 focus points, eg. D5,D500 (ref PH)
1093             # - 9 rows (A-I) with 17 columns (1-17), center is E9
1094             # - 55 of these are selectable cross points (odd rows and columns 1,3,4,6,7,9,11,12,14,15,17)
1095             my %afPoints153 = (
1096             1 => 'E9', 32 => 'A8', 63 => 'I13', 94 => 'B17', 125 => 'H4',
1097             2 => 'D9', 33 => 'F8', 64 => 'E14', 95 => 'A17', 126 => 'I4',
1098             3 => 'C9', 34 => 'G8', 65 => 'D14', 96 => 'F17', 127 => 'E3',
1099             4 => 'B9', 35 => 'H8', 66 => 'C14', 97 => 'G17', 128 => 'D3',
1100             5 => 'A9', 36 => 'I8', 67 => 'B14', 98 => 'H17', 129 => 'C3',
1101             6 => 'F9', 37 => 'E7', 68 => 'A14', 99 => 'I17', 130 => 'B3',
1102             7 => 'G9', 38 => 'D7', 69 => 'F14', 100 => 'E6', 131 => 'A3',
1103             8 => 'H9', 39 => 'C7', 70 => 'G14', 101 => 'D6', 132 => 'F3',
1104             9 => 'I9', 40 => 'B7', 71 => 'H14', 102 => 'C6', 133 => 'G3',
1105             10 => 'E10', 41 => 'A7', 72 => 'I14', 103 => 'B6', 134 => 'H3',
1106             11 => 'D10', 42 => 'F7', 73 => 'E15', 104 => 'A6', 135 => 'I3',
1107             12 => 'C10', 43 => 'G7', 74 => 'D15', 105 => 'F6', 136 => 'E2',
1108             13 => 'B10', 44 => 'H7', 75 => 'C15', 106 => 'G6', 137 => 'D2',
1109             14 => 'A10', 45 => 'I7', 76 => 'B15', 107 => 'H6', 138 => 'C2',
1110             15 => 'F10', 46 => 'E12', 77 => 'A15', 108 => 'I6', 139 => 'B2',
1111             16 => 'G10', 47 => 'D12', 78 => 'F15', 109 => 'E5', 140 => 'A2',
1112             17 => 'H10', 48 => 'C12', 79 => 'G15', 110 => 'D5', 141 => 'F2',
1113             18 => 'I10', 49 => 'B12', 80 => 'H15', 111 => 'C5', 142 => 'G2',
1114             19 => 'E11', 50 => 'A12', 81 => 'I15', 112 => 'B5', 143 => 'H2',
1115             20 => 'D11', 51 => 'F12', 82 => 'E16', 113 => 'A5', 144 => 'I2',
1116             21 => 'C11', 52 => 'G12', 83 => 'D16', 114 => 'F5', 145 => 'E1',
1117             22 => 'B11', 53 => 'H12', 84 => 'C16', 115 => 'G5', 146 => 'D1',
1118             23 => 'A11', 54 => 'I12', 85 => 'B16', 116 => 'H5', 147 => 'C1',
1119             24 => 'F11', 55 => 'E13', 86 => 'A16', 117 => 'I5', 148 => 'B1',
1120             25 => 'G11', 56 => 'D13', 87 => 'F16', 118 => 'E4', 149 => 'A1',
1121             26 => 'H11', 57 => 'C13', 88 => 'G16', 119 => 'D4', 150 => 'F1',
1122             27 => 'I11', 58 => 'B13', 89 => 'H16', 120 => 'C4', 151 => 'G1',
1123             28 => 'E8', 59 => 'A13', 90 => 'I16', 121 => 'B4', 152 => 'H1',
1124             29 => 'D8', 60 => 'F13', 91 => 'E17', 122 => 'A4', 153 => 'I1',
1125             30 => 'C8', 61 => 'G13', 92 => 'D17', 123 => 'F4',
1126             31 => 'B8', 62 => 'H13', 93 => 'C17', 124 => 'G4',
1127             );
1128              
1129             # AF point indices for models with 81 focus points, eg. Z6/Z7/Z50 (ref 38)
1130             # - 9 rows (A-I) with 9 columns (1-9), center is E5
1131             #
1132             # 7 6 5 4 3 2 1 0
1133             # 00 : [H5][G5][F5][A5][B5][C5][D5][E5]
1134             # 01 : [G6][F6][A6][B6][C6][D6][E6][I5]
1135             # 02 : [F4][A4][B4][C4][D4][E4][I6][H6]
1136             # 03 : [A7][B7][C7][D7][E7][I4][H4][G4]
1137             # 04 : [B3][C3][D3][E3][I7][H7][G7][F7]
1138             # 05 : [C8][D8][E8][I3][H3][G3][F3][A3]
1139             # 06 : [D2][E2][I8][H8][G8][F8][A8][B8]
1140             # 07 : [E9][I2][H2][G2][F2][A2][B2][C2]
1141             # 08 : [I9][H9][G9][F9][A9][B9][C9][D9]
1142             # 09 : [H1][G1][F1][A1][B1][C1][D1][E1]
1143             # 0a : [ ][ ][ ][ ][ ][ ][ ][I1]
1144             my %afPoints81 = (
1145             1 => 'E5', 18 => 'I6', 35 => 'H7', 52 => 'G8', 69 => 'F9',
1146             2 => 'D5', 19 => 'E4', 36 => 'I7', 53 => 'H8', 70 => 'G9',
1147             3 => 'C5', 20 => 'D4', 37 => 'E3', 54 => 'I8', 71 => 'H9',
1148             4 => 'B5', 21 => 'C4', 38 => 'D3', 55 => 'E2', 72 => 'I9',
1149             5 => 'A5', 22 => 'B4', 39 => 'C3', 56 => 'D2', 73 => 'E1',
1150             6 => 'F5', 23 => 'A4', 40 => 'B3', 57 => 'C2', 74 => 'D1',
1151             7 => 'G5', 24 => 'F4', 41 => 'A3', 58 => 'B2', 75 => 'C1',
1152             8 => 'H5', 25 => 'G4', 42 => 'F3', 59 => 'A2', 76 => 'B1',
1153             9 => 'I5', 26 => 'H4', 43 => 'G3', 60 => 'F2', 77 => 'A1',
1154             10 => 'E6', 27 => 'I4', 44 => 'H3', 61 => 'G2', 78 => 'F1',
1155             11 => 'D6', 28 => 'E7', 45 => 'I3', 62 => 'H2', 79 => 'G1',
1156             12 => 'C6', 29 => 'D7', 46 => 'E8', 63 => 'I2', 80 => 'H1',
1157             13 => 'B6', 30 => 'C7', 47 => 'D8', 64 => 'E9', 81 => 'I1',
1158             14 => 'A6', 31 => 'B7', 48 => 'C8', 65 => 'D9',
1159             15 => 'F6', 32 => 'A7', 49 => 'B8', 66 => 'C9',
1160             16 => 'G6', 33 => 'F7', 50 => 'A8', 67 => 'B9',
1161             17 => 'H6', 34 => 'G7', 51 => 'F8', 68 => 'A9',
1162             );
1163              
1164             my %cropHiSpeed = ( #IB
1165             0 => 'Off',
1166             1 => '1.3x Crop', # (1.3x Crop, Large)
1167             2 => 'DX Crop', # (1.5x)
1168             3 => '5:4 Crop',
1169             4 => '3:2 Crop', # (1.2x, ref 36)
1170             6 => '16:9 Crop',
1171             8 => '2.7x Crop', #36 (D4/D500)
1172             9 => 'DX Movie Crop', # (DX during movie recording, Large)
1173             10 => '1.3x Movie Crop', #36 (D4/D500)
1174             11 => 'FX Uncropped',
1175             12 => 'DX Uncropped',
1176             13 => '2.8x Movie Crop', #28 (D5/D6) 5584/1936
1177             14 => '1.4x Movie Crop', #28 (D5/D6) 5584/3856
1178             15 => '1.5x Movie Crop', #36 (D4/D500) 5600/3872
1179             17 => '1:1 Crop',
1180             OTHER => sub {
1181             my ($val, $inv, $conv) = @_;
1182             return undef if $inv;
1183             my @a = split ' ', $val;
1184             return "Unknown ($val)" unless @a == 7;
1185             $a[0] = $$conv{$a[0]} || "Unknown ($a[0])";
1186             return "$a[0] ($a[1]x$a[2] cropped to $a[3]x$a[4] at pixel $a[5],$a[6])";
1187             },
1188             );
1189              
1190             my %flashGroupOptionsMode = (
1191             0 => 'TTL',
1192             1 => 'Manual',
1193             2 => 'Auto',
1194             3 => 'Off',
1195             );
1196              
1197             my %nefCompression = ( #28 relocated to MakerNotes_0x51 at offset x'0a (Z9)
1198             1 => 'Lossy (type 1)', # (older models)
1199             2 => 'Uncompressed', #JD - D100 (even though TIFF compression is set!)
1200             3 => 'Lossless',
1201             4 => 'Lossy (type 2)',
1202             5 => 'Striped packed 12 bits', #IB
1203             6 => 'Uncompressed (reduced to 12 bit)', #IB
1204             7 => 'Unpacked 12 bits', #IB (padded to 16)
1205             8 => 'Small', #IB
1206             9 => 'Packed 12 bits', #IB (2 pixels in 3 bytes)
1207             10 => 'Packed 14 bits', #28 (4 pixels in 7 bytes, eg. D6 uncompressed 14 bit)
1208             13 => 'High Efficiency', #28
1209             14 => 'High Efficiency*', #28
1210             );
1211              
1212             my %noYes = ( 0 => 'No' , 1 => 'Yes', );
1213             my %offOn = ( 0 => 'Off', 1 => 'On' );
1214             my %onOff = ( 0 => 'On', 1 => 'Off' );
1215              
1216             # common attributes for writable BinaryData directories
1217             my %binaryDataAttrs = (
1218             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
1219             WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
1220             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
1221             WRITABLE => 1,
1222             FIRST_ENTRY => 0,
1223             );
1224              
1225             my %base64bin = ( ValueConv => 'Image::ExifTool::XMP::DecodeBase64($val)' );
1226             my %base64int32u = ( ValueConv => 'my $val=Image::ExifTool::XMP::DecodeBase64($val); unpack("V",$$val)' );
1227             my %base64bytes = ( ValueConv => 'my $val=Image::ExifTool::XMP::DecodeBase64($val); join(".",unpack("C*",$$val))' );
1228             my %base64double = (
1229             ValueConv => q{
1230             my $val=Image::ExifTool::XMP::DecodeBase64($val);
1231             my $saveOrder = GetByteOrder();
1232             SetByteOrder('II');
1233             $val = GetDouble($val,0);
1234             SetByteOrder($saveOrder);
1235             return $val;
1236             },
1237             );
1238             my %base64coord = (
1239             ValueConv => q{
1240             my $val=Image::ExifTool::XMP::DecodeBase64($val);
1241             my $saveOrder = GetByteOrder();
1242             SetByteOrder('II');
1243             $val = GetDouble($val,0) + GetDouble($val,8)/60 + GetDouble($val,16)/3600;
1244             SetByteOrder($saveOrder);
1245             return $val;
1246             },
1247             PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1)',
1248             );
1249             # Nikon maker note tags
1250             %Image::ExifTool::Nikon::Main = (
1251             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikon,
1252             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikon,
1253             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
1254             WRITABLE => 1,
1255             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
1256             PRINT_CONV => \&FormatString,
1257             0x0001 => { #2
1258             # the format differs for different models. for D70, this is a string '0210',
1259             # but for the E775 it is binary: "\x00\x01\x00\x00"
1260             Name => 'MakerNoteVersion',
1261             Writable => 'undef',
1262             Count => 4,
1263             # convert to string if binary
1264             ValueConv => '$_=$val; /^[\x00-\x09]/ and $_=join("",unpack("CCCC",$_)); $_',
1265             ValueConvInv => '$val',
1266             PrintConv => '$_=$val;s/^(\d{2})/$1\./;s/^0//;$_',
1267             PrintConvInv => '$_=$val;s/\.//;"0$_"',
1268             },
1269             0x0002 => {
1270             # this is the ISO actually used by the camera
1271             # (may be different than ISO setting if auto)
1272             Name => 'ISO',
1273             Writable => 'int16u',
1274             Count => 2,
1275             Priority => 0, # the EXIF ISO is more reliable
1276             Groups => { 2 => 'Image' },
1277             # D300 sets this to undef with 4 zero bytes when LO ISO is used - PH
1278             RawConv => '$val eq "\0\0\0\0" ? undef : $val',
1279             # first number is 1 for "Hi ISO" modes (H0.3, H0.7 and H1.0 on D80) - PH
1280             PrintConv => '$_=$val;s/^0 //;s/^1 (\d+)/Hi $1/;$_',
1281             PrintConvInv => '$_=$val;/^\d+/ ? "0 $_" : (s/Hi ?//i ? "1 $_" : $_)',
1282             },
1283             # Note: we attempt to fix the case of these string values (typically written in all caps)
1284             0x0003 => { Name => 'ColorMode', Writable => 'string' },
1285             0x0004 => { Name => 'Quality', Writable => 'string' },
1286             0x0005 => { Name => 'WhiteBalance', Writable => 'string' },
1287             0x0006 => { Name => 'Sharpness', Writable => 'string' },
1288             0x0007 => {
1289             Name => 'FocusMode',
1290             DataMember => 'FocusMode',
1291             Writable => 'string',
1292             RawConv => '$$self{FocusMode} = $val',
1293             },
1294             # FlashSetting (better named FlashSyncMode, ref 28) values:
1295             # "Normal", "Slow", "Rear Slow", "RED-EYE", "RED-EYE SLOW"
1296             0x0008 => { Name => 'FlashSetting', Writable => 'string' },
1297             # FlashType observed values:
1298             # internal: "Built-in,TTL", "Built-in,RPT", "Comdr.", "NEW_TTL"
1299             # external: "Optional,TTL", "Optional,RPT", "Optional,M", "Comdr."
1300             # both: "Built-in,TTL&Comdr."
1301             # no flash: ""
1302             0x0009 => { Name => 'FlashType', Writable => 'string' }, #2 (count varies by model - PH)
1303             # 0x000a - rational values: 5.6 to 9.33 - found in Coolpix models - PH
1304             # (seems constant for a given camera model, but not correlated with scale factor)
1305             0x000b => { #2
1306             Name => 'WhiteBalanceFineTune',
1307             Writable => 'int16s',
1308             Count => -1, # older models write 1 value, newer DSLR's write 2 - PH
1309             },
1310             0x000c => { # (D1X)
1311             Name => 'WB_RBLevels',
1312             Writable => 'rational64u',
1313             Count => 4, # (not sure what the last 2 values are for)
1314             },
1315             0x000d => { #15
1316             Name => 'ProgramShift',
1317             Writable => 'undef',
1318             Count => 4,
1319             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1320             ValueConvInv => q{
1321             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1322             $a<-128 or $a>127 ? undef : pack("c4",$a,1,6,0);
1323             },
1324             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1325             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1326             },
1327             0x000e => {
1328             Name => 'ExposureDifference',
1329             Writable => 'undef',
1330             Count => 4,
1331             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1332             ValueConvInv => q{
1333             my $a = int($val*12 + ($val>0 ? 0.5 : -0.5));
1334             $a<-128 or $a>127 ? undef : pack("c4",$a,1,12,0);
1335             },
1336             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
1337             PrintConvInv => '$val',
1338             },
1339             0x000f => { Name => 'ISOSelection', Writable => 'string' }, #2
1340             0x0010 => {
1341             Name => 'DataDump',
1342             Writable => 0,
1343             Binary => 1,
1344             },
1345             0x0011 => {
1346             Name => 'PreviewIFD',
1347             Groups => { 1 => 'PreviewIFD', 2 => 'Image' },
1348             Flags => 'SubIFD',
1349             SubDirectory => {
1350             TagTable => 'Image::ExifTool::Nikon::PreviewIFD',
1351             Start => '$val',
1352             },
1353             },
1354             0x0012 => { #2 (camera setting: combination of command dial and menus - PH)
1355             Name => 'FlashExposureComp',
1356             Description => 'Flash Exposure Compensation',
1357             Writable => 'undef',
1358             Count => 4,
1359             # (includes the built-in compensation for FlashType "Built-in,TTL&Comdr.")
1360             Notes => q{
1361             may be set even if flash does not fire. Does not include the effect of
1362             flash bracketing.
1363             },
1364             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1365             ValueConvInv => q{
1366             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1367             $a<-128 or $a>127 ? undef : pack("c4",$a,1,6,0);
1368             },
1369             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1370             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1371             },
1372             # D70 - another ISO tag
1373             0x0013 => { #2
1374             Name => 'ISOSetting',
1375             Writable => 'int16u',
1376             Count => 2,
1377             PrintConv => '$_=$val;s/^0 //;$_',
1378             PrintConvInv => '"0 $val"',
1379             },
1380             0x0014 => [
1381             { #4
1382             Name => 'ColorBalanceA',
1383             Condition => '$format eq "undef" and $count == 2560',
1384             SubDirectory => {
1385             TagTable => 'Image::ExifTool::Nikon::ColorBalanceA',
1386             ByteOrder => 'BigEndian',
1387             },
1388             },
1389             { #IB
1390             Name => 'NRWData',
1391             Condition => '$$valPt =~ /^NRW 0100/',
1392             Drop => 1, # 'Drop' because it is large and not found in JPEG images
1393             SubDirectory => {
1394             TagTable => 'Image::ExifTool::Nikon::ColorBalanceB',
1395             },
1396             },
1397             { #IB
1398             Name => 'NRWData',
1399             Condition => '$$valPt =~ /^NRW /',
1400             Drop => 1, # 'Drop' because it is large and not found in JPEG images
1401             SubDirectory => {
1402             TagTable => 'Image::ExifTool::Nikon::ColorBalanceC',
1403             },
1404             },
1405             ],
1406             # 0x0015 - string[8]: "AUTO "
1407             # D70 Image boundary?? top x,y bot-right x,y
1408             0x0016 => { #2
1409             Name => 'ImageBoundary',
1410             Writable => 'int16u',
1411             Count => 4,
1412             },
1413             0x0017 => { #28
1414             Name => 'ExternalFlashExposureComp', #PH (setting from external flash unit)
1415             Writable => 'undef',
1416             Count => 4,
1417             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1418             ValueConvInv => q{
1419             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1420             $a<-128 or $a>127 ? undef : pack("c4",$a,1,6,0);
1421             },
1422             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1423             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1424             },
1425             0x0018 => { #5
1426             Name => 'FlashExposureBracketValue',
1427             Writable => 'undef',
1428             Count => 4,
1429             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1430             ValueConvInv => q{
1431             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1432             $a<-128 or $a>127 ? undef : pack("c4",$a,1,6,0);
1433             },
1434             PrintConv => 'sprintf("%.1f",$val)',
1435             PrintConvInv => '$val',
1436             },
1437             0x0019 => { #5
1438             Name => 'ExposureBracketValue',
1439             Writable => 'rational64s',
1440             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1441             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1442             },
1443             0x001a => { #PH
1444             Name => 'ImageProcessing',
1445             Writable => 'string',
1446             },
1447             0x001b => { #15
1448             Name => 'CropHiSpeed',
1449             Writable => 'int16u',
1450             Count => 7,
1451             PrintConv => \%cropHiSpeed,
1452             },
1453             0x001c => { #28 (D3 "the application of CSb6 to the selected metering mode")
1454             Name => 'ExposureTuning',
1455             Writable => 'undef',
1456             Count => 3,
1457             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1458             ValueConvInv => q{
1459             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1460             $a<-128 or $a>127 ? undef : pack("c3",$a,1,6);
1461             },
1462             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1463             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1464             },
1465             0x001d => { #4
1466             Name => 'SerialNumber',
1467             # Note: this has been known to change even if the serial number on the body
1468             # stays the same if some parts of the camera were replaced by Nikon service
1469             Writable => 'string',
1470             Protected => 1,
1471             Notes => q{
1472             this value is used as a key to decrypt other information -- writing this tag
1473             causes the other information to be re-encrypted with the new key
1474             },
1475             PrintConv => undef, # disable default PRINT_CONV
1476             },
1477             0x001e => { #14
1478             Name => 'ColorSpace',
1479             Writable => 'int16u',
1480             PrintConv => {
1481             1 => 'sRGB',
1482             2 => 'Adobe RGB',
1483             },
1484             },
1485             0x001f => { #PH
1486             Name => 'VRInfo',
1487             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::VRInfo' },
1488             },
1489             0x0020 => { #16
1490             Name => 'ImageAuthentication',
1491             Writable => 'int8u',
1492             PrintConv => \%offOn,
1493             },
1494             0x0021 => { #PH
1495             Name => 'FaceDetect',
1496             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FaceDetect' },
1497             },
1498             0x0022 => { #21
1499             Name => 'ActiveD-Lighting',
1500             Writable => 'int16u',
1501             PrintConv => {
1502             0 => 'Off',
1503             1 => 'Low',
1504             3 => 'Normal',
1505             5 => 'High',
1506             7 => 'Extra High', #10
1507             8 => 'Extra High 1', #PH
1508             9 => 'Extra High 2', #PH
1509             10 => 'Extra High 3', #PH
1510             11 => 'Extra High 4', #PH
1511             0xffff => 'Auto', #10
1512             },
1513             },
1514             0x0023 => [
1515             { #PH (D300, but also found in D3,D3S,D3X,D90,D300S,D700,D3000,D5000)
1516             Name => 'PictureControlData',
1517             Condition => '$$valPt =~ /^01/',
1518             Writable => 'undef',
1519             Permanent => 0,
1520             Flags => [ 'Binary', 'Protected' ],
1521             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl' },
1522             },{ #28
1523             Name => 'PictureControlData',
1524             Condition => '$$valPt =~ /^02/',
1525             Writable => 'undef',
1526             Permanent => 0,
1527             Flags => [ 'Binary', 'Protected' ],
1528             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl2' },
1529             },{
1530             Name => 'PictureControlData',
1531             Condition => '$$valPt =~ /^03/',
1532             Writable => 'undef',
1533             Permanent => 0,
1534             Flags => [ 'Binary', 'Protected' ],
1535             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl3' },
1536             },{
1537             Name => 'PictureControlData',
1538             Writable => 'undef',
1539             Permanent => 0,
1540             Flags => [ 'Binary', 'Protected' ],
1541             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControlUnknown' },
1542             },
1543             ],
1544             0x0024 => { #JD
1545             Name => 'WorldTime',
1546             SubDirectory => {
1547             TagTable => 'Image::ExifTool::Nikon::WorldTime',
1548             # (CaptureNX does flip the byte order of this record)
1549             },
1550             },
1551             0x0025 => { #PH
1552             Name => 'ISOInfo',
1553             SubDirectory => {
1554             TagTable => 'Image::ExifTool::Nikon::ISOInfo',
1555             ByteOrder => 'BigEndian',
1556             },
1557             },
1558             0x002a => { #23 (this tag added with D3 firmware 1.10 -- also written by Nikon utilities)
1559             Name => 'VignetteControl',
1560             Writable => 'int16u',
1561             PrintConv => {
1562             0 => 'Off',
1563             1 => 'Low',
1564             3 => 'Normal',
1565             5 => 'High',
1566             },
1567             },
1568             0x002b => { #PH
1569             Name => 'DistortInfo',
1570             SubDirectory => {
1571             TagTable => 'Image::ExifTool::Nikon::DistortInfo',
1572             },
1573             },
1574             0x002c => { #29 (D7000)
1575             Name => 'UnknownInfo',
1576             SubDirectory => {
1577             TagTable => 'Image::ExifTool::Nikon::UnknownInfo',
1578             ByteOrder => 'BigEndian', #(NC)
1579             },
1580             },
1581             # 0x2d - "512 0 0","512 3 10","512 1 14",...
1582             0x0032 => { #PH
1583             Name => 'UnknownInfo2',
1584             SubDirectory => {
1585             TagTable => 'Image::ExifTool::Nikon::UnknownInfo2',
1586             ByteOrder => 'BigEndian', #(NC)
1587             },
1588             },
1589             0x0034 => { #forum9646
1590             Name => 'ShutterMode',
1591             Writable => 'int16u',
1592             PrintConv => {
1593             0 => 'Mechanical',
1594             16 => 'Electronic',
1595             # 33 => ? seen for 1J2
1596             48 => 'Electronic Front Curtain',
1597             64 => 'Electronic (Movie)', #JanSkoda (Z6II)
1598             80 => 'Auto (Mechanical)', #JanSkoda (Z6II)
1599             81 => 'Auto (Electronic Front Curtain)', #JanSkoda (Z6II)
1600             },
1601             },
1602             0x0035 => [{ #32
1603             Name => 'HDRInfo',
1604             Condition => '$count != 6',
1605             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::HDRInfo' },
1606             },{
1607             Name => 'HDRInfo2',
1608             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::HDRInfo2' },
1609             }],
1610             0x0037 => { #XavierJubier
1611             Name => 'MechanicalShutterCount',
1612             Writable => 'int32u',
1613             },
1614             0x0039 => {
1615             Name => 'LocationInfo',
1616             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LocationInfo' },
1617             },
1618             0x003d => { #IB
1619             Name => 'BlackLevel',
1620             Writable => 'int16u',
1621             Count => 4,
1622             # (may need to divide by 4 for some images, eg. D3300/D5300, 12 bit - ref IB)
1623             },
1624             0x003e => { #28
1625             Name => 'ImageSizeRAW',
1626             PrintConv => {
1627             1 => 'Large',
1628             2 => 'Medium',
1629             3 => 'Small',
1630             },
1631             },
1632             0x003f => { #https://github.com/darktable-org/darktable/issues/12282
1633             Name => 'WhiteBalanceFineTune',
1634             Writable => 'rational64s',
1635             Count => 2,
1636             },
1637             0x0045 => { #IB
1638             Name => 'CropArea',
1639             Notes => 'left, top, width, height',
1640             Writable => 'int16u',
1641             Count => 4,
1642             },
1643             0x004e => { #28
1644             Name => 'NikonSettings',
1645             Writable => 'undef',
1646             Permanent => 0,
1647             Flags => [ 'Binary', 'Protected' ],
1648             SubDirectory => { TagTable => 'Image::ExifTool::NikonSettings::Main' },
1649             },
1650             0x004f => { #IB (D850)
1651             Name => 'ColorTemperatureAuto',
1652             Writable => 'int16u',
1653             },
1654             0x0051 => { #28 (Z9)
1655             Name => 'MakerNotes0x51',
1656             Writable => 'undef',
1657             Hidden => 1,
1658             Permanent => 0,
1659             Flags => [ 'Binary', 'Protected' ],
1660             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::MakerNotes0x51' },
1661             },
1662             #0x0053 #28 possibly a secondary DistortionControl block (in addition to DistortInfo)? Certainly offset 0x04 within block contains tag AutoDistortionControl for Z72 and D6 (1=>On; 2=> Off)
1663             #0x005e #28 possibly DiffractionCompensation block? Certainly offset 0x04 within block contains tag DiffractionCompensation
1664             0x0080 => { Name => 'ImageAdjustment', Writable => 'string' },
1665             0x0081 => { Name => 'ToneComp', Writable => 'string' }, #2
1666             0x0082 => { Name => 'AuxiliaryLens', Writable => 'string' },
1667             0x0083 => {
1668             Name => 'LensType',
1669             Writable => 'int8u',
1670             # credit to Tom Christiansen (ref 7) for figuring this out...
1671             # (note that older models don't seem to set bits 4-7 (0xf0), so the
1672             # LensType may be different with different models, ref Kenneth Cochran)
1673             PrintConv => q[$_ = $val ? Image::ExifTool::DecodeBits($val,
1674             {
1675             0 => 'MF',
1676             1 => 'D',
1677             2 => 'G',
1678             3 => 'VR',
1679             4 => '1', #PH
1680             5 => 'FT-1', #PH/IB
1681             6 => 'E', #PH (electromagnetic aperture mechanism)
1682             7 => 'AF-P', #PH/IB
1683             }) : 'AF';
1684             # remove commas and change "D G" to just "G"
1685             s/,//g; s/\bD G\b/G/;
1686             s/ E\b// and s/^(G )?/E /; # put "E" at the start instead of "G"
1687             s/ 1// and $_ = "1 $_"; # put "1" at start
1688             s/FT-1 // and $_ .= ' FT-1'; # put "FT-1" at end
1689             return $_;
1690             ],
1691             PrintConvInv => q[
1692             my $bits = 0;
1693             $bits |= 0x01 if $val =~ /\bMF\b/i; # bit 0
1694             $bits |= 0x02 if $val =~ /\bD\b/i; # bit 1
1695             $bits |= 0x06 if $val =~ /\bG\b/i; # bits 1 and 2
1696             $bits |= 0x08 if $val =~ /\bVR\b/i; # bit 3
1697             $bits |= 0x10 if $val =~ /\b1\b/; # bit 4
1698             $bits |= 0x20 if $val =~ /\bFT-1/i; # bit 5
1699             $bits |= 0x80 if $val =~ /\bAF-P/i; # bit 7 (not used by all models)
1700             $bits |= 0x46 if $val =~ /\bE\b/i; # bits 1, 2 and 6
1701             return $bits;
1702             ],
1703             },
1704             0x0084 => { #2
1705             Name => "Lens",
1706             Writable => 'rational64u',
1707             Count => 4,
1708             # short focal, long focal, aperture at short focal, aperture at long focal
1709             PrintConv => \&Image::ExifTool::Exif::PrintLensInfo,
1710             PrintConvInv => \&Image::ExifTool::Exif::ConvertLensInfo,
1711             },
1712             0x0085 => {
1713             Name => 'ManualFocusDistance',
1714             Writable => 'rational64u',
1715             },
1716             0x0086 => {
1717             Name => 'DigitalZoom',
1718             Writable => 'rational64u',
1719             },
1720             0x0087 => { #5
1721             Name => 'FlashMode',
1722             Writable => 'int8u',
1723             PrintConv => {
1724             0 => 'Did Not Fire',
1725             1 => 'Fired, Manual', #14
1726             3 => 'Not Ready', #28
1727             7 => 'Fired, External', #14
1728             8 => 'Fired, Commander Mode',
1729             9 => 'Fired, TTL Mode',
1730             18 => 'LED Light', #G.F. (movie LED light)
1731             },
1732             },
1733             0x0088 => [
1734             {
1735             Name => 'AFInfo',
1736             Condition => '$$self{Model} =~ /^NIKON D/i',
1737             SubDirectory => {
1738             TagTable => 'Image::ExifTool::Nikon::AFInfo',
1739             ByteOrder => 'BigEndian',
1740             },
1741             },
1742             {
1743             Name => 'AFInfo',
1744             SubDirectory => {
1745             TagTable => 'Image::ExifTool::Nikon::AFInfo',
1746             ByteOrder => 'LittleEndian',
1747             },
1748             },
1749             ],
1750             0x0089 => { #5
1751             Name => 'ShootingMode',
1752             Writable => 'int16u',
1753             # the meaning of bit 5 seems to change: For the D200 it indicates "Auto ISO" - PH
1754             Notes => 'for the D70, Bit 5 = Unused LE-NR Slowdown',
1755             # credit to Tom Christiansen (ref 7) for figuring this out...
1756             # The (new?) bit 5 seriously complicates our life here: after firmwareB's
1757             # 1.03, bit 5 turns on when you ask for BUT DO NOT USE the long-range
1758             # noise reduction feature, probably because even not using it, it still
1759             # slows down your drive operation to 50% (1.5fps max not 3fps). But no
1760             # longer does !$val alone indicate single-frame operation. - TC, D70
1761             # The following comments are from Warren Hatch:
1762             # Bits 4,6,8 indicate bracketing mode.
1763             # - all 0's => Bracketing Off
1764             # - bit 4 on with bits 6,8 off => Exposure Bracketing On
1765             # - bits 4,6 on => WB bracketing On
1766             # - 4,8 on => ADL Bracketing On
1767             # Bit 2 gives tethered status: Off=>Not Tethered; On=Tethered.
1768             # - that this simply indicates a camera is connected via a cord to a PC
1769             # (doesn't necessarily mean that the shutter was tripped by the computer)
1770             # Bits 0,1,3,7,9 relate to how the shutter is tripped in concert with the
1771             # Release Mode dial [although I cannot cause bit 7 to flip with any of my gear and
1772             # I suspect it is no longer used for the D500]. Regardless, the ReleaseMode tag
1773             # offers a superior decoding of this information for the D4s, D810 and D500.
1774             # Bit 5 indicates whether or not AutoISO is enabled.
1775             PrintConv => q[
1776             $_ = '';
1777             unless ($val & 0x87) {
1778             return 'Single-Frame' unless $val;
1779             $_ = 'Single-Frame, ';
1780             }
1781             return $_ . Image::ExifTool::DecodeBits($val,
1782             {
1783             0 => 'Continuous',
1784             1 => 'Delay',
1785             2 => 'PC Control',
1786             3 => 'Self-timer', #forum6281 (NC)
1787             4 => 'Exposure Bracketing',
1788             5 => $$self{Model}=~/D70\b/ ? 'Unused LE-NR Slowdown' : 'Auto ISO',
1789             6 => 'White-Balance Bracketing',
1790             7 => 'IR Control',
1791             8 => 'D-Lighting Bracketing', #forum6281 (NC)
1792             });
1793             ],
1794             },
1795             # 0x008a - called "AutoBracketRelease" by ref 15 [but this seems wrong]
1796             # values: 0,255 (when writing NEF only), or 1,2 (when writing JPEG or JPEG+NEF)
1797             # --> makes odd, repeating pattern in sequential NEF images (ref 28)
1798             0x008b => { #8
1799             Name => 'LensFStops',
1800             ValueConv => 'my ($a,$b,$c)=unpack("C3",$val); $c ? $a*($b/$c) : 0',
1801             ValueConvInv => 'my $a=int($val*12+0.5);$a<256 ? pack("C4",$a,1,12,0) : undef',
1802             PrintConv => 'sprintf("%.2f", $val)',
1803             PrintConvInv => '$val',
1804             Writable => 'undef',
1805             Count => 4,
1806             },
1807             0x008c => {
1808             Name => 'ContrastCurve', #JD
1809             Writable => 'undef',
1810             Flags => [ 'Binary', 'Protected', 'Drop' ], # (drop because not found in Nikon JPEG's)
1811             },
1812             # ColorHue: MODE1/MODE1a=sRGB, MODE2=Adobe RGB, MODE3a=more saturated sRGB
1813             # --> should really be called ColorSpace or ColorMode, but that would conflict with other tags
1814             0x008d => { Name => 'ColorHue' , Writable => 'string' }, #2
1815             # SceneMode takes on the following values: PORTRAIT, PARTY/INDOOR, NIGHT PORTRAIT,
1816             # BEACH/SNOW, LANDSCAPE, SUNSET, NIGHT SCENE, MUSEUM, FIREWORKS, CLOSE UP, COPY,
1817             # BACK LIGHT, PANORAMA ASSIST, SPORT, DAWN/DUSK
1818             0x008f => { Name => 'SceneMode', Writable => 'string' }, #2
1819             # LightSource shows 3 values COLORED SPEEDLIGHT NATURAL.
1820             # (SPEEDLIGHT when flash goes. Have no idea about difference between other two.)
1821             0x0090 => { Name => 'LightSource', Writable => 'string' }, #2
1822             0x0091 => [ #18
1823             { #PH
1824             Condition => '$$valPt =~ /^0209/',
1825             Name => 'ShotInfoD40',
1826             SubDirectory => {
1827             TagTable => 'Image::ExifTool::Nikon::ShotInfoD40',
1828             DecryptStart => 4,
1829             DecryptLen => 748,
1830             ByteOrder => 'BigEndian',
1831             },
1832             },
1833             {
1834             Condition => '$$valPt =~ /^0208/',
1835             Name => 'ShotInfoD80',
1836             SubDirectory => {
1837             TagTable => 'Image::ExifTool::Nikon::ShotInfoD80',
1838             DecryptStart => 4,
1839             DecryptLen => 765,
1840             # (Capture NX can change the makernote byte order, but this stays big-endian)
1841             ByteOrder => 'BigEndian',
1842             },
1843             },
1844             { #PH (D90, firmware 1.00)
1845             Condition => '$$valPt =~ /^0213/',
1846             Name => 'ShotInfoD90',
1847             SubDirectory => {
1848             TagTable => 'Image::ExifTool::Nikon::ShotInfoD90',
1849             DecryptStart => 4,
1850             DecryptLen => 0x398,
1851             ByteOrder => 'BigEndian',
1852             },
1853             },
1854             { #PH (D3, firmware 0.37 and 1.00)
1855             Condition => '$$valPt =~ /^0210/ and $count == 5399',
1856             Name => 'ShotInfoD3a',
1857             SubDirectory => {
1858             TagTable => 'Image::ExifTool::Nikon::ShotInfoD3a',
1859             DecryptStart => 4,
1860             DecryptLen => 0x318,
1861             ByteOrder => 'BigEndian',
1862             },
1863             },
1864             { #PH (D3, firmware 1.10, 2.00 and 2.01 [count 5408], and 2.02 [count 5412])
1865             Condition => '$$valPt =~ /^0210/ and ($count == 5408 or $count == 5412)',
1866             Name => 'ShotInfoD3b',
1867             SubDirectory => {
1868             TagTable => 'Image::ExifTool::Nikon::ShotInfoD3b',
1869             DecryptStart => 4,
1870             DecryptLen => 0x321,
1871             ByteOrder => 'BigEndian',
1872             },
1873             },
1874             { #PH (D3X, firmware 1.00)
1875             Condition => '$$valPt =~ /^0214/ and $count == 5409',
1876             Name => 'ShotInfoD3X',
1877             SubDirectory => {
1878             TagTable => 'Image::ExifTool::Nikon::ShotInfoD3X',
1879             DecryptStart => 4,
1880             DecryptLen => 0x323,
1881             ByteOrder => 'BigEndian',
1882             },
1883             },
1884             { #PH (D3S, firmware 0.16 and 1.00)
1885             Condition => '$$valPt =~ /^0218/ and ($count == 5356 or $count == 5388)',
1886             Name => 'ShotInfoD3S',
1887             SubDirectory => {
1888             TagTable => 'Image::ExifTool::Nikon::ShotInfoD3S',
1889             DecryptStart => 4,
1890             DecryptLen => 0x2e9,
1891             ByteOrder => 'BigEndian',
1892             },
1893             },
1894             { #JD (D300, firmware 0.25 and 1.00)
1895             # D3 and D300 use the same version number, but the length is different
1896             Condition => '$$valPt =~ /^0210/ and $count == 5291',
1897             Name => 'ShotInfoD300a',
1898             SubDirectory => {
1899             TagTable => 'Image::ExifTool::Nikon::ShotInfoD300a',
1900             DecryptStart => 4,
1901             DecryptLen => 813,
1902             ByteOrder => 'BigEndian',
1903             },
1904             },
1905             { #PH (D300, firmware version 1.10)
1906             # yet again the same ShotInfoVersion for different data
1907             Condition => '$$valPt =~ /^0210/ and $count == 5303',
1908             Name => 'ShotInfoD300b',
1909             SubDirectory => {
1910             TagTable => 'Image::ExifTool::Nikon::ShotInfoD300b',
1911             DecryptStart => 4,
1912             DecryptLen => 825,
1913             ByteOrder => 'BigEndian',
1914             },
1915             },
1916             { #PH (D300S, firmware version 1.00)
1917             # yet again the same ShotInfoVersion for different data
1918             Condition => '$$valPt =~ /^0216/ and $count == 5311',
1919             Name => 'ShotInfoD300S',
1920             SubDirectory => {
1921             TagTable => 'Image::ExifTool::Nikon::ShotInfoD300S',
1922             DecryptStart => 4,
1923             DecryptLen => 827,
1924             ByteOrder => 'BigEndian',
1925             },
1926             },
1927             # 0225 - D600
1928             { #29 (D700 firmware version 1.02f)
1929             Condition => '$$valPt =~ /^0212/ and $count == 5312',
1930             Name => 'ShotInfoD700',
1931             SubDirectory => {
1932             TagTable => 'Image::ExifTool::Nikon::ShotInfoD700',
1933             DecryptStart => 4,
1934             DecryptLen => 0x358,
1935             ByteOrder => 'BigEndian',
1936             },
1937             },
1938             { #PH (D800 firmware 1.01a)
1939             Condition => '$$valPt =~ /^0222/',
1940             Name => 'ShotInfoD800',
1941             SubDirectory => {
1942             TagTable => 'Image::ExifTool::Nikon::ShotInfoD800',
1943             DecryptStart => 4,
1944             DecryptLen => 0x720,
1945             ByteOrder => 'BigEndian',
1946             },
1947             },
1948             { #28 (D810 firmware 1.01)
1949             Condition => '$$valPt =~ /^0233/',
1950             Name => 'ShotInfoD810',
1951             SubDirectory => {
1952             TagTable => 'Image::ExifTool::Nikon::ShotInfoD810',
1953             DecryptStart => 4,
1954             DecryptLen => 0x36f4 + 12,
1955             DecryptMore => 'Get32u(\$data, 0x84) + 12',
1956             ByteOrder => 'LittleEndian',
1957             },
1958             },
1959             { #28 (D850 firmware 1.00b)
1960             Condition => '$$valPt =~ /^0243/',
1961             Name => 'ShotInfoD850',
1962             SubDirectory => {
1963             TagTable => 'Image::ExifTool::Nikon::ShotInfoD850',
1964             DecryptStart => 4,
1965             DecryptLen => 0x2efb + 12,
1966             DecryptMore => 'Get32u(\$data, 0xa0) + 12',
1967             ByteOrder => 'LittleEndian',
1968             },
1969             },
1970             # 0217 - D3000
1971             # 0219 - D3100
1972             # 0224 - D3200
1973             { #PH
1974             Condition => '$$valPt =~ /^0215/ and $count == 6745',
1975             Name => 'ShotInfoD5000',
1976             SubDirectory => {
1977             TagTable => 'Image::ExifTool::Nikon::ShotInfoD5000',
1978             DecryptStart => 4,
1979             DecryptLen => 0x39a,
1980             ByteOrder => 'BigEndian',
1981             },
1982             },
1983             { #PH
1984             Condition => '$$valPt =~ /^0221/ and $count == 8902',
1985             Name => 'ShotInfoD5100',
1986             SubDirectory => {
1987             TagTable => 'Image::ExifTool::Nikon::ShotInfoD5100',
1988             DecryptStart => 4,
1989             DecryptLen => 0x430,
1990             ByteOrder => 'BigEndian',
1991             },
1992             },
1993             { #PH
1994             Condition => '$$valPt =~ /^0226/ and $count == 11587',
1995             Name => 'ShotInfoD5200',
1996             SubDirectory => {
1997             TagTable => 'Image::ExifTool::Nikon::ShotInfoD5200',
1998             DecryptStart => 4,
1999             DecryptLen => 0xd00,
2000             ByteOrder => 'BigEndian',
2001             },
2002             },
2003             { #29 (D7000 firmware version 1.01b)
2004             Condition => '$$valPt =~ /^0220/',
2005             Name => 'ShotInfoD7000',
2006             SubDirectory => {
2007             TagTable => 'Image::ExifTool::Nikon::ShotInfoD7000',
2008             DecryptStart => 4,
2009             DecryptLen => 0x448,
2010             ByteOrder => 'BigEndian',
2011             },
2012             },
2013             { # (D4 firmware version 1.00g)
2014             Condition => '$$valPt =~ /^0223/',
2015             Name => 'ShotInfoD4',
2016             SubDirectory => {
2017             TagTable => 'Image::ExifTool::Nikon::ShotInfoD4',
2018             DecryptStart => 4,
2019             DecryptLen => 0x789,
2020             ByteOrder => 'BigEndian',
2021             },
2022             },
2023             { # (D4S firmware version 1.00d and 1.01a)
2024             Condition => '$$valPt =~ /^0231/',
2025             Name => 'ShotInfoD4S',
2026             SubDirectory => {
2027             TagTable => 'Image::ExifTool::Nikon::ShotInfoD4S',
2028             DecryptStart => 4,
2029             DecryptLen => 0x3697,
2030             ByteOrder => 'LittleEndian',
2031             },
2032             },
2033             { #28 (D5 firmware version 1.10a)
2034             Condition => '$$valPt =~ /^0238/',
2035             Name => 'ShotInfoD5',
2036             SubDirectory => {
2037             TagTable => 'Image::ExifTool::Nikon::ShotInfoD500',
2038             DecryptStart => 4,
2039             DecryptLen => 0x2c24 + 12,
2040             DecryptMore => 'Get32u(\$data, 0xa8) + 0x2ea5 - 0x2c90',
2041             ByteOrder => 'LittleEndian',
2042             },
2043             },
2044             { # (D500 firmware version 1.00)
2045             Condition => '$$valPt =~ /^0239/',
2046             Name => 'ShotInfoD500',
2047             SubDirectory => {
2048             TagTable => 'Image::ExifTool::Nikon::ShotInfoD500',
2049             DecryptStart => 4,
2050             DecryptLen => 0x2cb2 + 4,
2051             DecryptMore => 'Get32u(\$data, 0xa8) + 0x2ea5 - 0x2c90',
2052             ByteOrder => 'LittleEndian',
2053             },
2054             },
2055             { # (D6 firmware version 1.00, ref 28)
2056             Condition => '$$valPt =~ /^0246/',
2057             Name => 'ShotInfoD6',
2058             SubDirectory => {
2059             TagTable => 'Image::ExifTool::Nikon::ShotInfoD6',
2060             DecryptStart => 4,
2061             DecryptLen => 0xc292 + 720, # thru decoded parts of Offset 32
2062             ByteOrder => 'LittleEndian',
2063             },
2064             },
2065             { # (D610 firmware version 1.00)
2066             Condition => '$$valPt =~ /^0232/',
2067             Name => 'ShotInfoD610',
2068             SubDirectory => {
2069             TagTable => 'Image::ExifTool::Nikon::ShotInfoD610',
2070             DecryptStart => 4,
2071             DecryptLen => 0x7ff,
2072             ByteOrder => 'BigEndian',
2073             },
2074             },
2075             { # (Z6_2 firmware version 1.00 and Z7II firmware versions 1.00 & 1.01, ref 28)
2076             # 0800=Z6/Z7 0801=Z50 0802=Z5 0803=Z6II/Z7II 0804=Zfc
2077             Condition => '$$valPt =~ /^080[01234]/',
2078             Name => 'ShotInfoZ7II',
2079             SubDirectory => {
2080             TagTable => 'Image::ExifTool::Nikon::ShotInfoZ7II',
2081             DecryptStart => 4,
2082             # TODO: eventually set the length dynamically according to actual offsets!
2083             DecryptLen => 0xd04e + 860, # thru decoded MenuSettingsZ7II
2084             ByteOrder => 'LittleEndian',
2085             },
2086             },
2087             { # (Z9 firmware version 1.00 ref 28)
2088             Condition => '$$valPt =~ /^0805/',
2089             Name => 'ShotInfoZ9',
2090             SubDirectory => {
2091             TagTable => 'Image::ExifTool::Nikon::ShotInfoZ9',
2092             DecryptStart => 4,
2093             # TODO: eventually set the length dynamically according to actual offsets!
2094             DecryptLen => 0xec4b + 2105, # decoded thru end of Offset26
2095             ByteOrder => 'LittleEndian',
2096             },
2097             },
2098             { # D7100=0227
2099             Condition => '$$valPt =~ /^0[28]/',
2100             Name => 'ShotInfo02xx',
2101             SubDirectory => {
2102             TagTable => 'Image::ExifTool::Nikon::ShotInfo',
2103             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2104             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2105             DecryptStart => 4,
2106             DecryptLen => 0x251,
2107             ByteOrder => 'BigEndian',
2108             },
2109             },
2110             {
2111             Name => 'ShotInfoUnknown',
2112             Writable => 0,
2113             SubDirectory => {
2114             TagTable => 'Image::ExifTool::Nikon::ShotInfo',
2115             ByteOrder => 'BigEndian',
2116             },
2117             },
2118             ],
2119             0x0092 => { #2
2120             Name => 'HueAdjustment',
2121             Writable => 'int16s',
2122             },
2123             # 0x0093 - ref 15 calls this Saturation, but this is wrong - PH
2124             0x0093 => { #21
2125             Name => 'NEFCompression',
2126             Writable => 'int16u',
2127             SeparateTable => 'NEFCompression',
2128             PrintConv => \%nefCompression,
2129             },
2130             0x0094 => { Name => 'SaturationAdj', Writable => 'int16s' },
2131             0x0095 => { Name => 'NoiseReduction', Writable => 'string' }, # ("Off" or "FPNR"=long exposure NR)
2132             0x0096 => {
2133             Name => 'NEFLinearizationTable', # same table as DNG LinearizationTable (ref JD)
2134             Writable => 'undef',
2135             Flags => [ 'Binary', 'Protected' ],
2136             },
2137             0x0097 => [ #4
2138             # (NOTE: these are byte-swapped by NX when byte order changes)
2139             {
2140             Condition => '$$valPt =~ /^0100/', # (D100 and Coolpix models)
2141             Name => 'ColorBalance0100',
2142             SubDirectory => {
2143             Start => '$valuePtr + 72',
2144             TagTable => 'Image::ExifTool::Nikon::ColorBalance1',
2145             },
2146             },
2147             {
2148             Condition => '$$valPt =~ /^0102/', # (D2H)
2149             Name => 'ColorBalance0102',
2150             SubDirectory => {
2151             Start => '$valuePtr + 10',
2152             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2153             },
2154             },
2155             {
2156             Condition => '$$valPt =~ /^0103/', # (D70/D70s)
2157             Name => 'ColorBalance0103',
2158             # D70: at file offset 'tag-value + base + 20', 4 16 bits numbers,
2159             # v[0]/v[1] , v[2]/v[3] are the red/blue multipliers.
2160             SubDirectory => {
2161             Start => '$valuePtr + 20',
2162             TagTable => 'Image::ExifTool::Nikon::ColorBalance3',
2163             },
2164             },
2165             {
2166             Condition => '$$valPt =~ /^0205/', # (D50)
2167             Name => 'ColorBalance0205',
2168             SubDirectory => {
2169             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2170             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2171             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2172             DecryptStart => 4,
2173             DecryptLen => 22, # 284 bytes encrypted, but don't need to decrypt it all
2174             DirOffset => 14,
2175             },
2176             },
2177             { # (D3/D3X/D300/D700=0209,D300S=0212,D3S=0214)
2178             Condition => '$$valPt =~ /^02(09|12|14)/',
2179             Name => 'ColorBalance0209',
2180             SubDirectory => {
2181             TagTable => 'Image::ExifTool::Nikon::ColorBalance4',
2182             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2183             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2184             DecryptStart => 284,
2185             DecryptLen => 18, # 324 bytes encrypted, but don't need to decrypt it all
2186             DirOffset => 10,
2187             },
2188             },
2189             { # (D2X/D2Xs=0204,D2Hs=0206,D200=0207,D40/D40X/D80=0208,D60=0210)
2190             Condition => '$$valPt =~ /^02(\d{2})/ and $1 < 11',
2191             Name => 'ColorBalance02',
2192             SubDirectory => {
2193             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2194             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2195             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2196             DecryptStart => 284,
2197             DecryptLen => 14, # don't need to decrypt it all
2198             DirOffset => 6,
2199             },
2200             },
2201             {
2202             Condition => '$$valPt =~ /^0211/', # (D90/D5000)
2203             Name => 'ColorBalance0211',
2204             SubDirectory => {
2205             TagTable => 'Image::ExifTool::Nikon::ColorBalance4',
2206             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2207             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2208             DecryptStart => 284,
2209             DecryptLen => 24, # don't need to decrypt it all
2210             DirOffset => 16,
2211             },
2212             },
2213             {
2214             Condition => '$$valPt =~ /^0213/', # (D3000)
2215             Name => 'ColorBalance0213',
2216             SubDirectory => {
2217             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2218             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2219             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2220             DecryptStart => 284,
2221             DecryptLen => 18, # don't need to decrypt it all
2222             DirOffset => 10,
2223             },
2224             },
2225             { # (D3100=0215,D7000/D5100=0216,D4/D600/D800/D800E/D3200=0217)
2226             Condition => '$$valPt =~ /^021[567]/',
2227             Name => 'ColorBalance0215',
2228             SubDirectory => {
2229             TagTable => 'Image::ExifTool::Nikon::ColorBalance4',
2230             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2231             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2232             DecryptStart => 284,
2233             DecryptLen => 12, # don't need to decrypt it all
2234             DirOffset => 4,
2235             },
2236             },
2237             { # (D5200/D7100=0218, D5300=0219, D610/Df=0220, D3300=0221, CoolpixA=0601)
2238             Name => 'ColorBalanceUnknown02',
2239             Condition => '$$valPt =~ /^0[26]/',
2240             SubDirectory => {
2241             TagTable => 'Image::ExifTool::Nikon::ColorBalanceUnknown',
2242             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2243             DecryptStart => 284,
2244             DecryptLen => 10, # (arbitrary)
2245             },
2246             },
2247             { # (1J1/1J2/1V1=0400, 1V2=0401, 1J3/1S1=0402, 1AW1=0403, Z6/Z7=0800)
2248             Name => 'ColorBalanceUnknown04',
2249             Condition => '$$valPt =~ /^0[48]/',
2250             SubDirectory => {
2251             TagTable => 'Image::ExifTool::Nikon::ColorBalanceUnknown',
2252             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2253             DecryptStart => 4,
2254             DecryptLen => 10, # (arbitrary)
2255             },
2256             },
2257             {
2258             # (CoolpixP7700/P7800=0500, CoolpixP330/P520=0502)
2259             Name => 'ColorBalanceUnknown',
2260             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::ColorBalanceUnknown' },
2261             },
2262             ],
2263             0x0098 => [
2264             { #8
2265             Condition => '$$valPt =~ /^0100/', # D100, D1X - PH
2266             Name => 'LensData0100',
2267             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LensData00' },
2268             },
2269             { #8
2270             Condition => '$$valPt =~ /^0101/', # D70, D70s - PH
2271             Name => 'LensData0101',
2272             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LensData01' },
2273             },
2274             # note: this information is encrypted if the version is 02xx
2275             { #8
2276             # 0201 - D200, D2Hs, D2X and D2Xs
2277             # 0202 - D40, D40X and D80
2278             # 0203 - D300
2279             Condition => '$$valPt =~ /^020[1-3]/',
2280             Name => 'LensData0201',
2281             SubDirectory => {
2282             TagTable => 'Image::ExifTool::Nikon::LensData01',
2283             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2284             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2285             DecryptStart => 4,
2286             },
2287             },
2288             { #PH
2289             Condition => '$$valPt =~ /^0204/', # D90, D7000
2290             Name => 'LensData0204',
2291             SubDirectory => {
2292             TagTable => 'Image::ExifTool::Nikon::LensData0204',
2293             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2294             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2295             DecryptStart => 4,
2296             },
2297             },
2298             {
2299             Condition => '$$valPt =~ /^040[01]/', # 0=1J1/1V1, 1=1J2
2300             Name => 'LensData0400',
2301             SubDirectory => {
2302             TagTable => 'Image::ExifTool::Nikon::LensData0400',
2303             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2304             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2305             DecryptStart => 4,
2306             },
2307             },
2308             {
2309             Condition => '$$valPt =~ /^0402/', # 1J3/1S1/1V2
2310             Name => 'LensData0402',
2311             SubDirectory => {
2312             TagTable => 'Image::ExifTool::Nikon::LensData0402',
2313             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2314             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2315             DecryptStart => 4,
2316             },
2317             },
2318             {
2319             Condition => '$$valPt =~ /^0403/', # 1J4,1J5
2320             Name => 'LensData0403',
2321             SubDirectory => {
2322             TagTable => 'Image::ExifTool::Nikon::LensData0403',
2323             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2324             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2325             DecryptStart => 4,
2326             },
2327             },
2328             {
2329             Condition => '$$valPt =~ /^080[012]/', # Z6/Z7/Z9
2330             Name => 'LensData0800',
2331             SubDirectory => {
2332             TagTable => 'Image::ExifTool::Nikon::LensData0800',
2333             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2334             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2335             DecryptStart => 4,
2336             ByteOrder => 'LittleEndian',
2337             },
2338             },
2339             {
2340             Name => 'LensDataUnknown',
2341             SubDirectory => {
2342             TagTable => 'Image::ExifTool::Nikon::LensDataUnknown',
2343             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2344             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2345             DecryptStart => 4,
2346             },
2347             },
2348             ],
2349             0x0099 => { #2/15
2350             Name => 'RawImageCenter',
2351             Writable => 'int16u',
2352             Count => 2,
2353             },
2354             0x009a => { #10
2355             Name => 'SensorPixelSize',
2356             Writable => 'rational64u',
2357             Count => 2,
2358             PrintConv => '$val=~s/ / x /;"$val um"',
2359             PrintConvInv => '$val=~tr/a-zA-Z/ /;$val',
2360             },
2361             0x009c => { #14
2362             # L2/L3 has these modes (from owner's manual): - PH
2363             # Portrait Assist: FACE-PRIORITY AF,PORTRAIT,PORTRAIT LEFT,PORTRAIT RIGHT,
2364             # PORTRAIT CLOSE-UP,PORTRAIT COUPLE,PORTRAIT-FIGURE
2365             # Landscape Assist:LANDSCAPE,SCENIC VIEW,ARCHITECTURE,GROUP RIGHT,GROUP LEFT
2366             # Sports Assist: SPORTS,SPORT SPECTATOR,SPORT COMPOSITE
2367             # P7100 has test modes: - PH
2368             # CREATIVE MONOCHROME,PAINTING,CROSS PROCESS,SOFT,NOSTALGIC SEPIA,
2369             # HIGH KEY,LOW KEY,SELECTIVE COLOR,ZOOM EXPOSURE EXP.,DEFOCUS DURING
2370             Name => 'SceneAssist',
2371             Writable => 'string',
2372             },
2373             0x009d => { #NealKrawetz
2374             Name => 'DateStampMode',
2375             Writable => 'int16u',
2376             Notes => 'feature to imprint date/time on image',
2377             PrintConv => { #PH
2378             0 => 'Off',
2379             1 => 'Date & Time',
2380             2 => 'Date',
2381             3 => 'Date Counter', # (NC) (D3500)
2382             },
2383             },
2384             0x009e => { #JD
2385             Name => 'RetouchHistory',
2386             Writable => 'int16u',
2387             Count => 10,
2388             # trim off extra "None" values
2389             ValueConv => '$val=~s/( 0)+$//; $val',
2390             ValueConvInv => 'my $n=($val=~/ \d+/g);$n < 9 ? $val . " 0" x (9-$n) : $val',
2391             PrintConvColumns => 2,
2392             PrintConv => [
2393             \%retouchValues,
2394             \%retouchValues,
2395             \%retouchValues,
2396             \%retouchValues,
2397             \%retouchValues,
2398             \%retouchValues,
2399             \%retouchValues,
2400             \%retouchValues,
2401             \%retouchValues,
2402             \%retouchValues,
2403             ],
2404             },
2405             0x00a0 => { Name => 'SerialNumber', Writable => 'string' }, #2
2406             0x00a2 => { # size of compressed image data plus EOI segment (ref 10)
2407             Name => 'ImageDataSize',
2408             Writable => 'int32u',
2409             },
2410             # 0x00a3 - int8u: 0 (All DSLR's but D1,D1H,D1X,D100)
2411             # 0x00a4 - version number found only in NEF images from DSLR models except the
2412             # D1,D1X,D2H and D100. Value is "0200" for all available samples except images
2413             # edited by Nikon Capture Editor 4.3.1 W and 4.4.2 which have "0100" - PH
2414             0x00a5 => { #15
2415             Name => 'ImageCount',
2416             Writable => 'int32u',
2417             },
2418             0x00a6 => { #15
2419             Name => 'DeletedImageCount',
2420             Writable => 'int32u',
2421             },
2422             # the sum of 0xa5 and 0xa6 is equal to 0xa7 ShutterCount (D2X,D2Hs,D2H,D200, ref 10)
2423             0x00a7 => { # Number of shots taken by camera so far (ref 2)
2424             Name => 'ShutterCount',
2425             Writable => 'int32u',
2426             Protected => 1,
2427             PrintConv => '$val == 4294965247 ? "n/a" : $val',
2428             PrintConvInv => '$val eq "n/a" ? 4294965247 : $val',
2429             Notes => q{
2430             includes both mechanical and electronic shutter activations for models with
2431             this feature. This value is used as a key to decrypt other information, and
2432             writing this tag causes the other information to be re-encrypted with the
2433             new key
2434             },
2435             },
2436             0x00a8 => [#JD
2437             {
2438             Name => 'FlashInfo0100',
2439             Condition => '$$valPt =~ /^010[01]/',
2440             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0100' },
2441             },
2442             {
2443             Name => 'FlashInfo0102',
2444             Condition => '$$valPt =~ /^0102/',
2445             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0102' },
2446             },
2447             {
2448             Name => 'FlashInfo0103',
2449             # (0104 for D7000, 0105 for D800)
2450             Condition => '$$valPt =~ /^010[345]/',
2451             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0103' },
2452             },
2453             {
2454             Name => 'FlashInfo0106', # (Df, D610, D3300, D5300, D7100, Coolpix A)
2455             Condition => '$$valPt =~ /^0106/',
2456             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0106' },
2457             },
2458             {
2459             Name => 'FlashInfo0107', # (0107 for D4S/D750/D810/D5500/D7200, 0108 for D5/D500/D3400)
2460             Condition => '$$valPt =~ /^010[78]/',
2461             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0107' },
2462             },
2463             {
2464             Name => 'FlashInfo0300', # (Z7II)
2465             Condition => '$$valPt =~ /^030[01]/',
2466             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0300' },
2467             },
2468             {
2469             Name => 'FlashInfoUnknown',
2470             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfoUnknown' },
2471             },
2472             ],
2473             0x00a9 => { Name => 'ImageOptimization',Writable => 'string' },#2
2474             0x00aa => { Name => 'Saturation', Writable => 'string' }, #2
2475             0x00ab => { Name => 'VariProgram', Writable => 'string' }, #2 (scene mode for DSLR's - PH)
2476             0x00ac => { Name => 'ImageStabilization',Writable=> 'string' }, #14
2477             0x00ad => { Name => 'AFResponse', Writable => 'string' }, #14
2478             0x00b0 => [{ #PH
2479             Name => 'MultiExposure',
2480             Condition => '$$valPt =~ /^0100/',
2481             SubDirectory => {
2482             TagTable => 'Image::ExifTool::Nikon::MultiExposure',
2483             # Note: this endianness varies with model, but Nikon software may change
2484             # metadata endianness (although it is unknown how it affects this record),
2485             # so for now don't specify ByteOrder although it may be wrong if the
2486             # file is rewritten by Nikon software --> see comments for FileInfo
2487             },
2488             },{
2489             Name => 'MultiExposure',
2490             Condition => '$$valPt =~ /^0101/',
2491             SubDirectory => {
2492             TagTable => 'Image::ExifTool::Nikon::MultiExposure',
2493             ByteOrder => 'LittleEndian',
2494             },
2495             },{
2496             Name => 'MultiExposure2',
2497             Condition => '$$valPt =~ /^010[23]/', # 0102 is NC (PH)
2498             SubDirectory => {
2499             TagTable => 'Image::ExifTool::Nikon::MultiExposure2',
2500             },
2501             }],
2502             0x00b1 => { #14/PH/JD (D80)
2503             Name => 'HighISONoiseReduction',
2504             Writable => 'int16u',
2505             PrintConv => {
2506             0 => 'Off',
2507             1 => 'Minimal', # for high ISO (>800) when setting is "Off"
2508             2 => 'Low', # Low,Normal,High take effect for ISO > 400
2509             3 => 'Medium Low',
2510             4 => 'Normal',
2511             5 => 'Medium High',
2512             6 => 'High',
2513             },
2514             },
2515             # 0x00b2 (string: "NORMAL ", 0xc3's, 0xff's or 0x20's)
2516             0x00b3 => { #14
2517             Name => 'ToningEffect',
2518             Writable => 'string',
2519             },
2520             0x00b6 => { #PH
2521             Name => 'PowerUpTime',
2522             Groups => { 2 => 'Time' },
2523             Shift => 'Time',
2524             # not clear whether "powered up" means "turned on" or "power applied" - PH
2525             Notes => 'date/time when camera was last powered up',
2526             Writable => 'undef',
2527             # must use RawConv so byte order is correct
2528             RawConv => sub {
2529             my $val = shift;
2530             return $val if length $val < 7;
2531             my $shrt = GetByteOrder() eq 'II' ? 'v' : 'n';
2532             my @date = unpack("${shrt}C5", $val);
2533             return sprintf('%.4d:%.2d:%.2d %.2d:%.2d:%.2d', @date);
2534             },
2535             RawConvInv => sub {
2536             my $val = shift;
2537             my $shrt = GetByteOrder() eq 'II' ? 'v' : 'n';
2538             my @date = ($val =~ /\d+/g);
2539             return pack("${shrt}C6", @date, 0);
2540             },
2541             PrintConv => '$self->ConvertDateTime($val)',
2542             PrintConvInv => '$self->InverseDateTime($val,0)',
2543             },
2544             0x00b7 => [{
2545             Name => 'AFInfo2',
2546             Condition => '$$self{Model} =~ /^NIKON Z 9\b/i', #AFInfo2Version 0400
2547             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0400' },
2548             },{ #JD
2549             Name => 'AFInfo2',
2550             # (this structure may be byte swapped when rewritten by CaptureNX)
2551             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2' },
2552             }],
2553             0x00b8 => [{ #PH
2554             Name => 'FileInfo',
2555             # unfortunately, some newer models write this as little-endian
2556             # (and CaptureNX can change the byte order of the maker notes,
2557             # but leaves this structure unchanged)
2558             # - it will be an ongoing pain to keep this list of models up-to-date,
2559             # so if only one ordering yields valid DirectoryNumber and FileNumber values,
2560             # use it, otherwise default to a-priori knowledge of the camera model
2561             # (assume that a valid DirectoryNumber is 100-999, and a valid FileNumber
2562             # is 0000-9999, although I have some samples with a DirectoryNumber of 99)
2563             Condition => q{
2564             if (length($$valPt) >= 0) {
2565             my ($dir, $file) = unpack('x6vv', $$valPt);
2566             my $littleEndian = ($dir >= 100 and $dir <= 999 and $file <= 9999);
2567             ($dir, $file) = unpack('x6nn', $$valPt);
2568             my $bigEndian = ($dir >= 100 and $dir <= 999 and $file <= 9999);
2569             return $littleEndian if $littleEndian xor $bigEndian;
2570             }
2571             return $$self{Model} =~ /^NIKON (D4S|D750|D810|D3300|D5200|D5300|D5500|D7100)$/;
2572             },
2573             SubDirectory => {
2574             TagTable => 'Image::ExifTool::Nikon::FileInfo',
2575             ByteOrder => 'LittleEndian',
2576             },
2577             },{
2578             Name => 'FileInfo',
2579             SubDirectory => {
2580             TagTable => 'Image::ExifTool::Nikon::FileInfo',
2581             ByteOrder => 'BigEndian',
2582             },
2583             }],
2584             0x00b9 => { #28
2585             Name => 'AFTune',
2586             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFTune' },
2587             },
2588             # 0x00ba - custom curve data? (ref 28?) (only in NEF images)
2589             0x00bb => { #forum6281
2590             Name => 'RetouchInfo',
2591             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::RetouchInfo' },
2592             },
2593             # 0x00bc - NEFThumbnail? (forum6281)
2594             0x00bd => { #PH (P6000)
2595             Name => 'PictureControlData',
2596             Writable => 'undef',
2597             Permanent => 0,
2598             Flags => [ 'Binary', 'Protected' ],
2599             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl' },
2600             },
2601             0x00bf => {
2602             Name => 'SilentPhotography',
2603             PrintConv => \%offOn,
2604             },
2605             0x00c3 => {
2606             Name => 'BarometerInfo',
2607             SubDirectory => {
2608             TagTable => 'Image::ExifTool::Nikon::BarometerInfo',
2609             # (little-endian in II EXIF, big-endian in MOV)
2610             },
2611             },
2612             0x0e00 => {
2613             Name => 'PrintIM',
2614             Description => 'Print Image Matching',
2615             Writable => 0,
2616             SubDirectory => {
2617             TagTable => 'Image::ExifTool::PrintIM::Main',
2618             },
2619             },
2620             # 0x0e01 - In D70 NEF files produced by Nikon Capture, the data for this tag extends 4 bytes
2621             # past the end of the maker notes. Very odd. I hope these 4 bytes aren't useful because
2622             # they will get lost by any utility that blindly copies the maker notes (not ExifTool) - PH
2623             0x0e01 => {
2624             Name => 'NikonCaptureData',
2625             Writable => 'undef',
2626             Permanent => 0,
2627             # (Drop because may be too large for JPEG images)
2628             Flags => [ 'Binary', 'Protected', 'Drop' ],
2629             Notes => q{
2630             this data is dropped when copying Nikon MakerNotes since it may be too large
2631             to fit in the EXIF segment of a JPEG image, but it may be copied as a block
2632             into existing Nikon MakerNotes later if desired
2633             },
2634             SubDirectory => {
2635             DirName => 'NikonCapture',
2636             TagTable => 'Image::ExifTool::NikonCapture::Main',
2637             },
2638             },
2639             # 0x0e05 written by Nikon Capture to NEF files, values of 1 and 2 - PH
2640             0x0e09 => { #12
2641             Name => 'NikonCaptureVersion',
2642             Writable => 'string',
2643             Permanent => 0,
2644             PrintConv => undef, # (avoid applying default print conversion to string)
2645             },
2646             # 0x0e0e is in D70 Nikon Capture files (not out-of-the-camera D70 files) - PH
2647             0x0e0e => { #PH
2648             Name => 'NikonCaptureOffsets',
2649             Writable => 'undef',
2650             Permanent => 0,
2651             SubDirectory => {
2652             TagTable => 'Image::ExifTool::Nikon::CaptureOffsets',
2653             Validate => '$val =~ /^0100/',
2654             Start => '$valuePtr + 4',
2655             },
2656             },
2657             0x0e10 => { #17
2658             Name => 'NikonScanIFD',
2659             Groups => { 1 => 'NikonScan', 2 => 'Image' },
2660             Flags => 'SubIFD',
2661             SubDirectory => {
2662             TagTable => 'Image::ExifTool::Nikon::Scan',
2663             Start => '$val',
2664             },
2665             },
2666             0x0e13 => [{ # PH/https://exiftool.org/forum/index.php/topic,2737.0.html
2667             Name => 'NikonCaptureEditVersions',
2668             Condition => '$self->Options("ExtractEmbedded")',
2669             Notes => q{
2670             the L option may be used to decode settings from the stored
2671             edit versions, otherwise this is extracted as a binary data block
2672             },
2673             Writable => 'undef',
2674             Permanent => 0,
2675             Drop => 1, # (may be too large for JPEG images)
2676             SubDirectory => {
2677             DirName => 'NikonCaptureEditVersions',
2678             TagTable => 'Image::ExifTool::NikonCapture::Main',
2679             ProcessProc => \&ProcessNikonCaptureEditVersions,
2680             WriteProc => sub { return undef }, # (writing not yet supported)
2681             },
2682             },{
2683             Name => 'NikonCaptureEditVersions',
2684             Writable => 'undef',
2685             Permanent => 0,
2686             Flags => [ 'Binary', 'Protected', 'Drop' ],
2687             }],
2688             0x0e1d => { #JD
2689             Name => 'NikonICCProfile',
2690             Flags => [ 'Binary', 'Protected' ],
2691             Writable => 'undef', # must be defined here so tag will be extracted if specified
2692             WriteCheck => q{
2693             require Image::ExifTool::ICC_Profile;
2694             return Image::ExifTool::ICC_Profile::ValidateICC(\$val);
2695             },
2696             SubDirectory => {
2697             DirName => 'NikonICCProfile',
2698             TagTable => 'Image::ExifTool::ICC_Profile::Main',
2699             },
2700             },
2701             0x0e1e => { #PH
2702             Name => 'NikonCaptureOutput',
2703             Writable => 'undef',
2704             Permanent => 0,
2705             Flags => [ 'Binary', 'Protected' ],
2706             SubDirectory => {
2707             TagTable => 'Image::ExifTool::Nikon::CaptureOutput',
2708             Validate => '$val =~ /^0100/',
2709             },
2710             },
2711             0x0e22 => { #28
2712             Name => 'NEFBitDepth',
2713             Writable => 'int16u',
2714             Count => 4,
2715             Protected => 1,
2716             PrintConv => {
2717             '0 0 0 0' => 'n/a (JPEG)',
2718             '8 8 8 0' => '8 x 3', # TIFF RGB
2719             '16 16 16 0' => '16 x 3', # TIFF 16-bit RGB
2720             '12 0 0 0' => 12,
2721             '14 0 0 0' => 14,
2722             },
2723             },
2724             );
2725              
2726             # NikonScan IFD entries (ref 17)
2727             %Image::ExifTool::Nikon::Scan = (
2728             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
2729             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
2730             WRITE_GROUP => 'NikonScan',
2731             WRITABLE => 1,
2732             GROUPS => { 0 => 'MakerNotes', 1 => 'NikonScan', 2 => 'Image' },
2733             VARS => { MINOR_ERRORS => 1 }, # this IFD is non-essential and often corrupted
2734             NOTES => 'This information is written by the Nikon Scan software.',
2735             0x02 => { Name => 'FilmType', Writable => 'string', },
2736             0x40 => { Name => 'MultiSample', Writable => 'string' },
2737             0x41 => { Name => 'BitDepth', Writable => 'int16u' },
2738             0x50 => {
2739             Name => 'MasterGain',
2740             Writable => 'rational64s',
2741             PrintConv => 'sprintf("%.2f",$val)',
2742             PrintConvInv => '$val',
2743             },
2744             0x51 => {
2745             Name => 'ColorGain',
2746             Writable => 'rational64s',
2747             Count => 3,
2748             PrintConv => 'sprintf("%.2f %.2f %.2f",split(" ",$val))',
2749             PrintConvInv => '$val',
2750             },
2751             0x60 => {
2752             Name => 'ScanImageEnhancer',
2753             Writable => 'int32u',
2754             PrintConv => \%offOn,
2755             },
2756             0x100 => { Name => 'DigitalICE', Writable => 'string' },
2757             0x110 => {
2758             Name => 'ROCInfo',
2759             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::ROC' },
2760             },
2761             0x120 => {
2762             Name => 'GEMInfo',
2763             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::GEM' },
2764             },
2765             0x200 => { Name => 'DigitalDEEShadowAdj', Writable => 'int32u' },
2766             0x201 => { Name => 'DigitalDEEThreshold', Writable => 'int32u' },
2767             0x202 => { Name => 'DigitalDEEHighlightAdj',Writable => 'int32u' },
2768             );
2769              
2770             # ref 17
2771             %Image::ExifTool::Nikon::ROC = (
2772             %binaryDataAttrs,
2773             FORMAT => 'int32u',
2774             GROUPS => { 0 => 'MakerNotes', 1 => 'NikonScan', 2 => 'Image' },
2775             0 => {
2776             Name => 'DigitalROC',
2777             ValueConv => '$val / 10',
2778             ValueConvInv => 'int($val * 10)',
2779             },
2780             );
2781              
2782             # ref 17
2783             %Image::ExifTool::Nikon::GEM = (
2784             %binaryDataAttrs,
2785             FORMAT => 'int32u',
2786             GROUPS => { 0 => 'MakerNotes', 1 => 'NikonScan', 2 => 'Image' },
2787             0 => {
2788             Name => 'DigitalGEM',
2789             ValueConv => '$val<95 ? $val/20-1 : 4',
2790             ValueConvInv => '$val == 4 ? 95 : int(($val + 1) * 20)',
2791             },
2792             );
2793              
2794             # Vibration Reduction information - PH (D300)
2795             %Image::ExifTool::Nikon::VRInfo = (
2796             %binaryDataAttrs,
2797             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
2798             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
2799             0 => {
2800             Name => 'VRInfoVersion',
2801             Format => 'undef[4]',
2802             Writable => 0,
2803             },
2804             4 => {
2805             Name => 'VibrationReduction',
2806             PrintConv => {
2807             0 => 'n/a', # (1V1 with a non-VR lens)
2808             1 => 'On',
2809             2 => 'Off',
2810             },
2811             },
2812             # 5 - values: 0, 1 (VR On), 2 (VR Off)
2813             6 => [{
2814             Name => 'VRMode',
2815             PrintConv => {
2816             0 => 'Off',
2817             1 => 'Normal', #39 (was 'Sport')
2818             3 => 'Sport', #39 (was 'Normal')
2819             },
2820             %infoZSeries,
2821             },{
2822             Name => 'VRMode',
2823             PrintConv => {
2824             0 => 'Normal',
2825             1 => 'On (1)', #PH (NC)
2826             2 => 'Active', # (1J1)
2827             3 => 'Sport', #PH (Z7)
2828             },
2829             }],
2830             # 7 - values: 0, 1
2831             8 => { #39
2832             Name => 'VRType',
2833             PrintConv => {
2834             2 => 'In-body', # (IBIS)
2835             3 => 'In-body + Lens', # (IBIS + VR)
2836             },
2837             },
2838             );
2839              
2840             # Face detection information - PH (S8100)
2841             %Image::ExifTool::Nikon::FaceDetect = (
2842             %binaryDataAttrs,
2843             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
2844             FORMAT => 'int16u',
2845             DATAMEMBER => [ 0x03 ],
2846             0x01 => {
2847             Name => 'FaceDetectFrameSize',
2848             Format => 'int16u[2]',
2849             },
2850             0x03 => {
2851             Name => 'FacesDetected',
2852             DataMember => 'FacesDetected',
2853             RawConv => '$$self{FacesDetected} = $val',
2854             },
2855             0x04 => {
2856             Name => 'Face1Position',
2857             Format => 'int16u[4]',
2858             RawConv => '$$self{FacesDetected} < 1 ? undef : $val',
2859             Notes => q{
2860             top, left, width and height of face detect area in coordinates of
2861             FaceDetectFrameSize
2862             },
2863             },
2864             0x08 => {
2865             Name => 'Face2Position',
2866             Format => 'int16u[4]',
2867             RawConv => '$$self{FacesDetected} < 2 ? undef : $val',
2868             },
2869             0x0c => {
2870             Name => 'Face3Position',
2871             Format => 'int16u[4]',
2872             RawConv => '$$self{FacesDetected} < 3 ? undef : $val',
2873             },
2874             0x10 => {
2875             Name => 'Face4Position',
2876             Format => 'int16u[4]',
2877             RawConv => '$$self{FacesDetected} < 4 ? undef : $val',
2878             },
2879             0x14 => {
2880             Name => 'Face5Position',
2881             Format => 'int16u[4]',
2882             RawConv => '$$self{FacesDetected} < 5 ? undef : $val',
2883             },
2884             0x18 => {
2885             Name => 'Face6Position',
2886             Format => 'int16u[4]',
2887             RawConv => '$$self{FacesDetected} < 6 ? undef : $val',
2888             },
2889             0x1c => {
2890             Name => 'Face7Position',
2891             Format => 'int16u[4]',
2892             RawConv => '$$self{FacesDetected} < 7 ? undef : $val',
2893             },
2894             0x20 => {
2895             Name => 'Face8Position',
2896             Format => 'int16u[4]',
2897             RawConv => '$$self{FacesDetected} < 8 ? undef : $val',
2898             },
2899             0x24 => {
2900             Name => 'Face9Position',
2901             Format => 'int16u[4]',
2902             RawConv => '$$self{FacesDetected} < 9 ? undef : $val',
2903             },
2904             0x28 => {
2905             Name => 'Face10Position',
2906             Format => 'int16u[4]',
2907             RawConv => '$$self{FacesDetected} < 10 ? undef : $val',
2908             },
2909             0x2c => {
2910             Name => 'Face11Position',
2911             Format => 'int16u[4]',
2912             RawConv => '$$self{FacesDetected} < 11 ? undef : $val',
2913             },
2914             0x30 => {
2915             Name => 'Face12Position',
2916             Format => 'int16u[4]',
2917             RawConv => '$$self{FacesDetected} < 12 ? undef : $val',
2918             },
2919             );
2920              
2921             # Picture Control information - PH (D300,P6000)
2922             %Image::ExifTool::Nikon::PictureControl = (
2923             %binaryDataAttrs,
2924             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
2925             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
2926             0 => {
2927             Name => 'PictureControlVersion',
2928             Format => 'undef[4]',
2929             Writable => 0,
2930             },
2931             4 => {
2932             Name => 'PictureControlName',
2933             Format => 'string[20]',
2934             # make lower case with a leading capital for each word
2935             PrintConv => \&FormatString,
2936             PrintConvInv => 'uc($val)',
2937             },
2938             24 => {
2939             Name => 'PictureControlBase',
2940             Format => 'string[20]',
2941             PrintConv => \&FormatString,
2942             PrintConvInv => 'uc($val)',
2943             },
2944             # beginning at byte 44, there is some interesting information.
2945             # here are the observed bytes for each PictureControlMode:
2946             # 44 45 46 47 48 49 50 51 52 53 54 55 56 57
2947             # STANDARD 00 01 00 00 00 80 83 80 80 80 80 ff ff ff
2948             # NEUTRAL 03 c2 00 00 00 ff 82 80 80 80 80 ff ff ff
2949             # VIVID 00 c3 00 00 00 80 84 80 80 80 80 ff ff ff
2950             # MONOCHROME 06 4d 00 01 02 ff 82 80 80 ff ff 80 80 ff
2951             # Neutral2 03 c2 01 00 02 ff 80 7f 81 00 7f ff ff ff (custom)
2952             # (note that up to 9 different custom picture controls can be stored)
2953             # --> bytes 44 and 45 are swapped if CaptureNX changes the byte order
2954             #
2955             48 => { #21
2956             Name => 'PictureControlAdjust',
2957             PrintConv => {
2958             0 => 'Default Settings',
2959             1 => 'Quick Adjust',
2960             2 => 'Full Control',
2961             },
2962             },
2963             49 => {
2964             Name => 'PictureControlQuickAdjust',
2965             # settings: -2 to +2 (n/a for Neutral and Monochrome modes)
2966             DelValue => 0xff,
2967             ValueConv => '$val - 0x80',
2968             ValueConvInv => '$val + 0x80',
2969             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
2970             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
2971             },
2972             50 => {
2973             Name => 'Sharpness',
2974             # settings: 0 to 9, Auto
2975             ValueConv => '$val - 0x80',
2976             ValueConvInv => '$val + 0x80',
2977             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"No Sharpening","%d")',
2978             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
2979             },
2980             51 => {
2981             Name => 'Contrast',
2982             # settings: -3 to +3, Auto
2983             ValueConv => '$val - 0x80',
2984             ValueConvInv => '$val + 0x80',
2985             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
2986             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
2987             },
2988             52 => {
2989             Name => 'Brightness',
2990             # settings: -1 to +1
2991             ValueConv => '$val - 0x80',
2992             ValueConvInv => '$val + 0x80',
2993             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
2994             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
2995             },
2996             53 => {
2997             Name => 'Saturation',
2998             # settings: -3 to +3, Auto (n/a for Monochrome mode)
2999             DelValue => 0xff,
3000             ValueConv => '$val - 0x80',
3001             ValueConvInv => '$val + 0x80',
3002             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3003             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3004             },
3005             54 => {
3006             Name => 'HueAdjustment',
3007             # settings: -3 to +3 (n/a for Monochrome mode)
3008             DelValue => 0xff,
3009             ValueConv => '$val - 0x80',
3010             ValueConvInv => '$val + 0x80',
3011             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None")',
3012             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3013             },
3014             55 => {
3015             Name => 'FilterEffect',
3016             # settings: Off,Yellow,Orange,Red,Green (n/a for color modes)
3017             DelValue => 0xff,
3018             PrintHex => 1,
3019             PrintConv => {
3020             0x80 => 'Off',
3021             0x81 => 'Yellow',
3022             0x82 => 'Orange',
3023             0x83 => 'Red',
3024             0x84 => 'Green',
3025             0xff => 'n/a',
3026             },
3027             },
3028             56 => {
3029             Name => 'ToningEffect',
3030             # settings: B&W,Sepia,Cyanotype,Red,Yellow,Green,Blue-Green,Blue,
3031             # Purple-Blue,Red-Purple (n/a for color modes)
3032             DelValue => 0xff,
3033             PrintHex => 1,
3034             PrintConvColumns => 2,
3035             PrintConv => {
3036             0x80 => 'B&W',
3037             0x81 => 'Sepia',
3038             0x82 => 'Cyanotype',
3039             0x83 => 'Red',
3040             0x84 => 'Yellow',
3041             0x85 => 'Green',
3042             0x86 => 'Blue-green',
3043             0x87 => 'Blue',
3044             0x88 => 'Purple-blue',
3045             0x89 => 'Red-purple',
3046             0xff => 'n/a',
3047             # 0x04 - seen for D810 (PH)
3048             },
3049             },
3050             57 => { #21
3051             Name => 'ToningSaturation',
3052             # settings: B&W,Sepia,Cyanotype,Red,Yellow,Green,Blue-Green,Blue,
3053             # Purple-Blue,Red-Purple (n/a unless ToningEffect is used)
3054             DelValue => 0xff,
3055             ValueConv => '$val - 0x80',
3056             ValueConvInv => '$val + 0x80',
3057             PrintConv => '$val==0x7f ? "n/a" : $val',
3058             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3059             },
3060             );
3061              
3062             # Picture Control information V2 (ref 28)
3063             %Image::ExifTool::Nikon::PictureControl2 = (
3064             %binaryDataAttrs,
3065             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3066             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3067             0 => {
3068             Name => 'PictureControlVersion',
3069             Format => 'undef[4]',
3070             Writable => 0,
3071             },
3072             4 => {
3073             Name => 'PictureControlName',
3074             Format => 'string[20]',
3075             # make lower case with a leading capital for each word
3076             PrintConv => \&FormatString,
3077             PrintConvInv => 'uc($val)',
3078             },
3079             24 => {
3080             Name => 'PictureControlBase',
3081             Format => 'string[20]',
3082             PrintConv => \&FormatString,
3083             PrintConvInv => 'uc($val)',
3084             },
3085             # beginning at byte 44, there is some interesting information.
3086             # here are the observed bytes for each PictureControlMode:
3087             # 44 45 46 47 48 49 50 51 52 53 54 55 56 57
3088             # STANDARD 00 01 00 00 00 80 83 80 80 80 80 ff ff ff
3089             # NEUTRAL 03 c2 00 00 00 ff 82 80 80 80 80 ff ff ff
3090             # VIVID 00 c3 00 00 00 80 84 80 80 80 80 ff ff ff
3091             # MONOCHROME 06 4d 00 01 02 ff 82 80 80 ff ff 80 80 ff
3092             # Neutral2 03 c2 01 00 02 ff 80 7f 81 00 7f ff ff ff (custom)
3093             # (note that up to 9 different custom picture controls can be stored)
3094             # --> bytes 44 and 45 are swapped if CaptureNX changes the byte order
3095             #
3096             48 => { #21
3097             Name => 'PictureControlAdjust',
3098             PrintConv => {
3099             0 => 'Default Settings',
3100             1 => 'Quick Adjust',
3101             2 => 'Full Control',
3102             },
3103             },
3104             49 => {
3105             Name => 'PictureControlQuickAdjust',
3106             # settings: -2 to +2 (n/a for Neutral and Monochrome modes)
3107             DelValue => 0xff,
3108             ValueConv => '$val - 0x80',
3109             ValueConvInv => '$val + 0x80',
3110             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3111             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3112             },
3113             51 => {
3114             Name => 'Sharpness',
3115             DelValue => 0xff,
3116             ValueConv => '$val - 0x80',
3117             ValueConvInv => '$val + 0x80',
3118             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3119             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3120             },
3121             53 => {
3122             Name => 'Clarity',
3123             DelValue => 0xff,
3124             ValueConv => '$val - 0x80',
3125             ValueConvInv => '$val + 0x80',
3126             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3127             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv2($val,4)',
3128             },
3129             55 => {
3130             Name => 'Contrast',
3131             DelValue => 0xff,
3132             ValueConv => '$val - 0x80',
3133             ValueConvInv => '$val + 0x80',
3134             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3135             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3136             },
3137             57 => { #21
3138             Name => 'Brightness',
3139             # settings: -1 to +1
3140             ValueConv => '$val - 0x80',
3141             ValueConvInv => '$val + 0x80',
3142             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,undef,"%.2f",4)',
3143             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3144             },
3145             59 => {
3146             Name => 'Saturation',
3147             DelValue => 0xff,
3148             ValueConv => '$val - 0x80',
3149             ValueConvInv => '$val + 0x80',
3150             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3151             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3152             },
3153             61 => {
3154             Name => 'Hue',
3155             DelValue => 0xff,
3156             ValueConv => '$val - 0x80',
3157             ValueConvInv => '$val + 0x80',
3158             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3159             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3160             },
3161             63 => {
3162             Name => 'FilterEffect',
3163             # settings: Off,Yellow,Orange,Red,Green (n/a for color modes)
3164             DelValue => 0xff,
3165             PrintHex => 1,
3166             PrintConv => {
3167             0x80 => 'Off',
3168             0x81 => 'Yellow',
3169             0x82 => 'Orange',
3170             0x83 => 'Red',
3171             0x84 => 'Green',
3172             0xff => 'n/a',
3173             },
3174             },
3175             64 => {
3176             Name => 'ToningEffect',
3177             # settings: B&W,Sepia,Cyanotype,Red,Yellow,Green,Blue-Green,Blue,
3178             # Purple-Blue,Red-Purple (n/a for color modes)
3179             DelValue => 0xff,
3180             PrintHex => 1,
3181             PrintConvColumns => 2,
3182             PrintConv => {
3183             0x80 => 'B&W',
3184             0x81 => 'Sepia',
3185             0x82 => 'Cyanotype',
3186             0x83 => 'Red',
3187             0x84 => 'Yellow',
3188             0x85 => 'Green',
3189             0x86 => 'Blue-green',
3190             0x87 => 'Blue',
3191             0x88 => 'Purple-blue',
3192             0x89 => 'Red-purple',
3193             0xff => 'n/a',
3194             },
3195             },
3196             65 => {
3197             Name => 'ToningSaturation',
3198             DelValue => 0xff,
3199             ValueConv => '$val - 0x80', #$val == 0x7f (n/a) for "B&W"
3200             ValueConvInv => '$val + 0x80',
3201             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3202             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3203              
3204             },
3205             );
3206              
3207             # Picture Control information V3 (ref PH, Z7)
3208             %Image::ExifTool::Nikon::PictureControl3 = (
3209             %binaryDataAttrs,
3210             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3211             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3212             0 => {
3213             Name => 'PictureControlVersion',
3214             Format => 'undef[4]',
3215             Writable => 0,
3216             },
3217             8 => {
3218             Name => 'PictureControlName',
3219             Format => 'string[20]',
3220             # make lower case with a leading capital for each word
3221             PrintConv => \&FormatString,
3222             PrintConvInv => 'uc($val)',
3223             },
3224             # 48 - looks like PictureControl2 byte 45
3225             28 => {
3226             Name => 'PictureControlBase',
3227             Format => 'string[20]',
3228             PrintConv => \&FormatString,
3229             PrintConvInv => 'uc($val)',
3230             },
3231             54 => { # (NC)
3232             Name => 'PictureControlAdjust',
3233             PrintConv => {
3234             0 => 'Default Settings',
3235             1 => 'Quick Adjust',
3236             2 => 'Full Control',
3237             },
3238             },
3239             55 => { # (NC)
3240             Name => 'PictureControlQuickAdjust',
3241             DelValue => 0xff,
3242             ValueConv => '$val - 0x80',
3243             ValueConvInv => '$val + 0x80',
3244             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3245             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3246             },
3247             57 => {
3248             Name => 'Sharpness',
3249             DelValue => 0xff,
3250             ValueConv => '$val - 0x80',
3251             ValueConvInv => '$val + 0x80',
3252             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3253             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3254             },
3255             59 => {
3256             Name => 'MidRangeSharpness',
3257             DelValue => 0xff,
3258             ValueConv => '$val - 0x80',
3259             ValueConvInv => '$val + 0x80',
3260             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3261             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3262             },
3263             61 => {
3264             Name => 'Clarity',
3265             DelValue => 0xff,
3266             ValueConv => '$val - 0x80',
3267             ValueConvInv => '$val + 0x80',
3268             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3269             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv2($val,4)',
3270             },
3271             63 => {
3272             Name => 'Contrast',
3273             DelValue => 0xff,
3274             ValueConv => '$val - 0x80',
3275             ValueConvInv => '$val + 0x80',
3276             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3277             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3278             },
3279             65 => { #21
3280             Name => 'Brightness',
3281             ValueConv => '$val - 0x80',
3282             ValueConvInv => '$val + 0x80',
3283             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,undef,"%.2f",4)',
3284             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3285             },
3286             67 => {
3287             Name => 'Saturation',
3288             DelValue => 0xff,
3289             ValueConv => '$val - 0x80',
3290             ValueConvInv => '$val + 0x80',
3291             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3292             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3293             },
3294             69 => {
3295             Name => 'Hue',
3296             DelValue => 0xff,
3297             ValueConv => '$val - 0x80',
3298             ValueConvInv => '$val + 0x80',
3299             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3300             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3301             },
3302             71 => { # (NC)
3303             Name => 'FilterEffect',
3304             DelValue => 0xff,
3305             PrintHex => 1,
3306             PrintConv => {
3307             0x80 => 'Off',
3308             0x81 => 'Yellow',
3309             0x82 => 'Orange',
3310             0x83 => 'Red',
3311             0x84 => 'Green',
3312             0xff => 'n/a',
3313             },
3314             },
3315             72 => { # (NC)
3316             Name => 'ToningEffect',
3317             DelValue => 0xff,
3318             PrintHex => 1,
3319             PrintConvColumns => 2,
3320             PrintConv => {
3321             0x80 => 'B&W',
3322             0x81 => 'Sepia',
3323             0x82 => 'Cyanotype',
3324             0x83 => 'Red',
3325             0x84 => 'Yellow',
3326             0x85 => 'Green',
3327             0x86 => 'Blue-green',
3328             0x87 => 'Blue',
3329             0x88 => 'Purple-blue',
3330             0x89 => 'Red-purple',
3331             0xff => 'n/a',
3332             },
3333             },
3334             73 => { # (NC)
3335             Name => 'ToningSaturation',
3336             DelValue => 0xff,
3337             ValueConv => '$val - 0x80',
3338             ValueConvInv => '$val + 0x80',
3339             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3340             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3341              
3342             },
3343             );
3344              
3345             # Unknown Picture Control information
3346             %Image::ExifTool::Nikon::PictureControlUnknown = (
3347             %binaryDataAttrs,
3348             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3349             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3350             0 => {
3351             Name => 'PictureControlVersion',
3352             Format => 'undef[4]',
3353             Writable => 0,
3354             },
3355             );
3356              
3357             # World Time information - JD (D300)
3358             %Image::ExifTool::Nikon::WorldTime = (
3359             %binaryDataAttrs,
3360             GROUPS => { 0 => 'MakerNotes', 2 => 'Time' },
3361             0 => {
3362             Name => 'TimeZone',
3363             Format => 'int16s',
3364             PrintConv => q{
3365             my $sign = $val < 0 ? '-' : '+';
3366             my $h = int(abs($val) / 60);
3367             sprintf("%s%.2d:%.2d", $sign, $h, abs($val)-60*$h);
3368             },
3369             PrintConvInv => q{
3370             $val =~ /Z$/ and return 0;
3371             $val =~ /([-+])(\d{1,2}):?(\d{2})$/ and return $1 . ($2 * 60 + $3);
3372             $val =~ /^(\d{2})(\d{2})$/ and return $1 * 60 + $2;
3373             return undef;
3374             },
3375             },
3376             2 => {
3377             Name => 'DaylightSavings',
3378             PrintConv => { 0 => 'No', 1 => 'Yes' },
3379             },
3380             3 => {
3381             Name => 'DateDisplayFormat',
3382             PrintConv => {
3383             0 => 'Y/M/D',
3384             1 => 'M/D/Y',
3385             2 => 'D/M/Y',
3386             },
3387             },
3388             );
3389              
3390             # ISO information - PH (D300)
3391             %Image::ExifTool::Nikon::ISOInfo = (
3392             %binaryDataAttrs,
3393             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3394             0 => {
3395             Name => 'ISO',
3396             Notes => 'val = 100 * 2**(raw/12-5)',
3397             Priority => 0, # because people like to see rounded-off values if they exist
3398             ValueConv => '100*exp(($val/12-5)*log(2))',
3399             ValueConvInv => '(log($val/100)/log(2)+5)*12',
3400             PrintConv => 'int($val + 0.5)',
3401             PrintConvInv => '$val',
3402             },
3403             # 1 - 0x01
3404             # 2 - 0x0c (probably the ISO divisor above)
3405             # 3 - 0x00
3406             4 => {
3407             Name => 'ISOExpansion',
3408             Format => 'int16u',
3409             PrintHex => 1,
3410             PrintConvColumns => 2,
3411             PrintConv => {
3412             0x000 => 'Off',
3413             0x101 => 'Hi 0.3',
3414             0x102 => 'Hi 0.5',
3415             0x103 => 'Hi 0.7',
3416             0x104 => 'Hi 1.0',
3417             0x105 => 'Hi 1.3', # (Hi 1.3-1.7 may be possible with future models)
3418             0x106 => 'Hi 1.5',
3419             0x107 => 'Hi 1.7',
3420             0x108 => 'Hi 2.0', #(NC) - D3 should have this mode
3421             0x109 => 'Hi 2.3', #IB
3422             0x10a => 'Hi 2.5', #IB
3423             0x10b => 'Hi 2.7', #IB
3424             0x10c => 'Hi 3.0', #IB
3425             0x10d => 'Hi 3.3', #IB
3426             0x10e => 'Hi 3.5', #IB
3427             0x10f => 'Hi 3.7', #IB
3428             0x110 => 'Hi 4.0', #IB
3429             0x111 => 'Hi 4.3', #IB
3430             0x112 => 'Hi 4.5', #IB
3431             0x113 => 'Hi 4.7', #IB
3432             0x114 => 'Hi 5.0', #IB
3433             0x201 => 'Lo 0.3',
3434             0x202 => 'Lo 0.5',
3435             0x203 => 'Lo 0.7',
3436             0x204 => 'Lo 1.0',
3437             },
3438             },
3439             # bytes 6-11 same as 0-4 in my samples (why is this duplicated?)
3440             6 => {
3441             Name => 'ISO2',
3442             Notes => 'val = 100 * 2**(raw/12-5)',
3443             ValueConv => '100*exp(($val/12-5)*log(2))',
3444             ValueConvInv => '(log($val/100)/log(2)+5)*12',
3445             PrintConv => 'int($val + 0.5)',
3446             PrintConvInv => '$val',
3447             },
3448             # 7 - 0x01
3449             # 8 - 0x0c (probably the ISO divisor above)
3450             # 9 - 0x00
3451             10 => {
3452             Name => 'ISOExpansion2',
3453             Format => 'int16u',
3454             PrintHex => 1,
3455             PrintConvColumns => 2,
3456             PrintConv => {
3457             0x000 => 'Off',
3458             0x101 => 'Hi 0.3',
3459             0x102 => 'Hi 0.5',
3460             0x103 => 'Hi 0.7',
3461             0x104 => 'Hi 1.0',
3462             0x105 => 'Hi 1.3', # (Hi 1.3-1.7 may be possible with future models)
3463             0x106 => 'Hi 1.5',
3464             0x107 => 'Hi 1.7',
3465             0x108 => 'Hi 2.0', #(NC) - D3 should have this mode
3466             0x201 => 'Lo 0.3',
3467             0x202 => 'Lo 0.5',
3468             0x203 => 'Lo 0.7',
3469             0x204 => 'Lo 1.0',
3470             },
3471             },
3472             # bytes 12-13: 00 00
3473             );
3474              
3475             # distortion information - PH (D5000)
3476             %Image::ExifTool::Nikon::DistortInfo = (
3477             %binaryDataAttrs,
3478             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3479             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3480             0 => {
3481             Name => 'DistortionVersion',
3482             Format => 'undef[4]',
3483             Writable => 0,
3484             Unknown => 1,
3485             },
3486             4 => {
3487             Name => 'AutoDistortionControl',
3488             PrintConv => {
3489             0 => 'Off',
3490             1 => 'On',
3491             2 => 'On (underwater)', # (1AW1)
3492             },
3493             },
3494             );
3495              
3496             # unknown information - PH (D7000)
3497             %Image::ExifTool::Nikon::UnknownInfo = (
3498             %binaryDataAttrs,
3499             FORMAT => 'int32u',
3500             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3501             0 => {
3502             Name => 'UnknownInfoVersion',
3503             Condition => '$$valPt =~ /^\d{4}/',
3504             Format => 'undef[4]',
3505             Writable => 0,
3506             Unknown => 1,
3507             },
3508             # (bytes 6/7 and 8/9 are swapped if CaptureNX changes the byte order)
3509             );
3510              
3511             # more unknown information - PH (D7000)
3512             %Image::ExifTool::Nikon::UnknownInfo2 = (
3513             %binaryDataAttrs,
3514             FORMAT => 'int32u',
3515             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3516             0 => {
3517             Name => 'UnknownInfo2Version',
3518             Condition => '$$valPt =~ /^\d{4}/',
3519             Format => 'undef[4]',
3520             Writable => 0,
3521             Unknown => 1,
3522             },
3523             # (byte 4 may be changed from 1 to 0 when rewritten by CaptureNX)
3524             );
3525              
3526             # Nikon AF information (ref 13)
3527             %Image::ExifTool::Nikon::AFInfo = (
3528             %binaryDataAttrs,
3529             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3530             0 => {
3531             Name => 'AFAreaMode',
3532             PrintConv => {
3533             0 => 'Single Area',
3534             1 => 'Dynamic Area',
3535             2 => 'Dynamic Area (closest subject)',
3536             3 => 'Group Dynamic',
3537             4 => 'Single Area (wide)',
3538             5 => 'Dynamic Area (wide)',
3539             },
3540             },
3541             1 => {
3542             Name => 'AFPoint',
3543             Notes => 'in some focus modes this value is not meaningful',
3544             PrintConvColumns => 2,
3545             PrintConv => {
3546             0 => 'Center',
3547             1 => 'Top',
3548             2 => 'Bottom',
3549             3 => 'Mid-left',
3550             4 => 'Mid-right',
3551             5 => 'Upper-left',
3552             6 => 'Upper-right',
3553             7 => 'Lower-left',
3554             8 => 'Lower-right',
3555             9 => 'Far Left',
3556             10 => 'Far Right',
3557             # (have also seen values of 11 and 12 when AFPointsInFocus is "(none)" - PH S3500)
3558             },
3559             },
3560             2 => {
3561             Name => 'AFPointsInFocus',
3562             Format => 'int16u',
3563             PrintConvColumns => 2,
3564             PrintConv => {
3565             0 => '(none)',
3566             0x7ff => 'All 11 Points',
3567             BITMASK => {
3568             0 => 'Center',
3569             1 => 'Top',
3570             2 => 'Bottom',
3571             3 => 'Mid-left',
3572             4 => 'Mid-right',
3573             5 => 'Upper-left',
3574             6 => 'Upper-right',
3575             7 => 'Lower-left',
3576             8 => 'Lower-right',
3577             9 => 'Far Left',
3578             10 => 'Far Right',
3579             },
3580             },
3581             },
3582             );
3583              
3584             # Nikon AF information for D3 and D300 (ref JD)
3585             %Image::ExifTool::Nikon::AFInfo2 = (
3586             %binaryDataAttrs,
3587             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3588             DATAMEMBER => [ 0, 4, 6 ],
3589             NOTES => "These tags are written by Nikon DSLR's which have the live view feature.",
3590             0 => {
3591             Name => 'AFInfo2Version',
3592             Format => 'undef[4]',
3593             Writable => 0,
3594             RawConv => '$$self{AFInfo2Version} = $val',
3595             },
3596             4 => { #PH
3597             Name => 'ContrastDetectAF',
3598             RawConv => '$$self{ContrastDetectAF} = $val',
3599             PrintConv => {
3600             %offOn,
3601             2 => 'On (2)', #PH (Z7)
3602             },
3603             Notes => 'this is Off for the hybrid AF used in Nikon 1 models',
3604             },
3605             5 => [
3606             {
3607             Name => 'AFAreaMode',
3608             Condition => 'not $$self{ContrastDetectAF}',
3609             Notes => 'ContrastDetectAF Off',
3610             PrintConv => {
3611             0 => 'Single Area', # (called "Single Point" in manual - PH)
3612             1 => 'Dynamic Area', #PH
3613             2 => 'Dynamic Area (closest subject)', #PH
3614             3 => 'Group Dynamic', #PH
3615             4 => 'Dynamic Area (9 points)', #JD/28
3616             5 => 'Dynamic Area (21 points)', #28
3617             6 => 'Dynamic Area (51 points)', #28
3618             7 => 'Dynamic Area (51 points, 3D-tracking)', #PH/28
3619             8 => 'Auto-area',
3620             9 => 'Dynamic Area (3D-tracking)', #PH (D5000 "3D-tracking (11 points)")
3621             10 => 'Single Area (wide)', #PH
3622             11 => 'Dynamic Area (wide)', #PH
3623             12 => 'Dynamic Area (wide, 3D-tracking)', #PH
3624             13 => 'Group Area', #PH
3625             14 => 'Dynamic Area (25 points)', #PH
3626             15 => 'Dynamic Area (72 points)', #PH
3627             16 => 'Group Area (HL)', #28
3628             17 => 'Group Area (VL)', #28
3629             18 => 'Dynamic Area (49 points)', #28
3630             128 => 'Single', #PH (1J1,1J2,1J3,1J4,1S1,1S2,1V2,1V3)
3631             129 => 'Auto (41 points)', #PH (1J1,1J2,1J3,1J4,1S1,1S2,1V1,1V2,1V3,AW1)
3632             130 => 'Subject Tracking (41 points)', #PH (1J1,1J4,1J3)
3633             131 => 'Face Priority (41 points)', #PH (1J1,1J3,1S1,1V2,AW1)
3634             # 134 - seen for 1V1[PhaseDetectAF=0] (PH)
3635             # 135 - seen for 1J2[PhaseDetectAF=4] (PH)
3636             192 => 'Pinpoint', #PH (NC)
3637             193 => 'Single', #PH (NC)
3638             195 => 'Wide (S)', #PH (NC)
3639             196 => 'Wide (L)', #PH (NC)
3640             197 => 'Auto', #PH (NC)
3641             },
3642             },
3643             { #PH (D3/D90/D5000)
3644             Name => 'AFAreaMode',
3645             Notes => 'ContrastDetectAF On',
3646             PrintConv => {
3647             0 => 'Contrast-detect', # (D3)
3648             1 => 'Contrast-detect (normal area)', # (D90/D5000)
3649             # (D90 and D5000 give value of 2 when set to 'Face Priority' and
3650             # 'Subject Tracking', but I didn't have a face to shoot at or a
3651             # moving subject to track so perhaps this value changes dynamically)
3652             2 => 'Contrast-detect (wide area)', # (D90/D5000)
3653             3 => 'Contrast-detect (face priority)', # (ViewNX)
3654             4 => 'Contrast-detect (subject tracking)', # (ViewNX)
3655             128 => 'Single', #PH (1V3)
3656             129 => 'Auto (41 points)', #PH (NC)
3657             130 => 'Subject Tracking (41 points)', #PH (NC)
3658             131 => 'Face Priority (41 points)', #PH (NC)
3659             192 => 'Pinpoint', #PH (Z7)
3660             193 => 'Single', #PH (Z7)
3661             194 => 'Dynamic', #PH (Z7)
3662             195 => 'Wide (S)', #PH (Z7)
3663             196 => 'Wide (L)', #PH (Z7)
3664             197 => 'Auto', #PH (Z7)
3665             198 => 'Auto (People)', #28 (Z7) #if no faces are detected, will record as 'Auto'. Camera setting recorded in AFAreaMode field in the MakerNotes area
3666             199 => 'Auto (Animal)', #28 (Z7) #if no animals are detected, will record as 'Auto'. Camera setting recorded in AFAreaMode field in the MakerNotes area
3667             200 => 'Normal-area AF', #28 (D6)
3668             201 => 'Wide-area AF', #28 (D6)
3669             202 => 'Face-priority AF', #28 (D6)
3670             203 => 'Subject-tracking AF', #28 (D6)
3671             204 => 'Dynamic Area (S)', #28 (Z9)
3672             205 => 'Dynamic Area (M)', #28 (Z9)
3673             206 => 'Dynamic Area (L)', #28 (Z9)
3674             207 => '3D-tracking', #28 (Z9)
3675             },
3676             },
3677             ],
3678             6 => {
3679             Name => 'PhaseDetectAF', #JD(AutoFocus), PH(PhaseDetectAF)
3680             Notes => 'PrimaryAFPoint and AFPointsUsed below are only valid when this is On',
3681             RawConv => '$$self{PhaseDetectAF} = $val',
3682             PrintConv => {
3683             # [observed AFAreaMode values in square brackets for each PhaseDetectAF value]
3684             0 => 'Off',
3685             1 => 'On (51-point)', #PH
3686             2 => 'On (11-point)', #PH
3687             3 => 'On (39-point)', #29 (D7000)
3688             4 => 'On (73-point)', #PH (1J1[128/129],1J2[128/129/135],1J3/1S1/1V2[128/129/131],1V1[129],AW1[129/131])
3689             5 => 'On (5)', #PH (1S2[128/129], 1J4/1V3[129])
3690             6 => 'On (105-point)', #PH (1J4/1V3[128/130])
3691             7 => 'On (153-point)', #PH (D5/D500/D850)
3692             8 => 'On (81-point)', #38
3693             9 => 'On (105-point)', #28 (D6)
3694             },
3695             },
3696             7 => [
3697             { #PH/JD
3698             Name => 'PrimaryAFPoint',
3699             # PrimaryAFPoint may only be valid for PhaseDetect - certainly true on the D6, possibly other bodies? (ref 28)
3700             Condition => '$$self{PhaseDetectAF} < 2 and $$self{AFInfo2Version} !~ /^03/',
3701             Notes => q{
3702             models with 51-point AF -- 5 rows (A-E) and 11 columns (1-11): D3, D3S, D3X,
3703             D4, D4S, D300, D300S, D700, D800, D800e and D810
3704             },
3705             PrintConvColumns => 5,
3706             PrintConv => {
3707             0 => '(none)',
3708             %afPoints51,
3709             1 => 'C6 (Center)', # (add " (Center)" to central point)
3710             },
3711             },
3712             { #10
3713             Name => 'PrimaryAFPoint',
3714             Notes => 'models with 11-point AF: D90, D3000, D3100, D5000 and D5100',
3715             Condition => '$$self{PhaseDetectAF} == 2',
3716             PrintConvColumns => 2,
3717             PrintConv => {
3718             0 => '(none)',
3719             1 => 'Center',
3720             2 => 'Top',
3721             3 => 'Bottom',
3722             4 => 'Mid-left',
3723             5 => 'Upper-left',
3724             6 => 'Lower-left',
3725             7 => 'Far Left',
3726             8 => 'Mid-right',
3727             9 => 'Upper-right',
3728             10 => 'Lower-right',
3729             11 => 'Far Right',
3730             },
3731             },
3732             { #29
3733             Name => 'PrimaryAFPoint',
3734             Condition => '$$self{PhaseDetectAF} == 3',
3735             Notes => 'models with 39-point AF: D600 and D7000',
3736             PrintConvColumns => 5,
3737             PrintConv => {
3738             0 => '(none)',
3739             %afPoints39,
3740             1 => 'C6 (Center)', # (add " (Center)" to central point)
3741             },
3742             },
3743             { #PH
3744             Name => 'PrimaryAFPoint',
3745             Condition => '$$self{PhaseDetectAF} == 4',
3746             Notes => 'Nikon 1 models with older 135-point AF and 73-point phase-detect AF',
3747             PrintConvColumns => 5,
3748             PrintConv => {
3749             0 => '(none)',
3750             %afPoints135,
3751             1 => 'E8 (Center)', # (add " (Center)" to central point)
3752             },
3753             },
3754             { #PH (NC)
3755             Name => 'PrimaryAFPoint',
3756             Condition => '$$self{PhaseDetectAF} == 5',
3757             Notes => q{
3758             Nikon 1 models with newer 135-point AF and 73-point phase-detect AF -- 9
3759             rows (B-J) and 15 columns (1-15), inside a grid of 11 rows by 15 columns.
3760             The points are numbered sequentially, with F8 at the center
3761             },
3762             PrintConv => {
3763             0 => '(none)',
3764             82 => 'F8 (Center)',
3765             OTHER => sub {
3766             my ($val, $inv) = @_;
3767             return GetAFPointGrid($val, 15, $inv);
3768             },
3769             },
3770             },
3771             { #PH
3772             Name => 'PrimaryAFPoint',
3773             Condition => '$$self{PhaseDetectAF} == 6',
3774             Notes => q{
3775             Nikon 1 models with 171-point AF and 105-point phase-detect AF -- 9 rows
3776             (B-J) and 19 columns (2-20), inside a grid of 11 rows by 21 columns. The
3777             points are numbered sequentially, with F11 at the center
3778             },
3779             PrintConv => {
3780             0 => '(none)',
3781             #22 => 'B2 (Top-left)',
3782             #40 => 'B20 (Top-right)',
3783             115 => 'F11 (Center)',
3784             #190 => 'J2 (Bottom-left)',
3785             #208 => 'J20 (Bottom-right)',
3786             OTHER => sub {
3787             my ($val, $inv) = @_;
3788             return GetAFPointGrid($val, 21, $inv);
3789             },
3790             },
3791             },
3792             { #PH
3793             Name => 'PrimaryAFPoint',
3794             Condition => '$$self{PhaseDetectAF} == 7 and $$self{AFInfo2Version} eq "0100"',
3795             Notes => q{
3796             Nikon models with 153-point AF -- 9 rows (A-I) and 17 columns (1-17): D5,
3797             D500 and D850
3798             },
3799             PrintConvColumns => 5,
3800             PrintConv => {
3801             0 => '(none)',
3802             %afPoints153,
3803             1 => 'E9 (Center)',
3804             },
3805             },
3806             {
3807             Name => 'PrimaryAFPoint',
3808             Condition => '$$self{AFInfo2Version} eq "0100"',
3809             Notes => 'future models?...',
3810             PrintConv => {
3811             0 => '(none)',
3812             1 => 'Center',
3813             },
3814             },
3815             ],
3816             8 => [
3817             { #JD/PH
3818             Name => 'AFPointsUsed',
3819             Condition => '$$self{PhaseDetectAF} < 2 and $$self{AFInfo2Version} !~ /^03/',
3820             Notes => q{
3821             models with 51-point AF -- 5 rows: A1-9, B1-11, C1-11, D1-11, E1-9. Center
3822             point is C6
3823             },
3824             Format => 'undef[7]',
3825             ValueConv => 'join(" ", unpack("H2"x7, $val))',
3826             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
3827             PrintConv => sub { PrintAFPoints(shift, \%afPoints51); },
3828             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints51); },
3829             },
3830             { #10
3831             Name => 'AFPointsUsed',
3832             Condition => '$$self{PhaseDetectAF} == 2',
3833             Notes => 'models with 11-point AF',
3834             # read as int16u in little-endian byte order
3835             Format => 'undef[2]',
3836             ValueConv => 'unpack("v",$val)',
3837             ValueConvInv => 'pack("v",$val)',
3838             PrintConvColumns => 2,
3839             PrintConv => {
3840             0 => '(none)',
3841             0x7ff => 'All 11 Points',
3842             BITMASK => {
3843             0 => 'Center',
3844             1 => 'Top',
3845             2 => 'Bottom',
3846             3 => 'Mid-left',
3847             4 => 'Upper-left',
3848             5 => 'Lower-left',
3849             6 => 'Far Left',
3850             7 => 'Mid-right',
3851             8 => 'Upper-right',
3852             9 => 'Lower-right',
3853             10 => 'Far Right',
3854             },
3855             },
3856             },
3857             { #29/PH
3858             Name => 'AFPointsUsed',
3859             Condition => '$$self{PhaseDetectAF} == 3',
3860             Notes => q{
3861             models with 39-point AF -- 5 rows: A1-3, B1-11, C1-11, D1-11, E1-3. Center
3862             point is C6
3863             },
3864             Format => 'undef[5]',
3865             ValueConv => 'join(" ", unpack("H2"x5, $val))',
3866             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
3867             PrintConv => sub { PrintAFPoints(shift, \%afPoints39); },
3868             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints39); },
3869             },
3870             { #PH (1AW1,1J1,1J2,1J3,1S1,1V1,1V2)
3871             Name => 'AFPointsUsed',
3872             Condition => '$$self{PhaseDetectAF} == 4',
3873             Notes => q{
3874             older models with 135-point AF -- 9 rows (A-I) and 15 columns (1-15).
3875             Center point is E8. The odd-numbered columns, columns 2 and 14, and the
3876             remaining corner points are not used for 41-point AF mode
3877             },
3878             Format => 'undef[17]',
3879             ValueConv => 'join(" ", unpack("H2"x17, $val))',
3880             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
3881             PrintConv => sub { PrintAFPoints(shift, \%afPoints135); },
3882             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints135); },
3883             },
3884             { #PH (1S2)
3885             Name => 'AFPointsUsed',
3886             Condition => '$$self{PhaseDetectAF} == 5',
3887             Notes => q{
3888             newer models with 135-point AF -- 9 rows (B-J) and 15 columns (1-15). Center
3889             point is F8
3890             },
3891             Format => 'undef[21]',
3892             ValueConv => 'join(" ", unpack("H2"x21, $val))',
3893             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
3894             PrintConv => sub { PrintAFPointsGrid(shift, 15); },
3895             PrintConvInv => sub { PrintAFPointsGridInv(shift, 15, 21); },
3896             },
3897             { #PH (1J4,1V3)
3898             Name => 'AFPointsUsed',
3899             Condition => '$$self{PhaseDetectAF} == 6',
3900             Notes => q{
3901             models with 171-point AF -- 9 rows (B-J) and 19 columns (2-20). Center
3902             point is F10
3903             },
3904             Format => 'undef[29]',
3905             ValueConv => 'join(" ", unpack("H2"x29, $val))',
3906             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
3907             PrintConv => sub { PrintAFPointsGrid(shift, 21); },
3908             PrintConvInv => sub { PrintAFPointsGridInv(shift, 21, 29); },
3909             },
3910             { #PH (D5,D500)
3911             Name => 'AFPointsUsed',
3912             Condition => '$$self{PhaseDetectAF} == 7',
3913             Notes => q{
3914             models with 153-point AF -- 9 rows (A-I) and 17 columns (1-17). Center
3915             point is E9
3916             },
3917             Format => 'undef[20]',
3918             ValueConv => 'join(" ", unpack("H2"x20, $val))',
3919             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
3920             PrintConv => sub { PrintAFPoints(shift, \%afPoints153); },
3921             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints153); },
3922             },
3923             { #PH
3924             Name => 'AFPointsUsed',
3925             # version 301 uses a separate field at offset 0x0a for this tag (ref 28)
3926             Condition => '$$self{AFInfo2Version} !~ /^03/',
3927             Format => 'undef[7]',
3928             ValueConv => 'join(" ", unpack("H2"x7, $val))',
3929             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
3930             PrintConv => '"Unknown ($val)"',
3931             PrintConvInv => '$val=~s/Unknown \\((.*)\\)/$1/; $val',
3932             },
3933             { #PH
3934             Name => 'PrimaryAFPoint',
3935             Condition => '$$self{PhaseDetectAF} == 1 and $$self{AFInfo2Version} =~ /^03/',
3936             Notes => 'newer models with 51-point AF',
3937             PrintConvColumns => 5,
3938             PrintConv => {
3939             0 => '(none)',
3940             %afPoints51,
3941             1 => 'C6 (Center)', # (add " (Center)" to central point)
3942             },
3943             },
3944             { #PH (Z7)
3945             Name => 'PrimaryAFPoint',
3946             Condition => '$$self{PhaseDetectAF} == 8 and $$self{AFInfo2Version} =~ /^03/',
3947             PrintConv => {
3948             0 => '(none)',
3949             %afPoints81,
3950             1 => 'E5 (Center)', # (add " (Center)" to central point)
3951             },
3952             },
3953             # this was wrong, but keep the code as a comment in case it may be useful later
3954             #{ #PH (Z7) (NC)
3955             # Name => 'PrimaryAFPoint',
3956             # Condition => '$$self{PhaseDetectAF} == 8 and $$self{AFInfo2Version} =~ /^03/',
3957             # Notes => q{
3958             # Nikon models with 493-point AF -- 17 rows (A-Q) and 29 columns (1-29), I15
3959             # at the center
3960             # },
3961             # PrintConv => {
3962             # 0 => '(none)',
3963             # 246 => 'I15 (Center)',
3964             # OTHER => sub {
3965             # my ($val, $inv) = @_;
3966             # return GetAFPointGrid($val, 29, $inv);
3967             # },
3968             # },
3969             #},
3970             ],
3971             0x0a => [{ #PH (D780)
3972             Name => 'AFPointsUsed',
3973             Condition => '$$self{PhaseDetectAF} == 1 and $$self{AFInfo2Version} =~ /^03/',
3974             Notes => 'newer models with 51-point AF',
3975             Format => 'undef[7]',
3976             ValueConv => 'join(" ", unpack("H2"x7, $val))',
3977             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
3978             PrintConv => sub { PrintAFPoints(shift, \%afPoints51); },
3979             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints51); },
3980             },{ #38 (Z6/Z7/Z50)
3981             Name => 'AFPointsUsed',
3982             Condition => '$$self{PhaseDetectAF} == 8 and $$self{AFInfo2Version} =~ /^03/',
3983             Notes => q{
3984             models with 81-selectable point AF -- 9 rows (A-I) and 9 columns (1-9) for
3985             phase detect AF points. Center point is E5
3986             },
3987             Format => 'undef[11]',
3988             ValueConv => 'join(" ", unpack("H2"x11, $val))',
3989             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
3990             PrintConv => sub { PrintAFPoints(shift, \%afPoints81); },
3991             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints81); },
3992             },{ #28 (D6) in any of the 3 Group modes on the D6, the points specify the outer boundaries of the focus point area; otherwise the tag value is consistent with other Nikon bodies
3993             Name => 'AFPointsUsed',
3994             Condition => '$$self{PhaseDetectAF} == 9 and $$self{AFInfo2Version} =~ /^03/',
3995             Notes => q{
3996             models with 105-point AF -- 7 rows (A-G) and 15 columns (1-15). Center
3997             point is D8
3998             },
3999             Format => 'undef[14]',
4000             ValueConv => 'join(" ", unpack("H2"x14, $val))',
4001             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4002             PrintConv => sub { PrintAFPoints(shift, \%afPoints105); },
4003             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints105); },
4004             }],
4005             0x10 => { #PH (D90 and D5000)
4006             Name => 'AFImageWidth',
4007             Condition => '$$self{AFInfo2Version} eq "0100"',
4008             Format => 'int16u',
4009             RawConv => '$val ? $val : undef',
4010             Notes => 'this and the following tags are valid only for contrast-detect AF',
4011             },
4012             0x12 => { #PH
4013             Name => 'AFImageHeight',
4014             Condition => '$$self{AFInfo2Version} eq "0100"',
4015             Format => 'int16u',
4016             RawConv => '$val ? $val : undef',
4017             },
4018             0x14 => { #PH
4019             Name => 'AFAreaXPosition',
4020             Condition => '$$self{AFInfo2Version} eq "0100"',
4021             Notes => 'center of AF area in AFImage coordinates',
4022             Format => 'int16u',
4023             RawConv => '$val ? $val : undef',
4024             },
4025             0x16 => { #PH
4026             Name => 'AFAreaYPosition',
4027             Condition => '$$self{AFInfo2Version} eq "0100"',
4028             Format => 'int16u',
4029             RawConv => '$val ? $val : undef',
4030             },
4031             # AFAreaWidth/Height for the D90 and D5000:
4032             # 352x288 (AF normal area),
4033             # 704x576 (AF face priority, wide area, subject tracking)
4034             0x18 => { #PH
4035             Name => 'AFAreaWidth',
4036             Condition => '$$self{AFInfo2Version} eq "0100"',
4037             Format => 'int16u',
4038             Notes => 'size of AF area in AFImage coordinates',
4039             RawConv => '$val ? $val : undef',
4040             },
4041             0x1a => { #PH
4042             Name => 'AFAreaHeight',
4043             Condition => '$$self{AFInfo2Version} eq "0100"',
4044             Format => 'int16u',
4045             RawConv => '$val ? $val : undef',
4046             },
4047             0x1c => [
4048             { #PH
4049             Name => 'ContrastDetectAFInFocus',
4050             Condition => '$$self{AFInfo2Version} eq "0100"',
4051             PrintConv => { 0 => 'No', 1 => 'Yes' },
4052             },{ #PH (D500, see forum11190)
4053             Name => 'AFPointsSelected',
4054             Condition => '$$self{AFInfo2Version} eq "0101" and $$self{PhaseDetectAF} == 7',
4055             Format => 'undef[20]',
4056             ValueConv => 'join(" ", unpack("H2"x20, $val))',
4057             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4058             PrintConv => sub { PrintAFPoints(shift, \%afPoints153); },
4059             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints153); },
4060             },
4061             ],
4062             # 0x1d - always zero (with or without live view)
4063             0x2a => { #PH (Z7)
4064             Name => 'AFImageWidth',
4065             Condition => '$$self{AFInfo2Version} =~ /^03/',
4066             Format => 'int16u',
4067             RawConv => '$val ? $val : undef',
4068             },
4069             0x2c => { #PH (Z7)
4070             Name => 'AFImageHeight',
4071             Condition => '$$self{AFInfo2Version} =~ /^03/',
4072             Format => 'int16u',
4073             RawConv => '$val ? $val : undef',
4074             },
4075             0x2e => { #PH (Z7)
4076             Name => 'AFAreaXPosition',
4077             Condition => q{
4078             $$self{ContrastDetectAF} == 2 and $$self{AFInfo2Version} =~ /^03/ or
4079             $$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} =~ /^0301/
4080             },
4081             Format => 'int16u',
4082             },
4083             0x2f => { #28 (Z7) Still photography range 1-17 for the 493 point Z7 (arranged in a 29x17 grid. Center at x=16, y=10).
4084             Name => 'AFFocusPointXPosition',
4085             Condition => q{
4086             $$self{ContrastDetectAF} == 2 and $$self{AFInfo2Version} =~ /^03/ or
4087             $$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} =~ /^0301/
4088             },
4089             PrintConv => sub { my ($val) = @_; PrintAFPointsLeftRight($val, 29 ); },
4090             },
4091             0x30 => [
4092             { #PH (Z7)
4093             Name => 'AFAreaYPosition',
4094             Condition => q{
4095             $$self{ContrastDetectAF} == 2 and $$self{AFInfo2Version} =~ /^03/ or
4096             $$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} =~ /^0301/
4097             },
4098             Format => 'int16u',
4099             },{ #PH (D500, see forum11190)
4100             Name => 'AFPointsInFocus',
4101             Condition => '$$self{AFInfo2Version} eq "0101" and $$self{PhaseDetectAF} == 7',
4102             Notes => 'AF points in focus at the time time image was captured',
4103             Format => 'undef[20]',
4104             ValueConv => 'join(" ", unpack("H2"x20, $val))',
4105             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4106             PrintConv => sub { PrintAFPoints(shift, \%afPoints153); },
4107             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints153); },
4108             },
4109             ],
4110             0x31 => { #28 (Z7)
4111             Name => 'AFFocusPointYPosition',
4112             Condition => q{
4113             $$self{ContrastDetectAF} == 2 and $$self{AFInfo2Version} =~ /^03/ or
4114             $$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} =~ /^0301/
4115             },
4116             PrintConv => sub { my ($val) = @_; PrintAFPointsUpDown($val, 17 ); },
4117             },
4118             0x32 => { #PH (Z7)
4119             Name => 'AFAreaWidth',
4120             Condition => '$$self{AFInfo2Version} =~ /^03/',
4121             Format => 'int16u',
4122             RawConv => '$val ? $val : undef',
4123             },
4124             0x34 => { #PH (Z7)
4125             Name => 'AFAreaHeight',
4126             Condition => '$$self{AFInfo2Version} =~ /^03/',
4127             Format => 'int16u',
4128             RawConv => '$val ? $val : undef',
4129             },
4130             0x38 => { #28
4131             Name => 'PrimaryAFPoint',
4132             Condition => '$$self{PhaseDetectAF} == 9 and $$self{AFInfo2Version} =~ /^03/',
4133             Notes => q{
4134             Nikon models with 105-point AF -- 7 rows (A-G) and 15 columns (1-15): D6
4135             },
4136             PrintConvColumns => 5,
4137             PrintConv => {
4138             0 => '(none)',
4139             %afPoints105,
4140             1 => 'D8 (Center)',
4141             },
4142             },
4143             0x44 => [
4144             {
4145             Name => 'PrimaryAFPoint',
4146             Condition => '$$self{PhaseDetectAF} == 7 and $$self{AFInfo2Version} eq "0101"',
4147             PrintConvColumns => 5,
4148             PrintConv => {
4149             0 => '(none)',
4150             %afPoints153,
4151             1 => 'E9 (Center)',
4152             },
4153             },
4154             { #PH
4155             Name => 'PrimaryAFPoint',
4156             Notes => 'D3500',
4157             Condition => '$$self{PhaseDetectAF} == 2 and $$self{AFInfo2Version} eq "0101"',
4158             PrintConvColumns => 2,
4159             PrintConv => {
4160             0 => '(none)',
4161             1 => 'Center',
4162             2 => 'Top',
4163             3 => 'Bottom',
4164             4 => 'Mid-left',
4165             5 => 'Upper-left',
4166             6 => 'Lower-left',
4167             7 => 'Far Left',
4168             8 => 'Mid-right',
4169             9 => 'Upper-right',
4170             10 => 'Lower-right',
4171             11 => 'Far Right',
4172             },
4173             },
4174             {
4175             Name => 'PrimaryAFPoint',
4176             Condition => '$$self{AFInfo2Version} eq "0101"',
4177             Notes => 'future models?...',
4178             Priority => 0,
4179             PrintConv => {
4180             0 => '(none)',
4181             1 => 'Center',
4182             },
4183             },
4184             ],
4185             0x46 => {
4186             Name => 'AFImageWidth',
4187             Condition => '$$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} eq "0101"',
4188             Format => 'int16u',
4189             RawConv => '$val ? $val : undef',
4190             Notes => 'this and the following tags are valid only for contrast-detect AF',
4191             },
4192             0x48 => {
4193             Name => 'AFImageHeight',
4194             Condition => '$$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} eq "0101"',
4195             Format => 'int16u',
4196             RawConv => '$val ? $val : undef',
4197             },
4198             0x4a => {
4199             Name => 'AFAreaXPosition',
4200             Condition => '$$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} eq "0101"',
4201             Notes => 'center of AF area in AFImage coordinates',
4202             Format => 'int16u',
4203             RawConv => '$val ? $val : undef',
4204             },
4205             0x4c => {
4206             Name => 'AFAreaYPosition',
4207             Condition => '$$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} eq "0101"',
4208             Format => 'int16u',
4209             RawConv => '$val ? $val : undef',
4210             },
4211             0x4e => {
4212             Name => 'AFAreaWidth',
4213             Condition => '$$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} eq "0101"',
4214             Format => 'int16u',
4215             Notes => 'size of AF area in AFImage coordinates',
4216             RawConv => '$val ? $val : undef',
4217             },
4218             0x50 => {
4219             Name => 'AFAreaHeight',
4220             Condition => '$$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} eq "0101"',
4221             Format => 'int16u',
4222             RawConv => '$val ? $val : undef',
4223             },
4224             0x52 => {
4225             Name => 'ContrastDetectAFInFocus',
4226             Condition => '$$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} eq "0101"',
4227             PrintConv => { 0 => 'No', 1 => 'Yes' },
4228             },
4229             );
4230              
4231             %Image::ExifTool::Nikon::AFInfo2V0400 = ( #V0400 related fields begin at x'3c' (Z9)
4232             %binaryDataAttrs,
4233             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4234             DATAMEMBER => [ 0 ],
4235             0 => {
4236             Name => 'AFInfo2Version',
4237             Format => 'undef[4]',
4238             Writable => 0,
4239             RawConv => '$$self{AFInfo2Version} = $val',
4240             },
4241             0x3e => {
4242             Name => 'AFImageWidth',
4243             Format => 'int16u',
4244             },
4245             0x40 => {
4246             Name => 'AFImageHeight',
4247             Format => 'int16u',
4248             },
4249             0x43 => {
4250             Name => 'FocusPositionHorizontal',
4251             Notes => q{
4252             the focus points form a 29x17 grid, but the X,Y coordinate values run from 1,1
4253             to 30,19. The horizontal coordinate 11R (5) and the vertical coordinates 6U
4254             (4) and 2D (12) are not used for some reason
4255             },
4256             # 493 focus points for Z9 fall in a 30x19 grid
4257             # (the 11R (5) position is not used, for a total of 29 columns, ref AlbertShan email)
4258             PrintConv => sub { my ($val) = @_; PrintAFPointsLeftRight($val, 29); },
4259             },
4260             0x45 => {
4261             Name => 'FocusPositionVertical',
4262             # (the 6U (4) and 2D (12) are not used, for a total of 17 rows, ref AlbertShan email)
4263             PrintConv => sub { my ($val) = @_; PrintAFPointsUpDown($val, 17); },
4264             },
4265             0x46 => {
4266             Name => 'AFAreaWidth',
4267             Format => 'int16u',
4268             Notes => 'size of AF area in AFImage pixels',
4269             RawConv => '$val ? $val : undef',
4270             },
4271             0x48 => {
4272             Name => 'AFAreaHeight',
4273             Format => 'int16u',
4274             RawConv => '$val ? $val : undef',
4275             },
4276             0x4a => {
4277             Name => 'FocusResult',
4278             # in Manual Foucs mode, reflects the state of viewfinder focus indicator.
4279             # In AF-C or AF-S, reflects the result of the last AF operation.
4280             PrintConv => { 0=> "Out of Focus", 1=>"Focus"},
4281             },
4282             );
4283              
4284             # Nikon AF fine-tune information (ref 28)
4285             %Image::ExifTool::Nikon::AFTune = (
4286             %binaryDataAttrs,
4287             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4288             0 => {
4289             Name => 'AFFineTune',
4290             PrintConv => {
4291             0 => 'Off',
4292             # (don't know what the difference between 1 and 2 is)
4293             1 => 'On (1)',
4294             2 => 'On (2)',
4295             3 => 'On (Zoom)', #28
4296             },
4297             },
4298             1 => {
4299             Name => 'AFFineTuneIndex',
4300             Notes => 'index of saved lens',
4301             PrintConv => '$val == 255 ? "n/a" : $val',
4302             PrintConvInv => '$val eq "n/a" ? 255 : $val',
4303             },
4304             2 => {
4305             # when AFFineTune = 3 (indicating a zoom lens), this Tag stores the tuning adjustment for the wide end of the zoom range (ref 28)
4306             Name => 'AFFineTuneAdj',
4307             Priority => 0, # so other value takes priority if it exists
4308             Notes => 'may only be valid for saved lenses',
4309             Format => 'int8s',
4310             PrintConv => '$val > 0 ? "+$val" : $val',
4311             PrintConvInv => '$val',
4312             },
4313             3 => {
4314             Name => 'AFFineTuneAdjTele',
4315             # should probably insert a Condition that restricts this to AFFineTune = 3 (ref 28)
4316             Notes => 'only valid for zoom lenses (ie, AFTune=3)',
4317             Format => 'int8s',
4318             PrintConv => '$val > 0 ? "+$val" : $val',
4319             PrintConvInv => '$val',
4320             },
4321             );
4322              
4323             # Nikon NEF processing information (ref forum6281)
4324             %Image::ExifTool::Nikon::RetouchInfo = (
4325             %binaryDataAttrs,
4326             FORMAT => 'int8s',
4327             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4328             DATAMEMBER => [ 0 ],
4329             0 => {
4330             Name => 'RetouchInfoVersion',
4331             Format => 'undef[4]',
4332             Writable => 0,
4333             RawConv => '$$self{RetouchInfoVersion} = $val',
4334             },
4335             # 4 - RetouchExposureComp (+$val/6 or -$val/6?)
4336             5 => {
4337             Name => 'RetouchNEFProcessing',
4338             Condition => '$$self{RetouchInfoVersion} ge "0200"',
4339             PrintConv => {
4340             -1 => 'Off',
4341             1 => 'On',
4342             },
4343             },
4344             );
4345              
4346             # Nikon File information - D60, D3 and D300 (ref PH)
4347             %Image::ExifTool::Nikon::FileInfo = (
4348             %binaryDataAttrs,
4349             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
4350             FORMAT => 'int16u',
4351             0 => {
4352             Name => 'FileInfoVersion',
4353             Format => 'undef[4]',
4354             Writable => 0,
4355             },
4356             2 => 'MemoryCardNumber',
4357             3 => {
4358             Name => 'DirectoryNumber',
4359             PrintConv => 'sprintf("%.3d", $val)',
4360             PrintConvInv => '$val',
4361             },
4362             4 => {
4363             Name => 'FileNumber',
4364             PrintConv => 'sprintf("%.4d", $val)',
4365             PrintConvInv => '$val',
4366             },
4367             );
4368              
4369             # ref PH
4370             %Image::ExifTool::Nikon::BarometerInfo = (
4371             %binaryDataAttrs,
4372             GROUPS => { 0 => 'MakerNotes', 2 => 'Location' },
4373             0 => {
4374             Name => 'BarometerInfoVersion',
4375             Format => 'undef[4]',
4376             Writable => 0,
4377             },
4378             6 => {
4379             Name => 'Altitude',
4380             Format => 'int32s',
4381             PrintConv => '"$val m"', # (always stored as metres)
4382             PrintConvInv => '$val=~s/\s*m$//; $val',
4383             },
4384             # 10: int16u - values: 0 (display in metres?), 18 (display in feet?)
4385             );
4386              
4387             # ref PH
4388             %Image::ExifTool::Nikon::CaptureOffsets = (
4389             PROCESS_PROC => \&ProcessNikonCaptureOffsets,
4390             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4391             # (note that these are duplicates of offsets in the normal TIFF structure,
4392             # and that these offsets are not updated when ExifTool rewrites the file)
4393             1 => 'IFD0_Offset',
4394             2 => 'PreviewIFD_Offset',
4395             3 => 'SubIFD_Offset',
4396             );
4397              
4398             # ref PH (Written by capture NX)
4399             %Image::ExifTool::Nikon::CaptureOutput = (
4400             %binaryDataAttrs,
4401             FORMAT => 'int32u',
4402             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
4403             # 1 = 1
4404             2 => 'OutputImageWidth',
4405             3 => 'OutputImageHeight',
4406             4 => 'OutputResolution',
4407             # 5 = 1
4408             );
4409              
4410             # ref IB
4411             %Image::ExifTool::Nikon::ColorBalanceA = (
4412             %binaryDataAttrs,
4413             FORMAT => 'int16u',
4414             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4415             624 => { #4
4416             Name => 'WB_RBLevels',
4417             Notes => 'as shot', #IB
4418             Format => 'int16u[2]',
4419             Protected => 1,
4420             },
4421             626 => {
4422             Name => 'WB_RBLevelsAuto',
4423             Format => 'int16u[2]',
4424             Protected => 1,
4425             },
4426             628 => {
4427             Name => 'WB_RBLevelsDaylight',
4428             Notes => 'red/blue levels for 0,+3,+2,+1,-1,-2,-3',
4429             Format => 'int16u[14]',
4430             Protected => 1,
4431             },
4432             642 => {
4433             Name => 'WB_RBLevelsIncandescent',
4434             Format => 'int16u[14]',
4435             Protected => 1,
4436             },
4437             656 => {
4438             Name => 'WB_RBLevelsFluorescent',
4439             Format => 'int16u[6]',
4440             Notes => 'red/blue levels for fluorescent W,N,D',
4441             Protected => 1,
4442             },
4443             662 => {
4444             Name => 'WB_RBLevelsCloudy',
4445             Format => 'int16u[14]',
4446             Protected => 1,
4447             },
4448             676 => {
4449             Name => 'WB_RBLevelsFlash',
4450             Format => 'int16u[14]',
4451             Protected => 1,
4452             },
4453             690 => {
4454             Name => 'WB_RBLevelsShade',
4455             Condition => '$$self{Model} ne "E8700"',
4456             Notes => 'not valid for E8700',
4457             Format => 'int16u[14]',
4458             Protected => 1,
4459             },
4460             );
4461              
4462             my %nrwLevels = (
4463             Format => 'int32u[4]',
4464             Protected => 1,
4465             ValueConv => 'my @a=split " ",$val;$a[0]*=2;$a[3]*=2;"@a"',
4466             ValueConvInv => 'my @a=split " ",$val;$a[0]/=2;$a[3]/=2;"@a"',
4467             );
4468              
4469             # (ref IB)
4470             %Image::ExifTool::Nikon::ColorBalanceB = (
4471             %binaryDataAttrs,
4472             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4473             NOTES => 'Color balance tags used by the P6000.',
4474             0x0004 => {
4475             Name => 'ColorBalanceVersion',
4476             Format => 'undef[4]',
4477             },
4478             0x13e8 => { Name => 'WB_RGGBLevels', %nrwLevels },
4479             0x13f8 => { Name => 'WB_RGGBLevelsDaylight', %nrwLevels },
4480             0x1408 => { Name => 'WB_RGGBLevelsCloudy', %nrwLevels },
4481             0x1428 => { Name => 'WB_RGGBLevelsTungsten', %nrwLevels },
4482             0x1438 => { Name => 'WB_RGGBLevelsFluorescentW',%nrwLevels },
4483             0x1448 => { Name => 'WB_RGGBLevelsFlash', %nrwLevels },
4484             0x1468 => { Name => 'WB_RGGBLevelsCustom', %nrwLevels, Notes => 'all zero if preset WB not used' },
4485             0x1478 => { Name => 'WB_RGGBLevelsAuto', %nrwLevels },
4486             );
4487              
4488             # (ref IB)
4489             %Image::ExifTool::Nikon::ColorBalanceC = (
4490             %binaryDataAttrs,
4491             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4492             DATAMEMBER => [ 4 ],
4493             NOTES => 'Color balance tags used by the P1000, P7000, P7100 and B700.',
4494             0x0004 => {
4495             Name => 'ColorBalanceVersion',
4496             Format => 'undef[4]',
4497             RawConv => '$$self{ColorBalanceVersion} = $val',
4498             },
4499             0x0020 => { Name => 'BlackLevel', Format => 'int16u' },
4500             0x0038 => { Name => 'WB_RGGBLevels', %nrwLevels },
4501             0x004c => { Name => 'WB_RGGBLevelsDaylight', %nrwLevels },
4502             0x0060 => { Name => 'WB_RGGBLevelsCloudy', %nrwLevels },
4503             0x0074 => {
4504             Name => 'WB_RGGBLevelsShade',
4505             Condition => '$$self{ColorBalanceVersion} ge "0104"',
4506             Notes => 'valid only for some models',
4507             %nrwLevels,
4508             },
4509             0x0088 => { Name => 'WB_RGGBLevelsTungsten', %nrwLevels },
4510             0x009c => { Name => 'WB_RGGBLevelsFluorescentW',%nrwLevels },
4511             0x00b0 => { Name => 'WB_RGGBLevelsFluorescentN',%nrwLevels },
4512             0x00c4 => { Name => 'WB_RGGBLevelsFluorescentD',%nrwLevels },
4513             0x00d8 => { Name => 'WB_RGGBLevelsHTMercury', %nrwLevels },
4514             0x0100 => { Name => 'WB_RGGBLevelsCustom', %nrwLevels, Notes => 'all zero if preset WB not used' },
4515             0x0114 => { Name => 'WB_RGGBLevelsAuto', %nrwLevels },
4516             );
4517              
4518             # ref 4
4519             %Image::ExifTool::Nikon::ColorBalance1 = (
4520             %binaryDataAttrs,
4521             FORMAT => 'int16u',
4522             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4523             0 => {
4524             Name => 'WB_RBGGLevels',
4525             Format => 'int16u[4]',
4526             Protected => 1,
4527             },
4528             );
4529              
4530             # ref 4
4531             %Image::ExifTool::Nikon::ColorBalance2 = (
4532             %binaryDataAttrs,
4533             FORMAT => 'int16u',
4534             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4535             NOTES => 'This information is encrypted for most camera models.',
4536             0 => {
4537             Name => 'WB_RGGBLevels',
4538             Format => 'int16u[4]',
4539             Protected => 1,
4540             },
4541             );
4542              
4543             # ref 4
4544             %Image::ExifTool::Nikon::ColorBalance3 = (
4545             %binaryDataAttrs,
4546             FORMAT => 'int16u',
4547             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4548             0 => {
4549             Name => 'WB_RGBGLevels',
4550             Format => 'int16u[4]',
4551             Protected => 1,
4552             },
4553             );
4554              
4555             # ref 4
4556             %Image::ExifTool::Nikon::ColorBalance4 = (
4557             %binaryDataAttrs,
4558             FORMAT => 'int16u',
4559             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4560             0 => {
4561             Name => 'WB_GRBGLevels',
4562             Format => 'int16u[4]',
4563             Protected => 1,
4564             },
4565             );
4566              
4567             %Image::ExifTool::Nikon::ColorBalanceUnknown = (
4568             %binaryDataAttrs,
4569             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4570             0 => {
4571             Name => 'ColorBalanceVersion',
4572             Format => 'undef[4]',
4573             },
4574             );
4575              
4576             %Image::ExifTool::Nikon::Type2 = (
4577             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
4578             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
4579             WRITABLE => 1,
4580             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4581             0x0003 => 'Quality',
4582             0x0004 => 'ColorMode',
4583             0x0005 => 'ImageAdjustment',
4584             0x0006 => 'CCDSensitivity',
4585             0x0007 => 'WhiteBalance',
4586             0x0008 => 'Focus',
4587             0x000A => 'DigitalZoom',
4588             0x000B => 'Converter',
4589             );
4590              
4591             # these are standard EXIF tags, but they are duplicated here so we can
4592             # set the family 0 group to 'MakerNotes' and set the MINOR_ERRORS flag
4593             %Image::ExifTool::Nikon::PreviewIFD = (
4594             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
4595             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
4596             GROUPS => { 0 => 'MakerNotes', 1 => 'PreviewIFD', 2 => 'Image'},
4597             VARS => { MINOR_ERRORS => 1 }, # this IFD is non-essential and often corrupted
4598             # (these tags are priority 0 by default because PreviewIFD is flagged in LOW_PRIORITY_DIR)
4599             0xfe => { # (not used by Nikon, but SRW images also use this table)
4600             Name => 'SubfileType',
4601             DataMember => 'SubfileType',
4602             RawConv => '$$self{SubfileType} = $val',
4603             PrintConv => \%Image::ExifTool::Exif::subfileType,
4604             },
4605             0x103 => {
4606             Name => 'Compression',
4607             SeparateTable => 'EXIF Compression',
4608             PrintConv => \%Image::ExifTool::Exif::compression,
4609             },
4610             0x11a => 'XResolution',
4611             0x11b => 'YResolution',
4612             0x128 => {
4613             Name => 'ResolutionUnit',
4614             PrintConv => {
4615             1 => 'None',
4616             2 => 'inches',
4617             3 => 'cm',
4618             },
4619             },
4620             0x201 => {
4621             Name => 'PreviewImageStart',
4622             Flags => [ 'IsOffset', 'Permanent' ],
4623             OffsetPair => 0x202,
4624             DataTag => 'PreviewImage',
4625             Writable => 'int32u',
4626             WriteGroup => 'MakerNotes',
4627             Protected => 2,
4628             },
4629             0x202 => {
4630             Name => 'PreviewImageLength',
4631             Flags => 'Permanent' ,
4632             OffsetPair => 0x201,
4633             DataTag => 'PreviewImage',
4634             Writable => 'int32u',
4635             WriteGroup => 'MakerNotes',
4636             Protected => 2,
4637             },
4638             0x213 => {
4639             Name => 'YCbCrPositioning',
4640             PrintConv => {
4641             1 => 'Centered',
4642             2 => 'Co-sited',
4643             },
4644             },
4645             );
4646              
4647             # these are duplicated enough times to make it worthwhile to define them centrally
4648             my %nikonApertureConversions = (
4649             ValueConv => '2**($val/24)',
4650             ValueConvInv => '$val>0 ? 24*log($val)/log(2) : 0',
4651             PrintConv => 'sprintf("%.1f",$val)',
4652             PrintConvInv => '$val',
4653             );
4654              
4655             my %nikonFocalConversions = (
4656             ValueConv => '5 * 2**($val/24)',
4657             ValueConvInv => '$val>0 ? 24*log($val/5)/log(2) : 0',
4658             PrintConv => 'sprintf("%.1f mm",$val)',
4659             PrintConvInv => '$val=~s/\s*mm$//;$val',
4660             );
4661              
4662             # Version 100 Nikon lens data
4663             %Image::ExifTool::Nikon::LensData00 = (
4664             %binaryDataAttrs,
4665             NOTES => 'This structure is used by the D100, and D1X with firmware version 1.1.',
4666             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4667             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
4668             0x00 => {
4669             Name => 'LensDataVersion',
4670             Format => 'undef[4]',
4671             Writable => 0,
4672             },
4673             0x06 => { #8
4674             Name => 'LensIDNumber',
4675             Notes => 'see LensID values below',
4676             },
4677             0x07 => { #8
4678             Name => 'LensFStops',
4679             ValueConv => '$val / 12',
4680             ValueConvInv => '$val * 12',
4681             PrintConv => 'sprintf("%.2f", $val)',
4682             PrintConvInv => '$val',
4683             },
4684             0x08 => { #8/9
4685             Name => 'MinFocalLength',
4686             %nikonFocalConversions,
4687             },
4688             0x09 => { #8/9
4689             Name => 'MaxFocalLength',
4690             %nikonFocalConversions,
4691             },
4692             0x0a => { #8
4693             Name => 'MaxApertureAtMinFocal',
4694             %nikonApertureConversions,
4695             },
4696             0x0b => { #8
4697             Name => 'MaxApertureAtMaxFocal',
4698             %nikonApertureConversions,
4699             },
4700             0x0c => 'MCUVersion', #8 (MCU = Micro Controller Unit)
4701             );
4702              
4703             # Nikon lens data (note: needs decrypting if LensDataVersion is 020x)
4704             %Image::ExifTool::Nikon::LensData01 = (
4705             %binaryDataAttrs,
4706             NOTES => q{
4707             Nikon encrypts the LensData information below if LensDataVersion is 0201 or
4708             higher, but the decryption algorithm is known so the information can be
4709             extracted.
4710             },
4711             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4712             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
4713             0x00 => {
4714             Name => 'LensDataVersion',
4715             Format => 'string[4]',
4716             Writable => 0,
4717             },
4718             0x04 => { #8
4719             Name => 'ExitPupilPosition',
4720             ValueConv => '$val ? 2048 / $val : $val',
4721             ValueConvInv => '$val ? 2048 / $val : $val',
4722             PrintConv => 'sprintf("%.1f mm",$val)',
4723             PrintConvInv => '$val=~s/\s*mm$//; $val',
4724             },
4725             0x05 => { #8
4726             Name => 'AFAperture',
4727             %nikonApertureConversions,
4728             },
4729             0x08 => { #8
4730             # this seems to be 2 values: the upper nibble gives the far focus
4731             # range and the lower nibble gives the near focus range. The values
4732             # are in the range 1-N, where N is lens-dependent. A value of 0 for
4733             # the far focus range indicates infinity. (ref JD)
4734             Name => 'FocusPosition',
4735             PrintConv => 'sprintf("0x%02x", $val)',
4736             PrintConvInv => '$val',
4737             },
4738             0x09 => { #8/9
4739             # With older AF lenses this does not work... (ref 13)
4740             # eg) AF Nikkor 50mm f/1.4 => 48 (0x30)
4741             # AF Zoom-Nikkor 35-105mm f/3.5-4.5 => @35mm => 15 (0x0f), @105mm => 141 (0x8d)
4742             Notes => 'this focus distance is approximate, and not very accurate for some lenses',
4743             Name => 'FocusDistance',
4744             ValueConv => '0.01 * 10**($val/40)', # in m
4745             ValueConvInv => '$val>0 ? 40*log($val*100)/log(10) : 0',
4746             PrintConv => '$val ? sprintf("%.2f m",$val) : "inf"',
4747             PrintConvInv => '$val eq "inf" ? 0 : $val =~ s/\s*m$//, $val',
4748             },
4749             0x0a => { #8/9
4750             Name => 'FocalLength',
4751             Priority => 0,
4752             %nikonFocalConversions,
4753             },
4754             0x0b => { #8
4755             Name => 'LensIDNumber',
4756             Notes => 'see LensID values below',
4757             },
4758             0x0c => { #8
4759             Name => 'LensFStops',
4760             ValueConv => '$val / 12',
4761             ValueConvInv => '$val * 12',
4762             PrintConv => 'sprintf("%.2f", $val)',
4763             PrintConvInv => '$val',
4764             },
4765             0x0d => { #8/9
4766             Name => 'MinFocalLength',
4767             %nikonFocalConversions,
4768             },
4769             0x0e => { #8/9
4770             Name => 'MaxFocalLength',
4771             %nikonFocalConversions,
4772             },
4773             0x0f => { #8
4774             Name => 'MaxApertureAtMinFocal',
4775             %nikonApertureConversions,
4776             },
4777             0x10 => { #8
4778             Name => 'MaxApertureAtMaxFocal',
4779             %nikonApertureConversions,
4780             },
4781             0x11 => 'MCUVersion', #8 (MCU = Micro Controller Unit)
4782             0x12 => { #8
4783             Name => 'EffectiveMaxAperture',
4784             %nikonApertureConversions,
4785             },
4786             );
4787              
4788             # Nikon lens data (note: needs decrypting)
4789             %Image::ExifTool::Nikon::LensData0204 = (
4790             %binaryDataAttrs,
4791             NOTES => q{
4792             Nikon encrypts the LensData information below if LensDataVersion is 0201 or
4793             higher, but the decryption algorithm is known so the information can be
4794             extracted.
4795             },
4796             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4797             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
4798             0x00 => {
4799             Name => 'LensDataVersion',
4800             Format => 'string[4]',
4801             Writable => 0,
4802             },
4803             0x04 => { #8
4804             Name => 'ExitPupilPosition',
4805             ValueConv => '$val ? 2048 / $val : $val',
4806             ValueConvInv => '$val ? 2048 / $val : $val',
4807             PrintConv => 'sprintf("%.1f mm",$val)',
4808             PrintConvInv => '$val=~s/\s*mm$//; $val',
4809             },
4810             0x05 => { #8
4811             Name => 'AFAperture',
4812             %nikonApertureConversions,
4813             },
4814             0x08 => { #8
4815             # this seems to be 2 values: the upper nibble gives the far focus
4816             # range and the lower nibble gives the near focus range. The values
4817             # are in the range 1-N, where N is lens-dependent. A value of 0 for
4818             # the far focus range indicates infinity. (ref JD)
4819             Name => 'FocusPosition',
4820             PrintConv => 'sprintf("0x%02x", $val)',
4821             PrintConvInv => '$val',
4822             },
4823             # --> extra byte at position 0x09 in this version of LensData (PH)
4824             0x0a => { #8/9
4825             # With older AF lenses this does not work... (ref 13)
4826             # eg) AF Nikkor 50mm f/1.4 => 48 (0x30)
4827             # AF Zoom-Nikkor 35-105mm f/3.5-4.5 => @35mm => 15 (0x0f), @105mm => 141 (0x8d)
4828             Notes => 'this focus distance is approximate, and not very accurate for some lenses',
4829             Name => 'FocusDistance',
4830             ValueConv => '0.01 * 10**($val/40)', # in m
4831             ValueConvInv => '$val>0 ? 40*log($val*100)/log(10) : 0',
4832             PrintConv => '$val ? sprintf("%.2f m",$val) : "inf"',
4833             PrintConvInv => '$val eq "inf" ? 0 : $val =~ s/\s*m$//, $val',
4834             },
4835             0x0b => { #8/9
4836             Name => 'FocalLength',
4837             Priority => 0,
4838             %nikonFocalConversions,
4839             },
4840             0x0c => { #8
4841             Name => 'LensIDNumber',
4842             Notes => 'see LensID values below',
4843             },
4844             0x0d => { #8
4845             Name => 'LensFStops',
4846             ValueConv => '$val / 12',
4847             ValueConvInv => '$val * 12',
4848             PrintConv => 'sprintf("%.2f", $val)',
4849             PrintConvInv => '$val',
4850             },
4851             0x0e => { #8/9
4852             Name => 'MinFocalLength',
4853             %nikonFocalConversions,
4854             },
4855             0x0f => { #8/9
4856             Name => 'MaxFocalLength',
4857             %nikonFocalConversions,
4858             },
4859             0x10 => { #8
4860             Name => 'MaxApertureAtMinFocal',
4861             %nikonApertureConversions,
4862             },
4863             0x11 => { #8
4864             Name => 'MaxApertureAtMaxFocal',
4865             %nikonApertureConversions,
4866             },
4867             0x12 => 'MCUVersion', #8 (MCU = Micro Controller Unit)
4868             0x13 => { #8
4869             Name => 'EffectiveMaxAperture',
4870             %nikonApertureConversions,
4871             },
4872             );
4873              
4874             # Nikon lens data version 0400 (note: needs decrypting) (ref PH)
4875             %Image::ExifTool::Nikon::LensData0400 = (
4876             %binaryDataAttrs,
4877             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4878             NOTES => 'Tags extracted from the encrypted lens data of the Nikon 1J1/1V1/1J2.',
4879             0x00 => {
4880             Name => 'LensDataVersion',
4881             Format => 'string[4]',
4882             Writable => 0,
4883             },
4884             0x18a => { #PH
4885             Name => 'LensModel',
4886             Format => 'string[64]',
4887             },
4888             );
4889              
4890             # Nikon lens data version 0402 (note: needs decrypting) (ref PH)
4891             %Image::ExifTool::Nikon::LensData0402 = (
4892             %binaryDataAttrs,
4893             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4894             NOTES => 'Tags extracted from the encrypted lens data of the Nikon 1J3/1S1/1V2.',
4895             0x00 => {
4896             Name => 'LensDataVersion',
4897             Format => 'string[4]',
4898             Writable => 0,
4899             },
4900             0x18b => { #PH
4901             Name => 'LensModel',
4902             Format => 'string[64]',
4903             },
4904             );
4905              
4906             # Nikon lens data version 0403 (note: needs decrypting) (ref PH)
4907             %Image::ExifTool::Nikon::LensData0403 = (
4908             %binaryDataAttrs,
4909             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4910             NOTES => 'Tags extracted from the encrypted lens data of the Nikon 1J4/1J5.',
4911             0x00 => {
4912             Name => 'LensDataVersion',
4913             Format => 'string[4]',
4914             Writable => 0,
4915             },
4916             0x2ac => { #PH
4917             Name => 'LensModel',
4918             Format => 'string[64]',
4919             },
4920             );
4921              
4922             # Nikon Z lens data (note: needs decrypting) (ref PH, based on LensData0204)
4923             %Image::ExifTool::Nikon::LensData0800 = (
4924             %binaryDataAttrs,
4925             NOTES => 'Tags found in the encrypted LensData from cameras such as the Z6 and Z7.',
4926             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4927             DATAMEMBER => [ 0x03, 0x2f, 0x35, 0x4c, 0x56 ],
4928             0x00 => {
4929             Name => 'LensDataVersion',
4930             Format => 'string[4]',
4931             Writable => 0,
4932             },
4933             0x03 => { # look forward to see if new old data exists...
4934             Name => 'OldLensData',
4935             Format => 'undef[17]',
4936             RawConv => '$$self{OldLensData} = 1 unless $val =~ /^.\0+$/s; undef',
4937             Hidden => 1,
4938             },
4939             0x04 => {
4940             Name => 'ExitPupilPosition',
4941             Condition => '$$self{OldLensData}',
4942             ValueConv => '$val ? 2048 / $val : $val',
4943             ValueConvInv => '$val ? 2048 / $val : $val',
4944             PrintConv => 'sprintf("%.1f mm",$val)',
4945             PrintConvInv => '$val=~s/\s*mm$//; $val',
4946             },
4947             0x05 => {
4948             Name => 'AFAperture',
4949             Condition => '$$self{OldLensData}',
4950             %nikonApertureConversions,
4951             },
4952             # --> another extra byte at position 0x08 in this version of LensData (PH)
4953             #0x09 => {
4954             # Name => 'FocusPosition', #28 - this appears to be copied from an older version of LensData and is no longer valid. Text with Z9 and Z7_2 with a variety of lenses
4955             # Condition => '$$self{OldLensData}',
4956             # PrintConv => 'sprintf("0x%02x", $val)',
4957             # PrintConvInv => '$val',
4958             #},
4959             0x0b => {
4960             Notes => 'this focus distance is approximate, and not very accurate for some lenses',
4961             Name => 'FocusDistance',
4962             Condition => '$$self{OldLensData}',
4963             ValueConv => '0.01 * 10**($val/40)', # in m
4964             ValueConvInv => '$val>0 ? 40*log($val*100)/log(10) : 0',
4965             PrintConv => '$val ? sprintf("%.2f m",$val) : "inf"',
4966             PrintConvInv => '$val eq "inf" ? 0 : $val =~ s/\s*m$//, $val',
4967             },
4968             0x0c => {
4969             Name => 'FocalLength',
4970             Condition => '$$self{OldLensData}',
4971             Priority => 0,
4972             %nikonFocalConversions,
4973             },
4974             0x0d => {
4975             Name => 'LensIDNumber',
4976             Condition => '$$self{OldLensData}',
4977             Notes => 'see LensID values below',
4978             },
4979             0x0e => {
4980             Name => 'LensFStops',
4981             Condition => '$$self{OldLensData}',
4982             ValueConv => '$val / 12',
4983             ValueConvInv => '$val * 12',
4984             PrintConv => 'sprintf("%.2f", $val)',
4985             PrintConvInv => '$val',
4986             },
4987             0x0f => {
4988             Name => 'MinFocalLength',
4989             Condition => '$$self{OldLensData}',
4990             %nikonFocalConversions,
4991             },
4992             0x10 => {
4993             Name => 'MaxFocalLength',
4994             Condition => '$$self{OldLensData}',
4995             %nikonFocalConversions,
4996             },
4997             0x11 => {
4998             Name => 'MaxApertureAtMinFocal',
4999             Condition => '$$self{OldLensData}',
5000             %nikonApertureConversions,
5001             },
5002             0x12 => {
5003             Name => 'MaxApertureAtMaxFocal',
5004             Condition => '$$self{OldLensData}',
5005             %nikonApertureConversions,
5006             },
5007             0x13 => {
5008             Name => 'MCUVersion',
5009             Condition => '$$self{OldLensData}',
5010             },
5011             0x14 => {
5012             Name => 'EffectiveMaxAperture',
5013             Condition => '$$self{OldLensData}',
5014             %nikonApertureConversions,
5015             },
5016             #
5017             # ---- new LensData tags used by Nikkor Z cameras (ref PH/28). ----
5018             # (some fields are strictly for Z-series lenses, others apply to legacy F-mount as well, ref 28)
5019             #
5020             0x2f => { # look forward to see if new lens data exists...
5021             Name => 'NewLensData',
5022             Format => 'undef[17]',
5023             RawConv => '$$self{NewLensData} = 1 unless $val =~ /^.\0+$/s; undef',
5024             Hidden => 1,
5025             },
5026             0x30 => { #PH
5027             Name => 'LensID',
5028             Condition => '$$self{NewLensData}',
5029             Notes => 'tags from here onward used for Nikkor Z lenses only',
5030             Format => 'int16u',
5031             PrintConv => {
5032             1 => 'Nikkor Z 24-70mm f/4 S',
5033             2 => 'Nikkor Z 14-30mm f/4 S',
5034             4 => 'Nikkor Z 35mm f/1.8 S',
5035             8 => 'Nikkor Z 58mm f/0.95 S Noct', #IB
5036             9 => 'Nikkor Z 50mm f/1.8 S',
5037             11 => 'Nikkor Z DX 16-50mm f/3.5-6.3 VR',
5038             12 => 'Nikkor Z DX 50-250mm f/4.5-6.3 VR',
5039             13 => 'Nikkor Z 24-70mm f/2.8 S',
5040             14 => 'Nikkor Z 85mm f/1.8 S',
5041             15 => 'Nikkor Z 24mm f/1.8 S', #IB
5042             16 => 'Nikkor Z 70-200mm f/2.8 VR S', #IB
5043             17 => 'Nikkor Z 20mm f/1.8 S', #IB
5044             18 => 'Nikkor Z 24-200mm f/4-6.3 VR', #IB
5045             21 => 'Nikkor Z 50mm f/1.2 S', #IB
5046             22 => 'Nikkor Z 24-50mm f/4-6.3', #IB
5047             23 => 'Nikkor Z 14-24mm f/2.8 S', #IB
5048             24 => 'Nikkor Z MC 105mm f/2.8 VR S', #IB
5049             27 => 'Nikkor Z MC 50mm f/2.8', #IB
5050             28 => 'Nikkor Z 100-400mm f/4.5-5.6 VR S', #28
5051             29 => 'Nikkor Z 28mm f/2.8', #IB
5052             30 => 'Nikkor Z 400mm f/2.8 TC VR S', #28
5053             31 => 'Nikkor Z 24-120 f/4', #28
5054             32 => 'Nikkor Z 800mm f/6.3 VR S', #28
5055             36 => 'Nikkor Z 400mm f/4.5 VR S', #IB
5056             },
5057             },
5058             0x35 => { #28
5059             Name => 'LensMountType',
5060             RawConv => '$$self{LensMountType} = $val', # 0=> DSLR lens via FTZ style adapter; 1=> Native Z lens;
5061             Format => 'int8u',
5062             Unknown => 1,
5063             PrintConv => {
5064             0 => 'F-mount Lens',
5065             1 => 'Z-mount Lens',
5066             },
5067             },
5068             0x36 => { #PH
5069             Name => 'MaxAperture',
5070             Condition => '$$self{NewLensData}',
5071             Format => 'int16u',
5072             Priority => 0,
5073             ValueConv => '2**($val/384-1)',
5074             ValueConvInv => '384*(log($val)/log(2)+1)',
5075             PrintConv => 'sprintf("%.1f",$val)',
5076             PrintConvInv => '$val',
5077             },
5078             0x38 => { #PH
5079             Name => 'FNumber',
5080             Condition => '$$self{NewLensData}',
5081             Format => 'int16u',
5082             Priority => 0,
5083             ValueConv => '2**($val/384-1)',
5084             ValueConvInv => '384*(log($val)/log(2)+1)',
5085             PrintConv => 'sprintf("%.1f",$val)',
5086             PrintConvInv => '$val',
5087             },
5088             0x3c => { #PH
5089             Name => 'FocalLength',
5090             Condition => '$$self{NewLensData}',
5091             Format => 'int16u',
5092             Priority => 0,
5093             PrintConv => '"$val mm"',
5094             PrintConvInv => '$val=~s/\s*mm$//;$val',
5095             },
5096             0x4c => { #28
5097             Name => 'FocusDistanceRangeWidth', #reflects the number of discrete absolute lens positions that are mapped to the reported FocusDistance. Will be 1 near CFD reflecting very narrow focus distance bands (i.e., quite accurate). Near Infinity will be something like 32. Note: 0 at infinity.
5098             Format => 'int8u',
5099             Condition => '$$self{NewLensData} and $$self{LensMountType} and $$self{LensMountType} == 1',
5100             RawConv => '$$self{FocusDistanceRangeWidth} = $val',
5101             Unknown => 1,
5102             },
5103             0x4e => { #28
5104             Name => 'FocusDistance',
5105             Format => 'int16u',
5106             Condition => '$$self{NewLensData} and $$self{LensMountType} and $$self{LensMountType} == 1',
5107             RawConv => '$val = $val/256', # 1st byte is the fractional component. This byte was not previously considered in the legacy calculation (which only used the 2nd byte). When 2nd byte < 80; distance is < 1 meter
5108             ValueConv => '0.01 * 10**($val/40)', # in m
5109             ValueConvInv => '$val>0 ? 40*log($val*100)/log(10) : 0',
5110             PrintConv => q{
5111             (defined $$self{FocusDistanceRangeWidth} and not $$self{FocusDistanceRangeWidth}) ? "Inf" : $val < 1 ? $val < 0.35 ? sprintf("%.4f m", $val): sprintf("%.3f m", $val): sprintf("%.2f m", $val), #distances less than 35mm are quite accurate with increasingly less precision past 1m
5112             },
5113             },
5114             0x56 => { #28
5115             Name => 'LensDriveEnd', # byte contains: 1 at CFD/MOD; 2 at Infinity; 0 otherwise
5116             Condition => '$$self{NewLensData} and $$self{LensMountType} and $$self{LensMountType} == 1',
5117             Format => 'int8u',
5118             RawConv => 'unless (defined $$self{FocusDistanceRangeWidth} and not $$self{FocusDistanceRangeWidth}) { if ($val == 0 ) {$$self{LensDriveEnd} = "No"} else { $$self{LensDriveEnd} = "CFD"}; } else{ $$self{LensDriveEnd} = "Inf"}',
5119             Unknown => 1,
5120             },
5121             0x5a => { #28
5122             Name => 'LensPositionAbsolute', # <=0 at infinity. Typical value at CFD might be 58000. Only valid for Z-mount lenses.
5123             Condition => '$$self{NewLensData} and $$self{LensMountType} and $$self{LensMountType} == 1',
5124             Format => 'int32s',
5125             Unknown => 1,
5126             },
5127             );
5128              
5129             # Unknown Nikon lens data (note: data may need decrypting after byte 4)
5130             %Image::ExifTool::Nikon::LensDataUnknown = (
5131             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
5132             FIRST_ENTRY => 0,
5133             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5134             0x00 => {
5135             Name => 'LensDataVersion',
5136             Format => 'string[4]',
5137             },
5138             );
5139              
5140             # shot information (encrypted in some cameras) - ref 18
5141             %Image::ExifTool::Nikon::ShotInfo = (
5142             %binaryDataAttrs,
5143             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5144             DATAMEMBER => [ 0 ],
5145             NOTES => q{
5146             This information is encrypted for ShotInfoVersion 02xx, and some tags are
5147             only valid for specific models.
5148             },
5149             0x00 => {
5150             Name => 'ShotInfoVersion',
5151             Format => 'string[4]',
5152             Writable => 0,
5153             RawConv => '$$self{ShotInfoVersion} = $val; $val =~ /^\d+$/ ? $val : undef',
5154             },
5155             0x04 => {
5156             Name => 'FirmwareVersion',
5157             Format => 'string[5]',
5158             Writable => 0,
5159             RawConv => '$val =~ /^\d\.\d+.$/ ? $val : undef',
5160             },
5161             0x10 => {
5162             Name => 'DistortionControl',
5163             Condition => '$$self{Model} =~ /P6000\b/',
5164             Notes => 'P6000',
5165             PrintConv => \%offOn,
5166             },
5167             0x66 => {
5168             Name => 'VR_0x66',
5169             Condition => '$$self{ShotInfoVersion} eq "0204"',
5170             Format => 'int8u',
5171             Unknown => 1,
5172             Notes => 'D2X, D2Xs (unverified)',
5173             PrintConv => {
5174             0 => 'Off',
5175             1 => 'On (normal)',
5176             2 => 'On (active)',
5177             },
5178             },
5179             # 6a, 6e not correct for 0103 (D70), 0207 (D200)
5180             0x6a => {
5181             Name => 'ShutterCount',
5182             Condition => '$$self{ShotInfoVersion} eq "0204"',
5183             Format => 'int32u',
5184             Priority => 0,
5185             Notes => 'D2X, D2Xs',
5186             },
5187             0x6e => {
5188             Name => 'DeletedImageCount',
5189             Condition => '$$self{ShotInfoVersion} eq "0204"',
5190             Format => 'int32u',
5191             Priority => 0,
5192             Notes => 'D2X, D2Xs',
5193             },
5194             0x75 => { #JD
5195             Name => 'VibrationReduction',
5196             Condition => '$$self{ShotInfoVersion} eq "0207"',
5197             Format => 'int8u',
5198             Notes => 'D200',
5199             PrintConv => {
5200             0 => 'Off',
5201             # (not sure what the different values represent, but values
5202             # of 1 and 2 have even been observed for non-VR lenses!)
5203             1 => 'On (1)', #PH
5204             2 => 'On (2)', #PH
5205             3 => 'On (3)', #PH (rare -- only seen once)
5206             },
5207             },
5208             0x82 => { # educated guess, needs verification
5209             Name => 'VibrationReduction',
5210             Condition => '$$self{ShotInfoVersion} eq "0204"',
5211             Format => 'int8u',
5212             Notes => 'D2X, D2Xs',
5213             PrintConv => {
5214             0 => 'Off',
5215             1 => 'On',
5216             },
5217             },
5218             # 0xac - int16u[600] TiffMeteringImage1: 30x20 image (ShotInfoVersion 0800, ref JR)
5219             0x157 => { #JD
5220             Name => 'ShutterCount',
5221             Condition => '$$self{ShotInfoVersion} eq "0205"',
5222             Format => 'undef[2]',
5223             Priority => 0,
5224             Notes => 'D50',
5225             # treat as a 2-byte big-endian integer
5226             ValueConv => 'unpack("n", $val)',
5227             ValueConvInv => 'pack("n",$val)',
5228             },
5229             0x1ae => { #JD
5230             Name => 'VibrationReduction',
5231             Condition => '$$self{ShotInfoVersion} eq "0205"',
5232             Format => 'int8u',
5233             Notes => 'D50',
5234             PrintHex => 1,
5235             PrintConv => {
5236             0x00 => 'n/a',
5237             0x0c => 'Off',
5238             0x0f => 'On',
5239             },
5240             },
5241             0x24d => { #PH
5242             Name => 'ShutterCount',
5243             Condition => '$$self{ShotInfoVersion} eq "0211"',
5244             Notes => 'D60',
5245             Format => 'int32u',
5246             Priority => 0,
5247             },
5248             # note: DecryptLen currently set to 0x251
5249              
5250             # 0x55c - int16u[2400] TiffMeteringImage2: 60x40 image (ShotInfoVersion 0800, ref JR)
5251             # 0x181c - int16u[1200] TiffMeteringImage?: 60x20 image for some NEF's (ShotInfoVersion 0800, ref JR)
5252             # 0x217c - int16u[2400] TiffMeteringImage3: 60x40 image (ShotInfoVersion 0800, ref JR)
5253             # 0x3d9c - int16u[2400] TiffMeteringImage4: 60x40 image (ShotInfoVersion 0800, ref JR)
5254             # 0x59c0 - TiffMeteringImageWidth (ShotInfoVersion 0800, ref JR)
5255             # 0x59c2 - TiffMeteringImageHeight (ShotInfoVersion 0800, ref JR)
5256             # 0x59c4 - int16u[1800] TiffMeteringImage5: 30x20 RGB image (ShotInfoVersion 0800, ref JR)
5257             );
5258              
5259             # shot information for D40 and D40X (encrypted) - ref PH
5260             %Image::ExifTool::Nikon::ShotInfoD40 = (
5261             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5262             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5263             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5264             VARS => { ID_LABEL => 'Index' },
5265             IS_SUBDIR => [ 729 ],
5266             WRITABLE => 1,
5267             FIRST_ENTRY => 0,
5268             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5269             NOTES => 'These tags are extracted from encrypted data in D40 and D40X images.',
5270             0x00 => {
5271             Name => 'ShotInfoVersion',
5272             Format => 'string[4]',
5273             Writable => 0,
5274             },
5275             582 => {
5276             Name => 'ShutterCount',
5277             Format => 'int32u',
5278             Priority => 0,
5279             },
5280             586.1 => { #JD
5281             Name => 'VibrationReduction',
5282             Mask => 0x08,
5283             PrintConv => { 0 => 'Off', 1 => 'On' },
5284             },
5285             729 => { #JD
5286             Name => 'CustomSettingsD40',
5287             Format => 'undef[12]',
5288             SubDirectory => {
5289             TagTable => 'Image::ExifTool::NikonCustom::SettingsD40',
5290             },
5291             },
5292             # note: DecryptLen currently set to 748
5293             );
5294              
5295             # shot information for D80 (encrypted) - ref JD
5296             %Image::ExifTool::Nikon::ShotInfoD80 = (
5297             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5298             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5299             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5300             VARS => { ID_LABEL => 'Index' },
5301             IS_SUBDIR => [ 748 ],
5302             WRITABLE => 1,
5303             FIRST_ENTRY => 0,
5304             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5305             NOTES => 'These tags are extracted from encrypted data in D80 images.',
5306             0x00 => {
5307             Name => 'ShotInfoVersion',
5308             Format => 'string[4]',
5309             Writable => 0,
5310             },
5311             586 => {
5312             Name => 'ShutterCount',
5313             Format => 'int32u',
5314             Priority => 0,
5315             },
5316             # split 590 into a few different tags
5317             590.1 => {
5318             Name => 'Rotation',
5319             Mask => 0x07,
5320             PrintConv => {
5321             0 => 'Horizontal',
5322             1 => 'Rotate 270 CW',
5323             2 => 'Rotate 90 CW',
5324             3 => 'Rotate 180',
5325             },
5326             },
5327             590.2 => {
5328             Name => 'VibrationReduction',
5329             Mask => 0x18,
5330             PrintConv => {
5331             0 => 'Off',
5332             3 => 'On',
5333             },
5334             },
5335             590.3 => {
5336             Name => 'FlashFired',
5337             Mask => 0xe0,
5338             PrintConv => { BITMASK => {
5339             1 => 'Internal',
5340             2 => 'External',
5341             }},
5342             },
5343             708 => {
5344             Name => 'NikonImageSize',
5345             Mask => 0xf0,
5346             PrintConv => {
5347             0 => 'Large (10.0 M)',
5348             1 => 'Medium (5.6 M)',
5349             2 => 'Small (2.5 M)',
5350             },
5351             },
5352             708.1 => {
5353             Name => 'ImageQuality',
5354             Mask => 0x0f,
5355             PrintConv => {
5356             0 => 'NEF (RAW)',
5357             1 => 'JPEG Fine',
5358             2 => 'JPEG Normal',
5359             3 => 'JPEG Basic',
5360             4 => 'NEF (RAW) + JPEG Fine',
5361             5 => 'NEF (RAW) + JPEG Normal',
5362             6 => 'NEF (RAW) + JPEG Basic',
5363             },
5364             },
5365             748 => { #JD
5366             Name => 'CustomSettingsD80',
5367             Format => 'undef[17]',
5368             SubDirectory => {
5369             TagTable => 'Image::ExifTool::NikonCustom::SettingsD80',
5370             },
5371             },
5372             # note: DecryptLen currently set to 765
5373             );
5374              
5375             # shot information for D90 (encrypted) - ref PH
5376             %Image::ExifTool::Nikon::ShotInfoD90 = (
5377             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5378             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5379             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5380             VARS => { ID_LABEL => 'Index' },
5381             IS_SUBDIR => [ 0x374 ],
5382             WRITABLE => 1,
5383             FIRST_ENTRY => 0,
5384             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5385             NOTES => q{
5386             These tags are extracted from encrypted data in images from the D90 with
5387             firmware 1.00.
5388             },
5389             0x00 => {
5390             Name => 'ShotInfoVersion',
5391             Format => 'string[4]',
5392             Writable => 0,
5393             },
5394             0x04 => {
5395             Name => 'FirmwareVersion',
5396             Format => 'string[5]',
5397             Writable => 0,
5398             },
5399             0x2b5 => { #JD (same value found at offset 0x39, 0x2bf, 0x346)
5400             Name => 'ISO2',
5401             ValueConv => '100*exp(($val/12-5)*log(2))',
5402             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5403             PrintConv => 'int($val + 0.5)',
5404             PrintConvInv => '$val',
5405             },
5406             0x2d5 => {
5407             Name => 'ShutterCount',
5408             Format => 'int32u',
5409             Priority => 0,
5410             },
5411             0x374 => {
5412             Name => 'CustomSettingsD90',
5413             Format => 'undef[36]',
5414             SubDirectory => {
5415             TagTable => 'Image::ExifTool::NikonCustom::SettingsD90',
5416             },
5417             },
5418             # note: DecryptLen currently set to 0x398
5419             );
5420              
5421             # shot information for the D3 firmware 0.37 and 1.00 (encrypted) - ref PH
5422             %Image::ExifTool::Nikon::ShotInfoD3a = (
5423             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5424             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5425             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5426             VARS => { ID_LABEL => 'Index' },
5427             IS_SUBDIR => [ 0x301 ],
5428             WRITABLE => 1,
5429             FIRST_ENTRY => 0,
5430             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5431             NOTES => q{
5432             These tags are extracted from encrypted data in images from the D3 with
5433             firmware 1.00 and earlier.
5434             },
5435             0x00 => {
5436             Name => 'ShotInfoVersion',
5437             Format => 'string[4]',
5438             Writable => 0,
5439             },
5440             0x256 => { #JD (same value found at offset 0x26b)
5441             Name => 'ISO2',
5442             ValueConv => '100*exp(($val/12-5)*log(2))',
5443             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5444             PrintConv => 'int($val + 0.5)',
5445             PrintConvInv => '$val',
5446             },
5447             0x276 => { #JD
5448             Name => 'ShutterCount',
5449             Format => 'int32u',
5450             Priority => 0,
5451             },
5452             723.1 => {
5453             Name => 'NikonImageSize',
5454             Mask => 0x18,
5455             PrintConv => {
5456             0 => 'Large',
5457             1 => 'Medium',
5458             2 => 'Small',
5459             },
5460             },
5461             723.2 => {
5462             Name => 'ImageQuality',
5463             Mask => 0x07,
5464             PrintConv => {
5465             0 => 'NEF (RAW) + JPEG Fine',
5466             1 => 'NEF (RAW) + JPEG Norm',
5467             2 => 'NEF (RAW) + JPEG Basic',
5468             3 => 'NEF (RAW)',
5469             4 => 'TIF (RGB)',
5470             5 => 'JPEG Fine',
5471             6 => 'JPEG Normal',
5472             7 => 'JPEG Basic',
5473             },
5474             },
5475             0x301 => { #(NC)
5476             Name => 'CustomSettingsD3',
5477             Format => 'undef[24]',
5478             SubDirectory => {
5479             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
5480             },
5481             },
5482             # note: DecryptLen currently set to 0x318
5483             );
5484              
5485             # shot information for the D3 firmware 1.10, 2.00 and 2.01 (encrypted) - ref PH
5486             %Image::ExifTool::Nikon::ShotInfoD3b = (
5487             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5488             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5489             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5490             VARS => { ID_LABEL => 'Index' },
5491             IS_SUBDIR => [ 0x30a ],
5492             WRITABLE => 1,
5493             FIRST_ENTRY => 0,
5494             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5495             DATAMEMBER => [ 4 ],
5496             NOTES => q{
5497             These tags are extracted from encrypted data in images from the D3 with
5498             firmware 1.10, 2.00, 2.01 and 2.02.
5499             },
5500             0x00 => {
5501             Name => 'ShotInfoVersion',
5502             Format => 'string[4]',
5503             Writable => 0,
5504             },
5505             0x04 => {
5506             Name => 'FirmwareVersion',
5507             Format => 'string[5]',
5508             Writable => 0,
5509             RawConv => '$$self{FirmwareVersion} = $val',
5510             },
5511             0x10 => { #28
5512             Name => 'ImageArea',
5513             PrintConv => {
5514             0 => 'FX (36.0 x 23.9 mm)',
5515             1 => 'DX (23.5 x 15.6 mm)',
5516             2 => '5:4 (30.0 x 23.9 mm)',
5517             },
5518             },
5519             0x25d => {
5520             Name => 'ISO2',
5521             ValueConv => '100*exp(($val/12-5)*log(2))',
5522             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5523             PrintConv => 'int($val + 0.5)',
5524             PrintConvInv => '$val',
5525             },
5526             0x27d => {
5527             Name => 'ShutterCount',
5528             Condition => '$$self{FirmwareVersion} =~ /^1\.01/',
5529             Notes => 'firmware 1.10',
5530             Format => 'int32u',
5531             Priority => 0,
5532             },
5533             0x27f => {
5534             Name => 'ShutterCount',
5535             Condition => '$$self{FirmwareVersion} =~ /^2\.0/',
5536             Notes => 'firmware 2.00, 2.01 and 2.02',
5537             Format => 'int32u',
5538             Priority => 0,
5539             },
5540             732.1 => { #28
5541             Name => 'NikonImageSize',
5542             Mask => 0x18,
5543             PrintConv => {
5544             0 => 'Large',
5545             1 => 'Medium',
5546             2 => 'Small',
5547             },
5548             },
5549             732.2 => { #28
5550             Name => 'ImageQuality',
5551             Mask => 0x07,
5552             PrintConv => {
5553             0 => 'NEF (RAW) + JPEG Fine',
5554             1 => 'NEF (RAW) + JPEG Norm',
5555             2 => 'NEF (RAW) + JPEG Basic',
5556             3 => 'NEF (RAW)',
5557             4 => 'TIF (RGB)',
5558             5 => 'JPEG Fine',
5559             6 => 'JPEG Normal',
5560             7 => 'JPEG Basic',
5561             },
5562             },
5563             0x28a => { #28
5564             Name => 'PreFlashReturnStrength',
5565             Notes => 'valid in TTL and TTL-BL flash control modes',
5566             # this is used to set the flash power using this relationship
5567             # for the SB-800 and SB-900:
5568             # $val < 140 ? 2**(0.08372*$val-12.352) : $val
5569             },
5570             0x30a => { # tested with firmware 2.00
5571             Name => 'CustomSettingsD3',
5572             Format => 'undef[24]',
5573             SubDirectory => {
5574             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
5575             },
5576             },
5577             # note: DecryptLen currently set to 0x321
5578             );
5579              
5580             # shot information for the D3X firmware 1.00 (encrypted) - ref PH
5581             %Image::ExifTool::Nikon::ShotInfoD3X = (
5582             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5583             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5584             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5585             VARS => { ID_LABEL => 'Index' },
5586             IS_SUBDIR => [ 0x30b ],
5587             WRITABLE => 1,
5588             FIRST_ENTRY => 0,
5589             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5590             NOTES => q{
5591             These tags are extracted from encrypted data in images from the D3X with
5592             firmware 1.00.
5593             },
5594             0x00 => {
5595             Name => 'ShotInfoVersion',
5596             Format => 'string[4]',
5597             Writable => 0,
5598             },
5599             0x04 => {
5600             Name => 'FirmwareVersion',
5601             Format => 'string[5]',
5602             Writable => 0,
5603             },
5604             0x25d => {
5605             Name => 'ISO2',
5606             ValueConv => '100*exp(($val/12-5)*log(2))',
5607             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5608             PrintConv => 'int($val + 0.5)',
5609             PrintConvInv => '$val',
5610             },
5611             0x280 => {
5612             Name => 'ShutterCount',
5613             Format => 'int32u',
5614             Priority => 0,
5615             },
5616             0x30b => { #(NC)
5617             Name => 'CustomSettingsD3X',
5618             Format => 'undef[24]',
5619             SubDirectory => {
5620             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
5621             },
5622             },
5623             # note: DecryptLen currently set to 0x323
5624             );
5625              
5626             # shot information for the D3S firmware 0.16 and 1.00 (encrypted) - ref PH
5627             %Image::ExifTool::Nikon::ShotInfoD3S = (
5628             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5629             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5630             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5631             VARS => { ID_LABEL => 'Index' },
5632             IS_SUBDIR => [ 0x2ce ],
5633             WRITABLE => 1,
5634             FIRST_ENTRY => 0,
5635             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5636             NOTES => q{
5637             These tags are extracted from encrypted data in images from the D3S with
5638             firmware 1.00 and earlier.
5639             },
5640             0x00 => {
5641             Name => 'ShotInfoVersion',
5642             Format => 'string[4]',
5643             Writable => 0,
5644             },
5645             0x04 => {
5646             Name => 'FirmwareVersion',
5647             Format => 'string[5]',
5648             Writable => 0,
5649             },
5650             0x10 => { #28
5651             Name => 'ImageArea',
5652             PrintConv => {
5653             0 => 'FX (36x24)',
5654             1 => 'DX (24x16)',
5655             2 => '5:4 (30x24)',
5656             3 => '1.2x (30x20)',
5657             },
5658             },
5659             0x221 => {
5660             Name => 'ISO2',
5661             ValueConv => '100*exp(($val/12-5)*log(2))',
5662             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5663             PrintConv => 'int($val + 0.5)',
5664             PrintConvInv => '$val',
5665             },
5666             0x242 => {
5667             Name => 'ShutterCount',
5668             Format => 'int32u',
5669             Priority => 0,
5670             },
5671             0x2ce => { #(NC)
5672             Name => 'CustomSettingsD3S',
5673             Format => 'undef[27]',
5674             SubDirectory => {
5675             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
5676             },
5677             },
5678             # note: DecryptLen currently set to 0x2e9
5679             );
5680              
5681             # shot information for the D300 firmware 1.00 (encrypted) - ref JD
5682             %Image::ExifTool::Nikon::ShotInfoD300a = (
5683             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5684             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5685             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5686             VARS => { ID_LABEL => 'Index' },
5687             IS_SUBDIR => [ 790 ],
5688             WRITABLE => 1,
5689             FIRST_ENTRY => 0,
5690             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5691             NOTES => q{
5692             These tags are extracted from encrypted data in images from the D300 with
5693             firmware 1.00 and earlier.
5694             },
5695             0x00 => {
5696             Name => 'ShotInfoVersion',
5697             Format => 'string[4]',
5698             Writable => 0,
5699             },
5700             604 => {
5701             Name => 'ISO2',
5702             ValueConv => '100*exp(($val/12-5)*log(2))',
5703             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5704             PrintConv => 'int($val + 0.5)',
5705             PrintConvInv => '$val',
5706             },
5707             633 => {
5708             Name => 'ShutterCount',
5709             Format => 'int32u',
5710             Priority => 0,
5711             },
5712             721 => { #PH
5713             Name => 'AFFineTuneAdj',
5714             Format => 'int16u',
5715             PrintHex => 1,
5716             PrintConvColumns => 3,
5717             # thanks to Neil Nappe for the samples to decode this!...
5718             # (have seen various unknown values here when flash is enabled, but
5719             # these are yet to be decoded: 0x2e,0x619,0xd0d,0x103a,0x2029 - PH)
5720             PrintConv => {
5721             0x403e => '+20',
5722             0x303e => '+19',
5723             0x203e => '+18',
5724             0x103e => '+17',
5725             0x003e => '+16',
5726             0xe03d => '+15',
5727             0xc03d => '+14',
5728             0xa03d => '+13',
5729             0x803d => '+12',
5730             0x603d => '+11',
5731             0x403d => '+10',
5732             0x203d => '+9',
5733             0x003d => '+8',
5734             0xc03c => '+7',
5735             0x803c => '+6',
5736             0x403c => '+5',
5737             0x003c => '+4',
5738             0x803b => '+3',
5739             0x003b => '+2',
5740             0x003a => '+1',
5741             0x0000 => '0',
5742             0x00c6 => '-1',
5743             0x00c5 => '-2',
5744             0x80c5 => '-3',
5745             0x00c4 => '-4',
5746             0x40c4 => '-5',
5747             0x80c4 => '-6',
5748             0xc0c4 => '-7',
5749             0x00c3 => '-8',
5750             0x20c3 => '-9',
5751             0x40c3 => '-10',
5752             0x60c3 => '-11',
5753             0x80c3 => '-12',
5754             0xa0c3 => '-13',
5755             0xc0c3 => '-14',
5756             0xe0c3 => '-15',
5757             0x00c2 => '-16',
5758             0x10c2 => '-17',
5759             0x20c2 => '-18',
5760             0x30c2 => '-19',
5761             0x40c2 => '-20',
5762             },
5763             },
5764             790 => {
5765             Name => 'CustomSettingsD300',
5766             Format => 'undef[24]',
5767             SubDirectory => {
5768             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
5769             },
5770             },
5771             # note: DecryptLen currently set to 813
5772             );
5773              
5774             # shot information for the D300 firmware 1.10 (encrypted) - ref PH
5775             %Image::ExifTool::Nikon::ShotInfoD300b = (
5776             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5777             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5778             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5779             VARS => { ID_LABEL => 'Index' },
5780             DATAMEMBER => [ 4 ],
5781             IS_SUBDIR => [ 802 ],
5782             WRITABLE => 1,
5783             FIRST_ENTRY => 0,
5784             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5785             NOTES => q{
5786             These tags are extracted from encrypted data in images from the D300 with
5787             firmware 1.10.
5788             },
5789             0x00 => {
5790             Name => 'ShotInfoVersion',
5791             Format => 'string[4]',
5792             Writable => 0,
5793             },
5794             0x04 => { #PH
5795             Name => 'FirmwareVersion',
5796             DataMember => 'FirmwareVersion',
5797             Format => 'string[5]',
5798             Writable => 0,
5799             RawConv => '$$self{FirmwareVersion} = $val',
5800             },
5801             613 => {
5802             Name => 'ISO2',
5803             ValueConv => '100*exp(($val/12-5)*log(2))',
5804             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5805             PrintConv => 'int($val + 0.5)',
5806             PrintConvInv => '$val',
5807             },
5808             644 => {
5809             Name => 'ShutterCount',
5810             Format => 'int32u',
5811             Priority => 0,
5812             },
5813             732 => [{
5814             Name => 'AFFineTuneAdj',
5815             Condition => '$$self{FirmwareVersion} eq "1.10B"',
5816             Notes => 'firmware version 1.10B',
5817             Format => 'int16u',
5818             PrintHex => 1,
5819             PrintConvColumns => 3,
5820             # thanks to Michael Tapes for the samples to decode this!...
5821             PrintConv => {
5822             0xe03e => '+20',
5823             0xc83e => '+19',
5824             0xb03e => '+18',
5825             0x983e => '+17',
5826             0x803e => '+16',
5827             0x683e => '+15',
5828             0x503e => '+14',
5829             0x383e => '+13',
5830             0x203e => '+12',
5831             0x083e => '+11',
5832             0xe03d => '+10',
5833             0xb03d => '+9',
5834             0x803d => '+8',
5835             0x503d => '+7',
5836             0x203d => '+6',
5837             0xe03c => '+5',
5838             0x803c => '+4',
5839             0x203c => '+3',
5840             0x803b => '+2',
5841             0x803a => '+1',
5842             0x0000 => '0',
5843             0x80c6 => '-1',
5844             0x80c5 => '-2',
5845             0x20c4 => '-3',
5846             0x80c4 => '-4',
5847             0xe0c4 => '-5',
5848             0x20c3 => '-6',
5849             0x50c3 => '-7',
5850             0x80c3 => '-8',
5851             0xb0c3 => '-9',
5852             0xe0c3 => '-10',
5853             0x08c2 => '-11',
5854             0x20c2 => '-12',
5855             0x38c2 => '-13',
5856             0x50c2 => '-14',
5857             0x68c2 => '-15',
5858             0x80c2 => '-16',
5859             0x98c2 => '-17',
5860             0xb0c2 => '-18',
5861             0xc8c2 => '-19',
5862             0xe0c2 => '-20',
5863             },
5864             },{
5865             Name => 'AFFineTuneAdj',
5866             Notes => 'other versions',
5867             Format => 'int16u',
5868             PrintHex => 1,
5869             PrintConvColumns => 3,
5870             # thanks to Stuart Solomon for the samples to decode this!...
5871             PrintConv => {
5872             0x903e => '+20',
5873             0x7c3e => '+19',
5874             0x683e => '+18',
5875             0x543e => '+17',
5876             0x403e => '+16',
5877             0x2c3e => '+15',
5878             0x183e => '+14',
5879             0x043e => '+13',
5880             0xe03d => '+12',
5881             0xb83d => '+11',
5882             0x903d => '+10',
5883             0x683d => '+9',
5884             0x403d => '+8',
5885             0x183d => '+7',
5886             0xe03c => '+6',
5887             0x903c => '+5',
5888             0x403c => '+4',
5889             0xe03b => '+3',
5890             0x403b => '+2',
5891             0x403a => '+1',
5892             0x0000 => '0',
5893             0x40c6 => '-1',
5894             0x40c5 => '-2',
5895             0xe0c5 => '-3',
5896             0x40c4 => '-4',
5897             0x90c4 => '-5',
5898             0xe0c4 => '-6',
5899             0x18c3 => '-7',
5900             0x40c3 => '-8',
5901             0x68c3 => '-9',
5902             0x90c3 => '-10',
5903             0xb8c3 => '-11',
5904             0xe0c3 => '-12',
5905             0x04c2 => '-13',
5906             0x18c2 => '-14',
5907             0x2cc2 => '-15',
5908             0x40c2 => '-16',
5909             0x54c2 => '-17',
5910             0x68c2 => '-18',
5911             0x7cc2 => '-19',
5912             0x90c2 => '-20',
5913             },
5914             }],
5915             802 => {
5916             Name => 'CustomSettingsD300',
5917             Format => 'undef[24]',
5918             SubDirectory => {
5919             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
5920             },
5921             },
5922             # note: DecryptLen currently set to 825
5923             );
5924              
5925             # shot information for the D300S firmware 1.00 (encrypted) - ref PH
5926             %Image::ExifTool::Nikon::ShotInfoD300S = (
5927             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5928             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5929             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5930             VARS => { ID_LABEL => 'Index' },
5931             IS_SUBDIR => [ 804 ],
5932             WRITABLE => 1,
5933             FIRST_ENTRY => 0,
5934             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5935             NOTES => q{
5936             These tags are extracted from encrypted data in images from the D300S with
5937             firmware 1.00.
5938             },
5939             0x00 => {
5940             Name => 'ShotInfoVersion',
5941             Format => 'string[4]',
5942             Writable => 0,
5943             },
5944             0x04 => {
5945             Name => 'FirmwareVersion',
5946             Format => 'string[5]',
5947             Writable => 0,
5948             },
5949             613 => {
5950             Name => 'ISO2',
5951             ValueConv => '100*exp(($val/12-5)*log(2))',
5952             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5953             PrintConv => 'int($val + 0.5)',
5954             PrintConvInv => '$val',
5955             },
5956             646 => {
5957             Name => 'ShutterCount',
5958             Format => 'int32u',
5959             Priority => 0,
5960             },
5961             804 => { #(NC)
5962             Name => 'CustomSettingsD300S',
5963             Format => 'undef[24]',
5964             SubDirectory => {
5965             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
5966             },
5967             },
5968             # note: DecryptLen currently set to 827
5969             );
5970              
5971             # shot information for the D700 firmware 1.02f (encrypted) - ref 29
5972             %Image::ExifTool::Nikon::ShotInfoD700 = (
5973             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5974             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5975             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5976             VARS => { ID_LABEL => 'Index' },
5977             IS_SUBDIR => [ 804 ],
5978             WRITABLE => 1,
5979             FIRST_ENTRY => 0,
5980             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5981             NOTES => q{
5982             These tags are extracted from encrypted data in images from the D700 with
5983             firmware 1.02f.
5984             },
5985             0x00 => {
5986             Name => 'ShotInfoVersion',
5987             Format => 'string[4]',
5988             Writable => 0,
5989             },
5990             0x04 => {
5991             Name => 'FirmwareVersion',
5992             Format => 'string[5]',
5993             Writable => 0,
5994             },
5995             613 => { # 0x265
5996             Name => 'ISO2',
5997             ValueConv => '100*exp(($val/12-5)*log(2))',
5998             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5999             PrintConv => 'int($val + 0.5)',
6000             PrintConvInv => '$val',
6001             },
6002             0x287 => {
6003             Name => 'ShutterCount',
6004             Format => 'int32u',
6005             Priority => 0,
6006             },
6007             804 => { # 0x324 (NC)
6008             Name => 'CustomSettingsD700',
6009             Format => 'undef[48]',
6010             SubDirectory => {
6011             TagTable => 'Image::ExifTool::NikonCustom::SettingsD700',
6012             },
6013             },
6014             # note: DecryptLen currently set to 852
6015             );
6016              
6017             # shot information for the D5000 firmware 1.00 (encrypted) - ref PH
6018             %Image::ExifTool::Nikon::ShotInfoD5000 = (
6019             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6020             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6021             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6022             VARS => { ID_LABEL => 'Index' },
6023             IS_SUBDIR => [ 0x378 ],
6024             WRITABLE => 1,
6025             FIRST_ENTRY => 0,
6026             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6027             NOTES => q{
6028             These tags are extracted from encrypted data in images from the D5000 with
6029             firmware 1.00.
6030             },
6031             0x00 => {
6032             Name => 'ShotInfoVersion',
6033             Format => 'string[4]',
6034             Writable => 0,
6035             },
6036             0x04 => {
6037             Name => 'FirmwareVersion',
6038             Format => 'string[5]',
6039             Writable => 0,
6040             },
6041             0x2b5 => { # (also found at 0x2c0)
6042             Name => 'ISO2',
6043             ValueConv => '100*exp(($val/12-5)*log(2))',
6044             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6045             PrintConv => 'int($val + 0.5)',
6046             PrintConvInv => '$val',
6047             },
6048             0x2d6 => {
6049             Name => 'ShutterCount',
6050             Format => 'int32u',
6051             Priority => 0,
6052             },
6053             0x378 => {
6054             Name => 'CustomSettingsD5000',
6055             Format => 'undef[34]',
6056             SubDirectory => {
6057             TagTable => 'Image::ExifTool::NikonCustom::SettingsD5000',
6058             },
6059             },
6060             # note: DecryptLen currently set to 0x39a
6061             );
6062              
6063             # shot information for the D5100 firmware 1.00f (encrypted) - ref PH
6064             %Image::ExifTool::Nikon::ShotInfoD5100 = (
6065             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6066             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6067             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6068             VARS => { ID_LABEL => 'Index' },
6069             IS_SUBDIR => [ 0x407 ],
6070             WRITABLE => 1,
6071             FIRST_ENTRY => 0,
6072             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6073             0x00 => {
6074             Name => 'ShotInfoVersion',
6075             Format => 'string[4]',
6076             Writable => 0,
6077             },
6078             0x04 => {
6079             Name => 'FirmwareVersion',
6080             Format => 'string[5]',
6081             Writable => 0,
6082             },
6083             0x321 => {
6084             Name => 'ShutterCount',
6085             Format => 'int32u',
6086             Priority => 0,
6087             },
6088             0x407 => {
6089             Name => 'CustomSettingsD5100',
6090             Format => 'undef[34]',
6091             SubDirectory => {
6092             TagTable => 'Image::ExifTool::NikonCustom::SettingsD5100',
6093             },
6094             },
6095             # note: DecryptLen currently set to 0x430
6096             );
6097              
6098             # shot information for the D5200 firmware 1.00 (encrypted) - ref PH
6099             %Image::ExifTool::Nikon::ShotInfoD5200 = (
6100             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6101             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6102             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6103             VARS => { ID_LABEL => 'Index' },
6104             IS_SUBDIR => [ 0xcd5 ],
6105             WRITABLE => 1,
6106             FIRST_ENTRY => 0,
6107             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6108             0x00 => {
6109             Name => 'ShotInfoVersion',
6110             Format => 'string[4]',
6111             Writable => 0,
6112             },
6113             0x04 => {
6114             Name => 'FirmwareVersion',
6115             Format => 'string[5]',
6116             Writable => 0,
6117             },
6118             # 0x101 - 2=VR Off, 3=VR On
6119             # 0x13d - 0=VR On, 1=VR Off
6120             0xbd8 => {
6121             Name => 'ShutterCount',
6122             Format => 'int32u',
6123             Priority => 0,
6124             },
6125             # 0xcd2 - 12=VR Off, 15=VR On
6126             0xcd5 => {
6127             Name => 'CustomSettingsD5200',
6128             Format => 'undef[34]',
6129             SubDirectory => {
6130             TagTable => 'Image::ExifTool::NikonCustom::SettingsD5200',
6131             },
6132             },
6133             # note: DecryptLen currently set to 0xd00
6134             );
6135              
6136             # shot information for the D7000 firmware 1.01d (encrypted) - ref 29
6137             %Image::ExifTool::Nikon::ShotInfoD7000 = (
6138             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6139             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6140             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6141             VARS => { ID_LABEL => 'Index' },
6142             IS_SUBDIR => [ 1028 ],
6143             WRITABLE => 1,
6144             FIRST_ENTRY => 0,
6145             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6146             NOTES => q{
6147             These tags are extracted from encrypted data in images from the D7000 with
6148             firmware 1.01b.
6149             },
6150             0x00 => {
6151             Name => 'ShotInfoVersion',
6152             Format => 'string[4]',
6153             Writable => 0,
6154             },
6155             0x04 => {
6156             Name => 'FirmwareVersion',
6157             Format => 'string[5]',
6158             Writable => 0,
6159             },
6160             #613 => {
6161             # Name => 'ISO2',
6162             # ValueConv => '100*exp(($val/12-5)*log(2))',
6163             # ValueConvInv => '(log($val/100)/log(2)+5)*12',
6164             # PrintConv => 'int($val + 0.5)',
6165             # PrintConvInv => '$val',
6166             #},
6167             0x320 => { # 800
6168             Name => 'ShutterCount',
6169             Format => 'int32u',
6170             Priority => 0,
6171             },
6172             0x404 => { # 1028 (NC)
6173             Name => 'CustomSettingsD7000',
6174             Format => 'undef[48]',
6175             SubDirectory => {
6176             TagTable => 'Image::ExifTool::NikonCustom::SettingsD7000',
6177             },
6178             },
6179             );
6180              
6181             # shot information for the D800 firmware 1.01a (encrypted) - ref PH
6182             %Image::ExifTool::Nikon::ShotInfoD800 = (
6183             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6184             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6185             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6186             VARS => { ID_LABEL => 'Index' },
6187             IS_SUBDIR => [ 0x6ec ],
6188             WRITABLE => 1,
6189             FIRST_ENTRY => 0,
6190             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6191             NOTES => 'These tags are extracted from encrypted data in images from the D800.',
6192             0x00 => {
6193             Name => 'ShotInfoVersion',
6194             Format => 'string[4]',
6195             Writable => 0,
6196             },
6197             0x04 => {
6198             Name => 'FirmwareVersion',
6199             Format => 'string[5]',
6200             Writable => 0,
6201             },
6202             0x4c0 => {
6203             Name => 'RepeatingFlashOutputExternal',
6204             ValueConv => '2 ** (-$val/6)',
6205             ValueConvInv => '$val > 0 ? -6*log($val)/log(2) : 0',
6206             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
6207             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
6208             },
6209             0x4c2 => {
6210             Name => 'RepeatingFlashRateExternal',
6211             DelValue => 0,
6212             RawConv => '$val || undef',
6213             PrintConv => '"$val Hz"',
6214             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
6215             },
6216             0x4c3 => {
6217             Name => 'RepeatingFlashCountExternal',
6218             DelValue => 0,
6219             RawConv => '$val || undef',
6220             },
6221             0x4d2 => {
6222             Name => 'FlashExposureComp2',
6223             Notes => 'includes the effect of flash bracketing',
6224             Format => 'int8s',
6225             ValueConv => '-$val/6',
6226             ValueConvInv => '-6 * $val',
6227             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
6228             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
6229             },
6230             # 0x4d4 - FEC again, doesn't include bracketing this time (internal?)
6231             # (not fully decoded, and duplicated in custom settings)
6232             # 0x4d9 => {
6233             # Name => 'FlashControlBuilt-in',
6234             # PrintConv => {
6235             # 1 => 'TTL',
6236             # 6 => 'Manual',
6237             # 7 => 'Repeating Flash',
6238             # },
6239             # },
6240             0x4da => {
6241             Name => 'RepeatingFlashRateBuilt-in',
6242             DelValue => 0,
6243             RawConv => '$val || undef',
6244             PrintConv => '"$val Hz"',
6245             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
6246             },
6247             0x4db => {
6248             Name => 'RepeatingFlashCountBuilt-in',
6249             DelValue => 0,
6250             RawConv => '$val || undef',
6251             },
6252             # 1294.1 => { # (0x4dc)
6253             # Name => 'FlashModeBuilt-in',
6254             # Mask => 0x0f,
6255             # PrintConv => {
6256             # 0 => 'Front-curtain Sync',
6257             # 1 => 'Red-eye Reduction',
6258             # 2 => 'Redy-eye Reduction with Slow Sync',
6259             # 3 => 'Slow Sync',
6260             # 4 => 'Rear-curtain Sync',
6261             # 5 => 'Rear-curtain Sync 2', # got this in P exposure mode
6262             # },
6263             # },
6264             # 1294.2 => { # (0x4dc)
6265             # Name => 'ExposureMode2',
6266             # Mask => 0xf0,
6267             # PrintConv => {
6268             # 0 => 'Program',
6269             # 1 => 'Aperture Priority',
6270             # 3 => 'Manual',
6271             # },
6272             # },
6273             # 0x511 - related to FlashSyncSpeed
6274             0x51c => 'SequenceNumber',
6275             # 0x4ba+0x63 - interesting
6276             # 0x4ba+0x68 - general downward trend
6277             # 0x4ba+0x7b - FlashControlBuilt-in: 8=TTL, 72=Manual
6278             # (not reliable)
6279             # 1346.1 => { # (0x542)
6280             # Name => 'RepeatingFlashOutputBuilt-in',
6281             # DelValue => 112,
6282             # Mask => 0xfc,
6283             # RawConv => '$val == 0x1c ? undef : 2 ** ($val/3-7)',
6284             # ValueConvInv => '$val > 0 ? (log($val)/log(2)+7)*3 : 0',
6285             # PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
6286             # PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
6287             # },
6288             0x5fb => {
6289             Name => 'ShutterCount',
6290             Format => 'int32u',
6291             },
6292             0x6ec => {
6293             Name => 'CustomSettingsD800',
6294             Format => 'undef[48]',
6295             SubDirectory => {
6296             TagTable => 'Image::ExifTool::NikonCustom::SettingsD800',
6297             },
6298             },
6299             # note: DecryptLen currently set to 0x720
6300             );
6301              
6302             # shot information for the D5 firmware 1.10a and D500 firmware 1.01 (encrypted) - ref 28
6303             %Image::ExifTool::Nikon::ShotInfoD500 = (
6304             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6305             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6306             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6307             VARS => { ID_LABEL => 'Index' },
6308             DATAMEMBER => [ 0x04, 0x10, 0x14, 0x2c, 0x50, 0x58, 0xa0, 0xa8, 0xb0,
6309             0x07b0, 0x086c, 0x0e7c, 0x0eea, 0x2c23, 0x2c8f ],
6310             IS_SUBDIR => [ 0x0eeb ],
6311             WRITABLE => 1,
6312             FIRST_ENTRY => 0,
6313             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6314             NOTES => 'These tags are extracted from encrypted data in images from the D5 and D500.',
6315             0x00 => {
6316             Name => 'ShotInfoVersion',
6317             Format => 'string[4]',
6318             Writable => 0,
6319             },
6320             0x04 => {
6321             Name => 'FirmwareVersion',
6322             DataMember => 'FirmwareVersion',
6323             Format => 'string[5]',
6324             Writable => 0,
6325             RawConv => '$$self{FirmwareVersion} = $val',
6326             },
6327             0x10 => {
6328             Name => 'RotationInfoOffset',
6329             DataMember => 'RotationInfoOffset',
6330             Format => 'int32u',
6331             Writable => 0,
6332             Hidden => 1,
6333             RawConv => '$$self{RotationInfoOffset} = $val || 0x10000000; undef', # (ignore if 0)
6334             },
6335             0x14 => {
6336             Name => 'JPGInfoOffset',
6337             DataMember => 'JPGInfoOffset',
6338             Format => 'int32u',
6339             Writable => 0,
6340             Hidden => 1,
6341             RawConv => '$$self{JPGInfoOffset} = $val || 0x10000000; undef', # (ignore if 0)
6342             },
6343             0x2c => {
6344             Name => 'BracketingInfoOffset',
6345             DataMember => 'BracketingInfoOffset',
6346             Format => 'int32u',
6347             Writable => 0,
6348             Hidden => 1,
6349             RawConv => '$$self{BracketingInfoOffset} = $val || 0x10000000; undef', # (ignore if 0)
6350             },
6351             0x50 => {
6352             Name => 'ShootingMenuOffset',
6353             DataMember => 'ShootingMenuOffset',
6354             Format => 'int32u',
6355             Writable => 0,
6356             Hidden => 1,
6357             RawConv => '$$self{ShootingMenuOffset} = $val || 0x10000000; undef', # (ignore if 0)
6358             },
6359             0x58 => {
6360             Name => 'CustomSettingsOffset',
6361             DataMember => 'CustomSettingsOffset',
6362             Format => 'int32u',
6363             Writable => 0,
6364             Hidden => 1,
6365             RawConv => '$$self{CustomSettingsOffset} = $val || 0x10000000; undef', # (ignore if 0)
6366             },
6367             0xa0 => {
6368             Name => 'OrientationOffset',
6369             DataMember => 'OrientationOffset',
6370             Format => 'int32u',
6371             Writable => 0,
6372             Hidden => 1,
6373             RawConv => '$$self{OrientationOffset} = $val || 0x10000000; undef', # (ignore if 0)
6374             },
6375             0xa8 => {
6376             Name => 'OtherOffset',
6377             DataMember => 'OtherOffset',
6378             Format => 'int32u',
6379             Writable => 0,
6380             Hidden => 1,
6381             RawConv => '$$self{OtherOffset} = $val || 0x10000000; undef', # (ignore if 0)
6382             },
6383             #
6384             # Tag ID's below are the offsets for a D500 JPEG image, but these offsets change
6385             # for various image types according to the offset table above
6386             #
6387             ### 0xb0 - RotationInfo start
6388             0xb0 => {
6389             Name => 'Hook1',
6390             Hidden => 1,
6391             RawConv => 'undef',
6392             # account for variable location of Rotation data
6393             Hook => '$varSize = $$self{RotationInfoOffset} - 0xb0',
6394             },
6395             0xca => {
6396             Name => 'Rotation',
6397             Mask => 0x03,
6398             PrintConv => {
6399             0 => 'Horizontal',
6400             1 => 'Rotate 270 CW',
6401             2 => 'Rotate 90 CW',
6402             3 => 'Rotate 180',
6403             },
6404             },
6405             0x0d0 => {
6406             Name => 'Interval',
6407             # prior version of the d% firmware do not support this tag, nor does the D500 (at least thru firmware 1.3)
6408             Condition => '$$self{Model} eq "NIKON D5" and $$self{FirmwareVersion} ge "1.40"',
6409             PrintConv => '$val > 0 ? sprintf("%.0f", $val) : ""',
6410             },
6411             0x0d4 => {
6412             Name => 'IntervalFrame',
6413             # prior version of the d% firmware do not support this tag, nor does the D500 (at least thru firmware 1.3)
6414             Condition => '$$self{Model} eq "NIKON D5" and $$self{FirmwareVersion} ge "1.40"',
6415             PrintConv => '$val > 0 ? sprintf("%.0f", $val) : ""',
6416             },
6417             0x05e2 => {
6418             Name => 'FlickerReductionIndicator',
6419             Mask => 0x01,
6420             PrintConv => { 0 => 'On', 1 => 'Off' },
6421             },
6422             ### 0x07b0 - JPEGInfo start
6423             0x07b0 => {
6424             Name => 'Hook2',
6425             Hidden => 1,
6426             RawConv => 'undef',
6427             # account for variable location of Shooting Menu data
6428             Hook => '$varSize = $$self{JPGInfoOffset} - 0x07b0',
6429             },
6430             0x07d4 => {
6431             Name => 'JPGCompression',
6432             Mask => 0x01,
6433             PrintConv => {
6434             0 => 'Size Priority',
6435             1 => 'Optimal Quality',
6436             },
6437             },
6438             ### 0x0830 - ? start
6439             ### 0x086c - BracketingInfo start
6440             0x086c => {
6441             Name => 'Hook3',
6442             Hidden => 1,
6443             RawConv => 'undef',
6444             # account for variable location of Shooting Menu data
6445             Hook => '$varSize = $$self{BracketingInfoOffset} - 0x086c',
6446             },
6447             0x087b => {
6448             Name => 'AEBracketingSteps',
6449             Condition => '$$self{FILE_TYPE} ne "TIFF"', # (covers NEF and TIFF)
6450             Mask => 0xff,
6451             PrintHex => 1,
6452             PrintConvColumns => 2,
6453             PrintConv => {
6454             0x00 => 'AE Bracketing Disabled',
6455             0x20 => 'AE Bracketing Disabled',
6456             0x30 => 'AE Bracketing Disabled',
6457             0x40 => 'AE Bracketing Disabled',
6458             0x50 => 'AE Bracketing Disabled',
6459             0x81 => '+3F0.3',
6460             0x82 => '-3F0.3',
6461             0x83 => '+2F0.3',
6462             0x84 => '-2F0.3',
6463             0x85 => '3F0.3',
6464             0x86 => '5F0.3',
6465             0x87 => '7F0.3',
6466             0x88 => '9F0.3',
6467             0x91 => '+3F0.5',
6468             0x92 => '-3F0.5',
6469             0x93 => '+2F0.5',
6470             0x94 => '-2F0.5',
6471             0x95 => '3F0.5',
6472             0x96 => '5F0.5',
6473             0x97 => '7F0.5',
6474             0x98 => '9F0.5',
6475             0xa1 => '+3F0.7',
6476             0xa2 => '-3F0.7',
6477             0xa3 => '+2F0.7',
6478             0xa4 => '-2F0.7',
6479             0xa5 => '3F0.7',
6480             0xa6 => '5F0.7',
6481             0xa7 => '7F0.7',
6482             0xa8 => '9F0.7',
6483             0xb1 => '+3F1',
6484             0xb2 => '-3F1',
6485             0xb3 => '+2F1',
6486             0xb4 => '-2F1',
6487             0xb5 => '3F1',
6488             0xb6 => '5F1',
6489             0xb7 => '7F1',
6490             0xb8 => '9F1',
6491             0xc1 => '+3F2',
6492             0xc2 => '-3F2',
6493             0xc3 => '+2F2',
6494             0xc4 => '-2F2',
6495             0xc5 => '3F2',
6496             0xc6 => '5F2',
6497             0xd1 => '+3F3',
6498             0xd2 => '-3F3',
6499             0xd3 => '+2F3',
6500             0xd4 => '-2F3',
6501             0xd5 => '3F3',
6502             0xd6 => '5F3',
6503             },
6504             },
6505             0x087c => {
6506             Name => 'WBBracketingSteps',
6507             Condition => '$$self{FILE_TYPE} ne "TIFF"', # (covers NEF and TIFF)
6508             Mask => 0xff,
6509             PrintHex => 1,
6510             PrintConvColumns => 2,
6511             PrintConv => {
6512             0x00 => 'WB Bracketing Disabled',
6513             0x01 => 'b3F 1',
6514             0x02 => 'A3F 1',
6515             0x03 => 'b2F 1',
6516             0x04 => 'A2F 1',
6517             0x05 => '3F 1',
6518             0x06 => '5F 1',
6519             0x07 => '7F 1',
6520             0x08 => '9F 1',
6521             0x10 => '0F 2',
6522             0x11 => 'b3F 2',
6523             0x12 => 'A3F 2',
6524             0x13 => 'b2F 2',
6525             0x14 => 'A2F 2',
6526             0x15 => '3F 2',
6527             0x16 => '5F 2',
6528             0x17 => '7F 2',
6529             0x18 => '9F 2',
6530             0x20 => '0F 3',
6531             0x21 => 'b3F 3',
6532             0x22 => 'A3F 3',
6533             0x23 => 'b2F 3',
6534             0x24 => 'A2F 3',
6535             0x25 => '3F 3',
6536             0x26 => '5F 3',
6537             0x27 => '7F 3',
6538             0x28 => '9F 3',
6539             0x22 => 'A3F 3',
6540             0x23 => 'b2F 3',
6541             0x24 => 'A2F 3',
6542             0x25 => '3F 3',
6543             0x26 => '5F 3',
6544             0x27 => '7F 3',
6545             0x28 => '9F 3',
6546             },
6547             },
6548             0x0883 => {
6549             Name => 'ADLBracketingStep',
6550             Mask => 0xf0,
6551             PrintConv => {
6552             0 => 'Off',
6553             1 => 'Low',
6554             2 => 'Normal',
6555             3 => 'High',
6556             4 => 'Extra High',
6557             8 => 'Auto',
6558             },
6559             },
6560             0x0884 => {
6561             Name => 'ADLBracketingType',
6562             Mask => 0x0f,
6563             PrintConv => {
6564             0 => 'Off',
6565             1 => '2 Shots',
6566             2 => '3 Shots',
6567             3 => '4 Shots',
6568             4 => '5 Shots',
6569             },
6570             },
6571             ### 0x0887 - ? start
6572             ### 0x089f - ? start
6573             ### 0x0929 - ? start
6574             ### 0x09c9 - ? start
6575             ### 0x0ac5 - ? start
6576             ### 0x0bc1 - ? start
6577             ### 0x0cbd - ? start
6578             ### 0x0d98 - ? start
6579             ### 0x0e7d - ShootingMenuOffset start
6580             0x0e7c => {
6581             Name => 'Hook4',
6582             Hidden => 1,
6583             RawConv => 'undef',
6584             # account for variable location of Shooting Menu data
6585             Hook => '$varSize = $$self{ShootingMenuOffset} - 0x0e7d',
6586             },
6587             0x0e7d => {
6588             Name => 'PhotoShootingMenuBank',
6589             Mask => 0x03,
6590             PrintConv => {
6591             0 => 'A',
6592             1 => 'B',
6593             2 => 'C',
6594             3 => 'D',
6595             },
6596             },
6597             0x0e7f => {
6598             Name => 'PrimarySlot',
6599             Condition => '$$self{Model} =~ /\bD500\b/',
6600             Notes => 'D500 only',
6601             Mask => 0x80,
6602             PrintConv => {
6603             0 => 'XQD Card',
6604             1 => 'SD Card',
6605             },
6606             },
6607             0x0e81 => {
6608             Name => 'ISOAutoShutterTime',
6609             Mask => 0x3f,
6610             PrintConv => {
6611             0 => '1/4000 s',
6612             1 => '1/3200 s',
6613             2 => '1/2500 s',
6614             3 => '1/2000 s',
6615             4 => '1/1600 s',
6616             5 => '1/1250 s',
6617             6 => '1/1000 s',
6618             7 => '1/800 s',
6619             8 => '1/640 s',
6620             9 => '1/500 s',
6621             10 => '1/400 s',
6622             11 => '1/320 s',
6623             12 => '1/250 s',
6624             13 => '1/200 s',
6625             14 => '1/160 s',
6626             15 => '1/125 s',
6627             16 => '1/100 s',
6628             17 => '1/80 s',
6629             18 => '1/60 s',
6630             19 => '1/50 s',
6631             20 => '1/40 s',
6632             21 => '1/30 s',
6633             22 => '1/15 s',
6634             23 => '1/8 s',
6635             24 => '1/4 s',
6636             25 => '1/2 s',
6637             26 => '1 s',
6638             27 => '2 s',
6639             28 => '4 s',
6640             29 => '8 s',
6641             30 => '15 s',
6642             31 => '30 s',
6643             32 => 'Auto (Slowest)',
6644             33 => 'Auto (Slower)',
6645             34 => 'Auto',
6646             35 => 'Auto (Faster)',
6647             36 => 'Auto (Fastest)',
6648             },
6649             },
6650             0x0e82 => {
6651             Name => 'ISOAutoHiLimit',
6652             Mask => 0xff,
6653             PrintHex => 1,
6654             PrintConv => {
6655             0x24 => 'ISO 200',
6656             0x26 => 'ISO 250',
6657             0x27 => 'ISO 280',
6658             0x28 => 'ISO 320',
6659             0x2a => 'ISO 400',
6660             0x2c => 'ISO 500',
6661             0x2d => 'ISO 560',
6662             0x2e => 'ISO 640',
6663             0x30 => 'ISO 800',
6664             0x32 => 'ISO 1000',
6665             0x33 => 'ISO 1100',
6666             0x34 => 'ISO 1250',
6667             0x36 => 'ISO 1600',
6668             0x38 => 'ISO 2000',
6669             0x39 => 'ISO 2200',
6670             0x3a => 'ISO 2500',
6671             0x3c => 'ISO 3200',
6672             0x3e => 'ISO 4000',
6673             0x3f => 'ISO 4500',
6674             0x40 => 'ISO 5000',
6675             0x42 => 'ISO 6400',
6676             0x44 => 'ISO 8000',
6677             0x45 => 'ISO 9000',
6678             0x46 => 'ISO 10000',
6679             0x48 => 'ISO 12800',
6680             0x4a => 'ISO 16000',
6681             0x4b => 'ISO 18000',
6682             0x4c => 'ISO 20000',
6683             0x4e => 'ISO 25600',
6684             0x50 => 'ISO 32000',
6685             0x51 => 'ISO 36000',
6686             0x52 => 'ISO 40000',
6687             0x54 => 'ISO 51200',
6688             0x56 => 'ISO Hi 0.3',
6689             0x57 => 'ISO Hi 0.5',
6690             0x58 => 'ISO Hi 0.7',
6691             0x5a => 'ISO Hi 1.0',
6692             0x60 => 'ISO Hi 2.0',
6693             0x66 => 'ISO Hi 3.0',
6694             0x6c => 'ISO Hi 4.0',
6695             0x72 => 'ISO Hi 5.0',
6696             },
6697             },
6698             0x0e84 => {
6699             Name => 'FlickerReduction',
6700             Mask => 0x20,
6701             PrintConv => {
6702             0 => 'Enable',
6703             1 => 'Disable',
6704             },
6705             },
6706             3716.1 => { # (0x0e84)
6707             Name => 'PhotoShootingMenuBankImageArea',
6708             Mask => 0x07,
6709             PrintConv => {
6710             0 => 'FX (36x24)',
6711             1 => 'DX (24x16)',
6712             2 => '5:4 (30x24)',
6713             3 => '1.2x (30x20)',
6714             4 => '1.3x (18x12)',
6715             },
6716             },
6717             ### 0x0ec4 - ? start
6718             ### 0x0eeb - CustomSettings start
6719             0x0eea => {
6720             Name => 'Hook5',
6721             Hidden => 1,
6722             RawConv => 'undef',
6723             # account for variable location of CustomSettings data
6724             Hook => '$varSize = $$self{CustomSettingsOffset} - 0x0eeb',
6725             },
6726             0x0eeb => [{
6727             Name => 'CustomSettingsD5',
6728             Condition => '$$self{Model} =~ /\bD5\b/',
6729             Format => 'undef[90]',
6730             SubDirectory => {
6731             TagTable => 'Image::ExifTool::NikonCustom::SettingsD5',
6732             },
6733             },{
6734             Name => 'CustomSettingsD500',
6735             Format => 'undef[90]',
6736             SubDirectory => {
6737             TagTable => 'Image::ExifTool::NikonCustom::SettingsD500',
6738             },
6739             }],
6740             # 0x0f68 => { #this decode works, but involves more bits than should be necessary
6741             # Name => 'ShutterTrigger',
6742             # Mask => 0xff,
6743             # PrintConv => {
6744             # 0 => 'Timer',
6745             # 15 => 'Cable Release/Remote',
6746             # 195 => 'Shutter Button',
6747             # },
6748             # },
6749             ### 0x2c24 - OrientationInfo start (D5 firmware 1.10b)
6750             0x2c23 => {
6751             Name => 'Hook6',
6752             Hidden => 1,
6753             RawConv => 'undef',
6754             # account for variable location of OrientationInfo data
6755             Hook => '$varSize = $$self{OrientationOffset} - 0x2c24',
6756             },
6757             0x2c24 => {
6758             Name => 'RollAngle',
6759             Format => 'fixed32u',
6760             Notes => 'converted to degrees of clockwise camera roll',
6761             ValueConv => '$val <= 180 ? $val : $val - 360',
6762             ValueConvInv => '$val >= 0 ? $val : $val + 360',
6763             PrintConv => 'sprintf("%.1f", $val)',
6764             PrintConvInv => '$val',
6765             },
6766             0x2c28 => {
6767             Name => 'PitchAngle',
6768             Format => 'fixed32u',
6769             Notes => 'converted to degrees of upward camera tilt',
6770             ValueConv => '$val <= 180 ? $val : $val - 360',
6771             ValueConvInv => '$val >= 0 ? $val : $val + 360',
6772             PrintConv => 'sprintf("%.1f", $val)',
6773             PrintConvInv => '$val',
6774             },
6775             0x2c2c => {
6776             Name => 'YawAngle',
6777             Format => 'fixed32u',
6778             Notes => 'the camera yaw angle when shooting in portrait orientation',
6779             ValueConv => '$val <= 180 ? $val : $val - 360',
6780             ValueConvInv => '$val >= 0 ? $val : $val + 360',
6781             PrintConv => 'sprintf("%.1f", $val)',
6782             PrintConvInv => '$val',
6783             },
6784             ### 0x2c90 - OtherInfo start (D500 firmware 1.20d)
6785             0x2c8f => {
6786             Name => 'Hook7',
6787             Hidden => 1,
6788             RawConv => 'undef',
6789             # account for variable location of OtherInfo data
6790             Hook => '$varSize = $$self{OtherOffset} - 0x2c90',
6791             },
6792             # (needs testing)
6793             #0x2cb2 => {
6794             # Name => 'ExtendedPhotoShootingBanks',
6795             # Mask => 0x01,
6796             # PrintConv => {
6797             # 0 => 'On',
6798             # 1 => 'Off',
6799             # },
6800             #},
6801             # (may not be reliable and is found elsewhere)
6802             #0x2ea2 => {
6803             # Name => 'Rotation',
6804             # Condition => '$$self{Model} =~ /\bD500\b/',
6805             # Notes => 'D500 firmware 1.1x',
6806             # Mask => 0x30,
6807             # PrintConv => {
6808             # 0 => 'Horizontal',
6809             # 1 => 'Rotate 270 CW',
6810             # 2 => 'Rotate 90 CW',
6811             # 3 => 'Rotate 180',
6812             # },
6813             #},
6814             0x2ea4 => { #PH
6815             Name => 'NikonMeteringMode',
6816             Condition => '$$self{Model} =~ /\bD500\b/', # (didn't seem to work for D5, but I need more samples)
6817             Notes => 'D500 only',
6818             Mask => 0x03,
6819             PrintConv => {
6820             0 => 'Matrix',
6821             1 => 'Center',
6822             2 => 'Spot',
6823             3 => 'Highlight'
6824             },
6825             },
6826             # note: DecryptLen currently set to OtherOffset + 0x2ea5 - 0x2c90
6827             );
6828              
6829             # shot information for the D6 firmware 1.00 (encrypted) - ref 28
6830             %Image::ExifTool::Nikon::ShotInfoD6 = (
6831             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6832             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6833             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6834             VARS => { ID_LABEL => 'Index' },
6835             DATAMEMBER => [ 0x30, 0x60, 0x9c, 0xa4, 0x75e7, 0x760c, 0x7610, 0xc219, 0xc292, 0xc40e, 0xc412, 0xc4a6, 0xc4be ],
6836             WRITABLE => 1,
6837             FIRST_ENTRY => 0,
6838             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6839             NOTES => 'These tags are extracted from encrypted data in images from the D6.',
6840             0x00 => {
6841             Name => 'ShotInfoVersion',
6842             Format => 'string[4]',
6843             Writable => 0,
6844             },
6845             0x04 => {
6846             Name => 'FirmwareVersion',
6847             Format => 'string[8]',
6848             Writable => 0,
6849             },
6850             0x24 => {
6851             Name => 'NumberOffsets', # (number of entries in offset table. offsets are from start of ShotInfo data)
6852             DataMember => 'NumberOffsets',
6853             Format => 'int32u',
6854             Writable => 0,
6855             Hidden => 1,
6856             },
6857             0x30 => {
6858             Name => 'Offset3',
6859             DataMember => 'Offset3',
6860             Format => 'int32u',
6861             Writable => 0,
6862             Hidden => 1,
6863             RawConv => '$$self{Offset3} = $val || 0x10000000; undef', # (ignore if 0)
6864             },
6865             0x60 => {
6866             Name => 'Offset15',
6867             DataMember => 'Offset15',
6868             Format => 'int32u',
6869             Writable => 0,
6870             Hidden => 1,
6871             RawConv => '$$self{Offset15} = $val || 0x10000000; undef', # (ignore if 0)
6872             },
6873             0x9c => {
6874             Name => 'OrientationOffset',
6875             DataMember => 'OrientationOffset',
6876             Format => 'int32u',
6877             Writable => 0,
6878             Hidden => 1,
6879             RawConv => '$$self{OrientationOffset} = $val || 0x10000000; undef', # (ignore if 0)
6880             },
6881             0xa4 => {
6882             Name => 'Offset32',
6883             DataMember => 'Offset32',
6884             Format => 'int32u',
6885             Writable => 0,
6886             Hidden => 1,
6887             RawConv => '$$self{Offset32} = $val || 0x10000000; undef', # (ignore if 0)
6888             },
6889             ### 0x75e8 - Offset3 info start (D6 firmware 1.33)
6890             0x75e7 => {
6891             Name => 'Hook1',
6892             Hidden => 1,
6893             RawConv => 'undef',
6894             # account for variable location of Offset5 data
6895             Hook => '$varSize = $$self{Offset3} - 0x75e8',
6896             },
6897             0x760c => {
6898             Name => 'IntervalShooting',
6899             RawConv => '$$self{IntervalShooting} = $val',
6900             Format => 'int16u',
6901             PrintConv => q{
6902             return 'Off' if $val == 0 ;
6903             my $i = sprintf("Interval %.0f of %.0f",$val, $$self{IntervalShootingIntervals}); #something like "Interval 1 of 3"
6904             my $f = $$self{IntervalShootingShotsPerInterval} > 1 ? sprintf(" Frame %.0f of %.0f",$$self{IntervalFrame}, $$self{IntervalShootingShotsPerInterval}): '' ; #something like "Frame 1 of 3" or blank
6905             return "On: $i$f"
6906             #$val == 0 ? 'Off' : sprintf("On: Interval %.0f of %.0f Frame %.0f of %.0f",$val, $$self{IntervalShootingIntervals}, $$self{IntervalFrame}, $$self{IntervalShootingShotsPerInterval}),
6907             },
6908             },
6909             0x7610 => {
6910             Name => 'IntervalFrame',
6911             RawConv => '$$self{IntervalFrame} = $val',
6912             Condition => '$$self{IntervalShooting} > 0',
6913             Format => 'int16u',
6914             Hidden => 1,
6915             },
6916             ### 0xc21a - OrientationInfo start (D6 firmware 1.00) (0xc952 for firmware 1.33)
6917             0xc219 => {
6918             Name => 'Hook2',
6919             Hidden => 1,
6920             RawConv => 'undef',
6921             # account for variable location of OrientationInfo data
6922             Hook => '$varSize = $$self{OrientationOffset} - 0xc21a',
6923             },
6924             0xc21a => {
6925             Name => 'RollAngle',
6926             Format => 'fixed32u',
6927             Notes => 'converted to degrees of clockwise camera roll',
6928             ValueConv => '$val <= 180 ? $val : $val - 360',
6929             ValueConvInv => '$val >= 0 ? $val : $val + 360',
6930             PrintConv => 'sprintf("%.1f", $val)',
6931             PrintConvInv => '$val',
6932             },
6933             0xc21e => {
6934             Name => 'PitchAngle',
6935             Format => 'fixed32u',
6936             Notes => 'converted to degrees of upward camera tilt',
6937             ValueConv => '$val <= 180 ? $val : $val - 360',
6938             ValueConvInv => '$val >= 0 ? $val : $val + 360',
6939             PrintConv => 'sprintf("%.1f", $val)',
6940             PrintConvInv => '$val',
6941             },
6942             0xc222 => {
6943             Name => 'YawAngle',
6944             Format => 'fixed32u',
6945             Notes => 'the camera yaw angle when shooting in portrait orientation',
6946             ValueConv => '$val <= 180 ? $val : $val - 360',
6947             ValueConvInv => '$val >= 0 ? $val : $val + 360',
6948             PrintConv => 'sprintf("%.1f", $val)',
6949             PrintConvInv => '$val',
6950             },
6951             ### 0xc9c6 - Offset32 start (D6 firmware 1.33)
6952             0xc292 => {
6953             Name => 'Hook3',
6954             Hidden => 1,
6955             RawConv => 'undef',
6956             # account for variable location of data
6957             Hook => '$varSize = $$self{Offset32} - 0xc292',
6958             },
6959             0xc40e => {
6960             Name => 'Intervals',
6961             Format => 'int32u',
6962             RawConv => '$$self{IntervalShootingIntervals} = $val',
6963             Condition => '$$self{IntervalShooting} > 0',
6964             },
6965             0xc412 => {
6966             Name => 'ShotsPerInterval',
6967             Format => 'int32u',
6968             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
6969             Condition => '$$self{IntervalShooting} > 0',
6970             },
6971             0xc416 => {
6972             Name => 'IntervalExposureSmoothing',
6973             Condition => '$$self{IntervalShooting} > 0',
6974             Format => 'int8u',
6975             PrintConv => \%offOn,
6976             },
6977             0xc418 => {
6978             Name => 'IntervalPriority',
6979             Condition => '$$self{IntervalShooting} > 0',
6980             Format => 'int8u',
6981             PrintConv => \%offOn,
6982             },
6983             0xc43a => {
6984             Name => 'FocusShiftNumberShots',
6985             },
6986             0xc43e => {
6987             Name => 'FocusShiftStepWidth',
6988             },
6989             0xc442 => {
6990             Name => 'FocusShiftInterval',
6991             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
6992             },
6993             0xc446 => {
6994             Name => 'FocusShiftExposureLock',
6995             PrintConv => \%offOn,
6996             },
6997             #0xc49c => HighISONoiseReduction
6998             0xc4a0 => {
6999             Name => 'DiffractionCompensation',
7000             Format => 'int8u',
7001             PrintConv => \%offOn,
7002             },
7003             #0xc4a1 => {Name => 'FlickerReductionShooting',}, #redundant with tag in NikonSettings
7004             0xc4a6 => {
7005             Name => 'FlashControlMode', #this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
7006             RawConv => '$$self{FlashControlMode} = $val',
7007             PrintConv => {
7008             0 => 'TTL',
7009             1 => 'Auto External Flash',
7010             2 => 'GN (distance priority)',
7011             3 => 'Manual',
7012             4 => 'Repeating Flash',
7013             },
7014             },
7015             0xc4ac => {
7016             Name => 'FlashGNDistance',
7017             Condition => '$$self{FlashControlMode} == 2',
7018             Unknown => 1,
7019             ValueConv => '$val + 3',
7020             PrintConv => \%flashGNDistance,
7021             },
7022             0xc4b0 => {
7023             Name => 'FlashOutput', #range[0,24] with 0=>Full; 1=>50%; then decreasing flash power in 1/3 stops to 0.39% (1/256 full power). #also found in FlashInfoUnknown at offset 0x0a (with different mappings)
7024             Condition => '$$self{FlashControlMode} >= 3',
7025             Unknown => 1,
7026             ValueConv => '2 ** (-$val/3)',
7027             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
7028             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
7029             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
7030             },
7031             0xc4ba => {
7032             Name => 'FlashRemoteControl',
7033             Unknown => 1,
7034             PrintConv => {
7035             0 => 'Group',
7036             1 => 'Quick Wireless',
7037             2 => 'Remote Repeating',
7038             },
7039             },
7040             0xc4be => {
7041             Name => 'FlashMasterControlMode', #tag name chosen for compatibility with those found in FlashInfo0102 & FlashInfo0103
7042             RawConv => '$$self{FlashGroupOptionsMasterMode} = $val',
7043             PrintConv => \%flashGroupOptionsMode,
7044             },
7045             0xc4c0 => {
7046             Name => 'FlashMasterCompensation',
7047             Unknown => 1,
7048             Format => 'int8s',
7049             Condition => '$$self{FlashGroupOptionsMasterMode} != 3', #other than 'Off'
7050             ValueConv => '$val/6',
7051             ValueConvInv => '6 * $val',
7052             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
7053             PrintConvInv => '$val',
7054             },
7055             0xc4c4 => {
7056             Name => 'FlashMasterOutput',
7057             Unknown => 1,
7058             Condition => '$$self{FlashGroupOptionsMasterMode} == 1', #only for Mode=M
7059             ValueConv => '2 ** (-$val/3)',
7060             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
7061             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
7062             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
7063             },
7064             0xc4c6 => {
7065             Name => 'FlashWirelessOption',
7066             Unknown => 1,
7067             PrintConv => {
7068             0 => 'Optical AWL',
7069             1 => 'Off',
7070             },
7071             },
7072             0xc55c => {
7073             Name => 'MovieType',
7074             Unknown => 1,
7075             PrintConv => {
7076             0 => 'MOV',
7077             1 => 'MP4',
7078             },
7079             },
7080             # note: DecryptLen currently set to 0xc9c6 + 720
7081             );
7082              
7083             # shot information for the D610 firmware 1.00 (encrypted) - ref PH
7084             %Image::ExifTool::Nikon::ShotInfoD610 = (
7085             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7086             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7087             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7088             VARS => { ID_LABEL => 'Index' },
7089             IS_SUBDIR => [ 0x07cf ],
7090             WRITABLE => 1,
7091             FIRST_ENTRY => 0,
7092             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7093             NOTES => 'These tags are extracted from encrypted data in images from the D610.',
7094             0x00 => {
7095             Name => 'ShotInfoVersion',
7096             Format => 'string[4]',
7097             Writable => 0,
7098             },
7099             0x04 => {
7100             Name => 'FirmwareVersion',
7101             Format => 'string[5]',
7102             Writable => 0,
7103             },
7104             0x07cf => {
7105             Name => 'CustomSettingsD610',
7106             Format => 'undef[48]',
7107             SubDirectory => {
7108             TagTable => 'Image::ExifTool::NikonCustom::SettingsD610',
7109             },
7110             },
7111             # note: DecryptLen currently set to 0x7ff
7112             );
7113              
7114             # shot information for the D810 firmware 1.00(PH)/1.01 (encrypted) - ref 28
7115             %Image::ExifTool::Nikon::ShotInfoD810 = (
7116             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7117             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7118             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7119             VARS => { ID_LABEL => 'Index' },
7120             DATAMEMBER => [ 0x04, 0x24, 0x38, 0x40, 0x84, 0x01d0, 0x175e, 0x185d, 0x18ab ],
7121             IS_SUBDIR => [ 0x18ab ],
7122             WRITABLE => 1,
7123             FIRST_ENTRY => 0,
7124             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7125             NOTES => q{
7126             These tags are extracted from encrypted data in images from the D810. Note
7127             that the indices listed below are for firmware version 1.0, but they may be
7128             different for other firmware versions.
7129             },
7130             0x00 => {
7131             Name => 'ShotInfoVersion',
7132             Format => 'string[4]',
7133             Writable => 0,
7134             },
7135             0x04 => {
7136             Name => 'FirmwareVersion',
7137             DataMember => 'FirmwareVersion',
7138             Format => 'string[5]',
7139             Writable => 0,
7140             RawConv => '$$self{FirmwareVersion} = $val',
7141             },
7142             # 0x0c - number of entries in offset table (= 0x21)
7143             # 0x10 - int32u[val 0x0c]: offset table
7144             0x24 => {
7145             Name => 'BracketingOffset',
7146             DataMember => 'BracketingOffset',
7147             Format => 'int32u',
7148             Writable => 0,
7149             Hidden => 1,
7150             RawConv => '$$self{BracketingOffset} = $val || 0x10000000; undef',
7151             },
7152             0x38 => {
7153             Name => 'ISOAutoOffset',
7154             DataMember => 'ISOAutoOffset',
7155             Format => 'int32u',
7156             Writable => 0,
7157             Hidden => 1,
7158             RawConv => '$$self{ISOAutoOffset} = $val || 0x10000000; undef',
7159             },
7160             0x40 => {
7161             Name => 'CustomSettingsOffset', # (relative offset from start of ShotInfo data)
7162             DataMember => 'CustomSettingsOffset',
7163             Format => 'int32u',
7164             Writable => 0,
7165             Hidden => 1,
7166             RawConv => '$$self{CustomSettingsOffset} = $val || 0x10000000; undef',
7167             },
7168             0x84 => {
7169             Name => 'OrientationOffset',
7170             DataMember => 'OrientationOffset',
7171             Format => 'int32u',
7172             Writable => 0,
7173             Hidden => 1,
7174             RawConv => '$$self{OrientationOffset} = $val || 0x10000000; undef',
7175             },
7176             0x01d0 => {
7177             Name => 'SecondarySlotFunction',
7178             Mask => 0x03,
7179             PrintConv => {
7180             0 => 'Overflow',
7181             2 => 'Backup',
7182             3 => 'NEF Primary + JPG Secondary',
7183             },
7184             Hook => '$varSize = $$self{BracketingOffset} - 0x1747',
7185             },
7186             0x1756 => {
7187             Name => 'AEBracketingSteps',
7188             Mask => 0xff,
7189             PrintHex => 1,
7190             PrintConvColumns => 2,
7191             PrintConv => {
7192             0x00 => 'AE Bracketing Disabled',
7193             0x20 => 'AE Bracketing Disabled',
7194             0x30 => 'AE Bracketing Disabled',
7195             0x40 => 'AE Bracketing Disabled',
7196             0x50 => 'AE Bracketing Disabled',
7197             0x81 => '+3F0.3',
7198             0x82 => '-3F0.3',
7199             0x83 => '+2F0.3',
7200             0x84 => '-2F0.3',
7201             0x85 => '3F0.3',
7202             0x86 => '5F0.3',
7203             0x87 => '7F0.3',
7204             0x88 => '9F0.3',
7205             0x91 => '+3F0.5',
7206             0x92 => '-3F0.5',
7207             0x93 => '+2F0.5',
7208             0x94 => '-2F0.5',
7209             0x95 => '3F0.5',
7210             0x96 => '5F0.5',
7211             0x97 => '7F0.5',
7212             0x98 => '9F0.5',
7213             0xa1 => '+3F0.7',
7214             0xa2 => '-3F0.7',
7215             0xa3 => '+2F0.7',
7216             0xa4 => '-2F0.7',
7217             0xa5 => '3F0.7',
7218             0xa6 => '5F0.7',
7219             0xa7 => '7F0.7',
7220             0xa8 => '9F0.7',
7221             0xb1 => '+3F1',
7222             0xb2 => '-3F1',
7223             0xb3 => '+2F1',
7224             0xb4 => '-2F1',
7225             0xb5 => '3F1',
7226             0xb6 => '5F1',
7227             0xb7 => '7F1',
7228             0xb8 => '9F1',
7229             0xc1 => '+3F2',
7230             0xc2 => '-3F2',
7231             0xc3 => '+2F2',
7232             0xc4 => '-2F2',
7233             0xc5 => '3F2',
7234             0xc6 => '5F2',
7235             0xd1 => '+3F3',
7236             0xd2 => '-3F3',
7237             0xd3 => '+2F3',
7238             0xd4 => '-2F3',
7239             0xd5 => '3F3',
7240             0xd6 => '5F3',
7241             },
7242             },
7243             0x1757 => {
7244             Name => 'WBBracketingSteps',
7245             Condition => '$$self{FILE_TYPE} ne "TIFF"', # (covers NEF and TIFF)
7246             Mask => 0xff,
7247             PrintHex => 1,
7248             PrintConvColumns => 2,
7249             PrintConv => {
7250             0x00 => 'WB Bracketing Disabled',
7251             0x01 => 'b3F 1',
7252             0x02 => 'A3F 1',
7253             0x03 => 'b2F 1',
7254             0x04 => 'A2F 1',
7255             0x05 => '3F 1',
7256             0x06 => '5F 1',
7257             0x07 => '7F 1',
7258             0x08 => '9F 1',
7259             0x10 => '0F 2',
7260             0x11 => 'b3F 2',
7261             0x12 => 'A3F 2',
7262             0x13 => 'b2F 2',
7263             0x14 => 'A2F 2',
7264             0x15 => '3F 2',
7265             0x16 => '5F 2',
7266             0x17 => '7F 2',
7267             0x18 => '9F 2',
7268             0x20 => '0F 3',
7269             0x21 => 'b3F 3',
7270             0x22 => 'A3F 3',
7271             0x23 => 'b2F 3',
7272             0x24 => 'A2F 3',
7273             0x25 => '3F 3',
7274             0x26 => '5F 3',
7275             0x27 => '7F 3',
7276             0x28 => '9F 3',
7277             0x22 => 'A3F 3',
7278             0x23 => 'b2F 3',
7279             0x24 => 'A2F 3',
7280             0x25 => '3F 3',
7281             0x26 => '5F 3',
7282             0x27 => '7F 3',
7283             0x28 => '9F 3',
7284             },
7285             },
7286             0x175e => {
7287             Name => 'NikonMeteringMode',
7288             Mask => 0x03,
7289             PrintConv => {
7290             0 => 'Matrix',
7291             1 => 'Center',
7292             2 => 'Spot',
7293             3 => 'Highlight'
7294             },
7295             Hook => '$varSize = $$self{ISOAutoOffset} - 0x1858',
7296             },
7297             0x185c => {
7298             Name => 'ISOAutoShutterTime',
7299             Mask => 0x3f,
7300             PrintConv => {
7301             0 => '1/4000 s',
7302             1 => '1/3200 s',
7303             2 => '1/2500 s',
7304             3 => '1/2000 s',
7305             4 => '1/1600 s',
7306             5 => '1/1250 s',
7307             6 => '1/1000 s',
7308             7 => '1/800 s',
7309             8 => '1/640 s',
7310             9 => '1/500 s',
7311             10 => '1/400 s',
7312             11 => '1/320 s',
7313             12 => '1/250 s',
7314             13 => '1/200 s',
7315             14 => '1/160 s',
7316             15 => '1/125 s',
7317             16 => '1/100 s',
7318             17 => '1/80 s',
7319             18 => '1/60 s',
7320             19 => '1/50 s',
7321             20 => '1/40 s',
7322             21 => '1/30 s',
7323             22 => '1/15 s',
7324             23 => '1/8 s',
7325             24 => '1/4 s',
7326             25 => '1/2 s',
7327             26 => '1 s',
7328             27 => '2 s',
7329             28 => '4 s',
7330             29 => '8 s',
7331             30 => '15 s',
7332             31 => '30 s',
7333             32 => 'Auto (Slowest)',
7334             33 => 'Auto (Slower)',
7335             34 => 'Auto',
7336             35 => 'Auto (Faster)',
7337             36 => 'Auto (Fastest)',
7338             },
7339             },
7340             0x185d => {
7341             Name => 'ISOAutoHiLimit',
7342             Mask => 0xff,
7343             PrintHex => 1,
7344             PrintConv => {
7345             0x24 => 'ISO 200',
7346             0x26 => 'ISO 250',
7347             0x27 => 'ISO 280',
7348             0x28 => 'ISO 320',
7349             0x2a => 'ISO 400',
7350             0x2c => 'ISO 500',
7351             0x2d => 'ISO 560',
7352             0x2e => 'ISO 640',
7353             0x30 => 'ISO 800',
7354             0x32 => 'ISO 1000',
7355             0x33 => 'ISO 1100',
7356             0x34 => 'ISO 1250',
7357             0x36 => 'ISO 1600',
7358             0x38 => 'ISO 2000',
7359             0x39 => 'ISO 2200',
7360             0x3a => 'ISO 2500',
7361             0x3c => 'ISO 3200',
7362             0x3e => 'ISO 4000',
7363             0x3f => 'ISO 4500',
7364             0x40 => 'ISO 5000',
7365             0x42 => 'ISO 6400',
7366             0x44 => 'ISO 8000',
7367             0x45 => 'ISO 9000',
7368             0x46 => 'ISO 10000',
7369             0x48 => 'ISO 12800',
7370             0x4a => 'ISO 16000',
7371             0x4b => 'ISO 18000',
7372             0x4c => 'ISO 20000',
7373             0x4e => 'ISO 25600',
7374             0x50 => 'ISO 32000',
7375             0x51 => 'ISO 36000',
7376             0x52 => 'ISO 40000',
7377             0x54 => 'ISO 51200',
7378             0x56 => 'ISO Hi 0.3',
7379             0x57 => 'ISO Hi 0.5',
7380             0x58 => 'ISO Hi 0.7',
7381             0x5a => 'ISO Hi 1.0',
7382             0x60 => 'ISO Hi 2.0',
7383             0x66 => 'ISO Hi 3.0',
7384             0x6c => 'ISO Hi 4.0',
7385             0x72 => 'ISO Hi 5.0',
7386             },
7387             Hook => '$varSize = $$self{CustomSettingsOffset} - 0x18ab',
7388             },
7389             0x18ab => { # (actual offset adjusted by Hook above)
7390             Name => 'CustomSettingsD810',
7391             Format => 'undef[53]',
7392             SubDirectory => {
7393             TagTable => 'Image::ExifTool::NikonCustom::SettingsD810',
7394             },
7395             Hook => '$varSize = $$self{OrientationOffset} - 0x36f4',
7396             },
7397             0x36f4 => {
7398             Name => 'RollAngle',
7399             Format => 'fixed32u',
7400             Notes => 'converted to degrees of clockwise camera roll',
7401             ValueConv => '$val <= 180 ? $val : $val - 360',
7402             ValueConvInv => '$val >= 0 ? $val : $val + 360',
7403             PrintConv => 'sprintf("%.1f", $val)',
7404             PrintConvInv => '$val',
7405             },
7406             0x36f8 => {
7407             Name => 'PitchAngle',
7408             Format => 'fixed32u',
7409             Notes => 'converted to degrees of upward camera tilt',
7410             ValueConv => '$val <= 180 ? $val : $val - 360',
7411             ValueConvInv => '$val >= 0 ? $val : $val + 360',
7412             PrintConv => 'sprintf("%.1f", $val)',
7413             PrintConvInv => '$val',
7414             },
7415             0x36fc => {
7416             Name => 'YawAngle',
7417             Format => 'fixed32u',
7418             Notes => 'the camera yaw angle when shooting in portrait orientation',
7419             ValueConv => '$val <= 180 ? $val : $val - 360',
7420             ValueConvInv => '$val >= 0 ? $val : $val + 360',
7421             PrintConv => 'sprintf("%.1f", $val)',
7422             PrintConvInv => '$val',
7423             },
7424             # note: DecryptLen currently set to OrientationOffset + 12
7425              
7426             # (moves around too much and doesn't fit cleanly in the offset table)
7427             #0x38be => {
7428             # Name => 'Rotation',
7429             # Condition => '$$self{FirmwareVersion} =~ /^1\.0/',
7430             # Mask => 0x30,
7431             # PrintConv => {
7432             # 0 => 'Horizontal',
7433             # 1 => 'Rotate 270 CW',
7434             # 2 => 'Rotate 90 CW',
7435             # 3 => 'Rotate 180',
7436             # },
7437             #},
7438             );
7439              
7440             # shot information for the D850 firmware 1.00b (encrypted) - ref 28
7441             %Image::ExifTool::Nikon::ShotInfoD850 = (
7442             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7443             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7444             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7445             VARS => { ID_LABEL => 'Index' },
7446             DATAMEMBER => [ 0x04, 0x58, 0xa0, 0x0fbf, 0x2efa ],
7447             IS_SUBDIR => [ 0x1038 ],
7448             WRITABLE => 1,
7449             FIRST_ENTRY => 0,
7450             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7451             NOTES => 'These tags are extracted from encrypted data in images from the D850.',
7452             0x00 => {
7453             Name => 'ShotInfoVersion',
7454             Format => 'string[4]',
7455             Writable => 0,
7456             },
7457             0x04 => {
7458             Name => 'FirmwareVersion',
7459             DataMember => 'FirmwareVersion',
7460             Format => 'string[5]',
7461             Writable => 0,
7462             RawConv => '$$self{FirmwareVersion} = $val',
7463             },
7464             0x58 => {
7465             Name => 'CustomSettingsOffset', # (relative offset from start of ShotInfo data)
7466             DataMember => 'CustomSettingsOffset',
7467             Format => 'int32u',
7468             Writable => 0,
7469             Hidden => 1,
7470             RawConv => '$$self{CustomSettingsOffset} = $val || 0x10000000; undef',
7471             },
7472             0xa0 => {
7473             Name => 'OrientationOffset',
7474             DataMember => 'OrientationOffset',
7475             Format => 'int32u',
7476             Writable => 0,
7477             Hidden => 1,
7478             RawConv => '$$self{OrientationOffset} = $val || 0x10000000; undef',
7479             },
7480             0x0791 => {
7481             Name => 'PhotoShootingMenuBankImageArea',
7482             Mask => 0x07,
7483             PrintConv => {
7484             0 => 'FX (36x24)',
7485             1 => 'DX (24x16)',
7486             2 => '5:4 (30x24)',
7487             3 => '1.2x (30x20)',
7488             4 => '1:1 (24x24)',
7489             },
7490             },
7491             0x0fbd => {
7492             Name => 'PhotoShootingMenuBank',
7493             Condition => '$$self{FILE_TYPE} eq "JPEG"',
7494             Notes => 'valid for JPEG images only',
7495             Mask => 0x03,
7496             PrintConv => {
7497             0 => 'A',
7498             1 => 'B',
7499             2 => 'C',
7500             3 => 'D',
7501             },
7502             },
7503             0x0fbf => {
7504             Name => 'PrimarySlot',
7505             Mask => 0x80,
7506             PrintConv => {
7507             0 => 'XQD Card',
7508             1 => 'SD Card',
7509             },
7510             Hook => '$varSize = $$self{CustomSettingsOffset} - 0x1038',
7511             },
7512             0x1038 => {
7513             Name => 'CustomSettingsD850',
7514             Format => 'undef[90]',
7515             SubDirectory => {
7516             TagTable => 'Image::ExifTool::NikonCustom::SettingsD850',
7517             },
7518             },
7519             ### 0x2efb - OrientationInfo start (D850 firmware 1.01a)
7520             0x2efa => {
7521             Name => 'Hook1',
7522             Hidden => 1,
7523             RawConv => 'undef',
7524             # account for variable location of OrientationInfo data
7525             Hook => '$varSize = $$self{OrientationOffset} - 0x2efb',
7526             },
7527             0x2efb => { #28
7528             Name => 'RollAngle',
7529             Format => 'fixed32u',
7530             Notes => 'converted to degrees of clockwise camera roll',
7531             ValueConv => '$val <= 180 ? $val : $val - 360',
7532             ValueConvInv => '$val >= 0 ? $val : $val + 360',
7533             PrintConv => 'sprintf("%.1f", $val)',
7534             PrintConvInv => '$val',
7535             },
7536             0x2eff => { #28
7537             Name => 'PitchAngle',
7538             Format => 'fixed32u',
7539             Notes => 'converted to degrees of upward camera tilt',
7540             ValueConv => '$val <= 180 ? $val : $val - 360',
7541             ValueConvInv => '$val >= 0 ? $val : $val + 360',
7542             PrintConv => 'sprintf("%.1f", $val)',
7543             PrintConvInv => '$val',
7544             },
7545             0x2f03 => { #28
7546             Name => 'YawAngle',
7547             Format => 'fixed32u',
7548             Notes => 'the camera yaw angle when shooting in portrait orientation',
7549             ValueConv => '$val <= 180 ? $val : $val - 360',
7550             ValueConvInv => '$val >= 0 ? $val : $val + 360',
7551             PrintConv => 'sprintf("%.1f", $val)',
7552             PrintConvInv => '$val',
7553             },
7554             # note: DecryptLen currently set to 0x2f07
7555             );
7556             # shot information for the D4 firmware 1.00g (ref PH)
7557             %Image::ExifTool::Nikon::ShotInfoD4 = (
7558             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7559             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7560             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7561             VARS => { ID_LABEL => 'Index' },
7562             IS_SUBDIR => [ 0x0751 ],
7563             WRITABLE => 1,
7564             FIRST_ENTRY => 0,
7565             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7566             NOTES => q{
7567             These tags are extracted from encrypted data in images from the D4.
7568             },
7569             0x00 => {
7570             Name => 'ShotInfoVersion',
7571             Format => 'string[4]',
7572             Writable => 0,
7573             },
7574             0x04 => {
7575             Name => 'FirmwareVersion',
7576             Format => 'string[5]',
7577             Writable => 0,
7578             },
7579             0x0751 => { #PH (NC)
7580             Name => 'CustomSettingsD4',
7581             # (seems to work for 1.00g and 1.02b)
7582             Format => 'undef[56]',
7583             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsD4' },
7584             },
7585             # note: DecryptLen currently set to 0x789
7586             );
7587              
7588             # shot information for the D4S firmware 1.01a (ref 28, encrypted)
7589             %Image::ExifTool::Nikon::ShotInfoD4S = (
7590             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7591             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7592             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7593             VARS => { ID_LABEL => 'Index' },
7594             DATAMEMBER => [ 4 ],
7595             IS_SUBDIR => [ 0x189d, 0x193d ],
7596             WRITABLE => 1,
7597             FIRST_ENTRY => 0,
7598             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7599             NOTES => 'These tags are extracted from encrypted data in images from the D4S.',
7600             0x00 => {
7601             Name => 'ShotInfoVersion',
7602             Format => 'string[4]',
7603             Writable => 0,
7604             },
7605             0x04 => {
7606             Name => 'FirmwareVersion',
7607             DataMember => 'FirmwareVersion',
7608             Format => 'string[5]',
7609             Writable => 0,
7610             RawConv => '$$self{FirmwareVersion} = $val',
7611             },
7612             0x01d0 => {
7613             Name => 'SecondarySlotFunction',
7614             Mask => 0x03,
7615             PrintConv => {
7616             0 => 'Overflow',
7617             2 => 'Backup',
7618             3 => 'NEF Primary + JPG Secondary',
7619             },
7620             },
7621             0x174c => {
7622             Name => 'AEBracketingSteps',
7623             Mask => 0xff,
7624             PrintHex => 1,
7625             PrintConvColumns => 2,
7626             PrintConv => {
7627             0x00 => 'AE Bracketing Disabled',
7628             0x20 => 'AE Bracketing Disabled',
7629             0x30 => 'AE Bracketing Disabled',
7630             0x40 => 'AE Bracketing Disabled',
7631             0x50 => 'AE Bracketing Disabled',
7632             0x81 => '+3F0.3',
7633             0x82 => '-3F0.3',
7634             0x83 => '+2F0.3',
7635             0x84 => '-2F0.3',
7636             0x85 => '3F0.3',
7637             0x86 => '5F0.3',
7638             0x87 => '7F0.3',
7639             0x88 => '9F0.3',
7640             0x91 => '+3F0.5',
7641             0x92 => '-3F0.5',
7642             0x93 => '+2F0.5',
7643             0x94 => '-2F0.5',
7644             0x95 => '3F0.5',
7645             0x96 => '5F0.5',
7646             0x97 => '7F0.5',
7647             0x98 => '9F0.5',
7648             0xa1 => '+3F0.7',
7649             0xa2 => '-3F0.7',
7650             0xa3 => '+2F0.7',
7651             0xa4 => '-2F0.7',
7652             0xa5 => '3F0.7',
7653             0xa6 => '5F0.7',
7654             0xa7 => '7F0.7',
7655             0xa8 => '9F0.7',
7656             0xb1 => '+3F1',
7657             0xb2 => '-3F1',
7658             0xb3 => '+2F1',
7659             0xb4 => '-2F1',
7660             0xb5 => '3F1',
7661             0xb6 => '5F1',
7662             0xb7 => '7F1',
7663             0xb8 => '9F1',
7664             0xc1 => '+3F2',
7665             0xc2 => '-3F2',
7666             0xc3 => '+2F2',
7667             0xc4 => '-2F2',
7668             0xc5 => '3F2',
7669             0xc6 => '5F2',
7670             0xd1 => '+3F3',
7671             0xd2 => '-3F3',
7672             0xd3 => '+2F3',
7673             0xd4 => '-2F3',
7674             0xd5 => '3F3',
7675             0xd6 => '5F3',
7676             },
7677             },
7678             0x174d => {
7679             Name => 'WBBracketingSteps',
7680             Condition => '$$self{FILE_TYPE} ne "TIFF"', # (covers NEF and TIFF)
7681             Mask => 0xff,
7682             PrintHex => 1,
7683             PrintConvColumns => 2,
7684             PrintConv => {
7685             0x00 => 'WB Bracketing Disabled',
7686             0x01 => 'b3F 1',
7687             0x02 => 'A3F 1',
7688             0x03 => 'b2F 1',
7689             0x04 => 'A2F 1',
7690             0x05 => '3F 1',
7691             0x06 => '5F 1',
7692             0x07 => '7F 1',
7693             0x08 => '9F 1',
7694             0x10 => '0F 2',
7695             0x11 => 'b3F 2',
7696             0x12 => 'A3F 2',
7697             0x13 => 'b2F 2',
7698             0x14 => 'A2F 2',
7699             0x15 => '3F 2',
7700             0x16 => '5F 2',
7701             0x17 => '7F 2',
7702             0x18 => '9F 2',
7703             0x20 => '0F 3',
7704             0x21 => 'b3F 3',
7705             0x22 => 'A3F 3',
7706             0x23 => 'b2F 3',
7707             0x24 => 'A2F 3',
7708             0x25 => '3F 3',
7709             0x26 => '5F 3',
7710             0x27 => '7F 3',
7711             0x28 => '9F 3',
7712             0x22 => 'A3F 3',
7713             0x23 => 'b2F 3',
7714             0x24 => 'A2F 3',
7715             0x25 => '3F 3',
7716             0x26 => '5F 3',
7717             0x27 => '7F 3',
7718             0x28 => '9F 3',
7719             },
7720             },
7721             0x184d => {
7722             Name => 'ReleaseMode',
7723             Mask => 0xff,
7724             PrintConv => {
7725             0 => 'Single Frame',
7726             1 => 'Continuous High Speed',
7727             3 => 'Continuous Low Speed',
7728             4 => 'Timer',
7729             32 => 'Mirror-Up',
7730             64 => 'Quiet',
7731             },
7732             },
7733             0x189d => { #PH (NC)
7734             Name => 'CustomSettingsD4S',
7735             Condition => '$$self{FirmwareVersion} =~ /^1\.00/',
7736             Notes => 'firmware version 1.00',
7737             Format => 'undef[56]',
7738             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsD4' },
7739             },
7740             0x18c2 => { # CSf1-c (no idea why it is so far away from the rest of the settings)
7741             Name => 'MultiSelectorLiveViewMode',
7742             Groups => { 1 => 'NikonCustom' },
7743             Condition => '$$self{FirmwareVersion} !~ /^1\.00/',
7744             Mask => 0xc0,
7745             PrintConv => {
7746             0 => 'Reset',
7747             1 => 'Zoom',
7748             3 => 'None',
7749             },
7750             },
7751             0x18ea => {
7752             Name => 'ISOAutoShutterTime',
7753             Mask => 0x3f,
7754             PrintConv => {
7755             0 => '1/4000 s',
7756             1 => '1/3200 s',
7757             2 => '1/2500 s',
7758             3 => '1/2000 s',
7759             4 => '1/1600 s',
7760             5 => '1/1250 s',
7761             6 => '1/1000 s',
7762             7 => '1/800 s',
7763             8 => '1/640 s',
7764             9 => '1/500 s',
7765             10 => '1/400 s',
7766             11 => '1/320 s',
7767             12 => '1/250 s',
7768             13 => '1/200 s',
7769             14 => '1/160 s',
7770             15 => '1/125 s',
7771             16 => '1/100 s',
7772             17 => '1/80 s',
7773             18 => '1/60 s',
7774             19 => '1/50 s',
7775             20 => '1/40 s',
7776             21 => '1/30 s',
7777             22 => '1/15 s',
7778             23 => '1/8 s',
7779             24 => '1/4 s',
7780             25 => '1/2 s',
7781             26 => '1 s',
7782             27 => '2 s',
7783             28 => '4 s',
7784             29 => '8 s',
7785             30 => '15 s',
7786             31 => '30 s',
7787             32 => 'Auto (Slowest)',
7788             33 => 'Auto (Slower)',
7789             34 => 'Auto',
7790             35 => 'Auto (Faster)',
7791             36 => 'Auto (Fastest)',
7792             },
7793             },
7794             0x18eb => {
7795             Name => 'ISOAutoHiLimit',
7796             Mask => 0xff,
7797             PrintHex => 1,
7798             PrintConv => {
7799             0x24 => 'ISO 200',
7800             0x26 => 'ISO 250',
7801             0x27 => 'ISO 280',
7802             0x28 => 'ISO 320',
7803             0x2a => 'ISO 400',
7804             0x2c => 'ISO 500',
7805             0x2d => 'ISO 560',
7806             0x2e => 'ISO 640',
7807             0x30 => 'ISO 800',
7808             0x32 => 'ISO 1000',
7809             0x33 => 'ISO 1100',
7810             0x34 => 'ISO 1250',
7811             0x36 => 'ISO 1600',
7812             0x38 => 'ISO 2000',
7813             0x39 => 'ISO 2200',
7814             0x3a => 'ISO 2500',
7815             0x3c => 'ISO 3200',
7816             0x3e => 'ISO 4000',
7817             0x3f => 'ISO 4500',
7818             0x40 => 'ISO 5000',
7819             0x42 => 'ISO 6400',
7820             0x44 => 'ISO 8000',
7821             0x45 => 'ISO 9000',
7822             0x46 => 'ISO 10000',
7823             0x48 => 'ISO 12800',
7824             0x4a => 'ISO 16000',
7825             0x4b => 'ISO 18000',
7826             0x4c => 'ISO 20000',
7827             0x4e => 'ISO 25600',
7828             0x50 => 'ISO 32000',
7829             0x51 => 'ISO 36000',
7830             0x52 => 'ISO 40000',
7831             0x54 => 'ISO 51200',
7832             0x56 => 'ISO Hi 0.3',
7833             0x57 => 'ISO Hi 0.5',
7834             0x58 => 'ISO Hi 0.7',
7835             0x5a => 'ISO Hi 1.0',
7836             0x60 => 'ISO Hi 2.0',
7837             0x66 => 'ISO Hi 3.0',
7838             0x6c => 'ISO Hi 4.0',
7839             0x72 => 'ISO Hi 5.0',
7840             },
7841             },
7842             0x193d => {
7843             Name => 'CustomSettingsD4S',
7844             Condition => '$$self{FirmwareVersion} !~ /^1\.00/',
7845             Notes => 'firmware version 1.01',
7846             Format => 'undef[56]',
7847             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsD4' },
7848             },
7849             # 0x1978 => { # this decode works, but involves more bits than should be necessary
7850             # Name => 'ShutterTrigger',
7851             # Mask => 0xff,
7852             # PrintConv => {
7853             # 0 => 'Timer',
7854             # 15 => 'Cable Release/Remote',
7855             # 195 => 'Shutter Button',
7856             # },
7857             # },
7858             0x350b => {
7859             Name => 'RollAngle',
7860             Format => 'fixed32u',
7861             Notes => 'converted to degrees of clockwise camera roll',
7862             ValueConv => '$val < 180 ? -$val : 360 - $val',
7863             ValueConvInv => '$val <= 0 ? -$val : 360 - $val',
7864             PrintConv => 'sprintf("%.1f", $val)',
7865             PrintConvInv => '$val',
7866             },
7867             0x350f => {
7868             Name => 'PitchAngle',
7869             Format => 'fixed32u',
7870             Notes => 'converted to degrees of upward camera tilt',
7871             ValueConv => '$val <= 180 ? $val : $val - 360',
7872             ValueConvInv => '$val >= 0 ? $val : $val + 360',
7873             PrintConv => 'sprintf("%.1f", $val)',
7874             PrintConvInv => '$val',
7875             },
7876             0x3513 => {
7877             Name => 'YawAngle',
7878             Format => 'fixed32u',
7879             Notes => 'the camera yaw angle when shooting in portrait orientation',
7880             ValueConv => '$val <= 180 ? $val : $val - 360',
7881             ValueConvInv => '$val >= 0 ? $val : $val + 360',
7882             PrintConv => 'sprintf("%.1f", $val)',
7883             PrintConvInv => '$val',
7884             },
7885             0x3693 => {
7886             Name => 'Rotation',
7887             Mask => 0x30,
7888             PrintConv => {
7889             0 => 'Horizontal',
7890             1 => 'Rotate 270 CW',
7891             2 => 'Rotate 90 CW',
7892             3 => 'Rotate 180',
7893             },
7894             },
7895             # note: DecryptLen currently set to 0x3697
7896             );
7897              
7898             # shot information for the Z7II firmware 1.00 (encrypted) - ref 28
7899             %Image::ExifTool::Nikon::ShotInfoZ7II = (
7900             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7901             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7902             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7903             VARS => { ID_LABEL => 'Index' },
7904             DATAMEMBER => [ 0x04, 0x30, 0x38, 0x98, 0xa0, 0x75e7, 0x760c,
7905             0x7610, 0x7eff, 0xce31, 0xcea5, 0xceb6, 0xceb7 ],
7906             IS_SUBDIR => [ 0xceb8 ],
7907             WRITABLE => 1,
7908             FIRST_ENTRY => 0,
7909             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7910             NOTES => 'These tags are extracted from encrypted data in images from the Z7II.',
7911             0x00 => {
7912             Name => 'ShotInfoVersion',
7913             Format => 'string[4]',
7914             Writable => 0,
7915             },
7916             0x04 => {
7917             Name => 'FirmwareVersion',
7918             DataMember => 'FirmwareVersion',
7919             Format => 'string[8]',
7920             Writable => 0,
7921             RawConv => '$$self{FirmwareVersion} = $val',
7922             },
7923             0x0e => {
7924             Name => 'FirmwareVersion2',
7925             Format => 'string[8]',
7926             Writable => 0,
7927             Hidden => 1,
7928             },
7929             0x18 => {
7930             Name => 'FirmwareVersion3',
7931             Format => 'string[8]',
7932             Writable => 0,
7933             Hidden => 1,
7934             },
7935             0x24 => {
7936             Name => 'NumberOffsets', # number of entries in offset table. offsets are from start of ShotInfo data.
7937             DataMember => 'NumberOffsets',
7938             Format => 'int32u',
7939             Writable => 0,
7940             Hidden => 1,
7941             },
7942             0x30 => {
7943             Name => 'Offset3',
7944             DataMember => 'Offset3',
7945             Format => 'int32u',
7946             Writable => 0,
7947             Hidden => 1,
7948             RawConv => '$$self{Offset3} = $val || 0x10000000; undef', # (ignore if 0)
7949             },
7950             0x38 => {
7951             Name => 'Offset5',
7952             DataMember => 'Offset5',
7953             Format => 'int32u',
7954             Writable => 0,
7955             Hidden => 1,
7956             RawConv => '$$self{Offset5} = $val || 0x10000000; undef', # (ignore if 0)
7957             },
7958             0x98 => {
7959             Name => 'OrientationOffset',
7960             DataMember => 'OrientationOffset',
7961             Format => 'int32u',
7962             Writable => 0,
7963             Hidden => 1,
7964             RawConv => '$$self{OrientationOffset} = $val || 0x10000000; undef', # (ignore if 0)
7965             },
7966             0xa0 => {
7967             Name => 'Offset31',
7968             DataMember => 'Offset31',
7969             Format => 'int32u',
7970             Writable => 0,
7971             Hidden => 1,
7972             RawConv => '$$self{Offset31} = $val || 0x10000000; undef', # (ignore if 0)
7973             },
7974             ### 0x75e8 - Offset3 info start (Z7II firmware 1.30)
7975             0x75e7 => {
7976             Name => 'Hook1',
7977             Hidden => 1,
7978             RawConv => 'undef',
7979             # account for variable location of Offset3 data
7980             Hook => '$varSize = $$self{Offset3} - 0x75e8',
7981             },
7982             0x760c => {
7983             Name => 'IntervalShooting',
7984             RawConv => '$$self{IntervalShooting} = $val',
7985             Format => 'int16u',
7986             PrintConv => q{
7987             return 'Off' if $val == 0 ;
7988             my $i = sprintf("Interval %.0f of %.0f",$val, $$self{IntervalShootingIntervals}); # something like "Interval 1 of 3"
7989             my $f = $$self{IntervalShootingShotsPerInterval} > 1 ? sprintf(" Frame %.0f of %.0f",$$self{IntervalFrame}, $$self{IntervalShootingShotsPerInterval}): '' ; # something like "Frame 1 of 3" or blank
7990             return "On: $i$f"
7991             #$val == 0 ? 'Off' : sprintf("On: Interval %.0f of %.0f Frame %.0f of %.0f",$val, $$self{IntervalShootingIntervals}, $$self{IntervalFrame}, $$self{IntervalShootingShotsPerInterval}),
7992             },
7993             },
7994             0x7610 => {
7995             Name => 'IntervalFrame',
7996             RawConv => '$$self{IntervalFrame} = $val',
7997             Condition => '$$self{IntervalShooting} > 0',
7998             Format => 'int16u',
7999             Hidden => 1,
8000             },
8001             ### 0x7f00 - Offset5 info start (Z7II firmware 1.30)
8002             0x7eff => {
8003             Name => 'Hook2',
8004             Hidden => 1,
8005             RawConv => 'undef',
8006             # account for variable location of Offset5 data
8007             Hook => '$varSize = $$self{Offset5} - 0x7f00',
8008             },
8009             0x7fa0 => { #28
8010             Name => 'PortraitImpressionBalance', # will be 0 for firmware 1.21 and earlier; firmware 1.30 onward: will be set by Photo Shooting Menu entry Portrait Impression Balance
8011             # offset5+160; 128 is neutral; >128 increases Yellow; <128 increases Magenta; increments of 4 result from 1 full unit adjustment on the camera
8012             # offset5+161 128 is neutral; >128 increases Brightness; <128 decreases Brightness
8013             # with firmware 1.30 when 'Off' is selected in the Shooting menu, offsets 160 & 161 will contain 255. Selecting Mode 1,2, or 3 will populate offsets 160 & 161 with values in the range [116,141]
8014             Format => 'int8u[2]',
8015             Condition => '$$self{FirmwareVersion} ge "01.30"',
8016             PrintConv => q{
8017             return 'Off' if $val eq '0 0' or $val eq '255 255';
8018             my @v = split ' ', $val;
8019             my $brightness = $v[1]==128 ? 'Brightness: Neutral' : sprintf('Brightness: %+.1f',($v[1]-128)/4);
8020             my $color = $v[0]==128 ? 'Color: Neutral' : sprintf('%s: %.1f', $v[0]>128 ? 'Yellow' : 'Magenta', abs($v[0]-128)/4);
8021             # will return something like: 'Magenta: 1.0 Brightness: Neutral'
8022             return "$color $brightness"
8023             },
8024             },
8025             ### 0xce32 - OrientationInfo start (Z7II firmware 1.00)
8026             0xce31 => {
8027             Name => 'Hook3',
8028             Hidden => 1,
8029             RawConv => 'undef',
8030             # account for variable location of OrientationInfo data
8031             Hook => '$varSize = $$self{OrientationOffset} - 0xce32',
8032             },
8033              
8034             0xce32 => {
8035             Name => 'RollAngle',
8036             Format => 'fixed32u',
8037             Notes => 'converted to degrees of clockwise camera roll',
8038             ValueConv => '$val <= 180 ? $val : $val - 360',
8039             ValueConvInv => '$val >= 0 ? $val : $val + 360',
8040             PrintConv => 'sprintf("%.1f", $val)',
8041             PrintConvInv => '$val',
8042             },
8043             0xce36 => {
8044             Name => 'PitchAngle',
8045             Format => 'fixed32u',
8046             Notes => 'converted to degrees of upward camera tilt',
8047             ValueConv => '$val <= 180 ? $val : $val - 360',
8048             ValueConvInv => '$val >= 0 ? $val : $val + 360',
8049             PrintConv => 'sprintf("%.1f", $val)',
8050             PrintConvInv => '$val',
8051             },
8052             0xce3a => {
8053             Name => 'YawAngle',
8054             Format => 'fixed32u',
8055             Notes => 'the camera yaw angle when shooting in portrait orientation',
8056             ValueConv => '$val <= 180 ? $val : $val - 360',
8057             ValueConvInv => '$val >= 0 ? $val : $val + 360',
8058             PrintConv => 'sprintf("%.1f", $val)',
8059             PrintConvInv => '$val',
8060             },
8061             0xcea5 => {
8062             Name => 'Hook4',
8063             Hidden => 1,
8064             RawConv => 'undef',
8065             # account for variable location of Offset31 data
8066             Hook => '$varSize = $$self{Offset31} - 0xcea6',
8067             },
8068             ### 0xcea6 - Offset31 info start (Z7II firmware 1.30)
8069             0xceb6 => {
8070             Name => 'MenuSettingsZ7IIOffset',
8071             # offset to MenuSettingsZ7II is relative to start of Offset31 block
8072             RawConv => '$$self{MenuSettingsZ7IIOffset} = ($val || 0x10000000) + $$self{Offset31}; undef', # (ignore if 0)
8073             },
8074             0xceb7 => {
8075             Name => 'Hook5',
8076             Hidden => 1,
8077             RawConv => 'undef',
8078             # account for variable location of Offset5 data
8079             Hook => '$varSize = $$self{MenuSettingsZ7IIOffset} - 0xceb8',
8080             },
8081             0xceb8 => { # (this is 0xd04e for the Z50)
8082             Name => 'MenuSettingsZ7II',
8083             Format => 'undef[860]',
8084             SubDirectory => {
8085             TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ7II',
8086             },
8087             }
8088             # note: DecryptLen currently set to 0xd04e + 860 (offset for Z50 is 0xd04e)
8089             );
8090              
8091             # shot information for the Z9 firmware 1.00 (encrypted) - ref 28
8092             %Image::ExifTool::Nikon::ShotInfoZ9 = (
8093             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
8094             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
8095             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8096             VARS => { ID_LABEL => 'Index' },
8097             DATAMEMBER => [ 0x04, 0x30, 0x38, 0x84, 0x8c, 0x6c6f, 0x6c90, 0x6c98,
8098             0x6c9a, 0xeaea, 0xeb6f, 0xeb70 ],
8099             IS_SUBDIR => [ 0xec4b ],
8100             WRITABLE => 1,
8101             FIRST_ENTRY => 0,
8102             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8103             NOTES => 'These tags are extracted from encrypted data in images from the Z9.',
8104             0x00 => {
8105             Name => 'ShotInfoVersion',
8106             Format => 'string[4]',
8107             Writable => 0,
8108             },
8109             0x04 => {
8110             Name => 'FirmwareVersion',
8111             DataMember => 'FirmwareVersion',
8112             Format => 'string[8]',
8113             Writable => 0,
8114             RawConv => '$$self{FirmwareVersion} = $val',
8115             },
8116             0x0e => {
8117             Name => 'FirmwareVersion2',
8118             Format => 'string[8]',
8119             Writable => 0,
8120             Hidden => 1,
8121             },
8122             0x18 => {
8123             Name => 'FirmwareVersion3',
8124             Format => 'string[8]',
8125             Writable => 0,
8126             Hidden => 1,
8127             },
8128             0x24 => {
8129             Name => 'NumberOffsets', # number of entries in offset table. offsets are from start of ShotInfo data.
8130             DataMember => 'NumberOffsets',
8131             Format => 'int32u',
8132             Writable => 0,
8133             Hidden => 1,
8134             },
8135             0x30 => {
8136             Name => 'Offset3', #offset3 - length 2528 (Z9 firmware 1.0)
8137             DataMember => 'Offset3',
8138             Format => 'int32u',
8139             Writable => 0,
8140             Hidden => 1,
8141             RawConv => '$$self{Offset3} = $val || 0x10000000; undef', # (ignore if 0)
8142             },
8143             0x38 => {
8144             Name => 'Offset5', #offset5 - length 2488 (Z9 firmware 1.0)
8145             DataMember => 'Offset5',
8146             Format => 'int32u',
8147             Writable => 0,
8148             Hidden => 1,
8149             RawConv => '$$self{Offset5} = $val || 0x10000000; undef', # (ignore if 0)
8150             },
8151             0x84 => {
8152             Name => 'OrientationOffset', #offset24 - length 108 (Z9 firmware 1.0)
8153             DataMember => 'OrientationOffset',
8154             Format => 'int32u',
8155             Writable => 0,
8156             Hidden => 1,
8157             RawConv => '$$self{OrientationOffset} = $val || 0x10000000; undef', # (ignore if 0)
8158             },
8159             0x8c => {
8160             Name => 'Offset26', #offset26 - length 1895 (Z9 firmware 1.0)
8161             DataMember => 'Offset26',
8162             Format => 'int32u',
8163             Writable => 0,
8164             Hidden => 1,
8165             RawConv => '$$self{Offset26} = $val || 0x10000000; undef', # (ignore if 0)
8166             },
8167             ### 0x6c70 - Offset3 info start (Z9 firmware 1.00)
8168             0x6c6f => {
8169             Name => 'Offset3Hook',
8170             Hidden => 1,
8171             RawConv => 'undef',
8172             # account for variable location of Offset3 data
8173             Hook => '$varSize = $$self{Offset3} - 0x6c70',
8174             },
8175             0x6c90 => {
8176             Name => 'FocusShiftShooting',
8177             RawConv => '$$self{FocusShiftShooting} = $val',
8178             PrintConv => q{
8179             return 'Off' if $val == 0 ;
8180             my $i = sprintf("Frame %.0f of %.0f",$val, $$self{FocusShiftNumberShots}); # something like Frame 1 of 100"
8181             return "On: $i"
8182             },
8183             },
8184             0x6c98 => {
8185             Name => 'IntervalShooting',
8186             RawConv => '$$self{IntervalShooting} = $val',
8187             Format => 'int16u',
8188             PrintConv => q{
8189             return 'Off' if $val == 0 ;
8190             my $i = sprintf("Interval %.0f of %.0f",$val, $$self{IntervalShootingIntervals}); # something like "Interval 1 of 3"
8191             my $f = $$self{IntervalShootingShotsPerInterval} > 1 ? sprintf(" Frame %.0f of %.0f",$$self{IntervalFrame}, $$self{IntervalShootingShotsPerInterval}): '' ; # something like "Frame 1 of 3" or blank
8192             return "On: $i$f"
8193             #$val == 0 ? 'Off' : sprintf("On: Interval %.0f of %.0f Frame %.0f of %.0f",$val, $$self{IntervalShootingIntervals}, $$self{IntervalFrame}, $$self{IntervalShootingShotsPerInterval}),
8194             },
8195             },
8196             0x6c9a => {
8197             Name => 'IntervalFrame',
8198             RawConv => '$$self{IntervalFrame} = $val',
8199             Condition => '$$self{IntervalShooting} > 0',
8200             Format => 'int16u',
8201             Hidden => 1,
8202             },
8203             ### 0xeaeb - OrientationInfo start (Z9 firmware 1.00)
8204             0xeaea => {
8205             Name => 'OrientationHook',
8206             Hidden => 1,
8207             RawConv => 'undef',
8208             # account for variable location of OrientationInfo data
8209             Hook => '$varSize = $$self{OrientationOffset} - 0xeaeb',
8210             },
8211             0xeaeb => {
8212             Name => 'RollAngle',
8213             Format => 'fixed32u',
8214             Notes => 'converted to degrees of clockwise camera roll',
8215             ValueConv => '$val <= 180 ? $val : $val - 360',
8216             ValueConvInv => '$val >= 0 ? $val : $val + 360',
8217             PrintConv => 'sprintf("%.1f", $val)',
8218             PrintConvInv => '$val',
8219             },
8220             0xeaef => {
8221             Name => 'PitchAngle',
8222             Format => 'fixed32u',
8223             Notes => 'converted to degrees of upward camera tilt',
8224             ValueConv => '$val <= 180 ? $val : $val - 360',
8225             ValueConvInv => '$val >= 0 ? $val : $val + 360',
8226             PrintConv => 'sprintf("%.1f", $val)',
8227             PrintConvInv => '$val',
8228             },
8229             0xeaf3 => {
8230             Name => 'YawAngle',
8231             Format => 'fixed32u',
8232             Notes => 'the camera yaw angle when shooting in portrait orientation',
8233             ValueConv => '$val <= 180 ? $val : $val - 360',
8234             ValueConvInv => '$val >= 0 ? $val : $val + 360',
8235             PrintConv => 'sprintf("%.1f", $val)',
8236             PrintConvInv => '$val',
8237             },
8238             ### 0xeb5f - Offset26 info start (Z9 firmware 1.00)
8239             0xeb6f => {
8240             Name => 'MenuSettingsZ9Offset',
8241             Writable => 0,
8242             Hidden => 1,
8243             # offset to MenuSettingsZ9 is relative to start of Offset26 block
8244             RawConv => '$$self{MenuSettingsZ9Offset} = ($val || 0x10000000) + $$self{Offset26}; undef', # (ignore if 0)
8245             },
8246             0xeb70 => {
8247             Name => 'Hook5',
8248             Hidden => 1,
8249             RawConv => 'undef',
8250             # account for variable location of menu settings data
8251             Hook => '$varSize = $$self{MenuSettingsZ9Offset} - 0xec4b',
8252             },
8253             0xec4b => {
8254             Name => 'MenuSettingsZ9',
8255             Format => 'undef[1646]',
8256             Condition => '$$self{FirmwareVersion} lt "03.00"',
8257             SubDirectory => {
8258             TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ9',
8259             },
8260             },
8261             # note: DecryptLen currently set to 0xec4b + 1646
8262             );
8263              
8264             %Image::ExifTool::Nikon::MenuSettingsZ7II = (
8265             %binaryDataAttrs,
8266             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8267             DATAMEMBER => [ 176, 180, 328, 352, 858 ],
8268             NOTES => 'These tags are used by the Z5, Z6, Z7, Z6II, Z7II, Z50 and Zfc.',
8269             160 => {
8270             Name => 'IntervalDurationHours',
8271             Format => 'int32u',
8272             #Condition => '$$self{IntervalShooting} > 0',
8273             },
8274             164 => {
8275             Name => 'IntervalDurationMinutes',
8276             Format => 'int32u',
8277             #Condition => '$$self{IntervalShooting} > 0',
8278             },
8279             168 => {
8280             Name => 'IntervalDurationSeconds',
8281             Format => 'int32u',
8282             #Condition => '$$self{IntervalShooting} > 0',
8283             },
8284             176 => {
8285             Name => 'Intervals',
8286             Format => 'int32u',
8287             RawConv => '$$self{IntervalShootingIntervals} = $val',
8288             #Condition => '$$self{IntervalShooting} > 0',
8289             },
8290             180 => {
8291             Name => 'ShotsPerInterval',
8292             Format => 'int32u',
8293             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
8294             #Condition => '$$self{IntervalShooting} > 0',
8295             },
8296             184 => {
8297             Name => 'IntervalExposureSmoothing',
8298             #Condition => '$$self{IntervalShooting} > 0',
8299             Format => 'int8u',
8300             PrintConv => \%offOn,
8301             },
8302             186 => {
8303             Name => 'IntervalPriority',
8304             #Condition => '$$self{IntervalShooting} > 0',
8305             Format => 'int8u',
8306             PrintConv => \%offOn,
8307             },
8308             220 => {
8309             Name => 'FocusShiftNumberShots',
8310             },
8311             224 => {
8312             Name => 'FocusShiftStepWidth',
8313             },
8314             228 => {
8315             Name => 'FocusShiftInterval',
8316             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
8317             },
8318             232 => {
8319             Name => 'FocusShiftExposureLock',
8320             PrintConv => \%offOn,
8321             },
8322             #304 => White Balance - Kelvin Temp
8323             #312 => ColorSpace
8324             #314 => ActiveD-Lighting
8325             #318 => HighISONoiseReduction
8326             322 => {
8327             Name => 'DiffractionCompensation',
8328             Format => 'int8u',
8329             PrintConv => \%offOn,
8330             },
8331             323 => {
8332             Name => 'AutoDistortionControl',
8333             Format => 'int8u',
8334             PrintConv => \%offOn,
8335             },
8336             #324 => {Name => 'FlickerReductionShooting',}, # redundant with tag in NikonSettings
8337             326 => {
8338             Name => 'NikonMeteringMode',
8339             Unknown => 1,
8340             PrintConv => {
8341             0 => 'Matrix',
8342             1 => 'Center',
8343             2 => 'Spot',
8344             3 => 'Highlight'
8345             },
8346             },
8347             326 => { Name => 'NikonMeteringMode', PrintConv => \%meteringModeZ7},
8348             328 => {
8349             Name => 'FlashControlMode', # this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
8350             RawConv => '$$self{FlashControlMode} = $val',
8351             PrintConv => \%flashControlModeZ7,
8352             },
8353             334 => {
8354             Name => 'FlashGNDistance',
8355             Condition => '$$self{FlashControlMode} == 2',
8356             Unknown => 1,
8357             ValueConv => '$val + 3',
8358             PrintConv => \%flashGNDistance,
8359             },
8360             338 => {
8361             Name => 'FlashOutput', # range[0,24] with 0=>Full; 1=>50%; then decreasing flash power in 1/3 stops to 0.39% (1/256 full power). also found in FlashInfoUnknown at offset 0x0a (with different mappings)
8362             Condition => '$$self{FlashControlMode} >= 3',
8363             Unknown => 1,
8364             ValueConv => '2 ** (-$val/3)',
8365             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
8366             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
8367             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
8368             },
8369             346 => { Name => 'FlashWirelessOption', PrintConv => \%flashWirelessOptionZ7, Unknown => 1},
8370             348 => { Name => 'FlashRemoteControl', PrintConv => \%flashRemoteControlZ7, Unknown => 1},
8371             352 => {
8372             Name => 'FlashMasterControlMode', # tag name chosen for compatibility with those found in FlashInfo0102 & FlashInfo0103
8373             RawConv => '$$self{FlashGroupOptionsMasterMode} = $val',
8374             PrintConv => \%flashGroupOptionsMode,
8375             },
8376             354 => {
8377             Name => 'FlashMasterCompensation',
8378             Format => 'int8s',
8379             Condition => '$$self{FlashGroupOptionsMasterMode} != 3', # other than 'Off'
8380             Unknown => 1,
8381             ValueConv => '$val/6',
8382             ValueConvInv => '6 * $val',
8383             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
8384             PrintConvInv => '$val',
8385             },
8386             358 => {
8387             Name => 'FlashMasterOutput',
8388             Unknown => 1,
8389             Condition => '$$self{FlashGroupOptionsMasterMode} == 1', # only for Mode=M
8390             ValueConv => '2 ** (-$val/3)',
8391             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
8392             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
8393             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
8394             },
8395             #360 => {Name => 'FlashGroupAControlMode', }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupACompensation at 362 and FlashGroupAOutput at 368
8396             #368 => {Name => 'FlashGroupBControlMode', }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupBCompensation at 370 and FlashGroupBOutput at 374
8397             #376 => {Name => 'FlashGroupCControlMode', }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupCCompensation at 378 and FlashGroupCOutput at 382
8398             #384 => {Name => 'FlashGroupDControlMode', }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupDCompensation at 386 and FlashGroupDOutput at 390
8399             #392 => {Name => 'FlashGroupEControlMode', }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupECompensation at 394 and FlashGroupEOutput at 398
8400             #400 => {Name => 'FlashGroupFControlMode', }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupFCompensation at 402 and FlashGroupFOutput at 406
8401             #434 => FocusMode
8402             #436 => AFAreaMode
8403             #438 => VibrationReduction
8404             #442 => BracketSet
8405             #444 => BracketProgram
8406             #446 => BracketIncrement
8407             #463 => SilentPhotography
8408             502 => { Name => 'MovieFrameSize', PrintConv => \%movieFrameSizeZ9, Unknown => 1},
8409             504 => { Name => 'MovieFrameRate', PrintConv => \%movieFrameRateZ7, Unknown => 1},
8410             506 => {
8411             Name => 'MovieSlowMotion',
8412             Unknown => 1,
8413             PrintConv => {
8414             0 => 'Off',
8415             1 => 'On (4x)', # 120p recording with playback @ 30p [1920 x 1080; 30p x 4] or 100p recording with playback @ 25p [1920 x 1080; 25p x 4]
8416             2 => 'On (5x)', # 120p recording with playback @ 24p [1920 x 1080; 20p x 5]
8417             },
8418             },
8419             510 => {
8420             Name => 'MovieType',
8421             Unknown => 1,
8422             PrintConv => {
8423             0 => 'MOV',
8424             1 => 'MP4',
8425             },
8426             },
8427             #512 => MovieISOAutoHiLimit
8428             516 => {
8429             Name => 'MovieISOAutoManualMode',
8430             Condition => '$$self{Model} =~ /^NIKON 7/', #ISO ranges vary by model. These mappings are for the Z7 and Z7II
8431             Format => 'int16u',
8432             Unknown => 1,
8433             ValueConv => '($val-104)/8',
8434             ValueConvInv => '8 * ($val + 104)',
8435             PrintConv => \%iSOAutoHiLimitZ7,
8436             },
8437             #520 => MovieWhiteBalanceSameAsPhoto
8438             568 => { Name => 'MovieActiveD-Lighting', PrintConv => \%activeDLightingZ7, Unknown => 1},
8439             572 => { Name => 'MovieHighISONoiseReduction', PrintConv => \%offLowNormalHighZ7, Unknown => 1},
8440             574 => { Name => 'MovieVignetteControl', PrintConv => \%offLowNormalHighZ7, Unknown => 1},
8441             576 => {
8442             Name => 'MovieVignetteControlSameAsPhoto',
8443             Unknown => 1,
8444             PrintConv => \%noYes
8445             },
8446             577 => {
8447             Name => 'MovieDiffractionCompensation',
8448             Unknown => 1,
8449             PrintConv => \%offOn
8450             },
8451             578 => {
8452             Name => 'MovieAutoDistortionControl',
8453             Unknown => 1,
8454             PrintConv => \%offOn
8455             },
8456             584 => { Name => 'MovieFocusMode', PrintConv => \%focusModeZ7, Unknown => 1},
8457             #586 => MovieAFAreaMode
8458             590 => {
8459             Name => 'MovieVibrationReduction',
8460             Unknown => 1,
8461             PrintConv => {
8462             0 => 'Off',
8463             1 => 'On (Normal)',
8464             2 => 'On (Sport)',
8465             },
8466             },
8467             591 => {
8468             Name => 'MovieVibrationReductionSameAsPhoto',
8469             Unknown => 1,
8470             PrintConv => \%noYes
8471             },
8472             #848 => HDMIOutputResolution
8473             #850 => HDMIOutputRange
8474             #854 => HDMIExternalRecorder
8475             #856 => HDMIBitDepth
8476             858 => {
8477             Name => 'HDMIOutputN-Log', # one of the choices under SettingsMenu/HDMI/Advanced. Curiously,the HDR/HLC output option which is controlled by the same sub-menu is decoded thru NikonSettings
8478             Condition => '$$self{HDMIBitDepth} and $$self{HDMIBitDepth} == 2', # only for 10 bit
8479             RawConv => '$$self{HDMIOutputNLog} = $val',
8480             Unknown => 1,
8481             PrintConv => \%offOn,
8482             },
8483             #859 => HDMIViewAssist
8484             );
8485              
8486             %Image::ExifTool::Nikon::MenuSettingsZ9 = (
8487             %binaryDataAttrs,
8488             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8489             DATAMEMBER => [ 140, 188, 192, 232, 424, 534 ],
8490             IS_SUBDIR => [ 799 ],
8491             NOTES => 'These tags are used by the Z9.',
8492             #90 ISO
8493             140 => {
8494             Name => 'MultipleExposureMode',
8495             RawConv => '$$self{MultipleExposureMode} = $val',
8496             PrintConv => {
8497             0 => 'Off',
8498             1 => 'On (Series)',
8499             2 => 'On',
8500             },
8501             },
8502             142 => {Name => 'MultiExposureShots', Condition => '$$self{MultipleExposureMode} != 0' }, #range 2-9
8503             188 => {
8504             Name => 'Intervals',
8505             Format => 'int32u',
8506             RawConv => '$$self{IntervalShootingIntervals} = $val',
8507             Condition => '$$self{IntervalShooting} > 0',
8508             },
8509             192 => {
8510             Name => 'ShotsPerInterval',
8511             Format => 'int32u',
8512             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
8513             Condition => '$$self{IntervalShooting} > 0',
8514             },
8515             #220 NEFCompression 0=> 'Lossless' 1=> 'High Efficiency*' 4=> 'High Efficientcy'
8516             232 => {
8517             Name => 'FocusShiftNumberShots', #1-300
8518             RawConv => '$$self{FocusShiftNumberShots} = $val',
8519             Condition => '$$self{FocusShiftShooting} > 0',
8520             },
8521             236 => {
8522             Name => 'FocusShiftStepWidth', #1(Narrow) to 10 (Wide)
8523             Condition => '$$self{FocusShiftShooting} > 0',
8524             },
8525             240 => {
8526             Name => 'FocusShiftInterval',
8527             Condition => '$$self{FocusShiftShooting} > 0',
8528             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
8529             },
8530             244 => {
8531             Name => 'FocusShiftExposureLock',
8532             Unknown => 1,
8533             PrintConv => \%offOn,
8534             Condition => '$$self{FocusShiftShooting} > 0',
8535             },
8536             274 => {
8537             Name => 'PhotoShootingMenuBank',
8538             PrintConv => {
8539             0 => 'A',
8540             1 => 'B',
8541             2 => 'C',
8542             3 => 'D',
8543             },
8544             },
8545             276 => { Name => 'ExtendedMenuBanks', PrintConv => \%offOn, }, #single tag from both Photo & Video menus
8546             308 => {
8547             Name => 'PhotoShootingMenuBankImageArea',
8548             PrintConv => {
8549             0 => 'FX',
8550             1 => 'DX',
8551             4 => '16:9',
8552             8 => '1:1',
8553             },
8554             },
8555             #310 ImageQuality
8556             322 => { Name => 'AutoISO', PrintConv => \%offOn, },
8557             324 => {
8558             Name => 'ISOAutoHiLimit',
8559             Format => 'int16u',
8560             Unknown => 1,
8561             ValueConv => '($val-104)/8',
8562             ValueConvInv => '8 * ($val + 104)',
8563             PrintConv => \%iSOAutoHiLimitZ7,
8564             },
8565             326 => {
8566             Name => 'ISOAutoFlashLimit',
8567             Format => 'int16u',
8568             Unknown => 1,
8569             ValueConv => '($val-104)/8',
8570             ValueConvInv => '8 * ($val + 104)',
8571             PrintConv => \%iSOAutoHiLimitZ7,
8572             },
8573             #332 ISOAutoShutterTime - Auto setting 0=> 'Auto (Slowest)', 1 => 'Auto (Slower)', 2=> 'Auto', 3=> 'Auto (Faster)', 4=> 'Auto (Fastest)'
8574             334 => {
8575             Name => 'ISOAutoShutterTime', #shutter speed is 2 ** (-$val/24)
8576             ValueConv => '$val / 8',
8577             Format => 'int16s',
8578             PrintConv => {
8579             -15 => 'Auto', #z9 firmware 1.00 maps both 'Auto' and '30 s' to -15
8580             -12 => '15 s',
8581             -9 => '8 s',
8582             -6 => '4 s',
8583             -3 => '2 s',
8584             0 => '1 s',
8585             1 => '1/1.3 s',
8586             2 => '1/1.6 s',
8587             3 => '1/2 s',
8588             4 => '1/2.5 s',
8589             5 => '1/3 s',
8590             6 => '1/4 s',
8591             7 => '1/5 s',
8592             8 => '1/6 s',
8593             9 => '1/8 s',
8594             10 => '1/10 s',
8595             11 => '1/13 s',
8596             12 => '1/15 s',
8597             13 => '1/20 s',
8598             14 => '1/25 s',
8599             15 => '1/30 s',
8600             16 => '1/40 s',
8601             17 => '1/50 s',
8602             18 => '1/60 s',
8603             19 => '1/80 s',
8604             20 => '1/100 s',
8605             21 => '1/120 s',
8606             22 => '1/160 s',
8607             23 => '1/200 s',
8608             24 => '1/250 s',
8609             25 => '1/320 s',
8610             26 => '1/400 s',
8611             27 => '1/500 s',
8612             28 => '1/640 s',
8613             29 => '1/800 s',
8614             30 => '1/1000 s',
8615             31 => '1/1250 s',
8616             32 => '1/1600 s',
8617             33 => '1/2000 s',
8618             34 => '1/2500 s',
8619             35 => '1/3200 s',
8620             36 => '1/4000 s',
8621             37 => '1/5000 s',
8622             37.5 => '1/6000 s',
8623             38 => '1/6400 s',
8624             39 => '1/8000 s',
8625             40 => '1/10000 s',
8626             40.5 => '1/12000 s',
8627             41 => '1/13000 s',
8628             42 => '1/16000 s',
8629             },
8630             },
8631             #336 WhiteBalance
8632             #406 PictureControl
8633             #408 ColorSpace
8634             #410 ActiveD-Lighting
8635             #412 => { Name => 'NoiseReduction', PrintConv => \%offOn }, #Long Exposure Noise Reduction
8636             #414 HighISONoiseReduction
8637             #414 VignetteControl
8638             416 => { Name => 'MovieVignetteControl', PrintConv => \%offLowNormalHighZ7, Unknown => 1},
8639             418 => { Name => 'DiffractionCompensation', PrintConv => \%offOn }, #value can be set from both the Photo Shoot Menu and the Video Shooting Menu
8640             #419 AutoDistortionControl #value can be set from both the Photo Shoot Menu and the Video Shooting Menu
8641             420 => { Name => 'FlickerReductionShooting', PrintConv => \%offOn },
8642             #422 MeteringMode
8643             424 => {
8644             Name => 'FlashControlMode', # this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
8645             RawConv => '$$self{FlashControlMode} = $val',
8646             PrintConv => \%flashControlModeZ7,
8647             },
8648             426 => {
8649             Name => 'FlashMasterCompensation',
8650             Format => 'int8s',
8651             Unknown => 1,
8652             ValueConv => '$val/6',
8653             ValueConvInv => '6 * $val',
8654             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
8655             PrintConvInv => '$val',
8656             },
8657             430 => {
8658             Name => 'FlashGNDistance',
8659             Condition => '$$self{FlashControlMode} == 2',
8660             Unknown => 1,
8661             ValueConv => '$val + 3',
8662             PrintConv => \%flashGNDistance,
8663             },
8664             434 => {
8665             Name => 'FlashOutput', # range[0,24] with 0=>Full; 1=>50%; then decreasing flash power in 1/3 stops to 0.39% (1/256 full power). also found in FlashInfoUnknown at offset 0x0a (with different mappings)
8666             Condition => '$$self{FlashControlMode} >= 3',
8667             Unknown => 1,
8668             ValueConv => '2 ** (-$val/3)',
8669             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
8670             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
8671             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
8672             },
8673             #442 flash wirelss control 0=> 'Off' 1=> 'CMD'
8674             444 => { Name => 'FlashRemoteControl', PrintConv => \%flashRemoteControlZ7, Unknown => 1},
8675             456 => { Name => 'FlashWirelessOption', PrintConv => \%flashWirelessOptionZ7, Unknown => 1},
8676             #526 FocusMode
8677             528 => {
8678             Name => 'AFAreaMode',
8679             PrintConv => {
8680             1 => 'Single',
8681             2 => 'Dynamic',
8682             3 => 'Wide (S)',
8683             4 => 'Wide (L)',
8684             5 => '3D',
8685             6 => 'Auto',
8686             12 => 'Wide (C1)',
8687             13 => 'Wide (C2)',
8688             },
8689             },
8690             530 => { Name => 'VRMode', PrintConv => \%vRModeZ9},
8691             534 => {
8692             Name => 'BracketSet',
8693             RawConv => '$$self{BracketSet} = $val',
8694             PrintConv => {
8695             0 => 'AE/Flash',
8696             1 => 'AE',
8697             2 => 'Flash',
8698             3 => 'White Balance',
8699             4 => 'Active-D Lighting',
8700             },
8701             },
8702             536 => {
8703             Name => 'BracketProgram',
8704             Condition => '$$self{BracketSet} < 3',
8705             Notes => 'AE and/or Flash Bracketing',
8706             PrintConv => {
8707             0 => 'Disabled',
8708             2 => '2F',
8709             3 => '3F',
8710             4 => '4F',
8711             5 => '5F',
8712             7 => '7F',
8713             9 => '9F',
8714             },
8715             },
8716             538 => {
8717             Name => 'BracketIncrement',
8718             Condition => '$$self{BracketSet} < 3',
8719             Notes => 'AE and/or Flash Bracketing',
8720             PrintConv => {
8721             0 => '0.3',
8722             #1 => '0.5',
8723             2 => '0.7',
8724             3 => '1.0',
8725             4 => '2.0',
8726             5 => '3.0',
8727             },
8728             },
8729             #544 BracketProgram for ADL
8730             556 => {
8731             Name => 'SecondarySlotFunction',
8732             PrintConv => {
8733             0 => 'Overflow',
8734             1 => 'Backup',
8735             2 => 'NEF Primary + JPG Secondary',
8736             3 => 'JPG Primary + JPG Secondary',
8737             },
8738             },
8739             572 => { Name => 'DXCropAlert', PrintConv => \%offOn, },
8740             574 => { Name => 'SubjectDetection', PrintConv => \%subjectDetectionZ9},
8741             604 => {
8742             Name => 'MovieImageArea',
8743             Unknown => 1,
8744             Mask => 0x01, #without the mask 4 => 'FX' 5 => DX only the 2nd Z-series field encountered with a mask.
8745             PrintConv => {
8746             0 => 'FX',
8747             1 => 'DX',
8748             },
8749             },
8750             614 => {
8751             Name => 'MovieType',
8752             Unknown => 1,
8753             PrintConv => {
8754             1 => 'H.265 8-bit (MP4)',
8755             2 => 'H.265 8-bit (MOV)',
8756             3 => 'H.265 10-bit (MOV)',
8757             4 => 'ProRes 422 HQ 10-bit (MOV)',
8758             5 => 'ProRes RAW HQ 12-bit (MOV)',
8759             6 => 'NRAW 12-bit (NEV)'
8760             },
8761             },
8762             616 => {
8763             Name => 'MovieISOAutoHiLimit',
8764             Format => 'int16u',
8765             Unknown => 1,
8766             ValueConv => '($val-104)/8',
8767             ValueConvInv => '8 * ($val + 104)',
8768             PrintConv => \%iSOAutoHiLimitZ7,
8769             },
8770             618 => { Name => 'MovieISOAutoControlManualMode', PrintConv => \%offOn, Unknown => 1},
8771             620 => {
8772             Name => 'MovieISOAutoManualMode',
8773             Format => 'int16u',
8774             Unknown => 1,
8775             ValueConv => '($val-104)/8',
8776             ValueConvInv => '8 * ($val + 104)',
8777             PrintConv => \%iSOAutoHiLimitZ7,
8778             },
8779             696 => { Name => 'MovieActiveD-Lighting', PrintConv => \%activeDLightingZ7, Unknown => 1},
8780             698 => { Name => 'MovieHighISONoiseReduction', PrintConv => \%offLowNormalHighZ7, Unknown => 1},
8781             704 => {
8782             Name => 'MovieFlickerReduction',
8783             PrintConv => {
8784             0 => 'Auto',
8785             1 => '50Hz',
8786             2 => '60Hz',
8787             },
8788             },
8789             706 => { Name => 'MovieMeteringMode', PrintConv => \%meteringModeZ7, , Unknown => 1},
8790             708 => { Name => 'MovieFocusMode', PrintConv => \%focusModeZ7, Unknown => 1},
8791             710 => {
8792             Name => 'MovieAFAreaMode',
8793             PrintConv => {
8794             1 => 'Single',
8795             3 => 'Wide (S)',
8796             4 => 'Wide (L)',
8797             6 => 'Auto',
8798             11 => 'Subject Tracking',
8799             },
8800             },
8801             712 => { Name => 'MovieVRMode', PrintConv => \%vRModeZ9, Unknown => 1},
8802             716 => { Name => 'MovieElectronicVR', PrintConv => \%offOn, Unknown => 1 }, #distinct from MoveieVRMode
8803             718 => { Name => 'MovieSoundRecording', PrintConv => { 0 => 'Off', 1 => 'On', 2 => 'On' }, Unknown => 1 }, #not sure why the unusal mapping with 2 => 'On'
8804             720 => { Name => 'MicrophoneSensitivity', Unknown => 1}, #1-20
8805             722 => { Name => 'MicrophoneAttenuator', PrintConv => \%offOn, Unknown => 1 }, #distinct from MoveieVRMode
8806             724 => { Name => 'MicrophoneFrequencyResponse', PrintConv => { 0 => 'Wide Range', 1 => 'Vocal Range' }, Unknown => 1 },
8807             726 => { Name => 'WindNoiseReduction', PrintConv => \%offOn, Unknown => 1 },
8808             748 => {
8809             Name => 'MovieToneMap',
8810             Unknown => 1,
8811             PrintConv => {
8812             0 => 'SDR',
8813             1 => 'HLG',
8814             2 => 'N-Log',
8815             },
8816             },
8817             754 => { Name => 'MovieFrameSize', PrintConv => \%movieFrameSizeZ9, Unknown => 1},
8818             756 => { Name => 'MovieFrameRate', PrintConv => \%movieFrameRateZ7, Unknown => 1},
8819             762 => { Name => 'MicrophoneJackPower', PrintConv => \%offOn, Unknown => 1 },
8820             763 => { Name => 'MovieDXCropAlert', PrintConv => \%offOn, Unknown => 1 },
8821             764 => { Name => 'MovieSubjectDetection', PrintConv => \%subjectDetectionZ9, Unknown => 1},
8822             799 => {
8823             Name => 'CustomSettingsZ9',
8824             Format => 'undef[608]',
8825             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsZ9' },
8826             },
8827             1426 => {
8828             Name => 'Language',
8829             Unknown => 1,
8830             PrintConv => {
8831             4 => 'English',
8832             5 => 'Spanish',
8833             7 => 'French',
8834             },
8835             },
8836             1428 => {
8837             Name => 'TimeZone',
8838             PrintConv => {
8839             5 => '+09:00 (Tokyo)',
8840             6 => '+08:00 (Beijing, Honk Kong, Sinapore)',
8841             10 => '+05:45 (Kathmandu)',
8842             11 => '+05:30 (New Dehli)',
8843             12 => '+05:00 (Islamabad)',
8844             13 => '+04:30 (Kabul)',
8845             14 => '+04:00 (Abu Dhabi)',
8846             15 => '+03:30 (Tehran)',
8847             16 => '+03:00 (Moscow, Nairobi)',
8848             17 => '+02:00 (Athens, Helsinki)',
8849             18 => '+01:00 (Madrid, Paris, Berlin)',
8850             19 => '+00:00 (London)',
8851             20 => '-01:00 (Azores)',
8852             21 => '-02:00 (Fernando de Noronha)',
8853             22 => '-03:00 (Buenos Aires, Sao Paulo)',
8854             23 => '-03:30 (Newfoundland)',
8855             24 => '-04:00 (Manaus, Caracas)',
8856             25 => '-05:00 (New York, Toronto, Lima)',
8857             26 => '-06:00 (Chicago, Mexico City)',
8858             27 => '-07:00 (Denver)',
8859             28 => '-08:00 (Los Angeles, Vancouver)',
8860             29 => '-09:00 (Anchorage)',
8861             30 => '-10:00 (Hawaii)',
8862             },
8863             },
8864             1434 => {Name => 'MonitorBrightness', ValueConv => '$val - 5', Unknown => 1}, # settings: -5 to +5
8865             1456 => { Name => 'AFFineTune', PrintConv => \%offOn, Unknown => 1 },
8866             1552 => {
8867             Name => 'HDMIOutputResolution',
8868             PrintConv => {
8869             0 => 'Auto',
8870             1 => '4320p',
8871             2 => '2160p',
8872             3 => '1080p',
8873             #4 => '1080i',
8874             5 => '720p',
8875             #6 => '576p',
8876             #7 => '480p',
8877             },
8878             },
8879             1565 => { Name => 'SetClockFromLocationData', PrintConv => \%offOn, Unknown => 1 },
8880             1572 => { Name => 'AirplaneMode', PrintConv => \%offOn, Unknown => 1 },
8881             1573 => { Name => 'EmptySlotRelease', PrintConv => { 0 => 'Disable Release', 1 => 'Enable Release' }, Unknown => 1 },
8882             1608 => { Name => 'EnergySavingMode', PrintConv =>\%offOn, Unknown => 1 },
8883             1632 => { Name => 'RecordLocationData', PrintConv => \%offOn, Unknown => 1 },
8884             1636 => { Name => 'USBPowerDelivery', PrintConv => \%offOn, Unknown => 1 },
8885             1645 => { Name => 'SensorShield', PrintConv => { 0 => 'Stays Open', 1 => 'Closes' }, Unknown => 1 },
8886             );
8887              
8888             # Flash information (ref JD)
8889             %Image::ExifTool::Nikon::FlashInfo0100 = (
8890             %binaryDataAttrs,
8891             DATAMEMBER => [ 9.2, 15, 16 ],
8892             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8893             NOTES => q{
8894             These tags are used by the D2H, D2Hs, D2X, D2Xs, D50, D70, D70s, D80 and
8895             D200.
8896             },
8897             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
8898             0 => {
8899             Name => 'FlashInfoVersion',
8900             Format => 'string[4]',
8901             Writable => 0,
8902             },
8903             4 => { #PH
8904             Name => 'FlashSource',
8905             PrintConv => {
8906             0 => 'None',
8907             1 => 'External',
8908             2 => 'Internal',
8909             },
8910             },
8911             # 5 - values: 46,48,50,54,78
8912             6 => {
8913             Format => 'int8u[2]',
8914             Name => 'ExternalFlashFirmware',
8915             SeparateTable => 'FlashFirmware',
8916             PrintConv => \%flashFirmware,
8917             },
8918             8 => {
8919             Name => 'ExternalFlashFlags',
8920             PrintConv => { 0 => '(none)',
8921             BITMASK => {
8922             0 => 'Fired', #28
8923             2 => 'Bounce Flash', #PH
8924             4 => 'Wide Flash Adapter',
8925             5 => 'Dome Diffuser', #28
8926             },
8927             },
8928             },
8929             9.1 => {
8930             Name => 'FlashCommanderMode',
8931             Mask => 0x80,
8932             PrintConv => { 0 => 'Off', 1 => 'On' },
8933             },
8934             9.2 => {
8935             Name => 'FlashControlMode',
8936             Mask => 0x7f,
8937             DataMember => 'FlashControlMode',
8938             RawConv => '$$self{FlashControlMode} = $val',
8939             PrintConv => \%flashControlMode,
8940             SeparateTable => 'FlashControlMode',
8941             },
8942             10 => [
8943             {
8944             Name => 'FlashOutput',
8945             Condition => '$$self{FlashControlMode} >= 0x06',
8946             ValueConv => '2 ** (-$val/6)',
8947             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
8948             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
8949             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
8950             },
8951             {
8952             Name => 'FlashCompensation',
8953             Format => 'int8s',
8954             Priority => 0,
8955             ValueConv => '-$val/6',
8956             ValueConvInv => '-6 * $val',
8957             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
8958             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
8959             },
8960             ],
8961             11 => {
8962             Name => 'FlashFocalLength',
8963             RawConv => '$val ? $val : undef',
8964             PrintConv => '"$val mm"',
8965             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
8966             },
8967             12 => {
8968             Name => 'RepeatingFlashRate',
8969             RawConv => '$val ? $val : undef',
8970             PrintConv => '"$val Hz"',
8971             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
8972             },
8973             13 => {
8974             Name => 'RepeatingFlashCount',
8975             RawConv => '$val ? $val : undef',
8976             },
8977             14 => { #PH
8978             Name => 'FlashGNDistance',
8979             SeparateTable => 1,
8980             PrintConv => \%flashGNDistance,
8981             },
8982             15 => {
8983             Name => 'FlashGroupAControlMode',
8984             Mask => 0x0f,
8985             DataMember => 'FlashGroupAControlMode',
8986             RawConv => '$$self{FlashGroupAControlMode} = $val',
8987             PrintConv => \%flashControlMode,
8988             SeparateTable => 'FlashControlMode',
8989             },
8990             16 => {
8991             Name => 'FlashGroupBControlMode',
8992             Mask => 0x0f,
8993             DataMember => 'FlashGroupBControlMode',
8994             RawConv => '$$self{FlashGroupBControlMode} = $val',
8995             PrintConv => \%flashControlMode,
8996             SeparateTable => 'FlashControlMode',
8997             },
8998             17 => [
8999             {
9000             Name => 'FlashGroupAOutput',
9001             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
9002             ValueConv => '2 ** (-$val/6)',
9003             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9004             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9005             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9006             },
9007             {
9008             Name => 'FlashGroupACompensation',
9009             Format => 'int8s',
9010             ValueConv => '-$val/6',
9011             ValueConvInv => '-6 * $val',
9012             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9013             PrintConvInv => '$val',
9014             },
9015             ],
9016             18 => [
9017             {
9018             Name => 'FlashGroupBOutput',
9019             Condition => '$$self{FlashGroupBControlMode} >= 0x06',
9020             ValueConv => '2 ** (-$val/6)',
9021             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9022             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9023             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9024             },
9025             {
9026             Name => 'FlashGroupBCompensation',
9027             Format => 'int8s',
9028             ValueConv => '-$val/6',
9029             ValueConvInv => '-6 * $val',
9030             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9031             PrintConvInv => '$val',
9032             },
9033             ],
9034             );
9035              
9036             # Flash information for D40, D40x, D3 and D300 (ref JD)
9037             %Image::ExifTool::Nikon::FlashInfo0102 = (
9038             %binaryDataAttrs,
9039             DATAMEMBER => [ 9.2, 16.1, 17.1, 17.2 ],
9040             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9041             NOTES => q{
9042             These tags are used by the D3 (firmware 1.x), D40, D40X, D60 and D300
9043             (firmware 1.00).
9044             },
9045             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
9046             0 => {
9047             Name => 'FlashInfoVersion',
9048             Format => 'string[4]',
9049             Writable => 0,
9050             },
9051             4 => { #PH
9052             Name => 'FlashSource',
9053             PrintConv => {
9054             0 => 'None',
9055             1 => 'External',
9056             2 => 'Internal',
9057             },
9058             },
9059             # 5 - values: 46,48,50,54,78
9060             6 => {
9061             Format => 'int8u[2]',
9062             Name => 'ExternalFlashFirmware',
9063             SeparateTable => 'FlashFirmware',
9064             PrintConv => \%flashFirmware,
9065             },
9066             8 => {
9067             Name => 'ExternalFlashFlags',
9068             PrintConv => { BITMASK => {
9069             0 => 'Fired', #28
9070             2 => 'Bounce Flash', #PH
9071             4 => 'Wide Flash Adapter',
9072             5 => 'Dome Diffuser', #28
9073             }},
9074             },
9075             9.1 => {
9076             Name => 'FlashCommanderMode',
9077             Mask => 0x80,
9078             PrintConv => { 0 => 'Off', 1 => 'On' },
9079             },
9080             9.2 => {
9081             Name => 'FlashControlMode',
9082             Mask => 0x7f,
9083             DataMember => 'FlashControlMode',
9084             RawConv => '$$self{FlashControlMode} = $val',
9085             PrintConv => \%flashControlMode,
9086             SeparateTable => 'FlashControlMode',
9087             },
9088             10 => [
9089             {
9090             Name => 'FlashOutput',
9091             Condition => '$$self{FlashControlMode} >= 0x06',
9092             ValueConv => '2 ** (-$val/6)',
9093             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9094             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9095             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9096             },
9097             {
9098             Name => 'FlashCompensation',
9099             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
9100             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
9101             Format => 'int8s',
9102             Priority => 0,
9103             ValueConv => '-$val/6',
9104             ValueConvInv => '-6 * $val',
9105             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9106             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9107             },
9108             ],
9109             12 => {
9110             Name => 'FlashFocalLength',
9111             RawConv => '$val ? $val : undef',
9112             PrintConv => '"$val mm"',
9113             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9114             },
9115             13 => {
9116             Name => 'RepeatingFlashRate',
9117             RawConv => '$val ? $val : undef',
9118             PrintConv => '"$val Hz"',
9119             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9120             },
9121             14 => {
9122             Name => 'RepeatingFlashCount',
9123             RawConv => '$val ? $val : undef',
9124             },
9125             15 => { #PH
9126             Name => 'FlashGNDistance',
9127             SeparateTable => 1,
9128             PrintConv => \%flashGNDistance,
9129             },
9130             16.1 => {
9131             Name => 'FlashGroupAControlMode',
9132             Mask => 0x0f,
9133             Notes => 'note: group A tags may apply to the built-in flash settings for some models',
9134             DataMember => 'FlashGroupAControlMode',
9135             RawConv => '$$self{FlashGroupAControlMode} = $val',
9136             PrintConv => \%flashControlMode,
9137             SeparateTable => 'FlashControlMode',
9138             },
9139             17.1 => {
9140             Name => 'FlashGroupBControlMode',
9141             Mask => 0xf0,
9142             Notes => 'note: group B tags may apply to group A settings for some models',
9143             DataMember => 'FlashGroupBControlMode',
9144             RawConv => '$$self{FlashGroupBControlMode} = $val',
9145             PrintConv => \%flashControlMode,
9146             SeparateTable => 'FlashControlMode',
9147             },
9148             17.2 => { #PH
9149             Name => 'FlashGroupCControlMode',
9150             Mask => 0x0f,
9151             Notes => 'note: group C tags may apply to group B settings for some models',
9152             DataMember => 'FlashGroupCControlMode',
9153             RawConv => '$$self{FlashGroupCControlMode} = $val',
9154             PrintConv => \%flashControlMode,
9155             SeparateTable => 'FlashControlMode',
9156             },
9157             18 => [
9158             {
9159             Name => 'FlashGroupAOutput',
9160             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
9161             ValueConv => '2 ** (-$val/6)',
9162             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9163             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9164             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9165             },
9166             {
9167             Name => 'FlashGroupACompensation',
9168             Format => 'int8s',
9169             ValueConv => '-$val/6',
9170             ValueConvInv => '-6 * $val',
9171             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9172             PrintConvInv => '$val',
9173             },
9174             ],
9175             19 => [
9176             {
9177             Name => 'FlashGroupBOutput',
9178             Condition => '$$self{FlashGroupBControlMode} >= 0x60',
9179             ValueConv => '2 ** (-$val/6)',
9180             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9181             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9182             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9183             },
9184             {
9185             Name => 'FlashGroupBCompensation',
9186             Format => 'int8s',
9187             ValueConv => '-$val/6',
9188             ValueConvInv => '-6 * $val',
9189             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9190             PrintConvInv => '$val',
9191             },
9192             ],
9193             20 => [ #PH
9194             {
9195             Name => 'FlashGroupCOutput',
9196             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
9197             ValueConv => '2 ** (-$val/6)',
9198             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9199             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9200             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9201             },
9202             {
9203             Name => 'FlashGroupCCompensation',
9204             Format => 'int8s',
9205             ValueConv => '-$val/6',
9206             ValueConvInv => '-6 * $val',
9207             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9208             PrintConvInv => '$val',
9209             },
9210             ],
9211             );
9212              
9213             # Flash information (ref JD)
9214             %Image::ExifTool::Nikon::FlashInfo0100 = (
9215             %binaryDataAttrs,
9216             DATAMEMBER => [ 9.2, 15, 16 ],
9217             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9218             NOTES => q{
9219             These tags are used by the D2H, D2Hs, D2X, D2Xs, D50, D70, D70s, D80 and
9220             D200.
9221             },
9222             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
9223             0 => {
9224             Name => 'FlashInfoVersion',
9225             Format => 'string[4]',
9226             Writable => 0,
9227             },
9228             4 => { #PH
9229             Name => 'FlashSource',
9230             PrintConv => {
9231             0 => 'None',
9232             1 => 'External',
9233             2 => 'Internal',
9234             },
9235             },
9236             # 5 - values: 46,48,50,54,78
9237             6 => {
9238             Format => 'int8u[2]',
9239             Name => 'ExternalFlashFirmware',
9240             SeparateTable => 'FlashFirmware',
9241             PrintConv => \%flashFirmware,
9242             },
9243             8 => {
9244             Name => 'ExternalFlashFlags',
9245             PrintConv => { 0 => '(none)',
9246             BITMASK => {
9247             0 => 'Fired', #28
9248             2 => 'Bounce Flash', #PH
9249             4 => 'Wide Flash Adapter',
9250             5 => 'Dome Diffuser', #28
9251             },
9252             },
9253             },
9254             9.1 => {
9255             Name => 'FlashCommanderMode',
9256             Mask => 0x80,
9257             PrintConv => { 0 => 'Off', 1 => 'On' },
9258             },
9259             9.2 => {
9260             Name => 'FlashControlMode',
9261             Mask => 0x7f,
9262             DataMember => 'FlashControlMode',
9263             RawConv => '$$self{FlashControlMode} = $val',
9264             PrintConv => \%flashControlMode,
9265             SeparateTable => 'FlashControlMode',
9266             },
9267             10 => [
9268             {
9269             Name => 'FlashOutput',
9270             Condition => '$$self{FlashControlMode} >= 0x06',
9271             ValueConv => '2 ** (-$val/6)',
9272             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9273             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9274             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9275             },
9276             {
9277             Name => 'FlashCompensation',
9278             Format => 'int8s',
9279             Priority => 0,
9280             ValueConv => '-$val/6',
9281             ValueConvInv => '-6 * $val',
9282             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9283             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9284             },
9285             ],
9286             11 => {
9287             Name => 'FlashFocalLength',
9288             RawConv => '$val ? $val : undef',
9289             PrintConv => '"$val mm"',
9290             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9291             },
9292             12 => {
9293             Name => 'RepeatingFlashRate',
9294             RawConv => '$val ? $val : undef',
9295             PrintConv => '"$val Hz"',
9296             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9297             },
9298             13 => {
9299             Name => 'RepeatingFlashCount',
9300             RawConv => '$val ? $val : undef',
9301             },
9302             14 => { #PH
9303             Name => 'FlashGNDistance',
9304             SeparateTable => 1,
9305             PrintConv => \%flashGNDistance,
9306             },
9307             15 => {
9308             Name => 'FlashGroupAControlMode',
9309             Mask => 0x0f,
9310             DataMember => 'FlashGroupAControlMode',
9311             RawConv => '$$self{FlashGroupAControlMode} = $val',
9312             PrintConv => \%flashControlMode,
9313             SeparateTable => 'FlashControlMode',
9314             },
9315             16 => {
9316             Name => 'FlashGroupBControlMode',
9317             Mask => 0x0f,
9318             DataMember => 'FlashGroupBControlMode',
9319             RawConv => '$$self{FlashGroupBControlMode} = $val',
9320             PrintConv => \%flashControlMode,
9321             SeparateTable => 'FlashControlMode',
9322             },
9323             17 => [
9324             {
9325             Name => 'FlashGroupAOutput',
9326             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
9327             ValueConv => '2 ** (-$val/6)',
9328             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9329             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9330             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9331             },
9332             {
9333             Name => 'FlashGroupACompensation',
9334             Format => 'int8s',
9335             ValueConv => '-$val/6',
9336             ValueConvInv => '-6 * $val',
9337             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9338             PrintConvInv => '$val',
9339             },
9340             ],
9341             18 => [
9342             {
9343             Name => 'FlashGroupBOutput',
9344             Condition => '$$self{FlashGroupBControlMode} >= 0x06',
9345             ValueConv => '2 ** (-$val/6)',
9346             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9347             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9348             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9349             },
9350             {
9351             Name => 'FlashGroupBCompensation',
9352             Format => 'int8s',
9353             ValueConv => '-$val/6',
9354             ValueConvInv => '-6 * $val',
9355             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9356             PrintConvInv => '$val',
9357             },
9358             ],
9359             );
9360              
9361             # Flash information for D40, D40x, D3 and D300 (ref JD)
9362             %Image::ExifTool::Nikon::FlashInfo0102 = (
9363             %binaryDataAttrs,
9364             DATAMEMBER => [ 9.2, 16.1, 17.1, 17.2 ],
9365             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9366             NOTES => q{
9367             These tags are used by the D3 (firmware 1.x), D40, D40X, D60 and D300
9368             (firmware 1.00).
9369             },
9370             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
9371             0 => {
9372             Name => 'FlashInfoVersion',
9373             Format => 'string[4]',
9374             Writable => 0,
9375             },
9376             4 => { #PH
9377             Name => 'FlashSource',
9378             PrintConv => {
9379             0 => 'None',
9380             1 => 'External',
9381             2 => 'Internal',
9382             },
9383             },
9384             # 5 - values: 46,48,50,54,78
9385             6 => {
9386             Format => 'int8u[2]',
9387             Name => 'ExternalFlashFirmware',
9388             SeparateTable => 'FlashFirmware',
9389             PrintConv => \%flashFirmware,
9390             },
9391             8 => {
9392             Name => 'ExternalFlashFlags',
9393             PrintConv => { BITMASK => {
9394             0 => 'Fired', #28
9395             2 => 'Bounce Flash', #PH
9396             4 => 'Wide Flash Adapter',
9397             5 => 'Dome Diffuser', #28
9398             }},
9399             },
9400             9.1 => {
9401             Name => 'FlashCommanderMode',
9402             Mask => 0x80,
9403             PrintConv => { 0 => 'Off', 1 => 'On' },
9404             },
9405             9.2 => {
9406             Name => 'FlashControlMode',
9407             Mask => 0x7f,
9408             DataMember => 'FlashControlMode',
9409             RawConv => '$$self{FlashControlMode} = $val',
9410             PrintConv => \%flashControlMode,
9411             SeparateTable => 'FlashControlMode',
9412             },
9413             10 => [
9414             {
9415             Name => 'FlashOutput',
9416             Condition => '$$self{FlashControlMode} >= 0x06',
9417             ValueConv => '2 ** (-$val/6)',
9418             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9419             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9420             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9421             },
9422             {
9423             Name => 'FlashCompensation',
9424             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
9425             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
9426             Format => 'int8s',
9427             Priority => 0,
9428             ValueConv => '-$val/6',
9429             ValueConvInv => '-6 * $val',
9430             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9431             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9432             },
9433             ],
9434             12 => {
9435             Name => 'FlashFocalLength',
9436             RawConv => '$val ? $val : undef',
9437             PrintConv => '"$val mm"',
9438             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9439             },
9440             13 => {
9441             Name => 'RepeatingFlashRate',
9442             RawConv => '$val ? $val : undef',
9443             PrintConv => '"$val Hz"',
9444             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9445             },
9446             14 => {
9447             Name => 'RepeatingFlashCount',
9448             RawConv => '$val ? $val : undef',
9449             },
9450             15 => { #PH
9451             Name => 'FlashGNDistance',
9452             SeparateTable => 1,
9453             PrintConv => \%flashGNDistance,
9454             },
9455             16.1 => {
9456             Name => 'FlashGroupAControlMode',
9457             Mask => 0x0f,
9458             Notes => 'note: group A tags may apply to the built-in flash settings for some models',
9459             DataMember => 'FlashGroupAControlMode',
9460             RawConv => '$$self{FlashGroupAControlMode} = $val',
9461             PrintConv => \%flashControlMode,
9462             SeparateTable => 'FlashControlMode',
9463             },
9464             17.1 => {
9465             Name => 'FlashGroupBControlMode',
9466             Mask => 0xf0,
9467             Notes => 'note: group B tags may apply to group A settings for some models',
9468             DataMember => 'FlashGroupBControlMode',
9469             RawConv => '$$self{FlashGroupBControlMode} = $val',
9470             PrintConv => \%flashControlMode,
9471             SeparateTable => 'FlashControlMode',
9472             },
9473             17.2 => { #PH
9474             Name => 'FlashGroupCControlMode',
9475             Mask => 0x0f,
9476             Notes => 'note: group C tags may apply to group B settings for some models',
9477             DataMember => 'FlashGroupCControlMode',
9478             RawConv => '$$self{FlashGroupCControlMode} = $val',
9479             PrintConv => \%flashControlMode,
9480             SeparateTable => 'FlashControlMode',
9481             },
9482             18 => [
9483             {
9484             Name => 'FlashGroupAOutput',
9485             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
9486             ValueConv => '2 ** (-$val/6)',
9487             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9488             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9489             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9490             },
9491             {
9492             Name => 'FlashGroupACompensation',
9493             Format => 'int8s',
9494             ValueConv => '-$val/6',
9495             ValueConvInv => '-6 * $val',
9496             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9497             PrintConvInv => '$val',
9498             },
9499             ],
9500             19 => [
9501             {
9502             Name => 'FlashGroupBOutput',
9503             Condition => '$$self{FlashGroupBControlMode} >= 0x60',
9504             ValueConv => '2 ** (-$val/6)',
9505             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9506             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9507             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9508             },
9509             {
9510             Name => 'FlashGroupBCompensation',
9511             Format => 'int8s',
9512             ValueConv => '-$val/6',
9513             ValueConvInv => '-6 * $val',
9514             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9515             PrintConvInv => '$val',
9516             },
9517             ],
9518             20 => [ #PH
9519             {
9520             Name => 'FlashGroupCOutput',
9521             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
9522             ValueConv => '2 ** (-$val/6)',
9523             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9524             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9525             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9526             },
9527             {
9528             Name => 'FlashGroupCCompensation',
9529             Format => 'int8s',
9530             ValueConv => '-$val/6',
9531             ValueConvInv => '-6 * $val',
9532             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9533             PrintConvInv => '$val',
9534             },
9535             ],
9536             );
9537              
9538             # Flash information for D90 and D700 (ref PH)
9539             # - confirmed in detail for D800 (0105) - PH
9540             %Image::ExifTool::Nikon::FlashInfo0103 = (
9541             %binaryDataAttrs,
9542             DATAMEMBER => [ 9.2, 17.1, 18.1, 18.2 ],
9543             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9544             NOTES => q{
9545             These tags are used by the D3 (firmware 2.x), D3X, D3S, D4, D90, D300
9546             (firmware 1.10), D300S, D600, D700, D800, D3000, D3100, D3200, D5000, D5100,
9547             D5200, D7000.
9548             },
9549             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
9550             0 => {
9551             Name => 'FlashInfoVersion',
9552             Format => 'string[4]',
9553             Writable => 0,
9554             },
9555             4 => { #PH
9556             Name => 'FlashSource',
9557             PrintConv => {
9558             0 => 'None',
9559             1 => 'External',
9560             2 => 'Internal',
9561             },
9562             },
9563             # 5 - values: 46,48,50,54,78
9564             6 => {
9565             Format => 'int8u[2]',
9566             Name => 'ExternalFlashFirmware',
9567             SeparateTable => 'FlashFirmware',
9568             PrintConv => \%flashFirmware,
9569             },
9570             8 => {
9571             Name => 'ExternalFlashFlags',
9572             PrintConv => { BITMASK => {
9573             0 => 'Fired', #28
9574             2 => 'Bounce Flash', #PH
9575             4 => 'Wide Flash Adapter',
9576             5 => 'Dome Diffuser', #28
9577             }},
9578             },
9579             9.1 => {
9580             Name => 'FlashCommanderMode',
9581             Mask => 0x80,
9582             PrintConv => { 0 => 'Off', 1 => 'On' },
9583             },
9584             9.2 => {
9585             Name => 'FlashControlMode',
9586             Mask => 0x7f,
9587             DataMember => 'FlashControlMode',
9588             RawConv => '$$self{FlashControlMode} = $val',
9589             PrintConv => \%flashControlMode,
9590             SeparateTable => 'FlashControlMode',
9591             },
9592             10 => [
9593             {
9594             Name => 'FlashOutput',
9595             Condition => '$$self{FlashControlMode} >= 0x06',
9596             ValueConv => '2 ** (-$val/6)',
9597             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9598             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9599             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9600             },
9601             {
9602             Name => 'FlashCompensation',
9603             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
9604             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
9605             Format => 'int8s',
9606             Priority => 0,
9607             ValueConv => '-$val/6',
9608             ValueConvInv => '-6 * $val',
9609             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9610             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9611             },
9612             ],
9613             12 => { #JD
9614             Name => 'FlashFocalLength',
9615             RawConv => '($val and $val != 255) ? $val : undef',
9616             PrintConv => '"$val mm"',
9617             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9618             },
9619             13 => { #JD
9620             Name => 'RepeatingFlashRate',
9621             RawConv => '($val and $val != 255) ? $val : undef',
9622             PrintConv => '"$val Hz"',
9623             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9624             },
9625             14 => { #JD
9626             Name => 'RepeatingFlashCount',
9627             RawConv => '($val and $val != 255) ? $val : undef',
9628             },
9629             15 => { #28
9630             Name => 'FlashGNDistance',
9631             SeparateTable => 1,
9632             PrintConv => \%flashGNDistance,
9633             },
9634             16 => { #28
9635             Name => 'FlashColorFilter',
9636             SeparateTable => 1,
9637             PrintConv => \%flashColorFilter,
9638             },
9639             17.1 => {
9640             Name => 'FlashGroupAControlMode',
9641             Mask => 0x0f,
9642             Notes => 'note: group A tags may apply to the built-in flash settings for some models',
9643             DataMember => 'FlashGroupAControlMode',
9644             RawConv => '$$self{FlashGroupAControlMode} = $val',
9645             PrintConv => \%flashControlMode,
9646             SeparateTable => 'FlashControlMode',
9647             },
9648             18.1 => {
9649             Name => 'FlashGroupBControlMode',
9650             Mask => 0xf0,
9651             Notes => 'note: group B tags may apply to group A settings for some models',
9652             DataMember => 'FlashGroupBControlMode',
9653             RawConv => '$$self{FlashGroupBControlMode} = $val',
9654             PrintConv => \%flashControlMode,
9655             SeparateTable => 'FlashControlMode',
9656             },
9657             18.2 => { #PH
9658             Name => 'FlashGroupCControlMode',
9659             Mask => 0x0f,
9660             Notes => 'note: group C tags may apply to group B settings for some models',
9661             DataMember => 'FlashGroupCControlMode',
9662             RawConv => '$$self{FlashGroupCControlMode} = $val',
9663             PrintConv => \%flashControlMode,
9664             SeparateTable => 'FlashControlMode',
9665             },
9666             0x13 => [
9667             {
9668             Name => 'FlashGroupAOutput',
9669             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
9670             ValueConv => '2 ** (-$val/6)',
9671             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9672             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9673             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9674             },
9675             {
9676             Name => 'FlashGroupACompensation',
9677             Format => 'int8s',
9678             ValueConv => '-$val/6',
9679             ValueConvInv => '-6 * $val',
9680             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9681             PrintConvInv => '$val',
9682             },
9683             ],
9684             0x14 => [
9685             {
9686             Name => 'FlashGroupBOutput',
9687             Condition => '$$self{FlashGroupBControlMode} >= 0x60',
9688             ValueConv => '2 ** (-$val/6)',
9689             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9690             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9691             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9692             },
9693             {
9694             Name => 'FlashGroupBCompensation',
9695             Format => 'int8s',
9696             ValueConv => '-$val/6',
9697             ValueConvInv => '-6 * $val',
9698             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9699             PrintConvInv => '$val',
9700             },
9701             ],
9702             0x15 => [ #PH
9703             {
9704             Name => 'FlashGroupCOutput',
9705             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
9706             ValueConv => '2 ** (-$val/6)',
9707             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9708             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9709             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9710             },
9711             {
9712             Name => 'FlashGroupCCompensation',
9713             Format => 'int8s',
9714             ValueConv => '-$val/6',
9715             ValueConvInv => '-6 * $val',
9716             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9717             PrintConvInv => '$val',
9718             },
9719             ],
9720             0x1b => { #PH
9721             Name => 'ExternalFlashCompensation',
9722             Format => 'int8s',
9723             Priority => 0,
9724             ValueConv => '-$val/6',
9725             ValueConvInv => '-6 * $val',
9726             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9727             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9728             },
9729             0x1d => { #PH
9730             Name => 'FlashExposureComp3',
9731             Format => 'int8s',
9732             # (does not include the built-in compensation for FlashType "Built-in,TTL&Comdr.")
9733             Notes => 'does not include the effect of flash bracketing',
9734             Priority => 0,
9735             ValueConv => '-$val/6',
9736             ValueConvInv => '-6 * $val',
9737             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9738             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9739             },
9740             0x27 => { #PH (same as ShotInfoD800 0x4d2 but also valid for repeating flash)
9741             Name => 'FlashExposureComp4',
9742             Format => 'int8s',
9743             Notes => 'includes the effect of flash bracketing. Valid for repeating flash',
9744             Priority => 0,
9745             ValueConv => '-$val/6',
9746             ValueConvInv => '-6 * $val',
9747             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9748             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9749             },
9750             # 0x2b - related to flash power (PH, D800, 96=full,62=1/4,2=1/128)
9751             );
9752              
9753             # Flash information for the D7100 (ref PH)
9754             # (this is VERY similar to FlashInfo0107, but there are a few differences that
9755             # would need to be resolved if these two definitions were to be combined)
9756             %Image::ExifTool::Nikon::FlashInfo0106 = (
9757             %binaryDataAttrs,
9758             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9759             DATAMEMBER => [ 9.2, 17.1, 18.1, 18.2 ],
9760             NOTES => 'These tags are used by the Df, D610, D3300, D5300, D7100 and Coolpix A.',
9761             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
9762             0 => {
9763             Name => 'FlashInfoVersion',
9764             Format => 'string[4]',
9765             Writable => 0,
9766             },
9767             4 => {
9768             Name => 'FlashSource',
9769             PrintConv => {
9770             0 => 'None',
9771             1 => 'External',
9772             2 => 'Internal',
9773             },
9774             },
9775             6 => {
9776             Format => 'int8u[2]',
9777             Name => 'ExternalFlashFirmware',
9778             SeparateTable => 'FlashFirmware',
9779             PrintConv => \%flashFirmware,
9780             },
9781             8 => {
9782             Name => 'ExternalFlashFlags',
9783             PrintConv => { BITMASK => {
9784             0 => 'Fired',
9785             2 => 'Bounce Flash',
9786             4 => 'Wide Flash Adapter',
9787             5 => 'Dome Diffuser', # (NC, not true for the SB-910 anyway)
9788             # 7 - ? (set for SB-910 when an advanced option is used, eg. diff pattern)
9789             }},
9790             },
9791             9.1 => { # (NC)
9792             Name => 'FlashCommanderMode',
9793             Mask => 0x80,
9794             PrintConv => { 0 => 'Off', 1 => 'On' },
9795             },
9796             9.2 => {
9797             Name => 'FlashControlMode',
9798             Mask => 0x7f,
9799             DataMember => 'FlashControlMode',
9800             RawConv => '$$self{FlashControlMode} = $val',
9801             PrintConv => \%flashControlMode,
9802             SeparateTable => 'FlashControlMode',
9803             },
9804             # 10 - similar to 0x27 but zero sometimes when I don't think it should be
9805             12 => {
9806             Name => 'FlashFocalLength',
9807             Notes => 'only valid if flash pattern is "Standard Illumination"',
9808             RawConv => '($val and $val != 255) ? $val : undef',
9809             PrintConv => '"$val mm"',
9810             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9811             },
9812             13 => {
9813             Name => 'RepeatingFlashRate',
9814             RawConv => '($val and $val != 255) ? $val : undef',
9815             PrintConv => '"$val Hz"',
9816             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9817             },
9818             14 => {
9819             Name => 'RepeatingFlashCount',
9820             RawConv => '($val and $val != 255) ? $val : undef',
9821             },
9822             15 => { # (NC)
9823             Name => 'FlashGNDistance',
9824             SeparateTable => 1,
9825             PrintConv => \%flashGNDistance,
9826             },
9827             16 => {
9828             Name => 'FlashColorFilter',
9829             SeparateTable => 1,
9830             PrintConv => \%flashColorFilter,
9831             },
9832             17.1 => {
9833             Name => 'FlashGroupAControlMode',
9834             Mask => 0x0f,
9835             DataMember => 'FlashGroupAControlMode',
9836             RawConv => '$$self{FlashGroupAControlMode} = $val',
9837             PrintConv => \%flashControlMode,
9838             SeparateTable => 'FlashControlMode',
9839             },
9840             18.1 => {
9841             Name => 'FlashGroupBControlMode',
9842             Mask => 0xf0,
9843             DataMember => 'FlashGroupBControlMode',
9844             RawConv => '$$self{FlashGroupBControlMode} = $val',
9845             PrintConv => \%flashControlMode,
9846             SeparateTable => 'FlashControlMode',
9847             },
9848             18.2 => {
9849             Name => 'FlashGroupCControlMode',
9850             Mask => 0x0f,
9851             DataMember => 'FlashGroupCControlMode',
9852             RawConv => '$$self{FlashGroupCControlMode} = $val',
9853             PrintConv => \%flashControlMode,
9854             SeparateTable => 'FlashControlMode',
9855             },
9856             # 0x13 - same as 0x28 but not zero when flash group A is Off
9857             # 0x14 - same as 0x29 but not zero when flash group B is Off
9858             # 0x15 - same as 0x2a but not zero when flash group B is Off
9859             # 0x1a - changes with illumination pattern (0=normal,1=narrow,2=wide), but other values seen
9860             # 0x26 - changes when diffuser is used
9861             0x27 => [
9862             {
9863             Name => 'FlashOutput',
9864             Condition => '$$self{FlashControlMode} >= 0x06',
9865             ValueConv => '2 ** (-$val/6)',
9866             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9867             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9868             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9869             },
9870             {
9871             Name => 'FlashCompensation',
9872             Format => 'int8s',
9873             Priority => 0,
9874             ValueConv => '-$val/6',
9875             ValueConvInv => '-6 * $val',
9876             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9877             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9878             },
9879             ],
9880             0x28 => [
9881             {
9882             Name => 'FlashGroupAOutput',
9883             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
9884             ValueConv => '2 ** (-$val/6)',
9885             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9886             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9887             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9888             },
9889             {
9890             Name => 'FlashGroupACompensation',
9891             Format => 'int8s',
9892             ValueConv => '-$val/6',
9893             ValueConvInv => '-6 * $val',
9894             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9895             PrintConvInv => '$val',
9896             },
9897             ],
9898             0x29 => [
9899             {
9900             Name => 'FlashGroupBOutput',
9901             Condition => '$$self{FlashGroupBControlMode} >= 0x60',
9902             ValueConv => '2 ** (-$val/6)',
9903             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9904             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9905             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9906             },
9907             {
9908             Name => 'FlashGroupBCompensation',
9909             Format => 'int8s',
9910             ValueConv => '-$val/6',
9911             ValueConvInv => '-6 * $val',
9912             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9913             PrintConvInv => '$val',
9914             },
9915             ],
9916             0x2a => [
9917             {
9918             Name => 'FlashGroupCOutput',
9919             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
9920             ValueConv => '2 ** (-$val/6)',
9921             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9922             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9923             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9924             },
9925             {
9926             Name => 'FlashGroupCCompensation',
9927             Format => 'int8s',
9928             ValueConv => '-$val/6',
9929             ValueConvInv => '-6 * $val',
9930             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9931             PrintConvInv => '$val',
9932             },
9933             ],
9934             );
9935              
9936             # Flash information for the D4S/D750/D810/D5500/D7200 (0107)
9937             # and D5/D500/D850/D3400 (0108) (ref 28)
9938             %Image::ExifTool::Nikon::FlashInfo0107 = (
9939             %binaryDataAttrs,
9940             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9941             DATAMEMBER => [ 17.1, 18.1, 18.2 ],
9942             NOTES => q{
9943             These tags are used by the D4S, D750, D810, D5500, D7200 (FlashInfoVersion
9944             0107) and the D5, D500, D850 and D3400 (FlashInfoVersion 0108).
9945             },
9946             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
9947             0 => {
9948             Name => 'FlashInfoVersion',
9949             Format => 'string[4]',
9950             Writable => 0,
9951             },
9952             4 => {
9953             Name => 'FlashSource',
9954             PrintConv => {
9955             0 => 'None',
9956             1 => 'External',
9957             2 => 'Internal',
9958             },
9959             },
9960             6 => {
9961             Format => 'int8u[2]',
9962             Name => 'ExternalFlashFirmware',
9963             SeparateTable => 'FlashFirmware',
9964             PrintConv => \%flashFirmware,
9965             },
9966             8.1 => {
9967             Name => 'ExternalFlashZoomOverride',
9968             Mask => 0x80,
9969             Notes => 'indicates that the user has overridden the flash zoom distance',
9970             PrintConv => { 0 => 'No', 1 => 'Yes' },
9971             },
9972             8.2 => {
9973             Name => 'ExternalFlashStatus',
9974             Mask => 0x01,
9975             PrintConv => {
9976             0 => 'Flash Not Attached',
9977             1 => 'Flash Attached',
9978             },
9979             },
9980             9.1 => {
9981             Name => 'ExternalFlashReadyState',
9982             Mask => 0x07,
9983             PrintConv => {
9984             0 => 'n/a',
9985             1 => 'Ready',
9986             6 => 'Not Ready',
9987             },
9988             },
9989             10 => {
9990             Name => 'FlashCompensation',
9991             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
9992             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
9993             Format => 'int8s',
9994             Priority => 0,
9995             ValueConv => '-$val/6',
9996             ValueConvInv => '-6 * $val',
9997             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9998             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9999             },
10000             12 => {
10001             Name => 'FlashFocalLength',
10002             Notes => 'only valid if flash pattern is "Standard Illumination"',
10003             RawConv => '($val and $val != 255) ? $val : undef',
10004             PrintConv => '"$val mm"',
10005             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
10006             },
10007             13 => {
10008             Name => 'RepeatingFlashRate',
10009             RawConv => '($val and $val != 255) ? $val : undef',
10010             PrintConv => '"$val Hz"',
10011             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
10012             },
10013             14 => {
10014             Name => 'RepeatingFlashCount',
10015             RawConv => '($val and $val != 255) ? $val : undef',
10016             },
10017             15 => {
10018             Name => 'FlashGNDistance',
10019             SeparateTable => 1,
10020             PrintConv => \%flashGNDistance,
10021             },
10022             17.1 => { #PH
10023             Name => 'FlashGroupAControlMode',
10024             Mask => 0x0f,
10025             Notes => 'note: group A tags may apply to the built-in flash settings for some models',
10026             DataMember => 'FlashGroupAControlMode',
10027             RawConv => '$$self{FlashGroupAControlMode} = $val',
10028             PrintConv => \%flashControlMode,
10029             SeparateTable => 'FlashControlMode',
10030             },
10031             18.1 => { #PH
10032             Name => 'FlashGroupBControlMode',
10033             Mask => 0xf0,
10034             Notes => 'note: group B tags may apply to group A settings for some models',
10035             DataMember => 'FlashGroupBControlMode',
10036             RawConv => '$$self{FlashGroupBControlMode} = $val',
10037             PrintConv => \%flashControlMode,
10038             SeparateTable => 'FlashControlMode',
10039             },
10040             18.2 => { #PH
10041             Name => 'FlashGroupCControlMode',
10042             Mask => 0x0f,
10043             Notes => 'note: group C tags may apply to group B settings for some models',
10044             DataMember => 'FlashGroupCControlMode',
10045             RawConv => '$$self{FlashGroupCControlMode} = $val',
10046             PrintConv => \%flashControlMode,
10047             SeparateTable => 'FlashControlMode',
10048             },
10049             # 0x13 - very similar to 0x28
10050             # 0x18 or 0x19 may indicate flash illumination pattern (Standard, Center-weighted, Even)
10051             0x28 => [ #PH
10052             {
10053             Name => 'FlashGroupAOutput',
10054             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
10055             ValueConv => '2 ** (-$val/6)',
10056             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
10057             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
10058             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
10059             },
10060             {
10061             Name => 'FlashGroupACompensation',
10062             Format => 'int8s',
10063             ValueConv => '-$val/6',
10064             ValueConvInv => '-6 * $val',
10065             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
10066             PrintConvInv => '$val',
10067             },
10068             ],
10069             0x29 => [ #PH
10070             {
10071             Name => 'FlashGroupBOutput',
10072             Condition => '$$self{FlashGroupBControlMode} >= 0x60',
10073             ValueConv => '2 ** (-$val/6)',
10074             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
10075             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
10076             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
10077             },
10078             {
10079             Name => 'FlashGroupBCompensation',
10080             Format => 'int8s',
10081             ValueConv => '-$val/6',
10082             ValueConvInv => '-6 * $val',
10083             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
10084             PrintConvInv => '$val',
10085             },
10086             ],
10087             0x2a => [ #PH
10088             {
10089             Name => 'FlashGroupCOutput',
10090             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
10091             ValueConv => '2 ** (-$val/6)',
10092             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
10093             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
10094             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
10095             },
10096             {
10097             Name => 'FlashGroupCCompensation',
10098             Format => 'int8s',
10099             ValueConv => '-$val/6',
10100             ValueConvInv => '-6 * $val',
10101             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
10102             PrintConvInv => '$val',
10103             },
10104             ],
10105             );
10106              
10107             # Flash information for the Z7II (ref 28)
10108             # (likey similar to FlashInfo010 and FlashInfo0108 with addition of support for radio controlled units such as the SB-5000?
10109             %Image::ExifTool::Nikon::FlashInfo0300 = (
10110             %binaryDataAttrs,
10111             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10112             0 => {
10113             Name => 'FlashInfoVersion',
10114             Format => 'string[4]',
10115             Writable => 0,
10116             },
10117             4 => {
10118             Name => 'FlashSource',
10119             PrintConv => {
10120             0 => 'None',
10121             1 => 'External',
10122             2 => 'Internal',
10123             },
10124             },
10125             6 => {
10126             Format => 'int8u[2]',
10127             Name => 'ExternalFlashFirmware',
10128             SeparateTable => 'FlashFirmware',
10129             PrintConv => \%flashFirmware,
10130             },
10131             10 => {
10132             Name => 'FlashCompensation',
10133             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
10134             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
10135             Format => 'int8s',
10136             Priority => 0,
10137             ValueConv => '-$val/6',
10138             ValueConvInv => '-6 * $val',
10139             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
10140             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
10141             },
10142             );
10143             # Unknown Flash information
10144             %Image::ExifTool::Nikon::FlashInfoUnknown = (
10145             %binaryDataAttrs,
10146             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10147             0 => {
10148             Name => 'FlashInfoVersion',
10149             Format => 'string[4]',
10150             Writable => 0,
10151             },
10152             );
10153              
10154             # Multi exposure / image overlay information (ref PH)
10155             %Image::ExifTool::Nikon::MultiExposure = (
10156             %binaryDataAttrs,
10157             FORMAT => 'int32u',
10158             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10159             0 => {
10160             Name => 'MultiExposureVersion',
10161             Format => 'string[4]',
10162             Writable => 0,
10163             },
10164             1 => {
10165             Name => 'MultiExposureMode',
10166             PrintConv => {
10167             0 => 'Off',
10168             1 => 'Multiple Exposure',
10169             2 => 'Image Overlay',
10170             3 => 'HDR', #31
10171             },
10172             },
10173             2 => 'MultiExposureShots',
10174             3 => {
10175             Name => 'MultiExposureAutoGain',
10176             PrintConv => \%offOn,
10177             },
10178             );
10179              
10180             # Multi exposure2 / image overlay information (ref 39)
10181             %Image::ExifTool::Nikon::MultiExposure2 = (
10182             %binaryDataAttrs,
10183             FORMAT => 'int32u',
10184             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10185             0 => {
10186             Name => 'MultiExposureVersion',
10187             Format => 'string[4]',
10188             Writable => 0,
10189             },
10190             1 => {
10191             Name => 'MultiExposureMode',
10192             PrintConv => {
10193             0 => 'Off',
10194             1 => 'Multiple Exposure',
10195             3 => 'HDR',
10196             },
10197             },
10198             2 => 'MultiExposureShots',
10199             3 => {
10200             Name => 'MultiExposureOverlayMode',
10201             PrintConv => {
10202             0 => 'Add',
10203             1 => 'Average',
10204             2 => 'Light',
10205             3 => 'Dark',
10206             },
10207             },
10208             );
10209              
10210             # HDR information (ref 32)
10211             %Image::ExifTool::Nikon::HDRInfo = (
10212             %binaryDataAttrs,
10213             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
10214             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
10215             0 => {
10216             Name => 'HDRInfoVersion',
10217             Format => 'string[4]',
10218             Writable => 0,
10219             },
10220             4 => {
10221             Name => 'HDR',
10222             PrintConv => {
10223             0 => 'Off',
10224             1 => 'On (normal)',
10225             48 => 'Auto', #PH (NC)
10226             },
10227             },
10228             5 => {
10229             Name => 'HDRLevel',
10230             PrintConv => {
10231             0 => 'Auto',
10232             1 => '1 EV',
10233             2 => '2 EV',
10234             3 => '3 EV',
10235             # 5 - seen for 1J4
10236             255 => 'n/a', #PH
10237             },
10238             },
10239             6 => {
10240             Name => 'HDRSmoothing',
10241             PrintConv => {
10242             0 => 'Off',
10243             1 => 'Normal',
10244             2 => 'Low',
10245             3 => 'High',
10246             48 => 'Auto', #PH (NC)
10247             255 => 'n/a', #PH
10248             },
10249             },
10250             7 => { #PH (P330, HDRInfoVersion=0101)
10251             Name => 'HDRLevel2',
10252             PrintConv => {
10253             0 => 'Auto',
10254             1 => '1 EV',
10255             2 => '2 EV',
10256             3 => '3 EV',
10257             255 => 'n/a',
10258             },
10259             },
10260             );
10261              
10262             # ref 39 (Z9)
10263             %Image::ExifTool::Nikon::HDRInfo2 = (
10264             %binaryDataAttrs,
10265             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
10266             0 => {
10267             Name => 'HDRInfoVersion', # 0200
10268             Format => 'string[4]',
10269             Writable => 0,
10270             },
10271             4 => {
10272             Name => 'HDR',
10273             PrintConv => {
10274             0 => 'Off',
10275             1 => 'On (normal)',
10276             },
10277             },
10278             5 => {
10279             Name => 'HDRLevel',
10280             PrintConv => {
10281             0 => 'n/a',
10282             1 => 'Normal',
10283             2 => 'Low',
10284             3 => 'High',
10285             4 => 'High+',
10286             5 => 'Auto',
10287             },
10288             },
10289             );
10290              
10291             # location information (ref PH)
10292             %Image::ExifTool::Nikon::LocationInfo = (
10293             %binaryDataAttrs,
10294             DATAMEMBER => [ 4 ],
10295             GROUPS => { 0 => 'MakerNotes', 2 => 'Location' },
10296             NOTES => 'Tags written by some Nikon GPS-equipped cameras like the AW100.',
10297             0 => {
10298             Name => 'LocationInfoVersion',
10299             Format => 'undef[4]',
10300             },
10301             4 => {
10302             Name => 'TextEncoding',
10303             DataMember => 'TextEncoding',
10304             RawConv => q{
10305             $$self{TextEncoding} = $Image::ExifTool::Nikon::nikonTextEncoding{$val} if $val;
10306             return $val;
10307             },
10308             PrintConv => \%Image::ExifTool::Nikon::nikonTextEncoding,
10309             },
10310             # (the CountryCode and Location tag names chosen to correspond with XMP::iptcCore)
10311             5 => {
10312             Name => 'CountryCode',
10313             Format => 'undef[3]',
10314             ValueConv => '$val=~s/\0.*//s; $val', # truncate at null
10315             ValueConvInv => '$val',
10316             },
10317             8 => 'POILevel', #forum5782
10318             9 => {
10319             Name => 'Location',
10320             Format => 'undef[70]',
10321             RawConv => '$$self{TextEncoding} ? $self->Decode($val,$$self{TextEncoding},"MM") : $val',
10322             RawConvInv => '$$self{TextEncoding} ? $self->Encode($val,$$self{TextEncoding},"MM") : $val',
10323             },
10324             );
10325              
10326             # MakerNotes0x51 - compression info for Z9
10327             %Image::ExifTool::Nikon::MakerNotes0x51 = (
10328             %binaryDataAttrs,
10329             DATAMEMBER => [ 0 ],
10330             GROUPS => { 0 => 'MakerNotes' },
10331             0 => {
10332             Name => 'FirmwareVersion',
10333             Format => 'string[8]',
10334             Writable => 0,
10335             RawConv => '$$self{FirmwareVersion} = $val',
10336             },
10337             10 => {
10338             Name => 'NEFCompression',
10339             Writable => 'int16u',
10340             SeparateTable => 'NEFCompression',
10341             PrintConv => \%nefCompression,
10342             },
10343             );
10344              
10345             # extra info found in IFD0 of NEF files (ref PH, Z6/Z7)
10346             %Image::ExifTool::Nikon::NEFInfo = (
10347             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10348             NOTES => q{
10349             As-yet unknown information found in SubIFD1 tag 0xc7d5 of NEF images from
10350             cameras such as the Z6 and Z7, and NRW images from some Coolpix cameras.
10351             },
10352             # 0x01 - undef[12]
10353             # 0x02 - undef[148]
10354             # 0x03 - undef[284]
10355             # 0x04 - undef[148,212]
10356             # 0x05 - undef[84] (barrel distortion params at offsets 0x14,0x1c,0x24, ref 28)
10357             # 0x06 - undef[116] (vignette correction params at offsets 0x24,0x34,0x44, ref 28)
10358             # 0x07 - undef[104]
10359             # 0x08 - undef[24]
10360             # 0x09 - undef[36]
10361             );
10362              
10363             # tags in Nikon QuickTime videos (PH - observations with Coolpix S3)
10364             # (similar information in Kodak,Minolta,Nikon,Olympus,Pentax and Sanyo videos)
10365             %Image::ExifTool::Nikon::MOV = (
10366             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
10367             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10368             FIRST_ENTRY => 0,
10369             NOTES => q{
10370             This information is found in MOV and QT videos from some Nikon cameras.
10371             },
10372             0x00 => {
10373             Name => 'Make',
10374             Format => 'string[24]',
10375             },
10376             0x18 => {
10377             Name => 'Model',
10378             Description => 'Camera Model Name',
10379             Format => 'string[8]',
10380             },
10381             # (01 00 at offset 0x20)
10382             0x26 => {
10383             Name => 'ExposureTime',
10384             Format => 'int32u',
10385             ValueConv => '$val ? 10 / $val : 0',
10386             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
10387             },
10388             0x2a => {
10389             Name => 'FNumber',
10390             Format => 'rational64u',
10391             PrintConv => 'sprintf("%.1f",$val)',
10392             },
10393             0x32 => {
10394             Name => 'ExposureCompensation',
10395             Format => 'rational64s',
10396             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
10397             },
10398             0x44 => {
10399             Name => 'WhiteBalance',
10400             Format => 'int16u',
10401             PrintConv => {
10402             0 => 'Auto',
10403             1 => 'Daylight',
10404             2 => 'Shade',
10405             3 => 'Fluorescent', #2
10406             4 => 'Tungsten',
10407             5 => 'Manual',
10408             },
10409             },
10410             0x48 => {
10411             Name => 'FocalLength',
10412             Format => 'rational64u',
10413             PrintConv => 'sprintf("%.1f mm",$val)',
10414             },
10415             0xaf => {
10416             Name => 'Software',
10417             Format => 'string[16]',
10418             },
10419             0xdf => { # (this is a guess ... could also be offset 0xdb)
10420             Name => 'ISO',
10421             Format => 'int16u',
10422             RawConv => '$val < 50 ? undef : $val', # (not valid for Coolpix L10)
10423             },
10424             );
10425              
10426             # Nikon metadata in AVI videos (PH)
10427             %Image::ExifTool::Nikon::AVI = (
10428             NOTES => 'Nikon-specific RIFF tags found in AVI videos.',
10429             GROUPS => { 0 => 'MakerNotes', 2 => 'Video' },
10430             nctg => {
10431             Name => 'NikonTags',
10432             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AVITags' },
10433             },
10434             ncth => {
10435             Name => 'ThumbnailImage',
10436             Groups => { 2 => 'Preview' },
10437             Binary => 1,
10438             },
10439             ncvr => {
10440             Name => 'NikonVers',
10441             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AVIVers' },
10442             },
10443             ncvw => {
10444             Name => 'PreviewImage',
10445             Groups => { 2 => 'Preview' },
10446             RawConv => 'length($val) ? $val : undef',
10447             Binary => 1,
10448             },
10449             );
10450              
10451             # version information in AVI videos (PH)
10452             %Image::ExifTool::Nikon::AVIVers = (
10453             GROUPS => { 0 => 'MakerNotes', 2 => 'Video' },
10454             PROCESS_PROC => \&ProcessNikonAVI,
10455             FORMAT => 'string',
10456             0x01 => 'MakerNoteType',
10457             0x02 => {
10458             Name => 'MakerNoteVersion',
10459             Format => 'int8u',
10460             ValueConv => 'my @a = reverse split " ", $val; join ".", @a;',
10461             },
10462             );
10463              
10464             # tags in AVI videos (PH)
10465             %Image::ExifTool::Nikon::AVITags = (
10466             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10467             PROCESS_PROC => \&ProcessNikonAVI,
10468             FORMAT => 'string',
10469             NOTES => q{
10470             These tags and the AVIVer tags below are found in proprietary-format records
10471             of Nikon AVI videos.
10472             },
10473             0x03 => 'Make',
10474             0x04 => 'Model',
10475             0x05 => {
10476             Name => 'Software',
10477             Format => 'undef',
10478             ValueConv => '$val =~ tr/\0//d; $val',
10479             },
10480             0x06 => 'Equipment', # "NIKON DIGITAL CAMERA"
10481             0x07 => { # (guess)
10482             Name => 'Orientation',
10483             Format => 'int16u',
10484             Groups => { 2 => 'Image' },
10485             PrintConv => \%Image::ExifTool::Exif::orientation,
10486             },
10487             0x08 => {
10488             Name => 'ExposureTime',
10489             Format => 'rational64u',
10490             Groups => { 2 => 'Image' },
10491             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
10492             },
10493             0x09 => {
10494             Name => 'FNumber',
10495             Format => 'rational64u',
10496             Groups => { 2 => 'Image' },
10497             PrintConv => 'sprintf("%.1f",$val)',
10498             },
10499             0x0a => {
10500             Name => 'ExposureCompensation',
10501             Format => 'rational64s',
10502             Groups => { 2 => 'Image' },
10503             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
10504             },
10505             0x0b => {
10506             Name => 'MaxApertureValue',
10507             Format => 'rational64u',
10508             ValueConv => '2 ** ($val / 2)',
10509             PrintConv => 'sprintf("%.1f",$val)',
10510             },
10511             0x0c => {
10512             Name => 'MeteringMode', # (guess)
10513             Format => 'int16u',
10514             PrintConv => {
10515             0 => 'Unknown',
10516             1 => 'Average',
10517             2 => 'Center-weighted average',
10518             3 => 'Spot',
10519             4 => 'Multi-spot',
10520             5 => 'Multi-segment',
10521             6 => 'Partial',
10522             255 => 'Other',
10523             },
10524             },
10525             0x0d => { # val: 0
10526             Name => 'Nikon_AVITags_0x000d',
10527             Format => 'int16u',
10528             Flags => [ 'Hidden', 'Unknown' ],
10529             },
10530             0x0e => { # val: 0
10531             Name => 'Nikon_AVITags_0x000e',
10532             Format => 'int16u',
10533             Flags => [ 'Hidden', 'Unknown' ],
10534             },
10535             0x0f => {
10536             Name => 'FocalLength',
10537             Format => 'rational64u',
10538             PrintConv => 'sprintf("%.1f mm",$val)',
10539             },
10540             0x10 => {
10541             Name => 'XResolution',
10542             Format => 'rational64u',
10543             Groups => { 2 => 'Image' },
10544             },
10545             0x11 => {
10546             Name => 'YResolution',
10547             Format => 'rational64u',
10548             Groups => { 2 => 'Image' },
10549             },
10550             0x12 => {
10551             Name => 'ResolutionUnit',
10552             Format => 'int16u',
10553             Groups => { 2 => 'Image' },
10554             PrintConv => {
10555             1 => 'None',
10556             2 => 'inches',
10557             3 => 'cm',
10558             },
10559             },
10560             0x13 => {
10561             Name => 'DateTimeOriginal', # (guess)
10562             Description => 'Date/Time Original',
10563             Groups => { 2 => 'Time' },
10564             PrintConv => '$self->ConvertDateTime($val)',
10565             },
10566             0x14 => {
10567             Name => 'CreateDate', # (guess)
10568             Groups => { 2 => 'Time' },
10569             PrintConv => '$self->ConvertDateTime($val)',
10570             },
10571             0x15 => {
10572             Name => 'Nikon_AVITags_0x0015',
10573             Format => 'int16u',
10574             Flags => [ 'Hidden', 'Unknown' ],
10575             },
10576             0x16 => {
10577             Name => 'Duration',
10578             Format => 'rational64u',
10579             PrintConv => '"$val s"',
10580             },
10581             0x17 => { # val: 1
10582             Name => 'Nikon_AVITags_0x0017',
10583             Format => 'int16u',
10584             Flags => [ 'Hidden', 'Unknown' ],
10585             },
10586             0x18 => 'FocusMode',
10587             0x19 => { # vals: -5, -2, 3, 5, 6, 8, 11, 12, 14, 20, 22
10588             Name => 'Nikon_AVITags_0x0019',
10589             Format => 'int32s',
10590             Flags => [ 'Hidden', 'Unknown' ],
10591             },
10592             0x1b => { # vals: 1 (640x480), 1.25 (320x240)
10593             Name => 'DigitalZoom',
10594             Format => 'rational64u',
10595             },
10596             0x1c => { # (same as Nikon_0x000a)
10597             Name => 'Nikon_AVITags_0x001c',
10598             Format => 'rational64u',
10599             Flags => [ 'Hidden', 'Unknown' ],
10600             },
10601             0x1d => 'ColorMode',
10602             0x1e => { # string[8] - val: "AUTO"
10603             Name => 'Sharpness', # (guess, could also be ISOSelection)
10604             },
10605             0x1f => { # string[16] - val: "AUTO"
10606             Name => 'WhiteBalance', # (guess, could also be ImageAdjustment)
10607             },
10608             0x20 => { # string[4] - val: "OFF"
10609             Name => 'NoiseReduction', # (guess)
10610             },
10611             0x801a => { # val: 0 (why is the 0x8000 bit set in the ID?)
10612             Name => 'Nikon_AVITags_0x801a',
10613             Format => 'int32s',
10614             Flags => [ 'Hidden', 'Unknown' ],
10615             }
10616             );
10617              
10618             # Nikon NCDT atoms (ref PH)
10619             %Image::ExifTool::Nikon::NCDT = (
10620             GROUPS => { 0 => 'MakerNotes', 1 => 'Nikon', 2 => 'Video' },
10621             NOTES => q{
10622             Nikon-specific QuickTime tags found in the NCDT atom of MOV videos from
10623             various Nikon models.
10624             },
10625             NCHD => {
10626             Name => 'MakerNoteVersion',
10627             Format => 'undef',
10628             ValueConv => q{
10629             $val =~ s/\0$//; # remove trailing null
10630             $val =~ s/([\0-\x1f])/'.'.ord($1)/ge;
10631             $val =~ s/\./ /; return $val;
10632             },
10633             },
10634             NCTG => {
10635             Name => 'NikonTags',
10636             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::NCTG' },
10637             },
10638             NCTH => {
10639             Name => 'ThumbnailImage',
10640             Groups => { 2 => 'Preview' },
10641             Format => 'undef',
10642             Binary => 1,
10643             },
10644             NCVW => {
10645             Name => 'PreviewImage',
10646             Groups => { 2 => 'Preview' },
10647             Format => 'undef',
10648             Binary => 1,
10649             },
10650             NCDB => { # (often 0 bytes long, or 4 null bytes)
10651             Name => 'NikonNCDB',
10652             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::NCDB' },
10653             },
10654             NCM1 => {
10655             Name => 'PreviewImage1',
10656             Groups => { 2 => 'Preview' },
10657             Format => 'undef',
10658             Binary => 1,
10659             RawConv => 'length $val ? $val : undef',
10660             },
10661             NCM2 => { #PH (guess - have only seen 0 bytes)
10662             Name => 'PreviewImage2',
10663             Groups => { 2 => 'Preview' },
10664             Format => 'undef',
10665             Binary => 1,
10666             RawConv => 'length $val ? $val : undef',
10667             },
10668             );
10669              
10670             # Nikon NCDB tags from MOV videos (ref PH)
10671             %Image::ExifTool::Nikon::NCDB = (
10672             GROUPS => { 0 => 'MakerNotes', 1 => 'Nikon', 2 => 'Video' },
10673             # the following probably contain encrypted data -- look into decryping these!
10674             # OP01 - 320 bytes, starts with "0200" (D600,D610,D810,D3200,D5200)
10675             # - 638 bytes, starts with "0200" (D7100)
10676             # OP02 - 2048 bytes, starts with "0200" (D810)
10677             );
10678              
10679             # Nikon NCTG tags from MOV videos (ref PH)
10680             %Image::ExifTool::Nikon::NCTG = (
10681             PROCESS_PROC => \&ProcessNikonMOV,
10682             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10683             NOTES => q{
10684             These tags are found in proprietary-format records of the NCTG atom in MOV
10685             videos from some Nikon cameras.
10686             },
10687             0x01 => 'Make',
10688             0x02 => 'Model',
10689             0x03 => 'Software',
10690             0x11 => {
10691             Name => 'CreateDate', #(guess, but matches QuickTime CreateDate)
10692             Groups => { 2 => 'Time' },
10693             PrintConv => '$self->ConvertDateTime($val)',
10694             },
10695             0x12 => {
10696             Name => 'DateTimeOriginal', #(guess, but time is 1 sec before tag 0x11)
10697             Description => 'Date/Time Original',
10698             Groups => { 2 => 'Time' },
10699             PrintConv => '$self->ConvertDateTime($val)',
10700             },
10701             0x13 => {
10702             Name => 'FrameCount',
10703             # int32u[2]: "467 0", "1038 0", "1127 0"
10704             ValueConv => '$val =~ s/ 0$//; $val', # (not sure what the extra "0" is for)
10705             },
10706             # 0x14 - int32u[2]: "0 0"
10707             # 0x15 - int32u[2]: "0 0"
10708             0x16 => {
10709             Name => 'FrameRate',
10710             Groups => { 2 => 'Video' },
10711             PrintConv => 'int($val * 1000 + 0.5) / 1000',
10712             },
10713             # 0x17 - rational62u: same value as FrameRate
10714             # 0x18 - int16u: 1, 2
10715             0x19 => {
10716             Name => 'TimeZone',
10717             Groups => { 2 => 'Time' },
10718             },
10719             # 0x21 - int16u: 1, 2
10720             0x22 => {
10721             Name => 'FrameWidth',
10722             Groups => { 2 => 'Video' },
10723             },
10724             0x23 => {
10725             Name => 'FrameHeight',
10726             Groups => { 2 => 'Video' },
10727             },
10728             # 0x24 - int16u: 1, 2
10729             # 0x31 - int16u: 0, 1, 2
10730             0x32 => { #(guess)
10731             Name => 'AudioChannels',
10732             Groups => { 2 => 'Audio' },
10733             },
10734             0x33 => {
10735             Name => 'AudioBitsPerSample',
10736             Groups => { 2 => 'Audio' },
10737             },
10738             0x34 => {
10739             Name => 'AudioSampleRate',
10740             Groups => { 2 => 'Audio' },
10741             },
10742             # 0x101 - int16u[4]: "160 120 1280 720", "160 120 3840 2160"
10743             # 0x102 - int16u[8]: "640 360 0 0 0 0 0 0", "640 360 1920 1080 0 0 0 0"
10744             # 0x1001 - int16s: 0
10745             0x1002 => {
10746             Name => 'NikonDateTime', #?
10747             Groups => { 2 => 'Time' },
10748             PrintConv => '$self->ConvertDateTime($val)',
10749             },
10750             # 0x1011 - int32u: 0
10751             # 0x1012 - int32u: 0
10752             0x1013 => { #HayoBaan
10753             Name => 'ElectronicVR',
10754             PrintConv => \%offOn,
10755             },
10756             # 0x1014 - int16u: 1
10757             # 0x1021 - int32u[32]: all zeros
10758             #
10759             # 0x110**** tags correspond to 0x**** tags in Exif::Main
10760             #
10761             0x110829a => { #34
10762             Name => 'ExposureTime',
10763             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
10764             },
10765             0x110829d => { #34
10766             Name => 'FNumber',
10767             PrintConv => 'Image::ExifTool::Exif::PrintFNumber($val)',
10768             },
10769             0x1108822 => {
10770             Name => 'ExposureProgram',
10771             PrintConv => {
10772             0 => 'Not Defined',
10773             1 => 'Manual',
10774             2 => 'Program AE',
10775             3 => 'Aperture-priority AE',
10776             4 => 'Shutter speed priority AE',
10777             5 => 'Creative (Slow speed)',
10778             6 => 'Action (High speed)',
10779             7 => 'Portrait',
10780             8 => 'Landscape',
10781             # 9 => 'Bulb', # (non-standard Canon value)
10782             },
10783             },
10784             0x1109204 => {
10785             Name => 'ExposureCompensation',
10786             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
10787             },
10788             0x1109207 => {
10789             Name => 'MeteringMode',
10790             PrintConv => {
10791             0 => 'Unknown',
10792             1 => 'Average',
10793             2 => 'Center-weighted average',
10794             3 => 'Spot',
10795             4 => 'Multi-spot',
10796             5 => 'Multi-segment',
10797             6 => 'Partial',
10798             255 => 'Other',
10799             },
10800             },
10801             0x110920a => { #34
10802             Name => 'FocalLength',
10803             PrintConv => 'sprintf("%.1f mm",$val)',
10804             },
10805             0x110a431 => 'SerialNumber',
10806             0x110a432 => {
10807             Name => 'LensInfo',
10808             PrintConv => \&Image::ExifTool::Exif::PrintLensInfo,
10809             },
10810             0x110a433 => 'LensMake',
10811             0x110a434 => 'LensModel',
10812             0x110a435 => 'LensSerialNumber',
10813             #
10814             # 0x120**** tags correspond to 0x**** tags in GPS::Main
10815             #
10816             0x1200000 => {
10817             Name => 'GPSVersionID',
10818             Groups => { 1 => 'GPS', 2 => 'Location' },
10819             PrintConv => '$val =~ tr/ /./; $val',
10820             },
10821             0x1200001 => {
10822             Name => 'GPSLatitudeRef',
10823             Groups => { 1 => 'GPS', 2 => 'Location' },
10824             PrintConv => {
10825             N => 'North',
10826             S => 'South',
10827             },
10828             },
10829             0x1200002 => {
10830             Name => 'GPSLatitude',
10831             Groups => { 1 => 'GPS', 2 => 'Location' },
10832             ValueConv => q{
10833             require Image::ExifTool::GPS;
10834             Image::ExifTool::GPS::ToDegrees($val);
10835             },
10836             PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1)',
10837             },
10838             0x1200003 => {
10839             Name => 'GPSLongitudeRef',
10840             Groups => { 1 => 'GPS', 2 => 'Location' },
10841             PrintConv => {
10842             E => 'East',
10843             W => 'West',
10844             },
10845             },
10846             0x1200004 => {
10847             Name => 'GPSLongitude',
10848             Groups => { 1 => 'GPS', 2 => 'Location' },
10849             ValueConv => q{
10850             require Image::ExifTool::GPS;
10851             Image::ExifTool::GPS::ToDegrees($val);
10852             },
10853             PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1)',
10854             },
10855             0x1200005 => {
10856             Name => 'GPSAltitudeRef',
10857             Groups => { 1 => 'GPS', 2 => 'Location' },
10858             PrintConv => {
10859             0 => 'Above Sea Level',
10860             1 => 'Below Sea Level',
10861             },
10862             },
10863             0x1200006 => {
10864             Name => 'GPSAltitude',
10865             Groups => { 1 => 'GPS', 2 => 'Location' },
10866             PrintConv => '$val =~ /^(inf|undef)$/ ? $val : "$val m"',
10867             },
10868             0x1200007 => {
10869             Name => 'GPSTimeStamp',
10870             Groups => { 1 => 'GPS', 2 => 'Time' },
10871             ValueConv => q{
10872             require Image::ExifTool::GPS;
10873             Image::ExifTool::GPS::ConvertTimeStamp($val);
10874             },
10875             PrintConv => 'Image::ExifTool::GPS::PrintTimeStamp($val)',
10876             },
10877             0x1200008 => {
10878             Name => 'GPSSatellites',
10879             Groups => { 1 => 'GPS', 2 => 'Location' },
10880             },
10881             0x1200010 => {
10882             Name => 'GPSImgDirectionRef',
10883             Groups => { 1 => 'GPS', 2 => 'Location' },
10884             PrintConv => {
10885             M => 'Magnetic North',
10886             T => 'True North',
10887             },
10888             },
10889             0x1200011 => {
10890             Name => 'GPSImgDirection',
10891             Groups => { 1 => 'GPS', 2 => 'Location' },
10892             },
10893             0x1200012 => {
10894             Name => 'GPSMapDatum',
10895             Groups => { 1 => 'GPS', 2 => 'Location' },
10896             },
10897             0x120001d => {
10898             Name => 'GPSDateStamp',
10899             Groups => { 1 => 'GPS', 2 => 'Time' },
10900             ValueConv => 'Image::ExifTool::Exif::ExifDate($val)',
10901             },
10902             #
10903             # 0x200**** tags correspond to 0x**** tags in Nikon::Main
10904             # (must be duplicated here so tagInfo "Table" entry will point to correct table.
10905             # Also there would be a problem with the PRINT_CONV from the Main table)
10906             #
10907             0x2000001 => {
10908             Name => 'MakerNoteVersion',
10909             PrintConv => '$_=$val;s/^(\d{2})/$1\./;s/^0//;$_',
10910             },
10911             0x2000005 => 'WhiteBalance',
10912             0x2000007 => { Name => 'FocusMode', Writable => 'string' }, #34
10913             0x200000b => 'WhiteBalanceFineTune',
10914             0x200001b => {
10915             Name => 'CropHiSpeed',
10916             Writable => 'int16u',
10917             Count => 7,
10918             PrintConv => \%cropHiSpeed,
10919             },
10920             0x200001e => {
10921             Name => 'ColorSpace',
10922             PrintConv => {
10923             1 => 'sRGB',
10924             2 => 'Adobe RGB',
10925             },
10926             },
10927             0x200001f => {
10928             Name => 'VRInfo',
10929             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::VRInfo' },
10930             },
10931             0x2000022 => {
10932             Name => 'ActiveD-Lighting',
10933             Writable => 'int16u',
10934             PrintConv => {
10935             0 => 'Off',
10936             1 => 'Low',
10937             3 => 'Normal',
10938             5 => 'High',
10939             7 => 'Extra High',
10940             8 => 'Extra High 1',
10941             9 => 'Extra High 2',
10942             10 => 'Extra High 3',
10943             11 => 'Extra High 4',
10944             0xffff => 'Auto',
10945             },
10946             },
10947             0x2000023 => [
10948             { #PH (D300, but also found in D3,D3S,D3X,D90,D300S,D700,D3000,D5000)
10949             Name => 'PictureControlData',
10950             Condition => '$$valPt =~ /^01/',
10951             Writable => 'undef',
10952             Permanent => 0,
10953             Flags => [ 'Binary', 'Protected' ],
10954             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl' },
10955             },{ #28
10956             Name => 'PictureControlData',
10957             Condition => '$$valPt =~ /^02/',
10958             Writable => 'undef',
10959             Permanent => 0,
10960             Flags => [ 'Binary', 'Protected' ],
10961             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl2' },
10962             },{
10963             Name => 'PictureControlData',
10964             Condition => '$$valPt =~ /^03/',
10965             Writable => 'undef',
10966             Permanent => 0,
10967             Flags => [ 'Binary', 'Protected' ],
10968             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl3' },
10969             },{
10970             Name => 'PictureControlData',
10971             Writable => 'undef',
10972             Permanent => 0,
10973             Flags => [ 'Binary', 'Protected' ],
10974             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControlUnknown' },
10975             },
10976             ],
10977             0x2000024 => {
10978             Name => 'WorldTime',
10979             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::WorldTime' },
10980             },
10981             0x2000025 => { #34
10982             Name => 'ISOInfo',
10983             SubDirectory => {
10984             TagTable => 'Image::ExifTool::Nikon::ISOInfo',
10985             ByteOrder => 'BigEndian', # (BigEndian even for D810, which is a little-endian camera)
10986             },
10987             },
10988             0x200002a => { #23 (this tag added with D3 firmware 1.10 -- also written by Nikon utilities)
10989             Name => 'VignetteControl',
10990             Writable => 'int16u',
10991             PrintConv => {
10992             0 => 'Off',
10993             1 => 'Low',
10994             3 => 'Normal',
10995             5 => 'High',
10996             },
10997             },
10998             0x200002c => {
10999             Name => 'UnknownInfo',
11000             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::UnknownInfo' },
11001             },
11002             # 0x200002d - int16u[3]: "512 0 0"
11003             0x2000032 => {
11004             Name => 'UnknownInfo2',
11005             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::UnknownInfo2' },
11006             },
11007             0x2000039 => {
11008             Name => 'LocationInfo',
11009             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LocationInfo' },
11010             },
11011             0x200003f => 'WhiteBalanceFineTune',
11012             # 0x200003f - rational64s[2]: "0 0"
11013             # 0x2000042 - undef[6]: "0100\x03\0"
11014             # 0x2000043 - undef[12]: all zeros
11015             0x200004e => {
11016             Name => 'NikonSettings',
11017             SubDirectory => { TagTable => 'Image::ExifTool::NikonSettings::Main' },
11018             },
11019             0x2000083 => {
11020             Name => 'LensType',
11021             # credit to Tom Christiansen (ref 7) for figuring this out...
11022             PrintConv => q[$_ = $val ? Image::ExifTool::DecodeBits($val,
11023             {
11024             0 => 'MF',
11025             1 => 'D',
11026             2 => 'G',
11027             3 => 'VR',
11028             4 => '1', #PH
11029             # bit 5 set for FT-1 adapter? - PH
11030             6 => 'E', #PH (electromagnetic aperture mechanism)
11031             # bit 7 set for AF-P lenses? - PH
11032             }) : 'AF';
11033             # remove commas and change "D G" to just "G"
11034             s/,//g; s/\bD G\b/G/;
11035             s/ E\b// and s/^(G )?/E /; # put "E" at the start instead of "G"
11036             s/ 1// and $_ = "1 $_"; # put "1" at start
11037             return $_;
11038             ],
11039             },
11040             0x2000084 => {
11041             Name => "Lens",
11042             # short focal, long focal, aperture at short focal, aperture at long focal
11043             PrintConv => \&Image::ExifTool::Exif::PrintLensInfo,
11044             },
11045             0x2000087 => {
11046             Name => 'FlashMode',
11047             Writable => 'int8u',
11048             PrintConv => {
11049             0 => 'Did Not Fire',
11050             1 => 'Fired, Manual', #14
11051             3 => 'Not Ready', #28
11052             7 => 'Fired, External', #14
11053             8 => 'Fired, Commander Mode',
11054             9 => 'Fired, TTL Mode',
11055             18 => 'LED Light', #G.F. (movie LED light)
11056             },
11057             },
11058             0x2000098 => [
11059             { #8
11060             Condition => '$$valPt =~ /^0100/', # D100, D1X - PH
11061             Name => 'LensData0100',
11062             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LensData00' },
11063             },
11064             { #8
11065             Condition => '$$valPt =~ /^0101/', # D70, D70s - PH
11066             Name => 'LensData0101',
11067             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LensData01' },
11068             },
11069             # note: this information is encrypted if the version is 02xx
11070             { #8
11071             # 0201 - D200, D2Hs, D2X and D2Xs
11072             # 0202 - D40, D40X and D80
11073             # 0203 - D300
11074             Condition => '$$valPt =~ /^020[1-3]/',
11075             Name => 'LensData0201',
11076             SubDirectory => {
11077             TagTable => 'Image::ExifTool::Nikon::LensData01',
11078             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
11079             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
11080             DecryptStart => 4,
11081             },
11082             },
11083             { #PH
11084             Condition => '$$valPt =~ /^0204/', # D90, D7000
11085             Name => 'LensData0204',
11086             SubDirectory => {
11087             TagTable => 'Image::ExifTool::Nikon::LensData0204',
11088             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
11089             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
11090             DecryptStart => 4,
11091             },
11092             },
11093             {
11094             Condition => '$$valPt =~ /^040[01]/', # 0=1J1/1V1, 1=1J2
11095             Name => 'LensData0400',
11096             SubDirectory => {
11097             TagTable => 'Image::ExifTool::Nikon::LensData0400',
11098             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
11099             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
11100             DecryptStart => 4,
11101             },
11102             },
11103             {
11104             Condition => '$$valPt =~ /^0402/', # 1J3/1S1/1V2
11105             Name => 'LensData0402',
11106             SubDirectory => {
11107             TagTable => 'Image::ExifTool::Nikon::LensData0402',
11108             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
11109             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
11110             DecryptStart => 4,
11111             },
11112             },
11113             {
11114             Condition => '$$valPt =~ /^0403/', # 1J4,1J5
11115             Name => 'LensData0403',
11116             SubDirectory => {
11117             TagTable => 'Image::ExifTool::Nikon::LensData0403',
11118             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
11119             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
11120             DecryptStart => 4,
11121             },
11122             },
11123             {
11124             Condition => '$$valPt =~ /^080[012]/', # Z6/Z7/Z9
11125             Name => 'LensData0800',
11126             SubDirectory => {
11127             TagTable => 'Image::ExifTool::Nikon::LensData0800',
11128             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
11129             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
11130             DecryptStart => 4,
11131             ByteOrder => 'LittleEndian',
11132             # 0x5a0c - NikonMeteringMode for some Z6 ver1.00 samples (ref PH)
11133             },
11134             },
11135             {
11136             Name => 'LensDataUnknown',
11137             SubDirectory => {
11138             TagTable => 'Image::ExifTool::Nikon::LensDataUnknown',
11139             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
11140             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
11141             DecryptStart => 4,
11142             },
11143             },
11144             ],
11145             0x20000a7 => { # Number of shots taken by camera so far (ref 2)
11146             Name => 'ShutterCount',
11147             PrintConv => '$val == 4294965247 ? "n/a" : $val',
11148             },
11149             0x20000a8 => [
11150             {
11151             Name => 'FlashInfo0100',
11152             Condition => '$$valPt =~ /^010[01]/',
11153             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0100' },
11154             },
11155             {
11156             Name => 'FlashInfo0102',
11157             Condition => '$$valPt =~ /^0102/',
11158             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0102' },
11159             },
11160             {
11161             Name => 'FlashInfo0103',
11162             # (0104 for D7000, 0105 for D800)
11163             Condition => '$$valPt =~ /^010[345]/',
11164             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0103' },
11165             },
11166             {
11167             Name => 'FlashInfo0106', # (0106 for D7100)
11168             Condition => '$$valPt =~ /^0106/',
11169             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0106' },
11170             },
11171             {
11172             Name => 'FlashInfo0107', # (0107 for D4S/D750/D810/D5500/D7200, 0108 for D5/D500/D3400)
11173             Condition => '$$valPt =~ /^010[78]/',
11174             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0107' },
11175             },
11176             {
11177             Name => 'FlashInfoUnknown',
11178             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfoUnknown' },
11179             },
11180             ],
11181             0x20000ab => { Name => 'VariProgram', Writable => 'string' }, #2 (scene mode for DSLR's - PH)
11182             0x20000b1 => { #34
11183             Name => 'HighISONoiseReduction',
11184             Writable => 'int16u',
11185             PrintConv => {
11186             0 => 'Off',
11187             1 => 'Minimal', # for high ISO (>800) when setting is "Off"
11188             2 => 'Low', # Low,Normal,High take effect for ISO > 400
11189             3 => 'Medium Low',
11190             4 => 'Normal',
11191             5 => 'Medium High',
11192             6 => 'High',
11193             },
11194             },
11195             0x20000b7 => {
11196             Name => 'AFInfo2',
11197             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2' },
11198             },
11199             # 0x20000c0 - undef[8]
11200             0x20000c3 => {
11201             Name => 'BarometerInfo',
11202             SubDirectory => {
11203             TagTable => 'Image::ExifTool::Nikon::BarometerInfo',
11204             # (little-endian in II EXIF, big-endian in MOV)
11205             },
11206             },
11207             );
11208              
11209             # Nikon XMP tags written in NKSC metadata
11210             %Image::ExifTool::Nikon::ast = (
11211             GROUPS => { 0 => 'XMP', 1 => 'XMP-ast', 2 => 'Image' },
11212             PROCESS_PROC => \&Image::ExifTool::XMP::ProcessXMP,
11213             NAMESPACE => 'ast',
11214             VARS => { NO_ID => 1 },
11215             NOTES => 'Tags used by Nikon NX Studio in Nikon NKSC sidecar files and trailers.',
11216             about => { },
11217             version => { },
11218             XMLPackets => {
11219             SubDirectory => { TagTable => 'Image::ExifTool::XMP::Main' },
11220             Encoding => 'Base64',
11221             Binary => 1,
11222             },
11223             IPTC => {
11224             SubDirectory => { TagTable => 'Image::ExifTool::IPTC::Main' },
11225             Encoding => 'Base64',
11226             Binary => 1,
11227             },
11228             GPSVersionID => { Groups => { 2 => 'Location' }, %base64bytes },
11229             GPSLatitudeRef => {
11230             Groups => { 2 => 'Location' },
11231             %base64int32u,
11232             PrintConv => { 0 => 'North', 1 => 'South' }, #PH (NC)
11233             },
11234             GPSLatitude => { Groups => { 2 => 'Location' }, %base64coord },
11235             GPSLongitudeRef => {
11236             Groups => { 2 => 'Location' },
11237             %base64int32u,
11238             PrintConv => { 2 => 'East', 3 => 'West' }, #PH (NC)
11239             },
11240             GPSLongitude => { Groups => { 2 => 'Location' }, %base64coord },
11241             GPSAltitudeRef => {
11242             Groups => { 2 => 'Location' },
11243             %base64bytes,
11244             PrintConv => {
11245             0 => 'Above Sea Level',
11246             1 => 'Below Sea Level',
11247             },
11248             },
11249             GPSAltitude => {
11250             Groups => { 2 => 'Location' },
11251             %base64double,
11252             PrintConv => '"$val m"',
11253             },
11254             GPSMapDatum => { Groups => { 2 => 'Location' } },
11255             GPSImgDirection => {
11256             Groups => { 2 => 'Location' },
11257             %base64double,
11258             PrintConv => 'sprintf("%.2f", $val)',
11259             },
11260             GPSImgDirectionRef => {
11261             Groups => { 2 => 'Location' },
11262             PrintConv => {
11263             M => 'Magnetic North',
11264             T => 'True North',
11265             },
11266             },
11267             );
11268             %Image::ExifTool::Nikon::sdc = (
11269             GROUPS => { 0 => 'XMP', 1 => 'XMP-sdc', 2 => 'Image' },
11270             PROCESS_PROC => \&Image::ExifTool::XMP::ProcessXMP,
11271             NAMESPACE => 'sdc',
11272             VARS => { NO_ID => 1 },
11273             about => { },
11274             version => { },
11275             appversion => { Name => 'AppVersion' },
11276             appname => { Name => 'AppName' },
11277             );
11278             %Image::ExifTool::Nikon::nine = (
11279             GROUPS => { 0 => 'XMP', 1 => 'XMP-nine', 2 => 'Image' },
11280             PROCESS_PROC => \&Image::ExifTool::XMP::ProcessXMP,
11281             NAMESPACE => 'nine',
11282             VARS => { NO_ID => 1 },
11283             about => { },
11284             version => { },
11285             Label => { },
11286             Rating => { },
11287             Trim => { %base64bin },
11288             NineEdits => {
11289             SubDirectory => {
11290             TagTable => 'Image::ExifTool::Nikon::NineEdits',
11291             IgnoreProp => { userData => 1 }, # remove "UserData" from already overly long tag names
11292             },
11293             Binary => 1,
11294             },
11295             );
11296             %Image::ExifTool::Nikon::NineEdits = (
11297             GROUPS => { 0 => 'XML', 1 => 'NineEdits', 2 => 'Image' },
11298             PROCESS_PROC => \&Image::ExifTool::XMP::ProcessXMP,
11299             VARS => { NO_ID => 1 },
11300             NOTES => 'XML-based tags used to store editing information.',
11301             filterParametersBinary => { %base64bin },
11302             filterParametersExportExportData => { %base64bin },
11303             filterParametersCustomCustomData => { %base64bin },
11304             );
11305              
11306             # Nikon composite tags
11307             %Image::ExifTool::Nikon::Composite = (
11308             GROUPS => { 2 => 'Camera' },
11309             LensSpec => {
11310             Require => {
11311             0 => 'Nikon:Lens',
11312             1 => 'Nikon:LensType',
11313             },
11314             ValueConv => '"$val[0] $val[1]"',
11315             PrintConv => '"$prt[0] $prt[1]"',
11316             },
11317             LensID => {
11318             SeparateTable => 'Nikon LensID', # print values in a separate table
11319             Require => {
11320             0 => 'Nikon:LensIDNumber',
11321             1 => 'LensFStops',
11322             2 => 'MinFocalLength',
11323             3 => 'MaxFocalLength',
11324             4 => 'MaxApertureAtMinFocal',
11325             5 => 'MaxApertureAtMaxFocal',
11326             6 => 'MCUVersion',
11327             7 => 'Nikon:LensType',
11328             },
11329             # construct lens ID string as per ref 11
11330             ValueConv => 'sprintf("%.2X"." %.2X"x7, @raw)',
11331             PrintConv => \%nikonLensIDs,
11332             },
11333             AutoFocus => {
11334             Require => {
11335             0 => 'Nikon:PhaseDetectAF',
11336             1 => 'Nikon:ContrastDetectAF',
11337             },
11338             ValueConv => '($val[0] or $val[1]) ? 1 : 0',
11339             PrintConv => \%offOn,
11340             },
11341             );
11342              
11343             # add our composite tags
11344             Image::ExifTool::AddCompositeTags('Image::ExifTool::Nikon');
11345              
11346             #------------------------------------------------------------------------------
11347             # Process Nikon AVI tags (D5000 videos)
11348             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
11349             # Returns: 1 on success
11350             sub ProcessNikonAVI($$$)
11351             {
11352 0     0 0 0 my ($et, $dirInfo, $tagTablePtr) = @_;
11353 0         0 my $dataPt = $$dirInfo{DataPt};
11354 0   0     0 my $pos = $$dirInfo{DirStart} || 0;
11355 0         0 my $dirEnd = $pos + $$dirInfo{DirLen};
11356 0         0 $et->VerboseDir($dirInfo, undef, $$dirInfo{DirLen});
11357 0         0 SetByteOrder('II');
11358 0         0 while ($pos + 4 <= $dirEnd) {
11359 0         0 my $tag = Get16u($dataPt, $pos);
11360 0         0 my $size = Get16u($dataPt, $pos + 2);
11361 0         0 $pos += 4;
11362 0 0       0 last if $pos + $size > $dirEnd;
11363 0         0 $et->HandleTag($tagTablePtr, $tag, undef,
11364             DataPt => $dataPt,
11365             Start => $pos,
11366             Size => $size,
11367             );
11368 0         0 $pos += $size;
11369             }
11370 0         0 return 1;
11371             }
11372              
11373             #------------------------------------------------------------------------------
11374             # Print conversion for Nikon AF points
11375             # Inputs: 0) value to convert (as a string of hex bytes),
11376             # 1) lookup for AF point bit number (starting at 1)
11377             sub PrintAFPoints($$)
11378             {
11379 0     0 0 0 my ($val, $afPoints) = @_;
11380 0         0 my ($i, $j, @points);
11381 0         0 $val =~ tr/ //d; # remove spaces from hex string
11382 0         0 my @dat = unpack 'C*', pack 'H*', $val; # convert to array of bytes
11383             # loop through all bytes to find active AF points
11384 0         0 for ($i=0; $i<=@dat; ++$i) {
11385 0 0       0 next unless $dat[$i];
11386 0         0 for ($j=0; $j<8; ++$j) {
11387 0 0       0 next unless $dat[$i] & (1 << $j);
11388 0         0 my $point = $$afPoints{$i*8 + $j + 1};
11389 0 0       0 push @points, $point if defined $point;
11390             }
11391             }
11392 0 0       0 return '(none)' unless @points;
11393             # sort the points and return as comma-separated string
11394             return join ',', sort {
11395 0 0       0 return $a cmp $b if length($a) == length($b);
  0         0  
11396 0 0       0 return substr($a,0,1).'0'.substr($a,1,1) cmp $b if length($a) == 2;
11397 0         0 return $a cmp substr($b,0,1).'0'.substr($b,1,1);
11398             } @points;
11399             }
11400              
11401             #------------------------------------------------------------------------------
11402             # Inverse print conversion for AF points
11403             # Inputs: 0) AF point string, 1) AF point lookup
11404             # Returns: AF point data as a string of hex bytes
11405             sub PrintAFPointsInv($$)
11406             {
11407 8     8 0 31 my ($val, $afPoints) = @_;
11408 8         55 my @points = ($val =~ /[A-Za-z]\d+/g);
11409 8         47 my $size = int((scalar(keys %$afPoints) + 7) / 8);
11410 8         54 my @dat = (0) x $size;
11411 8 50       40 if (@points) {
11412 0         0 my (%bitNum, $point);
11413 0         0 $bitNum{$$afPoints{$_}} = $_ foreach keys %$afPoints; # build reverse lookup
11414 0         0 foreach $point (@points) {
11415 0 0       0 my $bitNum = $bitNum{uc $point} or next;
11416 0         0 my $byte = int(($bitNum - 1) / 8);
11417 0         0 $dat[$byte] |= (1 << (($bitNum - 1) % 8));
11418             }
11419             }
11420 8         190 return join(" ", unpack("H2"x$size, pack('C*', @dat)));
11421             }
11422              
11423             #------------------------------------------------------------------------------
11424             # Get AF point name for grid-type AF
11425             # Inputs: 0) AF point number, 1) number of columns, 2) true for inverse conversion
11426             # Returns: AF point name, or undef
11427             sub GetAFPointGrid($$;$)
11428             {
11429 0     0 0 0 my ($val, $ncol, $inv) = @_;
11430 0 0       0 if ($inv) {
11431 0 0       0 return undef unless $val =~ /^([A-J])(\d+)$/i;
11432 0         0 return (ord(uc($1))-65) * $ncol + $2 - 1;
11433             } else {
11434 0         0 my $row = int(($val + 0.5) / $ncol) & 0xff;
11435 0         0 my $col = $val - $ncol * $row + 1;
11436 0         0 return chr(65+$row) . $col;
11437             }
11438             }
11439              
11440             #------------------------------------------------------------------------------
11441             # Print conversion for grid-type AF points
11442             # Inputs: 0) value to convert (as a string of hex bytes),
11443             # 1) number of columns in grid
11444             sub PrintAFPointsGrid($$)
11445             {
11446 0     0 0 0 my ($val, $ncol) = @_;
11447 0         0 my ($i, $j, @points);
11448 0         0 $val =~ tr/ //d; # remove spaces from hex string
11449 0         0 my @dat = unpack 'C*', pack 'H*', $val; # convert to array of bytes
11450             # loop through all bytes to find active AF points
11451 0         0 for ($i=0; $i<@dat; ++$i) {
11452 0 0       0 next unless $dat[$i];
11453 0         0 for ($j=0; $j<8; ++$j) {
11454 0 0       0 next unless $dat[$i] & (1 << $j);
11455 0         0 my $point = GetAFPointGrid($i*8 + $j, $ncol);
11456 0 0       0 push @points, $point if defined $point;
11457             }
11458             }
11459 0 0       0 return '(none)' unless @points;
11460 0         0 return join ',', @points; # return as comma-separated string
11461             }
11462              
11463             #------------------------------------------------------------------------------
11464             # Inverse print conversion for AF points
11465             # Inputs: 0) AF point string, 1) number of columns, 2) size of data
11466             # Returns: AF point data as a string of hex bytes
11467             sub PrintAFPointsGridInv($$$)
11468             {
11469 0     0 0 0 my ($val, $ncol, $size) = @_;
11470 0         0 my @points = ($val =~ /[A-Za-z]\d+/g);
11471 0         0 my @dat = (0) x $size;
11472 0         0 foreach (@points) {
11473 0         0 my $n = GetAFPointGrid($_, $ncol, 1);
11474 0 0       0 next unless defined $n;
11475 0         0 my $byte = int($n / 8);
11476 0 0       0 next if $byte > $size;
11477 0         0 $dat[$byte] |= (1 << ($n - $byte * 8));
11478             }
11479 0         0 return join(" ", unpack("H2"x$size, pack('C*', @dat)));
11480             }
11481              
11482             #------------------------------------------------------------------------------
11483             # Print conversion for relative Left/Right AF points (ref 28)
11484             # Inputs: 0) column, 1) number of columns
11485             # Returns: AF point data as a string (e.g. '2L of Center' or 'C' or '3R of Center')
11486             sub PrintAFPointsLeftRight($$)
11487             {
11488 0     0 0 0 my ($col, $ncol) = @_;
11489 0         0 my $center = 1 + ($ncol + 1)/2;
11490 0 0       0 return 'C' if $col == $center;
11491 0 0       0 return sprintf('%d', $center - $col) . 'L of Center' if $col < $center;
11492 0 0       0 return sprintf('%d', $col - $center) . 'R of Center' if $col > $center;
11493             }
11494              
11495             #------------------------------------------------------------------------------
11496             # Print conversion for relative Up/Down AF points (ref 28)
11497             # Inputs: 0) row, 1) number of rows
11498             # Returns: AF point data as a string (e.g. '2U from Center' or 'C' or '3D from Center')
11499             sub PrintAFPointsUpDown($$)
11500             {
11501 0     0 0 0 my ($row, $nrow) = @_;
11502 0         0 my $center = 1 + ($nrow + 1)/2;
11503 0 0       0 return 'C' if $row == $center;
11504 0 0       0 return sprintf('%d', $center - $row) . 'U from Center' if $row < $center;
11505 0 0       0 return sprintf('%d', $row - $center) . 'D from Center' if $row > $center;
11506             }
11507              
11508             #------------------------------------------------------------------------------
11509             # Print PictureControl value
11510             # Inputs: 0) value (with 0x80 subtracted),
11511             # 1) 'Normal' (0 value) string (default 'Normal')
11512             # 2) format string for numbers (default '%+d'), 3) v2 divisor
11513             # Returns: PrintConv value
11514             sub PrintPC($;$$$)
11515             {
11516 0     0 0 0 my ($val, $norm, $fmt, $div) = @_;
11517 0 0 0     0 return $norm || 'Normal' if $val == 0;
11518 0 0       0 return 'n/a' if $val == 0x7f;
11519 0 0       0 return 'Auto' if $val == -128;
11520             # -127 = custom curve created in Camera Control Pro (show as "User" by D3) - ref 28
11521 0 0       0 return 'User' if $val == -127; #28
11522 0   0     0 return sprintf($fmt || '%+d', $val / ($div || 1));
      0        
11523             }
11524              
11525             #------------------------------------------------------------------------------
11526             # Inverse of PrintPC
11527             # Inputs: 0) PrintConv value (after subracting 0x80 from raw value), 1) v2 divisor
11528             # Returns: unconverted value
11529             # Notes: raw values: 0=Auto, 1=User, 0xff=n/a, ... 0x7f=-1, 0x80=0, 0x81=1, ...
11530             sub PrintPCInv($;$)
11531             {
11532 114     114 0 379 my ($val, $div) = @_;
11533 114 100 100     5040 return $val * ($div || 1) if $val =~ /^[-+]?\d+(\.\d+)?$/;
11534 114 50       196 return 0x7f if $val =~ /n\/a/i;
11535 114 100       183 return -128 if $val =~ /auto/i;
11536 111 50       141 return -127 if $val =~ /user/i; #28
11537 111         481 return 0;
11538             }
11539              
11540             #------------------------------------------------------------------------------
11541             # Convert unknown LensID values
11542             # Inputs: 0) value, 1) flag for inverse conversion, 2) PrintConv hash ref
11543             sub LensIDConv($$$)
11544             {
11545 0     0 0 0 my ($val, $inv, $conv) = @_;
11546 0 0       0 return undef if $inv;
11547             # multiple lenses with the same LensID are distinguished by decimal values
11548 0 0       0 if ($$conv{"$val.1"}) {
11549 0         0 my ($i, @vals, @user);
11550 0         0 for ($i=1; ; ++$i) {
11551 0 0       0 my $lens = $$conv{"$val.$i"} or last;
11552 0 0       0 if ($Image::ExifTool::userLens{$lens}) {
11553 0         0 push @user, $lens;
11554             } else {
11555 0         0 push @vals, $lens;
11556             }
11557             }
11558 0 0       0 return join(' or ', @user) if @user;
11559 0         0 return join(' or ', @vals);
11560             }
11561             # Sigma has been changing the LensIDNumber on some new lenses
11562             # and with some Sigma lenses the LensFStops changes! (argh!)
11563             # Also, older cameras my not set bits 4-7 of LensType
11564 0         0 my $pat = $val;
11565 0         0 $pat =~ s/^\w+ \w+/.. ../; # ignore LensIDNumber and LensFStops
11566 0         0 $pat =~ s/\w(\w)$/.$1/; # ignore bits 4-7 of LensType
11567 0         0 my @ids = sort grep /^$pat$/, keys %$conv;
11568 0 0       0 if (@ids) {
11569             # first try different LensFStops (2nd value)
11570 0         0 ($pat = $val) =~ s/ \w+/ ../;
11571 0         0 my @good = grep /^$pat$/, @ids;
11572 0 0       0 return $$conv{$good[0]} if @good;
11573             # then try different LensIDNumber (1st value)
11574 0         0 ($pat = $val) =~ s/^\w+/../;
11575 0         0 @good = grep /^$pat$/, @ids;
11576 0 0       0 return "Unknown ($val) $$conv{$good[0]} ?" if @good;
11577             # older cameras may not set bits 4-7 of LensType
11578 0         0 ($pat = $val) =~ s/\w(\w)$/.$1/;
11579 0         0 @good = grep /^$pat$/, @ids;
11580 0 0       0 return "Unknown ($val) $$conv{$good[0]} ?" if @good;
11581             }
11582 0         0 return undef;
11583             }
11584              
11585             #------------------------------------------------------------------------------
11586             # Clean up formatting of string values
11587             # Inputs: 0) string value
11588             # Returns: formatted string value
11589             # - removes trailing spaces and changes case to something more sensible
11590             sub FormatString($)
11591             {
11592 153     153 0 324 my $str = shift;
11593             # limit string length (can be very long for some unknown tags)
11594 153 50       341 if (length($str) > 60) {
11595 0         0 $str = substr($str,0,55) . "[...]";
11596             } else {
11597 153         682 $str =~ s/\s+$//; # remove trailing white space
11598             # Don't change case of non-words (no vowels)
11599 153 100       520 if ($str =~ /[AEIOUY]/) {
11600             # change all letters but the first to lower case,
11601             # but only in words containing a vowel
11602 97 100       631 if ($str =~ s/\b([AEIOUY])([A-Z]+)/$1\L$2/g) {
11603 50         162 $str =~ s/\bAf\b/AF/; # patch for "AF"
11604             # patch for a number of models that write improper string
11605             # terminator for ImageStabilization (VR-OFF, VR-ON)
11606 50         101 $str =~ s/ +.$//s;
11607             }
11608 97 100       679 if ($str =~ s/\b([A-Z])([A-Z]*[AEIOUY][A-Z]*)/$1\L$2/g) {
11609 46         127 $str =~ s/\bRaw\b/RAW/; # patch for "RAW"
11610             }
11611             }
11612             }
11613 153         484 return $str;
11614             }
11615              
11616             #------------------------------------------------------------------------------
11617             # decoding tables from ref 4
11618             my @xlat = (
11619             [ 0xc1,0xbf,0x6d,0x0d,0x59,0xc5,0x13,0x9d,0x83,0x61,0x6b,0x4f,0xc7,0x7f,0x3d,0x3d,
11620             0x53,0x59,0xe3,0xc7,0xe9,0x2f,0x95,0xa7,0x95,0x1f,0xdf,0x7f,0x2b,0x29,0xc7,0x0d,
11621             0xdf,0x07,0xef,0x71,0x89,0x3d,0x13,0x3d,0x3b,0x13,0xfb,0x0d,0x89,0xc1,0x65,0x1f,
11622             0xb3,0x0d,0x6b,0x29,0xe3,0xfb,0xef,0xa3,0x6b,0x47,0x7f,0x95,0x35,0xa7,0x47,0x4f,
11623             0xc7,0xf1,0x59,0x95,0x35,0x11,0x29,0x61,0xf1,0x3d,0xb3,0x2b,0x0d,0x43,0x89,0xc1,
11624             0x9d,0x9d,0x89,0x65,0xf1,0xe9,0xdf,0xbf,0x3d,0x7f,0x53,0x97,0xe5,0xe9,0x95,0x17,
11625             0x1d,0x3d,0x8b,0xfb,0xc7,0xe3,0x67,0xa7,0x07,0xf1,0x71,0xa7,0x53,0xb5,0x29,0x89,
11626             0xe5,0x2b,0xa7,0x17,0x29,0xe9,0x4f,0xc5,0x65,0x6d,0x6b,0xef,0x0d,0x89,0x49,0x2f,
11627             0xb3,0x43,0x53,0x65,0x1d,0x49,0xa3,0x13,0x89,0x59,0xef,0x6b,0xef,0x65,0x1d,0x0b,
11628             0x59,0x13,0xe3,0x4f,0x9d,0xb3,0x29,0x43,0x2b,0x07,0x1d,0x95,0x59,0x59,0x47,0xfb,
11629             0xe5,0xe9,0x61,0x47,0x2f,0x35,0x7f,0x17,0x7f,0xef,0x7f,0x95,0x95,0x71,0xd3,0xa3,
11630             0x0b,0x71,0xa3,0xad,0x0b,0x3b,0xb5,0xfb,0xa3,0xbf,0x4f,0x83,0x1d,0xad,0xe9,0x2f,
11631             0x71,0x65,0xa3,0xe5,0x07,0x35,0x3d,0x0d,0xb5,0xe9,0xe5,0x47,0x3b,0x9d,0xef,0x35,
11632             0xa3,0xbf,0xb3,0xdf,0x53,0xd3,0x97,0x53,0x49,0x71,0x07,0x35,0x61,0x71,0x2f,0x43,
11633             0x2f,0x11,0xdf,0x17,0x97,0xfb,0x95,0x3b,0x7f,0x6b,0xd3,0x25,0xbf,0xad,0xc7,0xc5,
11634             0xc5,0xb5,0x8b,0xef,0x2f,0xd3,0x07,0x6b,0x25,0x49,0x95,0x25,0x49,0x6d,0x71,0xc7 ],
11635             [ 0xa7,0xbc,0xc9,0xad,0x91,0xdf,0x85,0xe5,0xd4,0x78,0xd5,0x17,0x46,0x7c,0x29,0x4c,
11636             0x4d,0x03,0xe9,0x25,0x68,0x11,0x86,0xb3,0xbd,0xf7,0x6f,0x61,0x22,0xa2,0x26,0x34,
11637             0x2a,0xbe,0x1e,0x46,0x14,0x68,0x9d,0x44,0x18,0xc2,0x40,0xf4,0x7e,0x5f,0x1b,0xad,
11638             0x0b,0x94,0xb6,0x67,0xb4,0x0b,0xe1,0xea,0x95,0x9c,0x66,0xdc,0xe7,0x5d,0x6c,0x05,
11639             0xda,0xd5,0xdf,0x7a,0xef,0xf6,0xdb,0x1f,0x82,0x4c,0xc0,0x68,0x47,0xa1,0xbd,0xee,
11640             0x39,0x50,0x56,0x4a,0xdd,0xdf,0xa5,0xf8,0xc6,0xda,0xca,0x90,0xca,0x01,0x42,0x9d,
11641             0x8b,0x0c,0x73,0x43,0x75,0x05,0x94,0xde,0x24,0xb3,0x80,0x34,0xe5,0x2c,0xdc,0x9b,
11642             0x3f,0xca,0x33,0x45,0xd0,0xdb,0x5f,0xf5,0x52,0xc3,0x21,0xda,0xe2,0x22,0x72,0x6b,
11643             0x3e,0xd0,0x5b,0xa8,0x87,0x8c,0x06,0x5d,0x0f,0xdd,0x09,0x19,0x93,0xd0,0xb9,0xfc,
11644             0x8b,0x0f,0x84,0x60,0x33,0x1c,0x9b,0x45,0xf1,0xf0,0xa3,0x94,0x3a,0x12,0x77,0x33,
11645             0x4d,0x44,0x78,0x28,0x3c,0x9e,0xfd,0x65,0x57,0x16,0x94,0x6b,0xfb,0x59,0xd0,0xc8,
11646             0x22,0x36,0xdb,0xd2,0x63,0x98,0x43,0xa1,0x04,0x87,0x86,0xf7,0xa6,0x26,0xbb,0xd6,
11647             0x59,0x4d,0xbf,0x6a,0x2e,0xaa,0x2b,0xef,0xe6,0x78,0xb6,0x4e,0xe0,0x2f,0xdc,0x7c,
11648             0xbe,0x57,0x19,0x32,0x7e,0x2a,0xd0,0xb8,0xba,0x29,0x00,0x3c,0x52,0x7d,0xa8,0x49,
11649             0x3b,0x2d,0xeb,0x25,0x49,0xfa,0xa3,0xaa,0x39,0xa7,0xc5,0xa7,0x50,0x11,0x36,0xfb,
11650             0xc6,0x67,0x4a,0xf5,0xa5,0x12,0x65,0x7e,0xb0,0xdf,0xaf,0x4e,0xb3,0x61,0x7f,0x2f ]
11651             );
11652              
11653             # Decrypt Nikon data block (ref 4)
11654             # Inputs: 0) reference to data block, 1) serial number key, 2) shutter count key
11655             # 4) optional start offset (default 0)
11656             # 5) optional number of bytes to decode (default to the end of the data)
11657             # Returns: data block with specified data decrypted
11658             sub Decrypt($$$;$$)
11659             {
11660 4     4 0 24 my ($dataPt, $serial, $count, $start, $len) = @_;
11661 4         10 my ($i, $dat);
11662              
11663 4 100       14 $start or $start = 0;
11664 4         10 my $maxLen = length($$dataPt) - $start;
11665 4 100 66     23 $len = $maxLen if not defined $len or $len > $maxLen;
11666 4 50       15 return $$dataPt if $len <= 0;
11667 4         9 my $key = 0;
11668 4         13 for ($i=0; $i<4; ++$i) {
11669 16         40 $key ^= ($count >> ($i*8)) & 0xff;
11670             }
11671 4         17 my $ci = $xlat[0][$serial & 0xff];
11672 4         11 my $cj = $xlat[1][$key];
11673 4         7 my $ck = 0x60;
11674 4         98 my @data = unpack("x${start}C$len", $$dataPt);
11675 4         17 foreach $dat (@data) {
11676 638         834 $cj = ($cj + $ci * $ck) & 0xff;
11677 638         856 $ck = ($ck + 1) & 0xff;
11678 638         906 $dat ^= $cj;
11679             }
11680 4         11 my $end = $start + $len;
11681 4 100       19 my $pre = $start ? substr($$dataPt, 0, $start) : '';
11682 4 100       19 my $post = $end < length($$dataPt) ? substr($$dataPt, $end) : '';
11683 4         52 return $pre . pack('C*',@data) . $post;
11684             }
11685              
11686             #------------------------------------------------------------------------------
11687             # Get serial number for use as a decryption key
11688             # Inputs: 0) ExifTool object ref, 1) serial number string
11689             # Returns: serial key integer or undef if no serial number provided
11690             sub SerialKey($$)
11691             {
11692 26     26 0 77 my ($et, $serial) = @_;
11693             # use serial number as key if integral
11694 26 50 66     280 return $serial if not defined $serial or $serial =~ /^\d+$/;
11695 0 0       0 return 0x22 if $$et{Model} =~ /\bD50$/; # D50 (ref 8)
11696 0         0 return 0x60; # D200 (ref 10), D40X (ref PH), etc
11697             }
11698              
11699             #------------------------------------------------------------------------------
11700             # Extract information from "NIKON APP" trailer (ref PH)
11701             # Inputs: 0) ExifTool ref, 1) Optional dirInfo ref for returning trailer info
11702             # Returns: true on success
11703             sub ProcessNikonApp($;$)
11704             {
11705 0     0 0 0 local $_;
11706 0         0 my ($et, $dirInfo) = @_;
11707 0         0 my $raf = $$et{RAF};
11708 0 0 0     0 my $offset = $dirInfo ? $$dirInfo{Offset} || 0 : 0;
11709 0         0 my $buff;
11710              
11711 0 0 0     0 return 0 unless $raf->Seek(-20-$offset, 2) and $raf->Read($buff, 20) == 20 and
      0        
11712             substr($buff,-16) eq "\0\0\0\0\0\0/NIKON APP"; # check magic number
11713              
11714 0         0 my $verbose = $et->Options('Verbose');
11715 0         0 my $fileEnd = $raf->Tell();
11716 0         0 my $trailerLen = unpack('N', $buff);
11717 0 0       0 $trailerLen > $fileEnd and $et->Warn('Bad NikonApp trailer size'), return 0;
11718 0 0       0 if ($dirInfo) {
11719 0 0       0 $$dirInfo{DirLen} = $trailerLen if $dirInfo;
11720 0         0 $$dirInfo{DataPos} = $fileEnd - $trailerLen;
11721 0 0       0 if ($$dirInfo{OutFile}) {
11722 0 0 0     0 if ($$et{DEL_GROUP}{NikonApp}) {
    0 0        
11723 0         0 ++$$et{CHANGED};
11724             # just copy the trailer when writing
11725             } elsif ($trailerLen > $fileEnd or not $raf->Seek($$dirInfo{DataPos}, 0) or
11726 0         0 $raf->Read(${$$dirInfo{OutFile}}, $trailerLen) != $trailerLen)
11727             {
11728 0         0 return 0;
11729             } else {
11730 0         0 return 1;
11731             }
11732             }
11733 0 0 0     0 $et->DumpTrailer($dirInfo) if $verbose or $$et{HTML_DUMP};
11734             }
11735 0 0 0     0 unless ($trailerLen >= 0x40 and $raf->Seek($fileEnd - $trailerLen, 0) and
      0        
      0        
11736             $raf->Read($buff, 0x40) == 0x40 and $buff =~ m(NIKON APP\0))
11737             {
11738 0         0 $et->Warn('Error reading NikonApp trailer');
11739 0         0 return 0;
11740             }
11741 0         0 $$et{SET_GROUP0} = 'NikonApp';
11742 0         0 while ($raf->Read($buff, 8) == 8) {
11743 0         0 my ($id, $len) = unpack('N2', $buff);
11744 0 0       0 if ($len & 0x80000000) {
11745 0         0 $et->Warn('Invalid NikonApp record length');
11746 0         0 last;
11747             }
11748 0 0 0     0 last if $id == 0 and $len == 0;
11749 0 0       0 unless ($raf->Read($buff, $len) == $len) {
11750 0         0 $et->Warn('Truncated NikonApp record');
11751 0         0 last;
11752             }
11753 0 0       0 if ($id == 1) {
11754 0         0 require Image::ExifTool::XMP;
11755 0         0 Image::ExifTool::XMP::ProcessXMP($et, { DataPt => \$buff });
11756             } else { # (haven't seen any other types of records)
11757 0         0 $et->Warn("Unknown NikonApp record $id");
11758 0         0 last;
11759             }
11760             }
11761 0         0 delete $$et{SET_GROUP0};
11762 0         0 return 1;
11763             }
11764              
11765             #------------------------------------------------------------------------------
11766             # Read Nikon NCTG tags in MOV videos
11767             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
11768             # Returns: 1 on success
11769             sub ProcessNikonMOV($$$)
11770             {
11771 0     0 0 0 my ($et, $dirInfo, $tagTablePtr) = @_;
11772 0         0 my $dataPt = $$dirInfo{DataPt};
11773 0         0 my $dataPos = $$dirInfo{DataPos};
11774 0         0 my %needTags = ( 0x110a431 => 0, 0x20000a7 => undef ); # needed for decryption
11775 0         0 $et->VerboseDir($$dirInfo{DirName}, 0, $$dirInfo{DirLen});
11776 0         0 my $pass;
11777             # do two passes so we can pre-scan for necessary decryption keys
11778 0         0 for ($pass=0; $pass<2; ++$pass) {
11779 0         0 my $pos = $$dirInfo{DirStart};
11780 0         0 my $end = $pos + $$dirInfo{DirLen};
11781 0         0 while ($pos + 8 < $end) {
11782 0         0 my $tag = Get32u($dataPt, $pos);
11783 0         0 my $fmt = Get16u($dataPt, $pos + 4); # (same format code as EXIF)
11784 0         0 my $count = Get16u($dataPt, $pos + 6);
11785 0         0 $pos += 8;
11786 0         0 my $fmtStr = $Image::ExifTool::Exif::formatName[$fmt];
11787 0 0       0 unless ($fmtStr) {
11788 0 0       0 $et->Warn(sprintf("Unknown format ($fmt) for $$dirInfo{DirName} tag 0x%x",$tag)) if $pass;
11789 0         0 last;
11790             }
11791 0         0 my $size = $count * $Image::ExifTool::Exif::formatSize[$fmt];
11792 0 0       0 if ($pos + $size > $end) {
11793 0 0       0 $et->Warn(sprintf("Truncated data for $$dirInfo{DirName} tag 0x%x",$tag)) if $pass;
11794 0         0 last;
11795             }
11796 0 0       0 if ($pass) {
    0          
11797 0         0 my $rational;
11798 0         0 my $val = ReadValue($dataPt, $pos, $fmtStr, $count, $size, \$rational);
11799             my $key = $et->HandleTag($tagTablePtr, $tag, $val,
11800             DataPt => $dataPt,
11801             DataPos => $dataPos,
11802             Format => $fmtStr,
11803             Start => $pos,
11804             Size => $size,
11805             Base => $$dirInfo{Base},
11806 0         0 );
11807 0 0 0     0 $$et{RATIONAL}{$key} = $rational if $rational and $key;
11808             } elsif (exists $needTags{$tag}) {
11809 0         0 $needTags{$tag} = ReadValue($dataPt, $pos, $fmtStr, $count, $size);
11810 0         0 $$et{NikonSerialKey} = SerialKey($et, $needTags{0x110a431});
11811 0         0 $$et{NikonCountKey} = $needTags{0x20000a7};
11812             }
11813 0         0 $pos += $size; # is this padded to an even offset????
11814             }
11815             }
11816 0         0 return 1;
11817             }
11818              
11819             #------------------------------------------------------------------------------
11820             # Read/Write Nikon Encrypted data block
11821             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
11822             # Returns: 1 on success when reading, or new directory when writing (IsWriting set)
11823             sub ProcessNikonEncrypted($$$)
11824             {
11825 207     207 0 492 my ($et, $dirInfo, $tagTablePtr) = @_;
11826 207 100       851 $et or return 1; # allow dummy access
11827 3         9 my $serial = $$et{NikonSerialKey};
11828 3         6 my $count = $$et{NikonCountKey};
11829 3 50 33     57 unless (defined $serial and defined $count and $serial =~ /^\d+$/ and $count =~ /^\d+$/) {
      33        
      33        
11830 0 0 0     0 if (defined $serial or defined $count) {
11831 0         0 my $msg;
11832 0 0 0     0 if (defined $serial and defined $count) {
11833 0 0       0 $msg = $serial =~ /^\d+$/ ? 'invalid ShutterCount' : 'invalid SerialNumber';
11834             } else {
11835 0 0       0 $msg = defined $serial ? 'no ShutterCount' : 'no SerialNumber';
11836             }
11837 0         0 $et->Warn("Can't decrypt Nikon information ($msg key)");
11838             }
11839 0         0 delete $$et{NikonSerialKey};
11840 0         0 delete $$et{NikonCountKey};
11841 0         0 return 0;
11842             }
11843 3 50       20 my $verbose = $$dirInfo{IsWriting} ? 0 : $et->Options('Verbose');
11844 3         12 my $tagInfo = $$dirInfo{TagInfo};
11845 3         6 my $dirStart = $$dirInfo{DirStart};
11846 3         6 my $data = substr(${$$dirInfo{DataPt}}, $dirStart, $$dirInfo{DirLen});
  3         12  
11847              
11848 3         10 my ($start, $len, $more, $offset, $byteOrder, $recrypt, $newSerial, $newCount);
11849              
11850             # must re-encrypt when writing if serial number or shutter count changes
11851 3 50       11 if ($$dirInfo{IsWriting}) {
11852 0 0       0 if ($$et{NewNikonSerialKey}) {
11853 0         0 $newSerial = $$et{NewNikonSerialKey};
11854 0         0 $recrypt = 1;
11855             }
11856 0 0       0 if ($$et{NewNikonCountKey}) {
11857 0         0 $newCount = $$et{NewNikonCountKey};
11858 0         0 $recrypt = 1;
11859             }
11860             }
11861 3 50 33     21 if ($tagInfo and $$tagInfo{SubDirectory}) {
11862 3         10 $start = $$tagInfo{SubDirectory}{DecryptStart};
11863             # may decrypt only part of the information to save time
11864 3 50 33     15 if ($verbose < 3 and $et->Options('Unknown') < 2 and not $recrypt) {
      33        
11865 3         11 $len = $$tagInfo{SubDirectory}{DecryptLen};
11866 3         6 $more = $$tagInfo{SubDirectory}{DecryptMore};
11867             }
11868 3         9 $offset = $$tagInfo{SubDirectory}{DirOffset};
11869 3         5 $byteOrder = $$tagInfo{SubDirectory}{ByteOrder};
11870             }
11871 3 50       10 $start or $start = 0;
11872 3 100       15 if (defined $offset) {
11873             # offset, if specified, is relative to start of encrypted data
11874 1         5 $offset += $start;
11875             } else {
11876 2         5 $offset = 0;
11877             }
11878 3         8 my $maxLen = length($data) - $start;
11879             # decrypt all the data unless DecryptLen is given
11880 3 100 66     14 unless ($len and $len < $maxLen) {
11881 1         4 $len = $maxLen;
11882 1         4 undef $more; # (can't decrypt more than this)
11883             }
11884              
11885 3         12 $data = Decrypt(\$data, $serial, $count, $start, $len);
11886              
11887             # set appropriate byte ordering before evaluating DecryptMore
11888 3         13 my $oldOrder = GetByteOrder();
11889 3 100       11 SetByteOrder($byteOrder) if $byteOrder;
11890              
11891 3 50       11 if ($more) {
11892             #### eval DecryptMore ($data)
11893 0         0 my $moreLen = eval $more;
11894 0 0       0 $moreLen = $maxLen if $moreLen > $maxLen;
11895             # re-decrypt with new length
11896 0 0       0 if ($len < $moreLen) {
11897 0         0 $len = $moreLen;
11898 0         0 $data = substr(${$$dirInfo{DataPt}}, $dirStart, $$dirInfo{DirLen});
  0         0  
11899 0         0 $data = Decrypt(\$data, $serial, $count, $start, $len);
11900             }
11901             }
11902 3 50       11 if ($verbose > 2) {
11903 0         0 $et->VerboseDir("Decrypted $$tagInfo{Name}");
11904             $et->VerboseDump(\$data,
11905 0         0 Prefix => $$et{INDENT} . ' ',
11906             # (remove this because it is useful to have decrypted offsets start at 0)
11907             #DataPos => $dirStart + $$dirInfo{DataPos} + ($$dirInfo{Base} || 0),
11908             );
11909             }
11910             # process the decrypted information
11911             my %subdirInfo = (
11912             DataPt => \$data,
11913             DirStart => $offset,
11914             DirLen => length($data) - $offset,
11915             DirName => $$dirInfo{DirName},
11916             DataPos => $$dirInfo{DataPos} + $dirStart,
11917             Base => $$dirInfo{Base},
11918 3         29 );
11919 3         8 my $rtnVal;
11920 3 50       10 if ($$dirInfo{IsWriting}) {
11921 0         0 my $changed = $$et{CHANGED};
11922 0         0 $rtnVal = $et->WriteBinaryData(\%subdirInfo, $tagTablePtr);
11923             # must re-encrypt if serial number or shutter count changes
11924 0 0       0 if ($recrypt) {
11925 0 0       0 $serial = $newSerial if defined $newSerial;
11926 0 0       0 $count = $newCount if defined $newCount;
11927 0         0 ++$$et{CHANGED};
11928             }
11929 0 0       0 if ($changed == $$et{CHANGED}) {
11930 0         0 undef $rtnVal; # nothing changed so use original data
11931             } else {
11932             # add back any un-encrypted data at start
11933 0 0       0 $rtnVal = substr($data, 0, $offset) . $rtnVal if $offset;
11934             # re-encrypt data (symmetrical algorithm)
11935 0         0 $rtnVal = Decrypt(\$rtnVal, $serial, $count, $start, $len);
11936             }
11937             } else {
11938 3         12 $rtnVal = $et->ProcessBinaryData(\%subdirInfo, $tagTablePtr);
11939             }
11940 3         14 SetByteOrder($oldOrder);
11941 3         13 return $rtnVal;
11942             }
11943              
11944             #------------------------------------------------------------------------------
11945             # Pre-scan EXIF directory to extract specific tags
11946             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) required tagID hash ref
11947             # Returns: 1 if directory was scanned successfully
11948             sub PrescanExif($$$)
11949             {
11950 19     19 0 59 my ($et, $dirInfo, $tagHash) = @_;
11951 19         57 my $dataPt = $$dirInfo{DataPt};
11952 19   100     90 my $dataPos = $$dirInfo{DataPos} || 0;
11953 19         49 my $dataLen = $$dirInfo{DataLen};
11954 19   50     66 my $dirStart = $$dirInfo{DirStart} || 0;
11955 19   50     74 my $base = $$dirInfo{Base} || 0;
11956 19         45 my $raf = $$dirInfo{RAF};
11957 19         47 my ($index, $numEntries, $data, $buff);
11958              
11959             # get number of entries in IFD
11960 19 50 33     121 if ($dirStart >= 0 and $dirStart <= $dataLen-2) {
11961 19         70 $numEntries = Get16u($dataPt, $dirStart);
11962             # reset $numEntries to read from file if necessary
11963 19 50       106 undef $numEntries if $dirStart + 2 + 12 * $numEntries > $dataLen;
11964             }
11965             # read IFD from file if necessary
11966 19 50       70 unless ($numEntries) {
11967 0 0       0 $raf or return 0;
11968 0         0 $dataPos += $dirStart; # read data from the start of the directory
11969 0 0 0     0 $raf->Seek($dataPos + $base, 0) and $raf->Read($data, 2) == 2 or return 0;
11970 0         0 $numEntries = Get16u(\$data, 0);
11971 0         0 my $len = 12 * $numEntries;
11972 0 0       0 $raf->Read($buff, $len) == $len or return 0;
11973 0         0 $data .= $buff;
11974             # update variables for the newly loaded IFD (already updated dataPos)
11975 0         0 $dataPt = \$data;
11976 0         0 $dataLen = length $data;
11977 0         0 $dirStart = 0;
11978             }
11979             # loop through Nikon MakerNote IFD entries
11980 19         96 for ($index=0; $index<$numEntries; ++$index) {
11981 507         756 my $entry = $dirStart + 2 + 12 * $index;
11982 507         976 my $tagID = Get16u($dataPt, $entry);
11983 507 100       1422 next unless exists $$tagHash{$tagID}; # only extract required tags
11984 8         29 my $format = Get16u($dataPt, $entry+2);
11985 8 50 33     56 next if $format < 1 or $format > 13;
11986 8         31 my $count = Get32u($dataPt, $entry+4);
11987 8         28 my $size = $count * $Image::ExifTool::Exif::formatSize[$format];
11988 8         22 my $formatStr = $Image::ExifTool::Exif::formatName[$format];
11989 8         22 my $valuePtr = $entry + 8; # pointer to value within $$dataPt
11990 8 100       33 if ($size > 4) {
11991 1 50       5 next if $size > 0x1000000; # set a reasonable limit on data size (16MB)
11992 1         4 $valuePtr = Get32u($dataPt, $valuePtr);
11993             # convert offset to pointer in $$dataPt
11994             # (don't yet handle EntryBased or FixOffsets)
11995 1         4 $valuePtr -= $dataPos;
11996 1 50 33     9 if ($valuePtr < 0 or $valuePtr+$size > $dataLen) {
11997 0 0 0     0 next unless $raf and $raf->Seek($base + $valuePtr + $dataPos,0) and
      0        
11998             $raf->Read($buff,$size) == $size;
11999 0         0 $$tagHash{$tagID} = ReadValue(\$buff,0,$formatStr,$count,$size);
12000 0         0 next;
12001             }
12002             }
12003 8         41 $$tagHash{$tagID} = ReadValue($dataPt,$valuePtr,$formatStr,$count,$size);
12004             }
12005 19         57 return 1;
12006             }
12007              
12008             #------------------------------------------------------------------------------
12009             # Process Nikon Capture history data
12010             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
12011             # Returns: 1 on success
12012             sub ProcessNikonCaptureEditVersions($$$)
12013             {
12014 0     0 0 0 my ($et, $dirInfo, $tagTablePtr) = @_;
12015 0         0 require Image::ExifTool::NikonCapture;
12016 0         0 return Image::ExifTool::NikonCapture::ProcessNikonCaptureEditVersions($et, $dirInfo, $tagTablePtr);
12017             }
12018              
12019             #------------------------------------------------------------------------------
12020             # Process Nikon Capture Offsets IFD (ref PH)
12021             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
12022             # Returns: 1 on success
12023             # Notes: This isn't a normal IFD, but is close...
12024             sub ProcessNikonCaptureOffsets($$$)
12025             {
12026 2     2 0 8 my ($et, $dirInfo, $tagTablePtr) = @_;
12027 2         7 my $dataPt = $$dirInfo{DataPt};
12028 2         6 my $dirStart = $$dirInfo{DirStart};
12029 2         6 my $dirLen = $$dirInfo{DirLen};
12030 2         6 my $success = 0;
12031 2 50       10 return 0 unless $dirLen > 2;
12032 2         9 my $count = Get16u($dataPt, $dirStart);
12033 2 50 33     23 return 0 unless $count and $count * 12 + 2 <= $dirLen;
12034 2 50       10 if ($et->Options('Verbose')) {
12035 0         0 $et->VerboseDir('NikonCaptureOffsets', $count);
12036             }
12037 2         8 my $index;
12038 2         16 for ($index=0; $index<$count; ++$index) {
12039 6         15 my $pos = $dirStart + 12 * $index + 2;
12040 6         17 my $tagID = Get32u($dataPt, $pos);
12041 6         21 my $value = Get32u($dataPt, $pos + 4);
12042 6 50       23 $et->HandleTag($tagTablePtr, $tagID, $value,
12043             Index => $index,
12044             DataPt => $dataPt,
12045             Start => $pos,
12046             Size => 12,
12047             ) and $success = 1;
12048             }
12049 2         8 return $success;
12050             }
12051              
12052             #------------------------------------------------------------------------------
12053             # Read/write Nikon MakerNotes directory
12054             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
12055             # Returns: 1 on success, otherwise returns 0 and sets a Warning when reading
12056             # or new directory when writing (IsWriting set in dirInfo)
12057             sub ProcessNikon($$$)
12058             {
12059 318     318 0 926 my ($et, $dirInfo, $tagTablePtr) = @_;
12060 318 100       1640 $et or return 1; # allow dummy access
12061              
12062             # pre-scan IFD to get SerialNumber (0x001d) and ShutterCount (0x00a7) for use in decryption
12063 19         98 my %needTags = ( 0x001d => 0, 0x00a7 => undef );
12064 19         113 PrescanExif($et, $dirInfo, \%needTags);
12065 19         127 $$et{NikonSerialKey} = SerialKey($et, $needTags{0x001d});
12066 19         72 $$et{NikonCountKey} = $needTags{0x00a7};
12067              
12068             # process Nikon makernotes
12069 19         41 my $rtnVal;
12070 19 100       96 if ($$dirInfo{IsWriting}) {
12071             # get new decryptino keys if they are being changed
12072 7         57 my $serial = $et->GetNewValue($Image::ExifTool::Nikon::Main{0x001d});
12073 7         33 my $count = $et->GetNewValue($Image::ExifTool::Nikon::Main{0x00a7});
12074 7         33 $$et{NewNikonSerialKey} = SerialKey($et, $serial);
12075 7         29 $$et{NewNikonCountKey} = $count;
12076 7         102 $rtnVal = Image::ExifTool::Exif::WriteExif($et, $dirInfo, $tagTablePtr);
12077 7         27 delete $$et{NewNikonSerialKey};
12078 7         21 delete $$et{NewNikonCountKey};
12079             } else {
12080 12         138 $rtnVal = Image::ExifTool::Exif::ProcessExif($et, $dirInfo, $tagTablePtr);
12081             }
12082 19         79 delete $$et{NikonSerialKey};
12083 19         56 delete $$et{NikonCountKey};
12084 19         83 return $rtnVal;
12085             }
12086              
12087             1; # end
12088              
12089             __END__