File Coverage

blib/lib/Image/ExifTool/Nikon.pm
Criterion Covered Total %
statement 208 517 40.2
branch 79 318 24.8
condition 32 150 21.3
subroutine 19 33 57.5
pod 0 25 0.0
total 338 1043 32.4


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 29     29   6126 use strict;
  29         51  
  29         1159  
61 29     29   158 use vars qw($VERSION %nikonLensIDs %nikonTextEncoding);
  29         46  
  29         1603  
62 29     29   114 use Image::ExifTool qw(:DataAccess :Utils);
  29         54  
  29         6475  
63 29     29   44649 use Image::ExifTool::NikonCustom qw(%buttonsZ8 %buttonsZ9);
  29         140  
  29         20279  
64 29     29   1536 use Image::ExifTool::Exif;
  29         55  
  29         935  
65 29     29   604 use Image::ExifTool::GPS;
  29         52  
  29         492  
66 29     29   10048 use Image::ExifTool::XMP;
  29         64  
  29         784401  
67              
68             $VERSION = '4.57';
69              
70             sub LensIDConv($$$);
71             sub ProcessNikonAVI($$$);
72             sub ProcessNikonMOV($$$);
73             sub ProcessNikonEncrypted($$$);
74             sub FormatString($$);
75             sub ProcessNikonCaptureEditVersions($$$);
76             sub PrintAFPoints($$);
77             sub PrintAFPointsInv($$);
78             sub PrintAFPointsGrid($$);
79             sub PrintAFPointsGridInv($$$);
80             sub GetAFPointGrid($$;$);
81              
82             # nikon lens ID numbers (ref 8/11)
83             %nikonLensIDs = (
84             Notes => q{
85             The Nikon LensID is constructed as a Composite tag from the raw hex values
86             of 8 other tags: LensIDNumber, LensFStops, MinFocalLength, MaxFocalLength,
87             MaxApertureAtMinFocal, MaxApertureAtMaxFocal, MCUVersion and LensType, in
88             that order. The user-defined "Lenses" list may be used to specify the lens
89             for ExifTool to choose in these cases (see the
90             L for details).
91             },
92             OTHER => \&LensIDConv,
93             # Note: Sync this list with Robert's Perl version at
94             # http://www.rottmerhusen.com/objektives/lensid/files/exif/fmountlens.p.txt
95             # (hex digits must be uppercase in keys below)
96             '01 58 50 50 14 14 02 00' => 'AF Nikkor 50mm f/1.8',
97             '01 58 50 50 14 14 05 00' => 'AF Nikkor 50mm f/1.8',
98             '02 42 44 5C 2A 34 02 00' => 'AF Zoom-Nikkor 35-70mm f/3.3-4.5',
99             '02 42 44 5C 2A 34 08 00' => 'AF Zoom-Nikkor 35-70mm f/3.3-4.5',
100             '03 48 5C 81 30 30 02 00' => 'AF Zoom-Nikkor 70-210mm f/4',
101             '04 48 3C 3C 24 24 03 00' => 'AF Nikkor 28mm f/2.8',
102             '05 54 50 50 0C 0C 04 00' => 'AF Nikkor 50mm f/1.4',
103             '06 54 53 53 24 24 06 00' => 'AF Micro-Nikkor 55mm f/2.8',
104             '07 40 3C 62 2C 34 03 00' => 'AF Zoom-Nikkor 28-85mm f/3.5-4.5',
105             '08 40 44 6A 2C 34 04 00' => 'AF Zoom-Nikkor 35-105mm f/3.5-4.5',
106             '09 48 37 37 24 24 04 00' => 'AF Nikkor 24mm f/2.8',
107             '0A 48 8E 8E 24 24 03 00' => 'AF Nikkor 300mm f/2.8 IF-ED',
108             '0A 48 8E 8E 24 24 05 00' => 'AF Nikkor 300mm f/2.8 IF-ED N',
109             '0B 48 7C 7C 24 24 05 00' => 'AF Nikkor 180mm f/2.8 IF-ED',
110             '0D 40 44 72 2C 34 07 00' => 'AF Zoom-Nikkor 35-135mm f/3.5-4.5',
111             '0E 48 5C 81 30 30 05 00' => 'AF Zoom-Nikkor 70-210mm f/4',
112             '0F 58 50 50 14 14 05 00' => 'AF Nikkor 50mm f/1.8 N',
113             '10 48 8E 8E 30 30 08 00' => 'AF Nikkor 300mm f/4 IF-ED',
114             '11 48 44 5C 24 24 08 00' => 'AF Zoom-Nikkor 35-70mm f/2.8',
115             '11 48 44 5C 24 24 15 00' => 'AF Zoom-Nikkor 35-70mm f/2.8', #Jakob Dettner
116             '12 48 5C 81 30 3C 09 00' => 'AF Nikkor 70-210mm f/4-5.6',
117             '13 42 37 50 2A 34 0B 00' => 'AF Zoom-Nikkor 24-50mm f/3.3-4.5',
118             '14 48 60 80 24 24 0B 00' => 'AF Zoom-Nikkor 80-200mm f/2.8 ED',
119             '15 4C 62 62 14 14 0C 00' => 'AF Nikkor 85mm f/1.8',
120             '17 3C A0 A0 30 30 0F 00' => 'Nikkor 500mm f/4 P ED IF',
121             '17 3C A0 A0 30 30 11 00' => 'Nikkor 500mm f/4 P ED IF',
122             '18 40 44 72 2C 34 0E 00' => 'AF Zoom-Nikkor 35-135mm f/3.5-4.5 N',
123             '1A 54 44 44 18 18 11 00' => 'AF Nikkor 35mm f/2',
124             '1B 44 5E 8E 34 3C 10 00' => 'AF Zoom-Nikkor 75-300mm f/4.5-5.6',
125             '1C 48 30 30 24 24 12 00' => 'AF Nikkor 20mm f/2.8',
126             '1D 42 44 5C 2A 34 12 00' => 'AF Zoom-Nikkor 35-70mm f/3.3-4.5 N',
127             '1E 54 56 56 24 24 13 00' => 'AF Micro-Nikkor 60mm f/2.8',
128             '1F 54 6A 6A 24 24 14 00' => 'AF Micro-Nikkor 105mm f/2.8',
129             '20 48 60 80 24 24 15 00' => 'AF Zoom-Nikkor 80-200mm f/2.8 ED',
130             '21 40 3C 5C 2C 34 16 00' => 'AF Zoom-Nikkor 28-70mm f/3.5-4.5',
131             '22 48 72 72 18 18 16 00' => 'AF DC-Nikkor 135mm f/2',
132             '23 30 BE CA 3C 48 17 00' => 'Zoom-Nikkor 1200-1700mm f/5.6-8 P ED IF',
133             '24 48 60 80 24 24 1A 02' => 'AF Zoom-Nikkor 80-200mm f/2.8D ED',
134             '25 48 44 5C 24 24 1B 02' => 'AF Zoom-Nikkor 35-70mm f/2.8D',
135             '25 48 44 5C 24 24 3A 02' => 'AF Zoom-Nikkor 35-70mm f/2.8D',
136             '25 48 44 5C 24 24 52 02' => 'AF Zoom-Nikkor 35-70mm f/2.8D',
137             '26 40 3C 5C 2C 34 1C 02' => 'AF Zoom-Nikkor 28-70mm f/3.5-4.5D',
138             '27 48 8E 8E 24 24 1D 02' => 'AF-I Nikkor 300mm f/2.8D IF-ED',
139             '27 48 8E 8E 24 24 F1 02' => 'AF-I Nikkor 300mm f/2.8D IF-ED + TC-14E',
140             '27 48 8E 8E 24 24 E1 02' => 'AF-I Nikkor 300mm f/2.8D IF-ED + TC-17E',
141             '27 48 8E 8E 24 24 F2 02' => 'AF-I Nikkor 300mm f/2.8D IF-ED + TC-20E',
142             '28 3C A6 A6 30 30 1D 02' => 'AF-I Nikkor 600mm f/4D IF-ED',
143             '28 3C A6 A6 30 30 F1 02' => 'AF-I Nikkor 600mm f/4D IF-ED + TC-14E',
144             '28 3C A6 A6 30 30 E1 02' => 'AF-I Nikkor 600mm f/4D IF-ED + TC-17E',
145             '28 3C A6 A6 30 30 F2 02' => 'AF-I Nikkor 600mm f/4D IF-ED + TC-20E',
146             '2A 54 3C 3C 0C 0C 26 02' => 'AF Nikkor 28mm f/1.4D',
147             '2B 3C 44 60 30 3C 1F 02' => 'AF Zoom-Nikkor 35-80mm f/4-5.6D',
148             '2C 48 6A 6A 18 18 27 02' => 'AF DC-Nikkor 105mm f/2D',
149             '2D 48 80 80 30 30 21 02' => 'AF Micro-Nikkor 200mm f/4D IF-ED',
150             '2E 48 5C 82 30 3C 22 02' => 'AF Nikkor 70-210mm f/4-5.6D',
151             '2E 48 5C 82 30 3C 28 02' => 'AF Nikkor 70-210mm f/4-5.6D',
152             '2F 48 30 44 24 24 29 02.1' => 'AF Zoom-Nikkor 20-35mm f/2.8D IF',
153             '30 48 98 98 24 24 24 02' => 'AF-I Nikkor 400mm f/2.8D IF-ED',
154             '30 48 98 98 24 24 F1 02' => 'AF-I Nikkor 400mm f/2.8D IF-ED + TC-14E',
155             '30 48 98 98 24 24 E1 02' => 'AF-I Nikkor 400mm f/2.8D IF-ED + TC-17E',
156             '30 48 98 98 24 24 F2 02' => 'AF-I Nikkor 400mm f/2.8D IF-ED + TC-20E',
157             '31 54 56 56 24 24 25 02' => 'AF Micro-Nikkor 60mm f/2.8D',
158             '32 54 6A 6A 24 24 35 02.1' => 'AF Micro-Nikkor 105mm f/2.8D',
159             '33 48 2D 2D 24 24 31 02' => 'AF Nikkor 18mm f/2.8D',
160             '34 48 29 29 24 24 32 02' => 'AF Fisheye Nikkor 16mm f/2.8D',
161             '35 3C A0 A0 30 30 33 02' => 'AF-I Nikkor 500mm f/4D IF-ED',
162             '35 3C A0 A0 30 30 F1 02' => 'AF-I Nikkor 500mm f/4D IF-ED + TC-14E',
163             '35 3C A0 A0 30 30 E1 02' => 'AF-I Nikkor 500mm f/4D IF-ED + TC-17E',
164             '35 3C A0 A0 30 30 F2 02' => 'AF-I Nikkor 500mm f/4D IF-ED + TC-20E',
165             '36 48 37 37 24 24 34 02' => 'AF Nikkor 24mm f/2.8D',
166             '37 48 30 30 24 24 36 02' => 'AF Nikkor 20mm f/2.8D',
167             '38 4C 62 62 14 14 37 02' => 'AF Nikkor 85mm f/1.8D',
168             '3A 40 3C 5C 2C 34 39 02' => 'AF Zoom-Nikkor 28-70mm f/3.5-4.5D',
169             '3B 48 44 5C 24 24 3A 02' => 'AF Zoom-Nikkor 35-70mm f/2.8D N',
170             '3C 48 60 80 24 24 3B 02' => 'AF Zoom-Nikkor 80-200mm f/2.8D ED', #NJ
171             '3D 3C 44 60 30 3C 3E 02' => 'AF Zoom-Nikkor 35-80mm f/4-5.6D',
172             '3E 48 3C 3C 24 24 3D 02' => 'AF Nikkor 28mm f/2.8D',
173             '3F 40 44 6A 2C 34 45 02' => 'AF Zoom-Nikkor 35-105mm f/3.5-4.5D',
174             '41 48 7C 7C 24 24 43 02' => 'AF Nikkor 180mm f/2.8D IF-ED',
175             '42 54 44 44 18 18 44 02' => 'AF Nikkor 35mm f/2D',
176             '43 54 50 50 0C 0C 46 02' => 'AF Nikkor 50mm f/1.4D',
177             '44 44 60 80 34 3C 47 02' => 'AF Zoom-Nikkor 80-200mm f/4.5-5.6D',
178             '45 40 3C 60 2C 3C 48 02' => 'AF Zoom-Nikkor 28-80mm f/3.5-5.6D',
179             '46 3C 44 60 30 3C 49 02' => 'AF Zoom-Nikkor 35-80mm f/4-5.6D N',
180             '47 42 37 50 2A 34 4A 02' => 'AF Zoom-Nikkor 24-50mm f/3.3-4.5D',
181             '48 48 8E 8E 24 24 4B 02' => 'AF-S Nikkor 300mm f/2.8D IF-ED',
182             '48 48 8E 8E 24 24 F1 02' => 'AF-S Nikkor 300mm f/2.8D IF-ED + TC-14E',
183             '48 48 8E 8E 24 24 E1 02' => 'AF-S Nikkor 300mm f/2.8D IF-ED + TC-17E',
184             '48 48 8E 8E 24 24 F2 02' => 'AF-S Nikkor 300mm f/2.8D IF-ED + TC-20E',
185             '49 3C A6 A6 30 30 4C 02' => 'AF-S Nikkor 600mm f/4D IF-ED',
186             '49 3C A6 A6 30 30 F1 02' => 'AF-S Nikkor 600mm f/4D IF-ED + TC-14E',
187             '49 3C A6 A6 30 30 E1 02' => 'AF-S Nikkor 600mm f/4D IF-ED + TC-17E',
188             '49 3C A6 A6 30 30 F2 02' => 'AF-S Nikkor 600mm f/4D IF-ED + TC-20E',
189             '4A 54 62 62 0C 0C 4D 02' => 'AF Nikkor 85mm f/1.4D IF',
190             '4B 3C A0 A0 30 30 4E 02' => 'AF-S Nikkor 500mm f/4D IF-ED',
191             '4B 3C A0 A0 30 30 F1 02' => 'AF-S Nikkor 500mm f/4D IF-ED + TC-14E',
192             '4B 3C A0 A0 30 30 E1 02' => 'AF-S Nikkor 500mm f/4D IF-ED + TC-17E',
193             '4B 3C A0 A0 30 30 F2 02' => 'AF-S Nikkor 500mm f/4D IF-ED + TC-20E',
194             '4C 40 37 6E 2C 3C 4F 02' => 'AF Zoom-Nikkor 24-120mm f/3.5-5.6D IF',
195             '4D 40 3C 80 2C 3C 62 02' => 'AF Zoom-Nikkor 28-200mm f/3.5-5.6D IF',
196             '4E 48 72 72 18 18 51 02' => 'AF DC-Nikkor 135mm f/2D',
197             '4F 40 37 5C 2C 3C 53 06' => 'IX-Nikkor 24-70mm f/3.5-5.6',
198             '50 48 56 7C 30 3C 54 06' => 'IX-Nikkor 60-180mm f/4-5.6',
199             '53 48 60 80 24 24 57 02' => 'AF Zoom-Nikkor 80-200mm f/2.8D ED',
200             '53 48 60 80 24 24 60 02' => 'AF Zoom-Nikkor 80-200mm f/2.8D ED',
201             '54 44 5C 7C 34 3C 58 02' => 'AF Zoom-Micro Nikkor 70-180mm f/4.5-5.6D ED',
202             '54 44 5C 7C 34 3C 61 02' => 'AF Zoom-Micro Nikkor 70-180mm f/4.5-5.6D ED',
203             '56 48 5C 8E 30 3C 5A 02' => 'AF Zoom-Nikkor 70-300mm f/4-5.6D ED',
204             '59 48 98 98 24 24 5D 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED',
205             '59 48 98 98 24 24 F1 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED + TC-14E',
206             '59 48 98 98 24 24 E1 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED + TC-17E',
207             '59 48 98 98 24 24 F2 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED + TC-20E',
208             '5A 3C 3E 56 30 3C 5E 06' => 'IX-Nikkor 30-60mm f/4-5.6',
209             '5B 44 56 7C 34 3C 5F 06' => 'IX-Nikkor 60-180mm f/4.5-5.6',
210             '5D 48 3C 5C 24 24 63 02' => 'AF-S Zoom-Nikkor 28-70mm f/2.8D IF-ED',
211             '5E 48 60 80 24 24 64 02' => 'AF-S Zoom-Nikkor 80-200mm f/2.8D IF-ED',
212             '5F 40 3C 6A 2C 34 65 02' => 'AF Zoom-Nikkor 28-105mm f/3.5-4.5D IF',
213             '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)
214             '61 44 5E 86 34 3C 67 02' => 'AF Zoom-Nikkor 75-240mm f/4.5-5.6D',
215             '63 48 2B 44 24 24 68 02' => 'AF-S Nikkor 17-35mm f/2.8D IF-ED',
216             '64 00 62 62 24 24 6A 02' => 'PC Micro-Nikkor 85mm f/2.8D',
217             '65 44 60 98 34 3C 6B 0A' => 'AF VR Zoom-Nikkor 80-400mm f/4.5-5.6D ED',
218             '66 40 2D 44 2C 34 6C 02' => 'AF Zoom-Nikkor 18-35mm f/3.5-4.5D IF-ED',
219             '67 48 37 62 24 30 6D 02' => 'AF Zoom-Nikkor 24-85mm f/2.8-4D IF',
220             '68 42 3C 60 2A 3C 6E 06' => 'AF Zoom-Nikkor 28-80mm f/3.3-5.6G',
221             '69 48 5C 8E 30 3C 6F 06' => 'AF Zoom-Nikkor 70-300mm f/4-5.6G',
222             '6A 48 8E 8E 30 30 70 02' => 'AF-S Nikkor 300mm f/4D IF-ED',
223             '6B 48 24 24 24 24 71 02' => 'AF Nikkor ED 14mm f/2.8D',
224             '6D 48 8E 8E 24 24 73 02' => 'AF-S Nikkor 300mm f/2.8D IF-ED II',
225             '6E 48 98 98 24 24 74 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED II',
226             '6F 3C A0 A0 30 30 75 02' => 'AF-S Nikkor 500mm f/4D IF-ED II',
227             '70 3C A6 A6 30 30 76 02' => 'AF-S Nikkor 600mm f/4D IF-ED II',
228             '72 48 4C 4C 24 24 77 00' => 'Nikkor 45mm f/2.8 P',
229             '74 40 37 62 2C 34 78 06' => 'AF-S Zoom-Nikkor 24-85mm f/3.5-4.5G IF-ED',
230             '75 40 3C 68 2C 3C 79 06' => 'AF Zoom-Nikkor 28-100mm f/3.5-5.6G',
231             '76 58 50 50 14 14 7A 02' => 'AF Nikkor 50mm f/1.8D',
232             '77 48 5C 80 24 24 7B 0E' => 'AF-S VR Zoom-Nikkor 70-200mm f/2.8G IF-ED',
233             '78 40 37 6E 2C 3C 7C 0E' => 'AF-S VR Zoom-Nikkor 24-120mm f/3.5-5.6G IF-ED',
234             '79 40 3C 80 2C 3C 7F 06' => 'AF Zoom-Nikkor 28-200mm f/3.5-5.6G IF-ED',
235             '7A 3C 1F 37 30 30 7E 06.1' => 'AF-S DX Zoom-Nikkor 12-24mm f/4G IF-ED',
236             '7B 48 80 98 30 30 80 0E' => 'AF-S VR Zoom-Nikkor 200-400mm f/4G IF-ED',
237             '7D 48 2B 53 24 24 82 06' => 'AF-S DX Zoom-Nikkor 17-55mm f/2.8G IF-ED',
238             '7F 40 2D 5C 2C 34 84 06' => 'AF-S DX Zoom-Nikkor 18-70mm f/3.5-4.5G IF-ED',
239             '80 48 1A 1A 24 24 85 06' => 'AF DX Fisheye-Nikkor 10.5mm f/2.8G ED',
240             '81 54 80 80 18 18 86 0E' => 'AF-S VR Nikkor 200mm f/2G IF-ED',
241             '82 48 8E 8E 24 24 87 0E' => 'AF-S VR Nikkor 300mm f/2.8G IF-ED',
242             '83 00 B0 B0 5A 5A 88 04' => 'FSA-L2, EDG 65, 800mm F13 G',
243             '89 3C 53 80 30 3C 8B 06' => 'AF-S DX Zoom-Nikkor 55-200mm f/4-5.6G ED',
244             '8A 54 6A 6A 24 24 8C 0E' => 'AF-S VR Micro-Nikkor 105mm f/2.8G IF-ED', #10
245             # when the TC-20 III 2x teleconverter is used with the above lens, the following have been observed:
246             # 8A 4D 6A 6A 24 24 8C 0E
247             # 8A 4E 6A 6A 24 24 8C 0E
248             # 8A 50 6A 6A 24 24 8C 0E
249             # 8A 51 6A 6A 24 24 8C 0E
250             # 8A 52 6A 6A 24 24 8C 0E
251             # 8A 53 6A 6A 24 24 8C 0E
252             # 8A 54 6A 6A 24 24 8C 0E (same as without the TC)
253             '8B 40 2D 80 2C 3C 8D 0E' => 'AF-S DX VR Zoom-Nikkor 18-200mm f/3.5-5.6G IF-ED',
254             '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
255             '8C 40 2D 53 2C 3C 8E 06' => 'AF-S DX Zoom-Nikkor 18-55mm f/3.5-5.6G ED',
256             '8D 44 5C 8E 34 3C 8F 0E' => 'AF-S VR Zoom-Nikkor 70-300mm f/4.5-5.6G IF-ED', #10
257             '8F 40 2D 72 2C 3C 91 06' => 'AF-S DX Zoom-Nikkor 18-135mm f/3.5-5.6G IF-ED',
258             '90 3B 53 80 30 3C 92 0E' => 'AF-S DX VR Zoom-Nikkor 55-200mm f/4-5.6G IF-ED',
259             '92 48 24 37 24 24 94 06' => 'AF-S Zoom-Nikkor 14-24mm f/2.8G ED',
260             '93 48 37 5C 24 24 95 06' => 'AF-S Zoom-Nikkor 24-70mm f/2.8G ED',
261             '94 40 2D 53 2C 3C 96 06' => 'AF-S DX Zoom-Nikkor 18-55mm f/3.5-5.6G ED II', #10 (D40)
262             '95 4C 37 37 2C 2C 97 02' => 'PC-E Nikkor 24mm f/3.5D ED',
263             '95 00 37 37 2C 2C 97 06' => 'PC-E Nikkor 24mm f/3.5D ED', #JD
264             '96 48 98 98 24 24 98 0E' => 'AF-S VR Nikkor 400mm f/2.8G ED',
265             '97 3C A0 A0 30 30 99 0E' => 'AF-S VR Nikkor 500mm f/4G ED',
266             '98 3C A6 A6 30 30 9A 0E' => 'AF-S VR Nikkor 600mm f/4G ED',
267             '99 40 29 62 2C 3C 9B 0E' => 'AF-S DX VR Zoom-Nikkor 16-85mm f/3.5-5.6G ED',
268             '9A 40 2D 53 2C 3C 9C 0E' => 'AF-S DX VR Zoom-Nikkor 18-55mm f/3.5-5.6G',
269             '9B 54 4C 4C 24 24 9D 02' => 'PC-E Micro Nikkor 45mm f/2.8D ED',
270             '9B 00 4C 4C 24 24 9D 06' => 'PC-E Micro Nikkor 45mm f/2.8D ED',
271             '9C 54 56 56 24 24 9E 06' => 'AF-S Micro Nikkor 60mm f/2.8G ED',
272             '9D 54 62 62 24 24 9F 02' => 'PC-E Micro Nikkor 85mm f/2.8D',
273             '9D 00 62 62 24 24 9F 06' => 'PC-E Micro Nikkor 85mm f/2.8D',
274             '9E 40 2D 6A 2C 3C A0 0E' => 'AF-S DX VR Zoom-Nikkor 18-105mm f/3.5-5.6G ED', #PH/10
275             '9F 58 44 44 14 14 A1 06' => 'AF-S DX Nikkor 35mm f/1.8G', #27
276             'A0 54 50 50 0C 0C A2 06' => 'AF-S Nikkor 50mm f/1.4G',
277             'A1 40 18 37 2C 34 A3 06' => 'AF-S DX Nikkor 10-24mm f/3.5-4.5G ED',
278             'A1 40 2D 53 2C 3C CB 86' => 'AF-P DX Nikkor 18-55mm f/3.5-5.6G', #30
279             'A2 48 5C 80 24 24 A4 0E' => 'AF-S Nikkor 70-200mm f/2.8G ED VR II',
280             'A3 3C 29 44 30 30 A5 0E' => 'AF-S Nikkor 16-35mm f/4G ED VR',
281             'A4 54 37 37 0C 0C A6 06' => 'AF-S Nikkor 24mm f/1.4G ED',
282             'A5 40 3C 8E 2C 3C A7 0E' => 'AF-S Nikkor 28-300mm f/3.5-5.6G ED VR',
283             'A6 48 8E 8E 24 24 A8 0E' => 'AF-S Nikkor 300mm f/2.8G IF-ED VR II',
284             'A7 4B 62 62 2C 2C A9 0E' => 'AF-S DX Micro Nikkor 85mm f/3.5G ED VR',
285             '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
286             'A9 54 80 80 18 18 AB 0E' => 'AF-S Nikkor 200mm f/2G ED VR II',
287             'AA 3C 37 6E 30 30 AC 0E' => 'AF-S Nikkor 24-120mm f/4G ED VR',
288             'AC 38 53 8E 34 3C AE 0E' => 'AF-S DX Nikkor 55-300mm f/4.5-5.6G ED VR',
289             'AD 3C 2D 8E 2C 3C AF 0E' => 'AF-S DX Nikkor 18-300mm f/3.5-5.6G ED VR',
290             'AE 54 62 62 0C 0C B0 06' => 'AF-S Nikkor 85mm f/1.4G',
291             'AF 54 44 44 0C 0C B1 06' => 'AF-S Nikkor 35mm f/1.4G',
292             'B0 4C 50 50 14 14 B2 06' => 'AF-S Nikkor 50mm f/1.8G',
293             'B1 48 48 48 24 24 B3 06' => 'AF-S DX Micro Nikkor 40mm f/2.8G', #27
294             'B2 48 5C 80 30 30 B4 0E' => 'AF-S Nikkor 70-200mm f/4G ED VR', #35
295             'B3 4C 62 62 14 14 B5 06' => 'AF-S Nikkor 85mm f/1.8G',
296             'B4 40 37 62 2C 34 B6 0E' => 'AF-S Zoom-Nikkor 24-85mm f/3.5-4.5G IF-ED VR', #30
297             'B5 4C 3C 3C 14 14 B7 06' => 'AF-S Nikkor 28mm f/1.8G', #30
298             'B6 3C B0 B0 3C 3C B8 0E' => 'AF-S VR Nikkor 800mm f/5.6E FL ED',
299             'B6 3C B0 B0 3C 3C B8 4E' => 'AF-S VR Nikkor 800mm f/5.6E FL ED', #PH
300             'B7 44 60 98 34 3C B9 0E' => 'AF-S Nikkor 80-400mm f/4.5-5.6G ED VR',
301             'B8 40 2D 44 2C 34 BA 06' => 'AF-S Nikkor 18-35mm f/3.5-4.5G ED',
302             'A0 40 2D 74 2C 3C BB 0E' => 'AF-S DX Nikkor 18-140mm f/3.5-5.6G ED VR', #PH
303             'A1 54 55 55 0C 0C BC 06' => 'AF-S Nikkor 58mm f/1.4G', #IB
304             'A1 48 6E 8E 24 24 DB 4E' => 'AF-S Nikkor 120-300mm f/2.8E FL ED SR VR', #28
305             'A2 40 2D 53 2C 3C BD 0E' => 'AF-S DX Nikkor 18-55mm f/3.5-5.6G VR II',
306             'A4 40 2D 8E 2C 40 BF 0E' => 'AF-S DX Nikkor 18-300mm f/3.5-6.3G ED VR',
307             'A5 4C 44 44 14 14 C0 06' => 'AF-S Nikkor 35mm f/1.8G ED', #35 ("ED" ref 11)
308             'A6 48 98 98 24 24 C1 0E' => 'AF-S Nikkor 400mm f/2.8E FL ED VR',
309             'A7 3C 53 80 30 3C C2 0E' => 'AF-S DX Nikkor 55-200mm f/4-5.6G ED VR II', #IB
310             'A8 48 8E 8E 30 30 C3 4E' => 'AF-S Nikkor 300mm f/4E PF ED VR', #35
311             'A8 48 8E 8E 30 30 C3 0E' => 'AF-S Nikkor 300mm f/4E PF ED VR', #30
312             'A9 4C 31 31 14 14 C4 06' => 'AF-S Nikkor 20mm f/1.8G ED', #30
313             'AA 48 37 5C 24 24 C5 4E' => 'AF-S Nikkor 24-70mm f/2.8E ED VR',
314             'AA 48 37 5C 24 24 C5 0E' => 'AF-S Nikkor 24-70mm f/2.8E ED VR',
315             'AB 3C A0 A0 30 30 C6 4E' => 'AF-S Nikkor 500mm f/4E FL ED VR',
316             'AC 3C A6 A6 30 30 C7 4E' => 'AF-S Nikkor 600mm f/4E FL ED VR', #PH
317             'AD 48 28 60 24 30 C8 4E' => 'AF-S DX Nikkor 16-80mm f/2.8-4E ED VR',
318             'AD 48 28 60 24 30 C8 0E' => 'AF-S DX Nikkor 16-80mm f/2.8-4E ED VR', #PH
319             'AE 3C 80 A0 3C 3C C9 4E' => 'AF-S Nikkor 200-500mm f/5.6E ED VR', #PH
320             'AE 3C 80 A0 3C 3C C9 0E' => 'AF-S Nikkor 200-500mm f/5.6E ED VR',
321             'A0 40 2D 53 2C 3C CA 8E' => 'AF-P DX Nikkor 18-55mm f/3.5-5.6G', #Yang You pvt communication
322             'A0 40 2D 53 2C 3C CA 0E' => 'AF-P DX Nikkor 18-55mm f/3.5-5.6G VR', #PH
323             'AF 4C 37 37 14 14 CC 06' => 'AF-S Nikkor 24mm f/1.8G ED', #IB
324             'A2 38 5C 8E 34 40 CD 86' => 'AF-P DX Nikkor 70-300mm f/4.5-6.3G VR', #PH
325             'A3 38 5C 8E 34 40 CE 8E' => 'AF-P DX Nikkor 70-300mm f/4.5-6.3G ED VR',
326             'A3 38 5C 8E 34 40 CE 0E' => 'AF-P DX Nikkor 70-300mm f/4.5-6.3G ED',
327             'A4 48 5C 80 24 24 CF 4E' => 'AF-S Nikkor 70-200mm f/2.8E FL ED VR',
328             'A4 48 5C 80 24 24 CF 0E' => 'AF-S Nikkor 70-200mm f/2.8E FL ED VR',
329             'A5 54 6A 6A 0C 0C D0 46' => 'AF-S Nikkor 105mm f/1.4E ED', #IB
330             'A5 54 6A 6A 0C 0C D0 06' => 'AF-S Nikkor 105mm f/1.4E ED', #IB
331             'A6 48 2F 2F 30 30 D1 46' => 'PC Nikkor 19mm f/4E ED',
332             'A6 48 2F 2F 30 30 D1 06' => 'PC Nikkor 19mm f/4E ED',
333             'A7 40 11 26 2C 34 D2 46' => 'AF-S Fisheye Nikkor 8-15mm f/3.5-4.5E ED',
334             'A7 40 11 26 2C 34 D2 06' => 'AF-S Fisheye Nikkor 8-15mm f/3.5-4.5E ED',
335             'A8 38 18 30 34 3C D3 8E' => 'AF-P DX Nikkor 10-20mm f/4.5-5.6G VR', #Yang You pvt communication
336             'A8 38 18 30 34 3C D3 0E' => 'AF-P DX Nikkor 10-20mm f/4.5-5.6G VR',
337             'A9 48 7C 98 30 30 D4 4E' => 'AF-S Nikkor 180-400mm f/4E TC1.4 FL ED VR', #IB
338             'A9 48 7C 98 30 30 D4 0E' => 'AF-S Nikkor 180-400mm f/4E TC1.4 FL ED VR',
339             'AA 48 88 A4 3C 3C D5 4E' => 'AF-S Nikkor 180-400mm f/4E TC1.4 FL ED VR + 1.4x TC', #IB
340             'AA 48 88 A4 3C 3C D5 0E' => 'AF-S Nikkor 180-400mm f/4E TC1.4 FL ED VR + 1.4x TC',
341             'AB 44 5C 8E 34 3C D6 CE' => 'AF-P Nikkor 70-300mm f/4.5-5.6E ED VR',
342             'AB 44 5C 8E 34 3C D6 0E' => 'AF-P Nikkor 70-300mm f/4.5-5.6E ED VR',
343             'AB 44 5C 8E 34 3C D6 4E' => 'AF-P Nikkor 70-300mm f/4.5-5.6E ED VR', #IB
344             'AC 54 3C 3C 0C 0C D7 46' => 'AF-S Nikkor 28mm f/1.4E ED',
345             'AC 54 3C 3C 0C 0C D7 06' => 'AF-S Nikkor 28mm f/1.4E ED',
346             'AD 3C A0 A0 3C 3C D8 0E' => 'AF-S Nikkor 500mm f/5.6E PF ED VR',
347             'AD 3C A0 A0 3C 3C D8 4E' => 'AF-S Nikkor 500mm f/5.6E PF ED VR',
348             '01 00 00 00 00 00 02 00' => 'TC-16A',
349             '01 00 00 00 00 00 08 00' => 'TC-16A',
350             '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',
351             '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',
352             '00 00 00 00 00 00 E1 12' => 'TC-17E II',
353             'FE 47 00 00 24 24 4B 06' => 'Sigma 4.5mm F2.8 EX DC HSM Circular Fisheye', #JD
354             '26 48 11 11 30 30 1C 02' => 'Sigma 8mm F4 EX Circular Fisheye',
355             '79 40 11 11 2C 2C 1C 06' => 'Sigma 8mm F3.5 EX Circular Fisheye', #JD
356             'DB 40 11 11 2C 2C 1C 06' => 'Sigma 8mm F3.5 EX DG Circular Fisheye', #30
357             'DC 48 19 19 24 24 4B 06' => 'Sigma 10mm F2.8 EX DC HSM Fisheye',
358             'C2 4C 24 24 14 14 4B 06' => 'Sigma 14mm F1.8 DG HSM | A', #IB
359             '48 48 24 24 24 24 4B 02' => 'Sigma 14mm F2.8 EX Aspherical HSM',
360             '02 3F 24 24 2C 2C 02 00' => 'Sigma 14mm F3.5',
361             '26 48 27 27 24 24 1C 02' => 'Sigma 15mm F2.8 EX Diagonal Fisheye',
362             'EA 48 27 27 24 24 1C 02' => 'Sigma 15mm F2.8 EX Diagonal Fisheye', #30
363             '26 58 31 31 14 14 1C 02' => 'Sigma 20mm F1.8 EX DG Aspherical RF',
364             '79 54 31 31 0C 0C 4B 06' => 'Sigma 20mm F1.4 DG HSM | A', #Rolf Probst
365             '26 58 37 37 14 14 1C 02' => 'Sigma 24mm F1.8 EX DG Aspherical Macro',
366             'E1 58 37 37 14 14 1C 02' => 'Sigma 24mm F1.8 EX DG Aspherical Macro',
367             '02 46 37 37 25 25 02 00' => 'Sigma 24mm F2.8 Super Wide II Macro',
368             '7E 54 37 37 0C 0C 4B 06' => 'Sigma 24mm F1.4 DG HSM | A', #30
369             '26 58 3C 3C 14 14 1C 02' => 'Sigma 28mm F1.8 EX DG Aspherical Macro',
370             'BC 54 3C 3C 0C 0C 4B 46' => 'Sigma 28mm F1.4 DG HSM | A', #30
371             '48 54 3E 3E 0C 0C 4B 06' => 'Sigma 30mm F1.4 EX DC HSM',
372             'F8 54 3E 3E 0C 0C 4B 06' => 'Sigma 30mm F1.4 EX DC HSM', #JD
373             '91 54 44 44 0C 0C 4B 06' => 'Sigma 35mm F1.4 DG HSM', #30
374             'BD 54 48 48 0C 0C 4B 46' => 'Sigma 40mm F1.4 DG HSM | A', #30
375             'DE 54 50 50 0C 0C 4B 06' => 'Sigma 50mm F1.4 EX DG HSM',
376             '88 54 50 50 0C 0C 4B 06' => 'Sigma 50mm F1.4 DG HSM | A',
377             '02 48 50 50 24 24 02 00' => 'Sigma Macro 50mm F2.8', #https://exiftool.org/forum/index.php/topic,4027.0.html
378             '32 54 50 50 24 24 35 02' => 'Sigma Macro 50mm F2.8 EX DG',
379             '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
380             '79 48 5C 5C 24 24 1C 06' => 'Sigma Macro 70mm F2.8 EX DG', #JD
381             '9B 54 62 62 0C 0C 4B 06' => 'Sigma 85mm F1.4 EX DG HSM',
382             'C8 54 62 62 0C 0C 4B 46' => 'Sigma 85mm F1.4 DG HSM | A', #JamiBradley
383             'C8 54 62 62 0C 0C 4B 06' => 'Sigma 85mm F1.4 DG HSM | A', #KennethCochran
384             '02 48 65 65 24 24 02 00' => 'Sigma Macro 90mm F2.8',
385             '32 54 6A 6A 24 24 35 02.2' => 'Sigma Macro 105mm F2.8 EX DG', #JD
386             'E5 54 6A 6A 24 24 35 02' => 'Sigma Macro 105mm F2.8 EX DG',
387             '97 48 6A 6A 24 24 4B 0E' => 'Sigma Macro 105mm F2.8 EX DG OS HSM',
388             'BE 54 6A 6A 0C 0C 4B 46' => 'Sigma 105mm F1.4 DG HSM | A', #30
389             '48 48 76 76 24 24 4B 06' => 'Sigma APO Macro 150mm F2.8 EX DG HSM',
390             'F5 48 76 76 24 24 4B 06' => 'Sigma APO Macro 150mm F2.8 EX DG HSM', #24
391             '99 48 76 76 24 24 4B 0E' => 'Sigma APO Macro 150mm F2.8 EX DG OS HSM', #(Christian Hesse)
392             '48 4C 7C 7C 2C 2C 4B 02' => 'Sigma APO Macro 180mm F3.5 EX DG HSM',
393             '48 4C 7D 7D 2C 2C 4B 02' => 'Sigma APO Macro 180mm F3.5 EX DG HSM',
394             'F4 4C 7C 7C 2C 2C 4B 02' => 'Sigma APO Macro 180mm F3.5 EX DG HSM', #Bruno
395             '94 48 7C 7C 24 24 4B 0E' => 'Sigma APO Macro 180mm F2.8 EX DG OS HSM', #MichaelTapes (HSM from ref 8)
396             '48 54 8E 8E 24 24 4B 02' => 'Sigma APO 300mm F2.8 EX DG HSM',
397             'FB 54 8E 8E 24 24 4B 02' => 'Sigma APO 300mm F2.8 EX DG HSM', #26
398             '26 48 8E 8E 30 30 1C 02' => 'Sigma APO Tele Macro 300mm F4',
399             '02 2F 98 98 3D 3D 02 00' => 'Sigma APO 400mm F5.6',
400             '26 3C 98 98 3C 3C 1C 02' => 'Sigma APO Tele Macro 400mm F5.6',
401             '02 37 A0 A0 34 34 02 00' => 'Sigma APO 500mm F4.5', #19
402             '48 44 A0 A0 34 34 4B 02' => 'Sigma APO 500mm F4.5 EX HSM',
403             'F1 44 A0 A0 34 34 4B 02' => 'Sigma APO 500mm F4.5 EX DG HSM',
404             '02 34 A0 A0 44 44 02 00' => 'Sigma APO 500mm F7.2',
405             '02 3C B0 B0 3C 3C 02 00' => 'Sigma APO 800mm F5.6',
406             '48 3C B0 B0 3C 3C 4B 02' => 'Sigma APO 800mm F5.6 EX HSM',
407             '9E 38 11 29 34 3C 4B 06' => 'Sigma 8-16mm F4.5-5.6 DC HSM',
408             'A1 41 19 31 2C 2C 4B 06' => 'Sigma 10-20mm F3.5 EX DC HSM',
409             '48 3C 19 31 30 3C 4B 06' => 'Sigma 10-20mm F4-5.6 EX DC HSM',
410             'F9 3C 19 31 30 3C 4B 06' => 'Sigma 10-20mm F4-5.6 EX DC HSM', #JD
411             '48 38 1F 37 34 3C 4B 06' => 'Sigma 12-24mm F4.5-5.6 EX DG Aspherical HSM',
412             'F0 38 1F 37 34 3C 4B 06' => 'Sigma 12-24mm F4.5-5.6 EX DG Aspherical HSM',
413             '96 38 1F 37 34 3C 4B 06' => 'Sigma 12-24mm F4.5-5.6 II DG HSM', #Jurgen Sahlberg
414             'CA 3C 1F 37 30 30 4B 46' => 'Sigma 12-24mm F4 DG HSM | A', #github issue#101
415             'C1 48 24 37 24 24 4B 46' => 'Sigma 14-24mm F2.8 DG HSM | A', #30
416             '26 40 27 3F 2C 34 1C 02' => 'Sigma 15-30mm F3.5-4.5 EX DG Aspherical DF',
417             '48 48 2B 44 24 30 4B 06' => 'Sigma 17-35mm F2.8-4 EX DG Aspherical HSM',
418             '26 54 2B 44 24 30 1C 02' => 'Sigma 17-35mm F2.8-4 EX Aspherical',
419             '9D 48 2B 50 24 24 4B 0E' => 'Sigma 17-50mm F2.8 EX DC OS HSM',
420             '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
421             '7A 47 2B 5C 24 34 4B 06' => 'Sigma 17-70mm F2.8-4.5 DC Macro Asp. IF HSM',
422             '7A 48 2B 5C 24 34 4B 06' => 'Sigma 17-70mm F2.8-4.5 DC Macro Asp. IF HSM',
423             '7F 48 2B 5C 24 34 1C 06' => 'Sigma 17-70mm F2.8-4.5 DC Macro Asp. IF',
424             '8E 3C 2B 5C 24 30 4B 0E' => 'Sigma 17-70mm F2.8-4 DC Macro OS HSM | C',
425             '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
426             '8B 4C 2D 44 14 14 4B 06' => 'Sigma 18-35mm F1.8 DC HSM', #30/NJ
427             '26 40 2D 44 2B 34 1C 02' => 'Sigma 18-35mm F3.5-4.5 Aspherical',
428             '26 48 2D 50 24 24 1C 06' => 'Sigma 18-50mm F2.8 EX DC',
429             '7F 48 2D 50 24 24 1C 06' => 'Sigma 18-50mm F2.8 EX DC Macro', #NJ
430             '7A 48 2D 50 24 24 4B 06' => 'Sigma 18-50mm F2.8 EX DC Macro',
431             'F6 48 2D 50 24 24 4B 06' => 'Sigma 18-50mm F2.8 EX DC Macro',
432             'A4 47 2D 50 24 34 4B 0E' => 'Sigma 18-50mm F2.8-4.5 DC OS HSM',
433             '26 40 2D 50 2C 3C 1C 06' => 'Sigma 18-50mm F3.5-5.6 DC',
434             '7A 40 2D 50 2C 3C 4B 06' => 'Sigma 18-50mm F3.5-5.6 DC HSM',
435             '26 40 2D 70 2B 3C 1C 06' => 'Sigma 18-125mm F3.5-5.6 DC',
436             'CD 3D 2D 70 2E 3C 4B 0E' => 'Sigma 18-125mm F3.8-5.6 DC OS HSM',
437             '26 40 2D 80 2C 40 1C 06' => 'Sigma 18-200mm F3.5-6.3 DC',
438             'FF 40 2D 80 2C 40 4B 06' => 'Sigma 18-200mm F3.5-6.3 DC', #30
439             '7A 40 2D 80 2C 40 4B 0E' => 'Sigma 18-200mm F3.5-6.3 DC OS HSM',
440             'ED 40 2D 80 2C 40 4B 0E' => 'Sigma 18-200mm F3.5-6.3 DC OS HSM', #JD
441             '90 40 2D 80 2C 40 4B 0E' => 'Sigma 18-200mm F3.5-6.3 II DC OS HSM', #JohnHelour
442             '89 30 2D 80 2C 40 4B 0E' => 'Sigma 18-200mm F3.5-6.3 DC Macro OS HS | C', #JoeSchonberg
443             'A5 40 2D 88 2C 40 4B 0E' => 'Sigma 18-250mm F3.5-6.3 DC OS HSM',
444             # LensFStops varies with FocalLength for this lens (ref 2):
445             '92 2C 2D 88 2C 40 4B 0E' => 'Sigma 18-250mm F3.5-6.3 DC Macro OS HSM', #2
446             '87 2C 2D 8E 2C 40 4B 0E' => 'Sigma 18-300mm F3.5-6.3 DC Macro HSM', #30
447             # '92 2C 2D 88 2C 40 4B 0E' (250mm)
448             # '92 2B 2D 88 2C 40 4B 0E' (210mm)
449             # '92 2C 2D 88 2C 40 4B 0E' (185mm)
450             # '92 2D 2D 88 2C 40 4B 0E' (155mm)
451             # '92 2E 2D 88 2C 40 4B 0E' (130mm)
452             # '92 2F 2D 88 2C 40 4B 0E' (105mm)
453             # '92 30 2D 88 2C 40 4B 0E' (90mm)
454             # '92 32 2D 88 2C 40 4B 0E' (75mm)
455             # '92 33 2D 88 2C 40 4B 0E' (62mm)
456             # '92 35 2D 88 2C 40 4B 0E' (52mm)
457             # '92 37 2D 88 2C 40 4B 0E' (44mm)
458             # '92 39 2D 88 2C 40 4B 0E' (38mm)
459             # '92 3A 2D 88 2C 40 4B 0E' (32mm)
460             # '92 3E 2D 88 2C 40 4B 0E' (22mm)
461             # '92 40 2D 88 2C 40 4B 0E' (18mm)
462             '26 48 31 49 24 24 1C 02' => 'Sigma 20-40mm F2.8',
463             '7B 48 37 44 18 18 4B 06' => 'Sigma 24-35mm F2.0 DG HSM | A', #30
464             '02 3A 37 50 31 3D 02 00' => 'Sigma 24-50mm F4-5.6 UC',
465             '26 48 37 56 24 24 1C 02' => 'Sigma 24-60mm F2.8 EX DG',
466             'B6 48 37 56 24 24 1C 02' => 'Sigma 24-60mm F2.8 EX DG',
467             'A6 48 37 5C 24 24 4B 06' => 'Sigma 24-70mm F2.8 IF EX DG HSM', #JD
468             'C9 48 37 5C 24 24 4B 4E' => 'Sigma 24-70mm F2.8 DG OS HSM | A', #30
469             '26 54 37 5C 24 24 1C 02' => 'Sigma 24-70mm F2.8 EX DG Macro',
470             '67 54 37 5C 24 24 1C 02' => 'Sigma 24-70mm F2.8 EX DG Macro',
471             'E9 54 37 5C 24 24 1C 02' => 'Sigma 24-70mm F2.8 EX DG Macro',
472             '26 40 37 5C 2C 3C 1C 02' => 'Sigma 24-70mm F3.5-5.6 Aspherical HF',
473             '8A 3C 37 6A 30 30 4B 0E' => 'Sigma 24-105mm F4 DG OS HSM', #IB
474             '26 54 37 73 24 34 1C 02' => 'Sigma 24-135mm F2.8-4.5',
475             '02 46 3C 5C 25 25 02 00' => 'Sigma 28-70mm F2.8',
476             '26 54 3C 5C 24 24 1C 02' => 'Sigma 28-70mm F2.8 EX',
477             '26 48 3C 5C 24 24 1C 06' => 'Sigma 28-70mm F2.8 EX DG',
478             '79 48 3C 5C 24 24 1C 06' => 'Sigma 28-70mm F2.8 EX DG', #30 ("D" removed)
479             '26 48 3C 5C 24 30 1C 02' => 'Sigma 28-70mm F2.8-4 DG',
480             '02 3F 3C 5C 2D 35 02 00' => 'Sigma 28-70mm F3.5-4.5 UC',
481             '26 40 3C 60 2C 3C 1C 02' => 'Sigma 28-80mm F3.5-5.6 Mini Zoom Macro II Aspherical',
482             '26 40 3C 65 2C 3C 1C 02' => 'Sigma 28-90mm F3.5-5.6 Macro',
483             '26 48 3C 6A 24 30 1C 02' => 'Sigma 28-105mm F2.8-4 Aspherical',
484             '26 3E 3C 6A 2E 3C 1C 02' => 'Sigma 28-105mm F3.8-5.6 UC-III Aspherical IF',
485             '26 40 3C 80 2C 3C 1C 02' => 'Sigma 28-200mm F3.5-5.6 Compact Aspherical Hyperzoom Macro',
486             '26 40 3C 80 2B 3C 1C 02' => 'Sigma 28-200mm F3.5-5.6 Compact Aspherical Hyperzoom Macro',
487             '26 3D 3C 80 2F 3D 1C 02' => 'Sigma 28-300mm F3.8-5.6 Aspherical',
488             '26 41 3C 8E 2C 40 1C 02' => 'Sigma 28-300mm F3.5-6.3 DG Macro',
489             '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
490             '26 40 3C 8E 2C 40 1C 02' => 'Sigma 28-300mm F3.5-6.3 Macro',
491             '02 3B 44 61 30 3D 02 00' => 'Sigma 35-80mm F4-5.6',
492             '02 40 44 73 2B 36 02 00' => 'Sigma 35-135mm F3.5-4.5 a',
493             'CC 4C 50 68 14 14 4B 06' => 'Sigma 50-100mm F1.8 DC HSM | A', #30
494             '7A 47 50 76 24 24 4B 06' => 'Sigma 50-150mm F2.8 EX APO DC HSM',
495             'FD 47 50 76 24 24 4B 06' => 'Sigma 50-150mm F2.8 EX APO DC HSM II',
496             '98 48 50 76 24 24 4B 0E' => 'Sigma 50-150mm F2.8 EX APO DC OS HSM', #30
497             '48 3C 50 A0 30 40 4B 02' => 'Sigma 50-500mm F4-6.3 EX APO RF HSM',
498             '9F 37 50 A0 34 40 4B 0E' => 'Sigma 50-500mm F4.5-6.3 DG OS HSM', #16
499             '26 3C 54 80 30 3C 1C 06' => 'Sigma 55-200mm F4-5.6 DC',
500             '7A 3B 53 80 30 3C 4B 06' => 'Sigma 55-200mm F4-5.6 DC HSM',
501             '48 54 5C 80 24 24 4B 02' => 'Sigma 70-200mm F2.8 EX APO IF HSM',
502             '7A 48 5C 80 24 24 4B 06' => 'Sigma 70-200mm F2.8 EX APO DG Macro HSM II',
503             'EE 48 5C 80 24 24 4B 06' => 'Sigma 70-200mm F2.8 EX APO DG Macro HSM II', #JD
504             '9C 48 5C 80 24 24 4B 0E' => 'Sigma 70-200mm F2.8 EX DG OS HSM', #Rolando Ruzic
505             'BB 48 5C 80 24 24 4B 4E' => 'Sigma 70-200mm F2.8 DG OS HSM | S', #forum13207
506             '02 46 5C 82 25 25 02 00' => 'Sigma 70-210mm F2.8 APO', #JD
507             '02 40 5C 82 2C 35 02 00' => 'Sigma APO 70-210mm F3.5-4.5',
508             '26 3C 5C 82 30 3C 1C 02' => 'Sigma 70-210mm F4-5.6 UC-II',
509             '02 3B 5C 82 30 3C 02 00' => 'Sigma Zoom-K 70-210mm F4-5.6', #30
510             '26 3C 5C 8E 30 3C 1C 02' => 'Sigma 70-300mm F4-5.6 DG Macro',
511             '56 3C 5C 8E 30 3C 1C 02' => 'Sigma 70-300mm F4-5.6 APO Macro Super II',
512             'E0 3C 5C 8E 30 3C 4B 06' => 'Sigma 70-300mm F4-5.6 APO DG Macro HSM', #22
513             'A3 3C 5C 8E 30 3C 4B 0E' => 'Sigma 70-300mm F4-5.6 DG OS',
514             '02 37 5E 8E 35 3D 02 00' => 'Sigma 75-300mm F4.5-5.6 APO',
515             '02 3A 5E 8E 32 3D 02 00' => 'Sigma 75-300mm F4.0-5.6',
516             '77 44 61 98 34 3C 7B 0E' => 'Sigma 80-400mm F4.5-5.6 EX OS',
517             '77 44 60 98 34 3C 7B 0E' => 'Sigma 80-400mm F4.5-5.6 APO DG D OS',
518             '48 48 68 8E 30 30 4B 02' => 'Sigma APO 100-300mm F4 EX IF HSM',
519             'F3 48 68 8E 30 30 4B 02' => 'Sigma APO 100-300mm F4 EX IF HSM',
520             '26 45 68 8E 34 42 1C 02' => 'Sigma 100-300mm F4.5-6.7 DL', #30
521             '48 54 6F 8E 24 24 4B 02' => 'Sigma APO 120-300mm F2.8 EX DG HSM',
522             '7A 54 6E 8E 24 24 4B 02' => 'Sigma APO 120-300mm F2.8 EX DG HSM',
523             '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
524             'CF 38 6E 98 34 3C 4B 0E' => 'Sigma APO 120-400mm F4.5-5.6 DG OS HSM',
525             'C3 34 68 98 38 40 4B 4E' => 'Sigma 100-400mm F5-6.3 DG OS HSM | C', #JR (017)
526             '8D 48 6E 8E 24 24 4B 0E' => 'Sigma 120-300mm F2.8 DG OS HSM Sports',
527             '26 44 73 98 34 3C 1C 02' => 'Sigma 135-400mm F4.5-5.6 APO Aspherical',
528             'CE 34 76 A0 38 40 4B 0E' => 'Sigma 150-500mm F5-6.3 DG OS APO HSM', #JD
529             '81 34 76 A6 38 40 4B 0E' => 'Sigma 150-600mm F5-6.3 DG OS HSM | S', #Jaap Voets
530             '82 34 76 A6 38 40 4B 0E' => 'Sigma 150-600mm F5-6.3 DG OS HSM | C',
531             'C4 4C 73 73 14 14 4B 46' => 'Sigma 135mm F1.8 DG HSM | A', #forum3833
532             '26 40 7B A0 34 40 1C 02' => 'Sigma APO 170-500mm F5-6.3 Aspherical RF',
533             'A7 49 80 A0 24 24 4B 06' => 'Sigma APO 200-500mm F2.8 EX DG',
534             '48 3C 8E B0 3C 3C 4B 02' => 'Sigma APO 300-800mm F5.6 EX DG HSM',
535             'D2 3C 8E B0 3C 3C 4B 02' => 'Sigma APO 300-800mm F5.6 EX DG HSM', #forum10942
536             #
537             '00 47 25 25 24 24 00 02' => 'Tamron SP AF 14mm f/2.8 Aspherical (IF) (69E)',
538             'C8 54 44 44 0D 0D DF 46' => 'Tamron SP 35mm f/1.4 Di USD (F045)', #IB
539             'E8 4C 44 44 14 14 DF 0E' => 'Tamron SP 35mm f/1.8 Di VC USD (F012)', #35
540             'E7 4C 4C 4C 14 14 DF 0E' => 'Tamron SP 45mm f/1.8 Di VC USD (F013)',
541             'F4 54 56 56 18 18 84 06' => 'Tamron SP AF 60mm f/2.0 Di II Macro 1:1 (G005)', #24
542             'E5 4C 62 62 14 14 C9 4E' => 'Tamron SP 85mm f/1.8 Di VC USD (F016)', #30
543             '1E 5D 64 64 20 20 13 00' => 'Tamron SP AF 90mm f/2.5 (52E)',
544             '20 5A 64 64 20 20 14 00' => 'Tamron SP AF 90mm f/2.5 Macro (152E)',
545             '22 53 64 64 24 24 E0 02' => 'Tamron SP AF 90mm f/2.8 Macro 1:1 (72E)',
546             '32 53 64 64 24 24 35 02' => 'Tamron SP AF 90mm f/2.8 [Di] Macro 1:1 (172E/272E)',
547             'F8 55 64 64 24 24 84 06' => 'Tamron SP AF 90mm f/2.8 Di Macro 1:1 (272NII)',
548             'F8 54 64 64 24 24 DF 06' => 'Tamron SP AF 90mm f/2.8 Di Macro 1:1 (272NII)',
549             'FE 54 64 64 24 24 DF 0E' => 'Tamron SP 90mm f/2.8 Di VC USD Macro 1:1 (F004)', #Jurgen Sahlberg
550             'E4 54 64 64 24 24 DF 0E' => 'Tamron SP 90mm f/2.8 Di VC USD Macro 1:1 (F017)', #Rolf Probst
551             '00 4C 7C 7C 2C 2C 00 02' => 'Tamron SP AF 180mm f/3.5 Di Model (B01)',
552             '21 56 8E 8E 24 24 14 00' => 'Tamron SP AF 300mm f/2.8 LD-IF (60E)',
553             '27 54 8E 8E 24 24 1D 02' => 'Tamron SP AF 300mm f/2.8 LD-IF (360E)',
554             'E1 40 19 36 2C 35 DF 4E' => 'Tamron 10-24mm f/3.5-4.5 Di II VC HLD (B023)',
555             'E1 40 19 36 2C 35 DF 0E' => 'Tamron 10-24mm f/3.5-4.5 Di II VC HLD (B023)', #30
556             'F6 3F 18 37 2C 34 84 06' => 'Tamron SP AF 10-24mm f/3.5-4.5 Di II LD Aspherical (IF) (B001)',
557             '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
558             '00 36 1C 2D 34 3C 00 06' => 'Tamron SP AF 11-18mm f/4.5-5.6 Di II LD Aspherical (IF) (A13)',
559             'E9 48 27 3E 24 24 DF 0E' => 'Tamron SP 15-30mm f/2.8 Di VC USD (A012)', #IB
560             'CA 48 27 3E 24 24 DF 4E' => 'Tamron SP 15-30mm f/2.8 Di VC USD G2 (A041)', #IB
561             '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)
562             '07 46 2B 44 24 30 03 02' => 'Tamron SP AF 17-35mm f/2.8-4 Di LD Aspherical (IF) (A05)',
563             'CB 3C 2B 44 24 31 DF 46' => 'Tamron 17-35mm f/2.8-4 Di OSD (A037)', #IB
564             '00 53 2B 50 24 24 00 06' => 'Tamron SP AF 17-50mm f/2.8 XR Di II LD Aspherical (IF) (A16)', #PH
565             '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)
566             '00 54 2B 50 24 24 00 06' => 'Tamron SP AF 17-50mm f/2.8 XR Di II LD Aspherical (IF) (A16NII)',
567             '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
568             'F3 54 2B 50 24 24 84 0E' => 'Tamron SP AF 17-50mm f/2.8 XR Di II VC LD Aspherical (IF) (B005)',
569             '00 3F 2D 80 2B 40 00 06' => 'Tamron AF 18-200mm f/3.5-6.3 XR Di II LD Aspherical (IF) (A14)',
570             '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)',
571             'EC 3E 3C 8E 2C 40 DF 0E' => 'Tamron 28-300mm f/3.5-6.3 Di VC PZD A010', #30
572             '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
573             '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)
574             '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)
575             '00 40 2D 88 2C 40 62 06' => 'Tamron AF 18-250mm f/3.5-6.3 Di II LD Aspherical (IF) Macro (A18)',
576             '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
577             '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)',
578             'F0 3F 2D 8A 2C 40 DF 0E' => 'Tamron AF 18-270mm f/3.5-6.3 Di II VC PZD (B008)',
579             'E0 40 2D 98 2C 41 DF 0E' => 'Tamron 18-400mm f/3.5-6.3 Di II VC HLD (B028)', #github385 (D90)
580             '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)
581             '07 40 2F 44 2C 34 03 02' => 'Tamron AF 19-35mm f/3.5-4.5 (A10)',
582             '07 40 30 45 2D 35 03 02.1' => 'Tamron AF 19-35mm f/3.5-4.5 (A10)',
583             '00 49 30 48 22 2B 00 02' => 'Tamron SP AF 20-40mm f/2.7-3.5 (166D)',
584             '0E 4A 31 48 23 2D 0E 02' => 'Tamron SP AF 20-40mm f/2.7-3.5 (166D)',
585             'FE 48 37 5C 24 24 DF 0E' => 'Tamron SP 24-70mm f/2.8 Di VC USD (A007)', #24
586             'CE 47 37 5C 25 25 DF 4E' => 'Tamron SP 24-70mm f/2.8 Di VC USD G2 (A032)', #forum9110
587             'CE 00 37 5C 25 25 DF 4E' => 'Tamron SP 24-70mm f/2.8 Di VC USD G2 (A032)', #github345
588             '45 41 37 72 2C 3C 48 02' => 'Tamron SP AF 24-135mm f/3.5-5.6 AD Aspherical (IF) Macro (190D)',
589             '33 54 3C 5E 24 24 62 02' => 'Tamron SP AF 28-75mm f/2.8 XR Di LD Aspherical (IF) Macro (A09)',
590             'FA 54 3C 5E 24 24 84 06' => 'Tamron SP AF 28-75mm f/2.8 XR Di LD Aspherical (IF) Macro (A09NII)', #JD
591             'FA 54 3C 5E 24 24 DF 06' => 'Tamron SP AF 28-75mm f/2.8 XR Di LD Aspherical (IF) Macro (A09NII)',
592             '10 3D 3C 60 2C 3C D2 02' => 'Tamron AF 28-80mm f/3.5-5.6 Aspherical (177D)',
593             '45 3D 3C 60 2C 3C 48 02' => 'Tamron AF 28-80mm f/3.5-5.6 Aspherical (177D)',
594             '00 48 3C 6A 24 24 00 02' => 'Tamron SP AF 28-105mm f/2.8 LD Aspherical IF (176D)',
595             '4D 3E 3C 80 2E 3C 62 02' => 'Tamron AF 28-200mm f/3.8-5.6 XR Aspherical (IF) Macro (A03N)',
596             '0B 3E 3D 7F 2F 3D 0E 00' => 'Tamron AF 28-200mm f/3.8-5.6 (71D)',
597             '0B 3E 3D 7F 2F 3D 0E 02' => 'Tamron AF 28-200mm f/3.8-5.6D (171D)',
598             '12 3D 3C 80 2E 3C DF 02' => 'Tamron AF 28-200mm f/3.8-5.6 AF Aspherical LD (IF) (271D)',
599             '4D 41 3C 8E 2B 40 62 02' => 'Tamron AF 28-300mm f/3.5-6.3 XR Di LD Aspherical (IF) (A061)',
600             '4D 41 3C 8E 2C 40 62 02' => 'Tamron AF 28-300mm f/3.5-6.3 XR LD Aspherical (IF) (185D)',
601             '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)',
602             'C9 3C 44 76 25 31 DF 4E' => 'Tamron 35-150mm f/2.8-4 Di VC OSD (A043)', #30
603             '00 47 53 80 30 3C 00 06' => 'Tamron AF 55-200mm f/4-5.6 Di II LD (A15)',
604             'F7 53 5C 80 24 24 84 06' => 'Tamron SP AF 70-200mm f/2.8 Di LD (IF) Macro (A001)',
605             'FE 53 5C 80 24 24 84 06' => 'Tamron SP AF 70-200mm f/2.8 Di LD (IF) Macro (A001)',
606             'F7 53 5C 80 24 24 40 06' => 'Tamron SP AF 70-200mm f/2.8 Di LD (IF) Macro (A001)',
607             # 'FE 54 5C 80 24 24 DF 0E' => 'Tamron SP AF 70-200mm f/2.8 Di VC USD (A009)',
608             'FE 54 5C 80 24 24 DF 0E' => 'Tamron SP 70-200mm f/2.8 Di VC USD (A009)', #NJ
609             'E2 47 5C 80 24 24 DF 4E' => 'Tamron SP 70-200mm f/2.8 Di VC USD G2 (A025)', #forum9549
610             '69 48 5C 8E 30 3C 6F 02' => 'Tamron AF 70-300mm f/4-5.6 LD Macro 1:2 (572D/772D)',
611             '69 47 5C 8E 30 3C 00 02' => 'Tamron AF 70-300mm f/4-5.6 Di LD Macro 1:2 (A17N)',
612             '00 48 5C 8E 30 3C 00 06' => 'Tamron AF 70-300mm f/4-5.6 Di LD Macro 1:2 (A17NII)', #JD
613             'F1 47 5C 8E 30 3C DF 0E' => 'Tamron SP 70-300mm f/4-5.6 Di VC USD (A005)',
614             'CF 47 5C 8E 31 3D DF 0E' => 'Tamron SP 70-300mm f/4-5.6 Di VC USD (A030)', #forum9773
615             'CC 44 68 98 34 41 DF 0E' => 'Tamron 100-400mm f/4.5-6.3 Di VC USD', #30
616             'EB 40 76 A6 38 40 DF 0E' => 'Tamron SP AF 150-600mm f/5-6.3 VC USD (A011)',
617             'E3 40 76 A6 38 40 DF 4E' => 'Tamron SP 150-600mm f/5-6.3 Di VC USD G2', #30
618             'E3 40 76 A6 38 40 DF 0E' => 'Tamron SP 150-600mm f/5-6.3 Di VC USD G2 (A022)', #forum3833
619             '20 3C 80 98 3D 3D 1E 02' => 'Tamron AF 200-400mm f/5.6 LD IF (75D)',
620             '00 3E 80 A0 38 3F 00 02' => 'Tamron SP AF 200-500mm f/5-6.3 Di LD (IF) (A08)',
621             '00 3F 80 A0 38 3F 00 02' => 'Tamron SP AF 200-500mm f/5-6.3 Di (A08)',
622             #
623             '00 40 2B 2B 2C 2C 00 02' => 'Tokina AT-X 17 AF PRO (AF 17mm f/3.5)',
624             '00 47 44 44 24 24 00 06' => 'Tokina AT-X M35 PRO DX (AF 35mm f/2.8 Macro)',
625             '8D 54 68 68 24 24 87 02' => 'Tokina AT-X PRO 100mm F2.8 D Macro', #30
626             '00 54 68 68 24 24 00 02' => 'Tokina AT-X M100 AF PRO D (AF 100mm f/2.8 Macro)',
627             '27 48 8E 8E 30 30 1D 02' => 'Tokina AT-X 304 AF (AF 300mm f/4.0)',
628             '00 54 8E 8E 24 24 00 02' => 'Tokina AT-X 300 AF PRO (AF 300mm f/2.8)',
629             '12 3B 98 98 3D 3D 09 00' => 'Tokina AT-X 400 AF SD (AF 400mm f/5.6)',
630             '00 40 18 2B 2C 34 00 06' => 'Tokina AT-X 107 AF DX Fisheye (AF 10-17mm f/3.5-4.5)',
631             '00 48 1C 29 24 24 00 06' => 'Tokina AT-X 116 PRO DX (AF 11-16mm f/2.8)',
632             '7A 48 1C 29 24 24 7E 06' => 'Tokina AT-X 116 PRO DX II (AF 11-16mm f/2.8)',
633             '80 48 1C 29 24 24 7A 06' => 'Tokina atx-i 11-16mm F2.8 CF', #exiv2 issue 1078
634             '7A 48 1C 30 24 24 7E 06' => 'Tokina AT-X 11-20 F2.8 PRO DX (AF 11-20mm f/2.8)',
635             '8B 48 1C 30 24 24 85 06' => 'Tokina AT-X 11-20 F2.8 PRO DX (AF 11-20mm f/2.8)', #forum12687
636             '00 3C 1F 37 30 30 00 06' => 'Tokina AT-X 124 AF PRO DX (AF 12-24mm f/4)',
637             '7A 3C 1F 37 30 30 7E 06.2' => 'Tokina AT-X 124 AF PRO DX II (AF 12-24mm f/4)',
638             '7A 3C 1F 3C 30 30 7E 06' => 'Tokina AT-X 12-28 PRO DX (AF 12-28mm f/4)',
639             '00 48 29 3C 24 24 00 06' => 'Tokina AT-X 16-28 AF PRO FX (AF 16-28mm f/2.8)',
640             '00 48 29 50 24 24 00 06' => 'Tokina AT-X 165 PRO DX (AF 16-50mm f/2.8)',
641             '00 40 2A 72 2C 3C 00 06' => 'Tokina AT-X 16.5-135 DX (AF 16.5-135mm F3.5-5.6)',
642             '00 3C 2B 44 30 30 00 06' => 'Tokina AT-X 17-35 F4 PRO FX (AF 17-35mm f/4)',
643             '2F 40 30 44 2C 34 29 02.2' => 'Tokina AF 193 (AF 19-35mm f/3.5-4.5)',
644             '2F 48 30 44 24 24 29 02.2' => 'Tokina AT-X 235 AF PRO (AF 20-35mm f/2.8)',
645             '2F 40 30 44 2C 34 29 02.1' => 'Tokina AF 235 II (AF 20-35mm f/3.5-4.5)',
646             '00 48 37 5C 24 24 00 06' => 'Tokina AT-X 24-70 F2.8 PRO FX (AF 24-70mm f/2.8)',
647             '00 40 37 80 2C 3C 00 02' => 'Tokina AT-X 242 AF (AF 24-200mm f/3.5-5.6)',
648             '25 48 3C 5C 24 24 1B 02.1' => 'Tokina AT-X 270 AF PRO II (AF 28-70mm f/2.6-2.8)',
649             '25 48 3C 5C 24 24 1B 02.2' => 'Tokina AT-X 287 AF PRO SV (AF 28-70mm f/2.8)',
650             '07 48 3C 5C 24 24 03 00' => 'Tokina AT-X 287 AF (AF 28-70mm f/2.8)',
651             '07 47 3C 5C 25 35 03 00' => 'Tokina AF 287 SD (AF 28-70mm f/2.8-4.5)',
652             '07 40 3C 5C 2C 35 03 00' => 'Tokina AF 270 II (AF 28-70mm f/3.5-4.5)',
653             '00 48 3C 60 24 24 00 02' => 'Tokina AT-X 280 AF PRO (AF 28-80mm f/2.8)',
654             '25 44 44 8E 34 42 1B 02' => 'Tokina AF 353 (AF 35-300mm f/4.5-6.7)',
655             '00 48 50 72 24 24 00 06' => 'Tokina AT-X 535 PRO DX (AF 50-135mm f/2.8)',
656             '00 3C 5C 80 30 30 00 0E' => 'Tokina AT-X 70-200 F4 FX VCM-S (AF 70-200mm f/4)',
657             '00 48 5C 80 30 30 00 0E' => 'Tokina AT-X 70-200 F4 FX VCM-S (AF 70-200mm f/4)',
658             '12 44 5E 8E 34 3C 09 00' => 'Tokina AF 730 (AF 75-300mm F4.5-5.6)',
659             '14 54 60 80 24 24 0B 00' => 'Tokina AT-X 828 AF (AF 80-200mm f/2.8)',
660             '24 54 60 80 24 24 1A 02' => 'Tokina AT-X 828 AF PRO (AF 80-200mm f/2.8)',
661             '24 44 60 98 34 3C 1A 02' => 'Tokina AT-X 840 AF-II (AF 80-400mm f/4.5-5.6)',
662             '00 44 60 98 34 3C 00 02' => 'Tokina AT-X 840 D (AF 80-400mm f/4.5-5.6)',
663             '14 48 68 8E 30 30 0B 00' => 'Tokina AT-X 340 AF (AF 100-300mm f/4)',
664             '8C 48 29 3C 24 24 86 06' => 'Tokina opera 16-28mm F2.8 FF', #30
665             #
666             '06 3F 68 68 2C 2C 06 00' => 'Cosina AF 100mm F3.5 Macro',
667             '07 36 3D 5F 2C 3C 03 00' => 'Cosina AF Zoom 28-80mm F3.5-5.6 MC Macro',
668             '07 46 3D 6A 25 2F 03 00' => 'Cosina AF Zoom 28-105mm F2.8-3.8 MC',
669             '12 36 5C 81 35 3D 09 00' => 'Cosina AF Zoom 70-210mm F4.5-5.6 MC Macro',
670             '12 39 5C 8E 34 3D 08 02' => 'Cosina AF Zoom 70-300mm F4.5-5.6 MC Macro',
671             '12 3B 68 8D 3D 43 09 02' => 'Cosina AF Zoom 100-300mm F5.6-6.7 MC Macro',
672             #
673             '12 38 69 97 35 42 09 02' => 'Promaster Spectrum 7 100-400mm F4.5-6.7',
674             #
675             '00 40 31 31 2C 2C 00 00' => 'Voigtlander Color Skopar 20mm F3.5 SLII Aspherical',
676             '00 48 3C 3C 24 24 00 00' => 'Voigtlander Color Skopar 28mm F2.8 SL II',
677             '00 54 48 48 18 18 00 00' => 'Voigtlander Ultron 40mm F2 SLII Aspherical',
678             '00 54 55 55 0C 0C 00 00' => 'Voigtlander Nokton 58mm F1.4 SLII',
679             '00 40 64 64 2C 2C 00 00' => 'Voigtlander APO-Lanthar 90mm F3.5 SLII Close Focus',
680             '07 40 30 45 2D 35 03 02.2' => 'Voigtlander Ultragon 19-35mm F3.5-4.5 VMV', #NJ
681             '71 48 64 64 24 24 00 00' => 'Voigtlander APO-Skopar 90mm F2.8 SL IIs', #30
682             'FD 00 50 50 18 18 DF 00' => 'Voigtlander APO-Lanthar 50mm F2 Aspherical', #35
683             'FD 00 44 44 18 18 DF 00' => 'Voigtlander APO-Lanthar 35mm F2', #30
684             'FD 00 59 59 18 18 DF 00' => 'Voigtlander Macro APO-Lanthar 65mm F2', #30
685             'FD 00 48 48 07 07 DF 00' => 'Voigtlander Nokton 40mm F1.2 Aspherical', #30
686             'FD 00 3C 3C 18 18 DF 00' => 'Voigtlander APO-Lanthar 28mm F2 Aspherical', #30
687              
688             '00 40 2D 2D 2C 2C 00 00' => 'Carl Zeiss Distagon T* 3.5/18 ZF.2',
689             '00 48 27 27 24 24 00 00' => 'Carl Zeiss Distagon T* 2.8/15 ZF.2', #MykytaKozlov
690             '00 48 32 32 24 24 00 00' => 'Carl Zeiss Distagon T* 2.8/21 ZF.2',
691             '00 54 38 38 18 18 00 00' => 'Carl Zeiss Distagon T* 2/25 ZF.2',
692             '00 54 3C 3C 18 18 00 00' => 'Carl Zeiss Distagon T* 2/28 ZF.2',
693             '00 54 44 44 0C 0C 00 00' => 'Carl Zeiss Distagon T* 1.4/35 ZF.2',
694             '00 54 44 44 18 18 00 00' => 'Carl Zeiss Distagon T* 2/35 ZF.2',
695             '00 54 50 50 0C 0C 00 00' => 'Carl Zeiss Planar T* 1.4/50 ZF.2',
696             '00 54 50 50 18 18 00 00' => 'Carl Zeiss Makro-Planar T* 2/50 ZF.2',
697             '00 54 62 62 0C 0C 00 00' => 'Carl Zeiss Planar T* 1.4/85 ZF.2',
698             '00 54 68 68 18 18 00 00' => 'Carl Zeiss Makro-Planar T* 2/100 ZF.2',
699             '00 54 72 72 18 18 00 00' => 'Carl Zeiss Apo Sonnar T* 2/135 ZF.2',
700             '02 54 3C 3C 0C 0C 00 00' => 'Zeiss Otus 1.4/28 ZF.2', #30
701             '00 54 53 53 0C 0C 00 00' => 'Zeiss Otus 1.4/55', #IB
702             '01 54 62 62 0C 0C 00 00' => 'Zeiss Otus 1.4/85',
703             '03 54 68 68 0C 0C 00 00' => 'Zeiss Otus 1.4/100', #IB
704             '52 54 44 44 18 18 00 00' => 'Zeiss Milvus 35mm f/2',
705             '53 54 50 50 0C 0C 00 00' => 'Zeiss Milvus 50mm f/1.4', #IB
706             '54 54 50 50 18 18 00 00' => 'Zeiss Milvus 50mm f/2 Macro',
707             '55 54 62 62 0C 0C 00 00' => 'Zeiss Milvus 85mm f/1.4', #IB
708             '56 54 68 68 18 18 00 00' => 'Zeiss Milvus 100mm f/2 Macro',
709             #
710             '00 54 56 56 30 30 00 00' => 'Coastal Optical Systems 60mm 1:4 UV-VIS-IR Macro Apo',
711             #
712             'BF 4E 26 26 1E 1E 01 04' => 'Irix 15mm f/2.4 Firefly', #30 (guessing the Blackstone version may be the same ID - PH)
713             'BF 3C 1B 1B 30 30 01 04' => 'Irix 11mm f/4 Firefly', #30 (guessing the Blackstone version may be the same ID - PH)
714             #
715             '4A 40 11 11 2C 0C 4D 02' => 'Samyang 8mm f/3.5 Fish-Eye CS',
716             '4A 48 24 24 24 0C 4D 02.1' => 'Samyang 10mm f/2.8 ED AS NCS CS',
717             '4A 48 1E 1E 24 0C 4D 02' => 'Samyang 12mm f/2.8 ED AS NCS Fish-Eye', #Jurgen Sahlberg
718             '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
719             '4A 4C 24 24 1E 6C 4D 06' => 'Samyang 14mm f/2.4 Premium',
720             '4A 54 29 29 18 0C 4D 02' => 'Samyang 16mm f/2.0 ED AS UMC CS', #Jon Bloom (by email)
721             '4A 60 36 36 0C 0C 4D 02' => 'Samyang 24mm f/1.4 ED AS UMC',
722             '4A 60 44 44 0C 0C 4D 02' => 'Samyang 35mm f/1.4 AS UMC',
723             '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
724             #
725             '9A 4C 50 50 14 14 9C 06' => 'Yongnuo YN50mm F1.8N',
726             '9F 48 48 48 24 24 A1 06' => 'Yongnuo YN40mm F2.8N', #30
727             '9F 54 68 68 18 18 A2 06' => 'Yongnuo YN100mm F2N', #30
728             '9F 4C 44 44 18 18 A1 06' => 'Yongnuo YN35mm F2', #30
729             '9F 4D 50 50 14 14 A0 06' => 'Yongnuo YN50mm F1.8N', #30
730             #
731             '02 40 44 5C 2C 34 02 00' => 'Exakta AF 35-70mm 1:3.5-4.5 MC',
732             #
733             '07 3E 30 43 2D 35 03 00' => 'Soligor AF Zoom 19-35mm 1:3.5-4.5 MC',
734             '03 43 5C 81 35 35 02 00' => 'Soligor AF C/D Zoom UMCS 70-210mm 1:4.5',
735             '12 4A 5C 81 31 3D 09 00' => 'Soligor AF C/D Auto Zoom+Macro 70-210mm 1:4-5.6 UMCS',
736             '12 36 69 97 35 42 09 00' => 'Soligor AF Zoom 100-400mm 1:4.5-6.7 MC',
737             #
738             '00 00 00 00 00 00 00 01' => 'Manual Lens No CPU',
739             #
740             '00 00 48 48 53 53 00 01' => 'Loreo 40mm F11-22 3D Lens in a Cap 9005', #PH
741             '00 47 10 10 24 24 00 00' => 'Fisheye Nikkor 8mm f/2.8 AiS',
742             '00 47 3C 3C 24 24 00 00' => 'Nikkor 28mm f/2.8 AiS', #35
743             # '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)
744             '00 57 50 50 14 14 00 00' => 'Nikkor 50mm f/1.8 AI', #35
745             '00 48 50 50 18 18 00 00' => 'Nikkor H 50mm f/2',
746             '00 48 68 68 24 24 00 00' => 'Series E 100mm f/2.8',
747             '00 4C 6A 6A 20 20 00 00' => 'Nikkor 105mm f/2.5 AiS',
748             '00 48 80 80 30 30 00 00' => 'Nikkor 200mm f/4 AiS',
749             '00 40 11 11 2C 2C 00 00' => 'Samyang 8mm f/3.5 Fish-Eye',
750             '00 58 64 64 20 20 00 00' => 'Soligor C/D Macro MC 90mm f/2.5',
751             '4A 58 30 30 14 0C 4D 02' => 'Rokinon 20mm f/1.8 ED AS UMC', #30
752             #
753             'A0 56 44 44 14 14 A2 06' => 'Sony FE 35mm F1.8', #IB (Techart adapter)
754             'A0 37 5C 8E 34 3C A2 06' => 'Sony FE 70-300mm F4.5-5.6 G OSS', #IB (Techart adapter)
755             );
756              
757             # text encoding used in LocationInfo (ref PH)
758             %nikonTextEncoding = (
759             0 => 'n/a',
760             1 => 'UTF8',
761             # UTF16 is a guess here: it could also be Unicode or JIS,
762             # but I chose UTF16 due to the similarity with the QuickTime stringEncoding
763             2 => 'UTF16',
764             );
765              
766             # flash firmware decoding (ref JD)
767             my %flashFirmware = (
768             '0 0' => 'n/a',
769             '1 1' => '1.01 (SB-800 or Metz 58 AF-1)',
770             '1 3' => '1.03 (SB-800)',
771             '2 1' => '2.01 (SB-800)',
772             '2 4' => '2.04 (SB-600)',
773             '2 5' => '2.05 (SB-600)',
774             '3 1' => '3.01 (SU-800 Remote Commander)',
775             '4 1' => '4.01 (SB-400)',
776             '4 2' => '4.02 (SB-400)',
777             '4 4' => '4.04 (SB-400)',
778             '5 1' => '5.01 (SB-900)',
779             '5 2' => '5.02 (SB-900)',
780             '6 1' => '6.01 (SB-700)', #https://exiftool.org/forum/index.php/topic,5034.0.html
781             '7 1' => '7.01 (SB-910)', #PH
782             '14 3' => '14.03 (SB-5000)', #28
783             OTHER => sub {
784             my ($val, $inv) = @_;
785             return sprintf('%d.%.2d (Unknown model)', split(' ', $val)) unless $inv;
786             return "$1 $2" if $val =~ /(\d+)\.(\d+)/;
787             return '0 0';
788             },
789             );
790              
791             # flash Guide Number (GN) distance settings (ref 28)
792             my %flashGNDistance = (
793             0 => 0, 19 => '2.8 m',
794             1 => '0.1 m', 20 => '3.2 m',
795             2 => '0.2 m', 21 => '3.6 m',
796             3 => '0.3 m', 22 => '4.0 m',
797             4 => '0.4 m', 23 => '4.5 m',
798             5 => '0.5 m', 24 => '5.0 m',
799             6 => '0.6 m', 25 => '5.6 m',
800             7 => '0.7 m', 26 => '6.3 m',
801             8 => '0.8 m', 27 => '7.1 m',
802             9 => '0.9 m', 28 => '8.0 m',
803             10 => '1.0 m', 29 => '9.0 m',
804             11 => '1.1 m', 30 => '10.0 m',
805             12 => '1.3 m', 31 => '11.0 m',
806             13 => '1.4 m', 32 => '13.0 m',
807             14 => '1.6 m', 33 => '14.0 m',
808             15 => '1.8 m', 34 => '16.0 m',
809             16 => '2.0 m', 35 => '18.0 m',
810             17 => '2.2 m', 36 => '20.0 m',
811             18 => '2.5 m', 255 => 'n/a',
812             );
813              
814             # flash color filter values (ref 28)
815             my %flashColorFilter = (
816             0x00 => 'None',
817             1 => 'FL-GL1 or SZ-2FL Fluorescent', # (green) (SZ model ref PH)
818             2 => 'FL-GL2',
819             9 => 'TN-A1 or SZ-2TN Incandescent', # (orange) (SZ model ref PH)
820             10 => 'TN-A2',
821             65 => 'Red',
822             66 => 'Blue',
823             67 => 'Yellow',
824             68 => 'Amber',
825             128 => 'Incandescent', #SZ-4TN Incandescent
826             );
827              
828             # flash control mode values (ref JD)
829             my %flashControlMode = (
830             0x00 => 'Off',
831             0x01 => 'iTTL-BL',
832             0x02 => 'iTTL',
833             0x03 => 'Auto Aperture',
834             0x04 => 'Automatic', #28
835             0x05 => 'GN (distance priority)', #28 (Guide Number, but called "GN" in manual)
836             0x06 => 'Manual',
837             0x07 => 'Repeating Flash',
838             );
839              
840             my %activeDLightingZ7 = (
841             0 => 'Off',
842             2 => 'Low',
843             3 => 'Normal',
844             4 => 'High',
845             5 => 'Extra High',
846             );
847              
848             my %aFAreaModeCD = ( #contrast detect modes
849             0 => 'Contrast-detect', # (D3)
850             1 => 'Contrast-detect (normal area)', # (D90/D5000)
851             # (D90 and D5000 give value of 2 when set to 'Face Priority' and
852             # 'Subject Tracking', but I didn't have a face to shoot at or a
853             # moving subject to track so perhaps this value changes dynamically)
854             2 => 'Contrast-detect (wide area)', # (D90/D5000)
855             3 => 'Contrast-detect (face priority)', # (ViewNX)
856             4 => 'Contrast-detect (subject tracking)', # (ViewNX)
857             128 => 'Single', #PH (1V3)
858             129 => 'Auto (41 points)', #PH (NC)
859             130 => 'Subject Tracking (41 points)', #PH (NC)
860             131 => 'Face Priority (41 points)', #PH (NC)
861             192 => 'Pinpoint', #PH (Z7)
862             193 => 'Single', #PH (Z7)
863             194 => 'Dynamic', #PH (Z7)
864             195 => 'Wide (S)', #PH (Z7)
865             196 => 'Wide (L)', #PH (Z7)
866             197 => 'Auto', #PH (Z7)
867             198 => 'Auto (People)', #28 (Z7) #if no faces are detected, will record as 'Auto'. Camera setting recorded in AFAreaMode field in the MakerNotes area
868             199 => 'Auto (Animal)', #28 (Z7) #if no animals are detected, will record as 'Auto'. Camera setting recorded in AFAreaMode field in the MakerNotes area
869             200 => 'Normal-area AF', #28 (D6)
870             201 => 'Wide-area AF', #28 (D6)
871             202 => 'Face-priority AF', #28 (D6)
872             203 => 'Subject-tracking AF', #28 (D6)
873             204 => 'Dynamic Area (S)', #28 (Z9)
874             205 => 'Dynamic Area (M)', #28 (Z9)
875             206 => 'Dynamic Area (L)', #28 (Z9)
876             207 => '3D-tracking', #28 (Z9)
877             208 => 'Wide-Area (C1/C2)', #28 (Z8, Z9)
878             );
879              
880             my %aFAreaModePD = ( #phase detect modes
881             0 => 'Single Area', # (called "Single Point" in manual - PH)
882             1 => 'Dynamic Area', #PH
883             2 => 'Dynamic Area (closest subject)', #PH
884             3 => 'Group Dynamic', #PH
885             4 => 'Dynamic Area (9 points)', #JD/28
886             5 => 'Dynamic Area (21 points)', #28
887             6 => 'Dynamic Area (51 points)', #28
888             7 => 'Dynamic Area (51 points, 3D-tracking)', #PH/28
889             8 => 'Auto-area',
890             9 => 'Dynamic Area (3D-tracking)', #PH (D5000 "3D-tracking (11 points)")
891             10 => 'Single Area (wide)', #PH
892             11 => 'Dynamic Area (wide)', #PH
893             12 => 'Dynamic Area (wide, 3D-tracking)', #PH
894             13 => 'Group Area', #PH
895             14 => 'Dynamic Area (25 points)', #PH
896             15 => 'Dynamic Area (72 points)', #PH
897             16 => 'Group Area (HL)', #28
898             17 => 'Group Area (VL)', #28
899             18 => 'Dynamic Area (49 points)', #28
900             128 => 'Single', #PH (1J1,1J2,1J3,1J4,1S1,1S2,1V2,1V3)
901             129 => 'Auto (41 points)', #PH (1J1,1J2,1J3,1J4,1S1,1S2,1V1,1V2,1V3,AW1)
902             130 => 'Subject Tracking (41 points)', #PH (1J1,1J4,1J3)
903             131 => 'Face Priority (41 points)', #PH (1J1,1J3,1S1,1V2,AW1)
904             # 134 - seen for 1V1[PhaseDetectAF=0] (PH)
905             # 135 - seen for 1J2[PhaseDetectAF=4] (PH)
906             192 => 'Pinpoint', #PH (NC)
907             193 => 'Single', #PH (NC)
908             194 => 'Dynamic', #28 (Z7)
909             195 => 'Wide (S)', #PH (NC)
910             196 => 'Wide (L)', #PH (NC)
911             197 => 'Auto', #PH (NC)
912             199 => 'Auto', #28 (Z7) Z7 has also been observed to record 197 for Auto-area (same camera, different firmware versions, early production model)
913             );
914              
915             my %aFAreaModeZ9 = (
916             0 => 'Pinpoint',
917             1 => 'Single',
918             2 => 'Dynamic',
919             3 => 'Wide (S)',
920             4 => 'Wide (L)',
921             5 => '3D',
922             6 => 'Auto',
923             11 => 'Subject Tracking',
924             12 => 'Wide (C1)',
925             13 => 'Wide (C2)',
926             );
927              
928             my %aFDetectionMethod = (
929             0 => 'Phase Detect', #thru viewfinder
930             1 => 'Contrast Detect', #LiveView
931             2 => 'Hybrid', #Z-series and D780
932             );
933              
934              
935             my %banksZ9 = (
936             0 => 'A',
937             1 => 'B',
938             2 => 'C',
939             3 => 'D',
940             );
941              
942             my %bracketIncrementZ9 = (
943             0 => '0.3',
944             1 => '0.5',
945             2 => '0.7',
946             3 => '1.0',
947             4 => '2.0',
948             5 => '3.0',
949             6 => '1.3',
950             7 => '1.5',
951             8 => '1.7',
952             9 => '2.3',
953             10 => '2.5',
954             11 => '2.7',
955             );
956              
957             my %bracketSetZ9 = (
958             0 => 'AE/Flash',
959             1 => 'AE',
960             2 => 'Flash',
961             3 => 'White Balance',
962             4 => 'Active-D Lighting',
963             );
964              
965             my %bracketProgramZ9 = (
966             0 => 'Disabled',
967             2 => '2F',
968             3 => '3F',
969             4 => '4F',
970             5 => '5F',
971             7 => '7F',
972             9 => '9F',
973             );
974              
975             my %dialsFrameAdvanceZoomPositionZ9 = (
976             0 => 'Hold',
977             1 => 'Focus Point',
978             2 => 'Face Priority',
979             );
980              
981             my %dynamicAfAreaModesZ9 = (
982             0 => 'Small',
983             1 => 'Medium',
984             2 => 'Large',
985             );
986              
987             my %flashControlModeZ7 = (
988             0 => 'TTL',
989             1 => 'Auto External Flash',
990             2 => 'GN (distance priority)',
991             3 => 'Manual',
992             4 => 'Repeating Flash',
993             );
994              
995             my %flashRemoteControlZ7 = (
996             0 => 'Group',
997             1 => 'Quick Wireless',
998             2 => 'Remote Repeating',
999             );
1000              
1001             my %flashWirelessOptionZ7 = (
1002             0 => 'Off',
1003             1 => 'Optical AWL',
1004             2 => 'Optical/Radio AWL',
1005             3 => 'Radio AWL',
1006             );
1007              
1008             my %focusModeZ7 = (
1009             0 => 'Manual',
1010             1 => 'AF-S',
1011             2 => 'AF-C',
1012             4 => 'AF-F', # full frame
1013             );
1014              
1015             my %hDMIOutputResolutionZ9 = (
1016             0 => 'Auto',
1017             1 => '4320p',
1018             2 => '2160p',
1019             3 => '1080p',
1020             4 => '1080i',
1021             5 => '720p',
1022             #6 => '576p',
1023             #7 => '480p',
1024             );
1025              
1026             my %hdrLevelZ8 = (
1027             0 => 'Auto',
1028             1 => 'Extra High',
1029             2 => 'High',
1030             3 => 'Normal',
1031             4 => 'Low',
1032             );
1033              
1034             my %highFrameRateZ9 = (
1035             0 => 'Off',
1036             1 => 'CH',
1037             2 => 'CH*', #28 (Z6III)
1038             3 => 'C30',
1039             5 => 'C60',
1040             4 => 'C120',
1041             6 => 'C15',
1042             );
1043              
1044             my %imageAreaD6 = (
1045             0 => 'FX (36x24)',
1046             1 => 'DX (24x16)',
1047             2 => '5:4 (30x24)',
1048             3 => '1.2x (30x20)',
1049             4 => '1:1 (24x24)',
1050             6 => '16:9',
1051             );
1052              
1053             my %imageAreaZ9 = (
1054             0 => 'FX',
1055             1 => 'DX',
1056             4 => '16:9',
1057             8 => '1:1',
1058             );
1059              
1060             my %imageAreaZ9b = (
1061             0 => 'FX',
1062             1 => 'DX',
1063             );
1064              
1065             my %infoZSeries = (
1066             Condition => '$$self{Model} =~ /^NIKON Z (30|5|50|6|6_2|7|7_2|8|f|fc|9)\b/i or $$self{Model} =~ /^NIKON Z(5_2|50_2|6_3)\b/i', #no space after 'Nikon Z' on models from Oct 2023
1067             Notes => 'Z Series cameras thru July 2025',
1068             );
1069              
1070             my %iSOAutoHiLimitZ6III = ( #28
1071             5 => 'ISO 200',
1072             6 => 'ISO 250',
1073             7 => 'ISO 320',
1074             8 => 'ISO 400',
1075             9 => 'ISO 500',
1076             10 => 'ISO 640',
1077             11 => 'ISO 800',
1078             12 => 'ISO 1000',
1079             13 => 'ISO 1250',
1080             14 => 'ISO 1600',
1081             15 => 'ISO 2000',
1082             16 => 'ISO 2500',
1083             17 => 'ISO 3200',
1084             18 => 'ISO 4000',
1085             19 => 'ISO 5000',
1086             20 => 'ISO 6400',
1087             21 => 'ISO 8000',
1088             22 => 'ISO 10000',
1089             23 => 'ISO 12800',
1090             24 => 'ISO 16000',
1091             25 => 'ISO 20000',
1092             26 => 'ISO 25600',
1093             27 => 'ISO 32000',
1094             28 => 'ISO 40000',
1095             29 => 'ISO 51200',
1096             30 => 'ISO 64000',
1097             31 => 'ISO Hi 0.3',
1098             32 => 'ISO Hi 0.7',
1099             33 => 'ISO Hi 1.0',
1100             35 => 'ISO Hi 1.7',
1101             );
1102              
1103             my %isoAutoHiLimitZ7 = (
1104             Format => 'int16u',
1105             Unknown => 1,
1106             ValueConv => '($val-104)/8',
1107             ValueConvInv => '8 * ($val + 104)',
1108             SeparateTable => 'ISOAutoHiLimitZ7',
1109             PrintConv => {
1110             0 => 'ISO 64', 17 => 'ISO 3200',
1111             1 => 'ISO 80', 18 => 'ISO 4000',
1112             2 => 'ISO 100', 19 => 'ISO 5000',
1113             3 => 'ISO 125', 20 => 'ISO 6400',
1114             4 => 'ISO 160', 21 => 'ISO 8000',
1115             5 => 'ISO 200', 22 => 'ISO 10000',
1116             6 => 'ISO 250', 23 => 'ISO 12800',
1117             7 => 'ISO 320', 24 => 'ISO 16000',
1118             8 => 'ISO 400', 25 => 'ISO 20000',
1119             9 => 'ISO 500', 26 => 'ISO 25600',
1120             10 => 'ISO 640', 27 => 'ISO Hi 0.3',
1121             11 => 'ISO 800', 28 => 'ISO Hi 0.7',
1122             12 => 'ISO 1000', 29 => 'ISO Hi 1.0',
1123             13 => 'ISO 1250', 32 => 'ISO Hi 2.0',
1124             14 => 'ISO 1600',
1125             15 => 'ISO 2000',
1126             16 => 'ISO 2500',
1127             },
1128             );
1129              
1130             my %iSOAutoShutterTimeZ9 = (
1131             -15 => 'Auto', #z9 firmware 1.00 maps both 'Auto' and '30 s' to -15
1132             -12 => '15 s',
1133             -9 => '8 s',
1134             -6 => '4 s',
1135             -3 => '2 s',
1136             0 => '1 s',
1137             1 => '1/1.3 s',
1138             2 => '1/1.6 s',
1139             3 => '1/2 s',
1140             4 => '1/2.5 s',
1141             5 => '1/3 s',
1142             6 => '1/4 s',
1143             7 => '1/5 s',
1144             8 => '1/6 s',
1145             9 => '1/8 s',
1146             10 => '1/10 s',
1147             11 => '1/13 s',
1148             12 => '1/15 s',
1149             13 => '1/20 s',
1150             14 => '1/25 s',
1151             15 => '1/30 s',
1152             16 => '1/40 s',
1153             17 => '1/50 s',
1154             18 => '1/60 s',
1155             19 => '1/80 s',
1156             20 => '1/100 s',
1157             21 => '1/120 s',
1158             22 => '1/160 s',
1159             23 => '1/200 s',
1160             24 => '1/250 s',
1161             25 => '1/320 s',
1162             26 => '1/400 s',
1163             27 => '1/500 s',
1164             28 => '1/640 s',
1165             29 => '1/800 s',
1166             30 => '1/1000 s',
1167             31 => '1/1250 s',
1168             32 => '1/1600 s',
1169             33 => '1/2000 s',
1170             34 => '1/2500 s',
1171             35 => '1/3200 s',
1172             36 => '1/4000 s',
1173             37 => '1/5000 s',
1174             37.5 => '1/6000 s',
1175             38 => '1/6400 s',
1176             39 => '1/8000 s',
1177             40 => '1/10000 s',
1178             40.5 => '1/12000 s',
1179             41 => '1/13000 s',
1180             42 => '1/16000 s',
1181             );
1182              
1183             my %languageZ9 = (
1184             4 => 'English',
1185             5 => 'Spanish',
1186             7 => 'French',
1187             15 => 'Portuguese'
1188             );
1189              
1190             my %meteringModeZ7 = (
1191             0 => 'Matrix',
1192             1 => 'Center',
1193             2 => 'Spot',
1194             3 => 'Highlight'
1195             );
1196              
1197             my %monitorBrightnessZ9 = (
1198             0 => '-5',
1199             1 => '-4',
1200             2 => '-3',
1201             3 => '-2',
1202             4 => '-1',
1203             5 => '0',
1204             6 => '1',
1205             7 => '2',
1206             8 => '3',
1207             9 => '4',
1208             10 => '5',
1209             14 => 'Hi1',
1210             15 => 'Hi2',
1211             16 => 'Lo2',
1212             17 => 'Lo1',
1213             );
1214              
1215             my %movieFlickerReductionZ9 = (
1216             0 => 'Auto',
1217             1 => '50Hz',
1218             2 => '60Hz',
1219             );
1220              
1221             my %movieFrameRateZ6III = ( #28
1222             0 => '240p',
1223             1 => '200p',
1224             2 => '120p',
1225             3 => '100p',
1226             4 => '60p',
1227             5 => '50p',
1228             6 => '30p',
1229             7 => '25p',
1230             8 => '24p',
1231             );
1232              
1233             my %movieFrameRateZ7 = (
1234             0 => '120p',
1235             1 => '100p',
1236             2 => '60p',
1237             3 => '50p',
1238             4 => '30p',
1239             5 => '25p',
1240             6 => '24p',
1241             );
1242              
1243             my %movieFrameSizeZ9 = (
1244             1 => '1920x1080',
1245             2 => '3840x2160',
1246             3 => '7680x4320',
1247             7 => '5376x3024', #28 (Z6III)
1248             );
1249              
1250             my %movieSlowMotion = (
1251             0 => 'Off',
1252             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]
1253             2 => 'On (5x)', # 120p recording with playback @ 24p [1920 x 1080; 20p x 5]
1254             );
1255              
1256             my %movieToneMapZ9 = (
1257             0 => 'SDR',
1258             1 => 'HLG',
1259             2 => 'N-Log',
1260             );
1261              
1262             my %movieTypeZ9 = (
1263             1 => 'H.264 8-bit (MP4)',
1264             2 => 'H.265 8-bit (MOV)',
1265             3 => 'H.265 10-bit (MOV)',
1266             4 => 'ProRes 422 HQ 10-bit (MOV)',
1267             5 => 'ProRes RAW HQ 12-bit (MOV)',
1268             6 => 'NRAW 12-bit (NEV)'
1269             );
1270              
1271             my %multipleExposureModeZ9 = (
1272             0 => 'Off',
1273             1 => 'On',
1274             2 => 'On (Series)',
1275             );
1276              
1277             my %nonCPULensApertureZ8 = ( # 2**(val/6) rounded - non-CPU aperture interface, values and storage differ from the Z8
1278             Format => 'int16u',
1279             Unknown => 1,
1280             SeparateTable => 'NonCPULensApertureZ8',
1281             PrintConv => {
1282             12 => 'f/1.2', 128 => 'f/6.3',
1283             24 => 'f/1.4', 136 => 'f/7.1',
1284             40 => 'f/1.8', 144 => 'f/8',
1285             48 => 'f/2.0', 156 => 'f/9.5',
1286             64 => 'f/2.5', 168 => 'f/11',
1287             72 => 'f/2.8', 180 => 'f/13',
1288             84 => 'f/3.3', 188 => 'f/15',
1289             88 => 'f/3.5', 192 => 'f/16',
1290             96 => 'f/4.0', 204 => 'f/19',
1291             104 => 'f/4.5', 216 => 'f/22',
1292             112 => 'f/5.0', 313 => 'N/A', #camera menu shows "--" indicating value has not been set for the lens,
1293             120 => 'f/5.6',
1294             },
1295             );
1296              
1297             my %offLowNormalHighZ7 = (
1298             0 => 'Off',
1299             1 => 'Low',
1300             2 => 'Normal',
1301             3 => 'High',
1302             );
1303              
1304             my %pixelShiftDelay = (
1305             0 => 'Off',
1306             1 => '1 s',
1307             2 => '2 s',
1308             3 => '3 s',
1309             4 => '5 s',
1310             5 => '10 s',
1311             );
1312              
1313             my %pixelShiftNumberShots = (
1314             0 => '4',
1315             1 => '8',
1316             2 => '16',
1317             3 => '32',
1318             );
1319              
1320             my %portraitImpressionBalanceZ8 = (
1321             0 => 'Off',
1322             1 => 'Mode 1',
1323             2 => 'Mode 2',
1324             3 => 'Mode 3',
1325             );
1326              
1327             my %releaseModeZ7 = (
1328             0 => 'Continuous Low',
1329             1 => 'Continuous High',
1330             2 => 'Continuous High (Extended)',
1331             4 => 'Timer',
1332             5 => 'Single Frame',
1333             );
1334              
1335             my %secondarySlotFunctionZ9 = (
1336             0 => 'Overflow',
1337             1 => 'Backup',
1338             2 => 'NEF Primary + JPG Secondary',
1339             3 => 'JPG Primary + JPG Secondary',
1340             );
1341              
1342             my %subjectDetectionAreaMZ6III = ( #28
1343             0 => 'Off',
1344             1 => 'All',
1345             2 => 'Wide (L)',
1346             3 => 'Wide (S)',
1347             );
1348              
1349             my %subjectDetectionZ9 = (
1350             0 => 'Off',
1351             1 => 'Auto',
1352             2 => 'People',
1353             3 => 'Animals',
1354             4 => 'Vehicles',
1355             5 => 'Birds',
1356             6 => 'Airplanes',
1357             7 => 'Faces', #introduced with Z9 firmware 5.30 as an Auto Capture option
1358             );
1359              
1360             my %timeZoneZ9 = (
1361             3 => '+10:00 (Sydney)',
1362             5 => '+09:00 (Tokyo)',
1363             6 => '+08:00 (Beijing, Honk Kong, Sinapore)',
1364             10 => '+05:45 (Kathmandu)',
1365             11 => '+05:30 (New Dehli)',
1366             12 => '+05:00 (Islamabad)',
1367             13 => '+04:30 (Kabul)',
1368             14 => '+04:00 (Abu Dhabi)',
1369             15 => '+03:30 (Tehran)',
1370             16 => '+03:00 (Moscow, Nairobi)',
1371             17 => '+02:00 (Athens, Helsinki)',
1372             18 => '+01:00 (Madrid, Paris, Berlin)',
1373             19 => '+00:00 (London)',
1374             20 => '-01:00 (Azores)',
1375             21 => '-02:00 (Fernando de Noronha)',
1376             22 => '-03:00 (Buenos Aires, Sao Paulo)',
1377             23 => '-03:30 (Newfoundland)',
1378             24 => '-04:00 (Manaus, Caracas)',
1379             25 => '-05:00 (New York, Toronto, Lima)',
1380             26 => '-06:00 (Chicago, Mexico City)',
1381             27 => '-07:00 (Denver)',
1382             28 => '-08:00 (Los Angeles, Vancouver)',
1383             29 => '-09:00 (Anchorage)',
1384             30 => '-10:00 (Hawaii)',
1385             );
1386              
1387              
1388             my %vRModeZ9 = (
1389             0 => 'Off',
1390             1 => 'Normal',
1391             2 => 'Sport',
1392             );
1393              
1394             my %retouchValues = ( #PH
1395             0 => 'None',
1396             3 => 'B & W',
1397             4 => 'Sepia',
1398             5 => 'Trim',
1399             6 => 'Small Picture',
1400             7 => 'D-Lighting',
1401             8 => 'Red Eye',
1402             9 => 'Cyanotype',
1403             10 => 'Sky Light',
1404             11 => 'Warm Tone',
1405             12 => 'Color Custom',
1406             13 => 'Image Overlay',
1407             14 => 'Red Intensifier',
1408             15 => 'Green Intensifier',
1409             16 => 'Blue Intensifier',
1410             17 => 'Cross Screen',
1411             18 => 'Quick Retouch',
1412             19 => 'NEF Processing',
1413             23 => 'Distortion Control',
1414             25 => 'Fisheye',
1415             26 => 'Straighten',
1416             29 => 'Perspective Control',
1417             30 => 'Color Outline',
1418             31 => 'Soft Filter',
1419             32 => 'Resize', #31
1420             33 => 'Miniature Effect',
1421             34 => 'Skin Softening', # (S9200)
1422             35 => 'Selected Frame', #31 (frame exported from MOV)
1423             37 => 'Color Sketch', #31
1424             38 => 'Selective Color', # (S9200)
1425             39 => 'Glamour', # (S3500)
1426             40 => 'Drawing', # (S9200)
1427             44 => 'Pop', # (S3500)
1428             45 => 'Toy Camera Effect 1', # (S3500)
1429             46 => 'Toy Camera Effect 2', # (S3500)
1430             47 => 'Cross Process (red)', # (S3500)
1431             48 => 'Cross Process (blue)', # (S3500)
1432             49 => 'Cross Process (green)', # (S3500)
1433             50 => 'Cross Process (yellow)', # (S3500)
1434             51 => 'Super Vivid', # (S3500)
1435             52 => 'High-contrast Monochrome', # (S3500)
1436             53 => 'High Key', # (S3500)
1437             54 => 'Low Key', # (S3500)
1438             );
1439              
1440             # AF points for AFInfo models with 11 focus points
1441             my %afPoints11 = (
1442             0 => '(none)',
1443             0x7ff => 'All 11 Points',
1444             BITMASK => {
1445             0 => 'Center',
1446             1 => 'Top',
1447             2 => 'Bottom',
1448             3 => 'Mid-left',
1449             4 => 'Mid-right',
1450             5 => 'Upper-left',
1451             6 => 'Upper-right',
1452             7 => 'Lower-left',
1453             8 => 'Lower-right',
1454             9 => 'Far Left',
1455             10 => 'Far Right',
1456             },
1457             );
1458              
1459             # AF point indices for models with 51 focus points, eg. D3 (ref JD/PH)
1460             # A1 A2 A3 A4 A5 A6 A7 A8 A9
1461             # B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11
1462             # C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11
1463             # D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11
1464             # E1 E2 E3 E4 E5 E6 E7 E8 E9
1465             my %afPoints51 = (
1466             1 => 'C6', 11 => 'C5', 21 => 'C9', 31 => 'C11',41 => 'A2', 51 => 'D1',
1467             2 => 'B6', 12 => 'B5', 22 => 'B9', 32 => 'B11',42 => 'D3',
1468             3 => 'A5', 13 => 'A4', 23 => 'A8', 33 => 'D11',43 => 'E2',
1469             4 => 'D6', 14 => 'D5', 24 => 'D9', 34 => 'C4', 44 => 'C2',
1470             5 => 'E5', 15 => 'E4', 25 => 'E8', 35 => 'B4', 45 => 'B2',
1471             6 => 'C7', 16 => 'C8', 26 => 'C10',36 => 'A3', 46 => 'A1',
1472             7 => 'B7', 17 => 'B8', 27 => 'B10',37 => 'D4', 47 => 'D2',
1473             8 => 'A6', 18 => 'A7', 28 => 'A9', 38 => 'E3', 48 => 'E1',
1474             9 => 'D7', 19 => 'D8', 29 => 'D10',39 => 'C3', 49 => 'C1',
1475             10 => 'E6', 20 => 'E7', 30 => 'E9', 40 => 'B3', 50 => 'B1',
1476             );
1477              
1478             # AF point indices for models with 39 focus points, eg. D7000 (ref 29)
1479             # A1 A2 A3
1480             # B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11
1481             # C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11
1482             # D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11
1483             # E1 E2 E3
1484             my %afPoints39 = (
1485             1 => 'C6', 11 => 'C5', 21 => 'D9', 31 => 'C3',
1486             2 => 'B6', 12 => 'B5', 22 => 'C10',32 => 'B3',
1487             3 => 'A2', 13 => 'A1', 23 => 'B10',33 => 'D3',
1488             4 => 'D6', 14 => 'D5', 24 => 'D10',34 => 'C2',
1489             5 => 'E2', 15 => 'E1', 25 => 'C11',35 => 'B2',
1490             6 => 'C7', 16 => 'C8', 26 => 'B11',36 => 'D2',
1491             7 => 'B7', 17 => 'B8', 27 => 'D11',37 => 'C1',
1492             8 => 'A3', 18 => 'D8', 28 => 'C4', 38 => 'B1',
1493             9 => 'D7', 19 => 'C9', 29 => 'B4', 39 => 'D1',
1494             10 => 'E3', 20 => 'B9', 30 => 'D4',
1495             );
1496              
1497             # AF point indices for models with 105 focus points, eg. D6 (ref 28)
1498             # - 7 rows (A-G) with 15 columns (1-15), center is D8
1499             my %afPoints105 = (
1500             1 => 'D8', 28 => 'G7', 55 => 'F13', 82 => 'E4',
1501             2 => 'C8', 29 => 'D6', 56 => 'G13', 83 => 'F4',
1502             3 => 'B8', 30 => 'C6', 57 => 'D14', 84 => 'G4',
1503             4 => 'A8', 31 => 'B6', 58 => 'C14', 85 => 'D3',
1504             5 => 'E8', 32 => 'A6', 59 => 'B14', 86 => 'C3',
1505             6 => 'F8', 33 => 'E6', 60 => 'A14', 87 => 'B3',
1506             7 => 'G8', 34 => 'F6', 61 => 'E14', 88 => 'A3',
1507             8 => 'D9', 35 => 'G6', 62 => 'F14', 89 => 'E3',
1508             9 => 'C9', 36 => 'D11', 63 => 'G14', 90 => 'F3',
1509             10 => 'B9', 37 => 'C11', 64 => 'D15', 91 => 'G3',
1510             11 => 'A9', 38 => 'B11', 65 => 'C15', 92 => 'D2',
1511             12 => 'E9', 39 => 'A11', 66 => 'B15', 93 => 'C2',
1512             13 => 'F9', 40 => 'E11', 67 => 'A15', 94 => 'B2',
1513             14 => 'G9', 41 => 'F11', 68 => 'E15', 95 => 'A2',
1514             15 => 'D10', 42 => 'G11', 69 => 'F15', 96 => 'E2',
1515             16 => 'C10', 43 => 'D12', 70 => 'G15', 97 => 'F2',
1516             17 => 'B10', 44 => 'C12', 71 => 'D5', 98 => 'G2',
1517             18 => 'A10', 45 => 'B12', 72 => 'C5', 99 => 'D1',
1518             19 => 'E10', 46 => 'A12', 73 => 'B5', 100 => 'C1',
1519             20 => 'F10', 47 => 'E12', 74 => 'A5', 101 => 'B1',
1520             21 => 'G10', 48 => 'F12', 75 => 'E5', 102 => 'A1',
1521             22 => 'D7', 49 => 'G12', 76 => 'F5', 103 => 'E1',
1522             23 => 'C7', 50 => 'D13', 77 => 'G5', 104 => 'F1',
1523             24 => 'B7', 51 => 'C13', 78 => 'D4', 105 => 'G1',
1524             25 => 'A7', 52 => 'B13', 79 => 'C4',
1525             26 => 'E7', 53 => 'A13', 80 => 'B4',
1526             27 => 'F7', 54 => 'E13', 81 => 'A4',
1527             );
1528              
1529             # AF point indices for models with 135 focus points, eg. 1J1 (ref PH)
1530             # - 9 rows (A-I) with 15 columns (1-15), center is E8
1531             # - odd columns, columns 2 and 14, and the remaining corner points are
1532             # not used in 41-point mode
1533             my %afPoints135 = (
1534             1 => 'E8', 28 => 'E10', 55 => 'E13', 82 => 'E6', 109 => 'E3',
1535             2 => 'D8', 29 => 'D10', 56 => 'D13', 83 => 'D6', 110 => 'D3',
1536             3 => 'C8', 30 => 'C10', 57 => 'C13', 84 => 'C6', 111 => 'C3',
1537             4 => 'B8', 31 => 'B10', 58 => 'B13', 85 => 'B6', 112 => 'B3',
1538             5 => 'A8', 32 => 'A10', 59 => 'A13', 86 => 'A6', 113 => 'A3',
1539             6 => 'F8', 33 => 'F10', 60 => 'F13', 87 => 'F6', 114 => 'F3',
1540             7 => 'G8', 34 => 'G10', 61 => 'G13', 88 => 'G6', 115 => 'G3',
1541             8 => 'H8', 35 => 'H10', 62 => 'H13', 89 => 'H6', 116 => 'H3',
1542             9 => 'I8', 36 => 'I10', 63 => 'I13', 90 => 'I6', 117 => 'I3',
1543             10 => 'E9', 37 => 'E11', 64 => 'E14', 91 => 'E5', 118 => 'E2',
1544             11 => 'D9', 38 => 'D11', 65 => 'D14', 92 => 'D5', 119 => 'D2',
1545             12 => 'C9', 39 => 'C11', 66 => 'C14', 93 => 'C5', 120 => 'C2',
1546             13 => 'B9', 40 => 'B11', 67 => 'B14', 94 => 'B5', 121 => 'B2',
1547             14 => 'A9', 41 => 'A11', 68 => 'A14', 95 => 'A5', 122 => 'A2',
1548             15 => 'F9', 42 => 'F11', 69 => 'F14', 96 => 'F5', 123 => 'F2',
1549             16 => 'G9', 43 => 'G11', 70 => 'G14', 97 => 'G5', 124 => 'G2',
1550             17 => 'H9', 44 => 'H11', 71 => 'H14', 98 => 'H5', 125 => 'H2',
1551             18 => 'I9', 45 => 'I11', 72 => 'I14', 99 => 'I5', 126 => 'I2',
1552             19 => 'E7', 46 => 'E12', 73 => 'E15', 100 => 'E4', 127 => 'E1',
1553             20 => 'D7', 47 => 'D12', 74 => 'D15', 101 => 'D4', 128 => 'D1',
1554             21 => 'C7', 48 => 'C12', 75 => 'C15', 102 => 'C4', 129 => 'C1',
1555             22 => 'B7', 49 => 'B12', 76 => 'B15', 103 => 'B4', 130 => 'B1',
1556             23 => 'A7', 50 => 'A12', 77 => 'A15', 104 => 'A4', 131 => 'A1',
1557             24 => 'F7', 51 => 'F12', 78 => 'F15', 105 => 'F4', 132 => 'F1',
1558             25 => 'G7', 52 => 'G12', 79 => 'G15', 106 => 'G4', 133 => 'G1',
1559             26 => 'H7', 53 => 'H12', 80 => 'H15', 107 => 'H4', 134 => 'H1',
1560             27 => 'I7', 54 => 'I12', 81 => 'I15', 108 => 'I4', 135 => 'I1',
1561             );
1562              
1563             # AF point indices for models with 153 focus points, eg. D5,D500 (ref PH)
1564             # - 9 rows (A-I) with 17 columns (1-17), center is E9
1565             # - 55 of these are selectable cross points (odd rows and columns 1,3,4,6,7,9,11,12,14,15,17)
1566             my %afPoints153 = (
1567             1 => 'E9', 32 => 'A8', 63 => 'I13', 94 => 'B17', 125 => 'H4',
1568             2 => 'D9', 33 => 'F8', 64 => 'E14', 95 => 'A17', 126 => 'I4',
1569             3 => 'C9', 34 => 'G8', 65 => 'D14', 96 => 'F17', 127 => 'E3',
1570             4 => 'B9', 35 => 'H8', 66 => 'C14', 97 => 'G17', 128 => 'D3',
1571             5 => 'A9', 36 => 'I8', 67 => 'B14', 98 => 'H17', 129 => 'C3',
1572             6 => 'F9', 37 => 'E7', 68 => 'A14', 99 => 'I17', 130 => 'B3',
1573             7 => 'G9', 38 => 'D7', 69 => 'F14', 100 => 'E6', 131 => 'A3',
1574             8 => 'H9', 39 => 'C7', 70 => 'G14', 101 => 'D6', 132 => 'F3',
1575             9 => 'I9', 40 => 'B7', 71 => 'H14', 102 => 'C6', 133 => 'G3',
1576             10 => 'E10', 41 => 'A7', 72 => 'I14', 103 => 'B6', 134 => 'H3',
1577             11 => 'D10', 42 => 'F7', 73 => 'E15', 104 => 'A6', 135 => 'I3',
1578             12 => 'C10', 43 => 'G7', 74 => 'D15', 105 => 'F6', 136 => 'E2',
1579             13 => 'B10', 44 => 'H7', 75 => 'C15', 106 => 'G6', 137 => 'D2',
1580             14 => 'A10', 45 => 'I7', 76 => 'B15', 107 => 'H6', 138 => 'C2',
1581             15 => 'F10', 46 => 'E12', 77 => 'A15', 108 => 'I6', 139 => 'B2',
1582             16 => 'G10', 47 => 'D12', 78 => 'F15', 109 => 'E5', 140 => 'A2',
1583             17 => 'H10', 48 => 'C12', 79 => 'G15', 110 => 'D5', 141 => 'F2',
1584             18 => 'I10', 49 => 'B12', 80 => 'H15', 111 => 'C5', 142 => 'G2',
1585             19 => 'E11', 50 => 'A12', 81 => 'I15', 112 => 'B5', 143 => 'H2',
1586             20 => 'D11', 51 => 'F12', 82 => 'E16', 113 => 'A5', 144 => 'I2',
1587             21 => 'C11', 52 => 'G12', 83 => 'D16', 114 => 'F5', 145 => 'E1',
1588             22 => 'B11', 53 => 'H12', 84 => 'C16', 115 => 'G5', 146 => 'D1',
1589             23 => 'A11', 54 => 'I12', 85 => 'B16', 116 => 'H5', 147 => 'C1',
1590             24 => 'F11', 55 => 'E13', 86 => 'A16', 117 => 'I5', 148 => 'B1',
1591             25 => 'G11', 56 => 'D13', 87 => 'F16', 118 => 'E4', 149 => 'A1',
1592             26 => 'H11', 57 => 'C13', 88 => 'G16', 119 => 'D4', 150 => 'F1',
1593             27 => 'I11', 58 => 'B13', 89 => 'H16', 120 => 'C4', 151 => 'G1',
1594             28 => 'E8', 59 => 'A13', 90 => 'I16', 121 => 'B4', 152 => 'H1',
1595             29 => 'D8', 60 => 'F13', 91 => 'E17', 122 => 'A4', 153 => 'I1',
1596             30 => 'C8', 61 => 'G13', 92 => 'D17', 123 => 'F4',
1597             31 => 'B8', 62 => 'H13', 93 => 'C17', 124 => 'G4',
1598             );
1599              
1600             # AF point indices for models with 81 Auto-area focus points, eg. Z6/Z7/Z50 (ref 38)
1601             # - 9 rows (A-I) with 9 columns (1-9), center is E5
1602             #
1603             # 7 6 5 4 3 2 1 0
1604             # 00 : [H5][G5][F5][A5][B5][C5][D5][E5]
1605             # 01 : [G6][F6][A6][B6][C6][D6][E6][I5]
1606             # 02 : [F4][A4][B4][C4][D4][E4][I6][H6]
1607             # 03 : [A7][B7][C7][D7][E7][I4][H4][G4]
1608             # 04 : [B3][C3][D3][E3][I7][H7][G7][F7]
1609             # 05 : [C8][D8][E8][I3][H3][G3][F3][A3]
1610             # 06 : [D2][E2][I8][H8][G8][F8][A8][B8]
1611             # 07 : [E9][I2][H2][G2][F2][A2][B2][C2]
1612             # 08 : [I9][H9][G9][F9][A9][B9][C9][D9]
1613             # 09 : [H1][G1][F1][A1][B1][C1][D1][E1]
1614             # 0a : [ ][ ][ ][ ][ ][ ][ ][I1]
1615             my %afPoints81 = (
1616             1 => 'E5', 18 => 'I6', 35 => 'H7', 52 => 'G8', 69 => 'F9',
1617             2 => 'D5', 19 => 'E4', 36 => 'I7', 53 => 'H8', 70 => 'G9',
1618             3 => 'C5', 20 => 'D4', 37 => 'E3', 54 => 'I8', 71 => 'H9',
1619             4 => 'B5', 21 => 'C4', 38 => 'D3', 55 => 'E2', 72 => 'I9',
1620             5 => 'A5', 22 => 'B4', 39 => 'C3', 56 => 'D2', 73 => 'E1',
1621             6 => 'F5', 23 => 'A4', 40 => 'B3', 57 => 'C2', 74 => 'D1',
1622             7 => 'G5', 24 => 'F4', 41 => 'A3', 58 => 'B2', 75 => 'C1',
1623             8 => 'H5', 25 => 'G4', 42 => 'F3', 59 => 'A2', 76 => 'B1',
1624             9 => 'I5', 26 => 'H4', 43 => 'G3', 60 => 'F2', 77 => 'A1',
1625             10 => 'E6', 27 => 'I4', 44 => 'H3', 61 => 'G2', 78 => 'F1',
1626             11 => 'D6', 28 => 'E7', 45 => 'I3', 62 => 'H2', 79 => 'G1',
1627             12 => 'C6', 29 => 'D7', 46 => 'E8', 63 => 'I2', 80 => 'H1',
1628             13 => 'B6', 30 => 'C7', 47 => 'D8', 64 => 'E9', 81 => 'I1',
1629             14 => 'A6', 31 => 'B7', 48 => 'C8', 65 => 'D9',
1630             15 => 'F6', 32 => 'A7', 49 => 'B8', 66 => 'C9',
1631             16 => 'G6', 33 => 'F7', 50 => 'A8', 67 => 'B9',
1632             17 => 'H6', 34 => 'G7', 51 => 'F8', 68 => 'A9',
1633             );
1634              
1635             # AF point indices for 209/231 focus point(single-point AF) cameras equipped with Expeed 7 processor eg. Z50ii). Single-point AF array is 11 rows x 19 columns. (ref 28)
1636             # - Auto Area AF has 2 additional columns available and provides 231 focus points. Uses 11 rows (A-K) and 21 columns (1-21), center is F11
1637             my @afPoints231 = (qw(
1638             A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 A16 A17 A18 A19 A20 A21
1639             B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 B12 B13 B14 B15 B16 B17 B18 B19 B20 B21
1640             C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 C16 C17 C18 C19 C20 C21
1641             D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13 D14 D15 D16 D17 D18 D19 D20 D21
1642             E1 E2 E3 E4 E5 E6 E7 E8 E9 E10 E11 E12 E13 E14 E15 E16 E17 E18 E19 E20 E21
1643             F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21
1644             G1 G2 G3 G4 G5 G6 G7 G8 G9 G10 G11 G12 G13 G14 G15 G16 G17 G18 G19 G20 G21
1645             H1 H2 H3 H4 H5 H6 H7 H8 H9 H10 H11 H12 H13 H14 H15 H16 H17 H18 H19 H20 H21
1646             I1 I2 I3 I4 I5 I6 I7 I8 I9 I10 I11 I12 I13 I14 I15 I16 I17 I18 I19 I20 I21
1647             J1 J2 J3 J4 J5 J6 J7 J8 J9 J10 J11 J12 J13 J14 J15 J16 J17 J18 J19 J20 J21
1648             K1 K2 K3 K4 K5 K6 K7 K8 K9 K10 K11 K12 K13 K14 K15 K16 K17 K18 K19 K20 K21
1649             ));
1650              
1651             # AF point indices for 273/299 focus point (single-point AF) cameras equipped with Expeed 7 processor (eg. Z6iii and Zf). Single-point AF array is 13 rows x 21 columns (ref 28)
1652             # - Auto Area AF has 2 additional columns available and provides 299 focus points. Uses 13 rows (A-M) and 23 columns (1-23), center is G12
1653             #
1654             my @afPoints299 = (qw(
1655             A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 A16 A17 A18 A19 A20 A21 A22 A23
1656             B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 B12 B13 B14 B15 B16 B17 B18 B19 B20 B21 B22 B23
1657             C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 C16 C17 C18 C19 C20 C21 C22 C23
1658             D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13 D14 D15 D16 D17 D18 D19 D20 D21 D22 D23
1659             E1 E2 E3 E4 E5 E6 E7 E8 E9 E10 E11 E12 E13 E14 E15 E16 E17 E18 E19 E20 E21 E22 E23
1660             F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23
1661             G1 G2 G3 G4 G5 G6 G7 G8 G9 G10 G11 G12 G13 G14 G15 G16 G17 G18 G19 G20 G21 G22 G23
1662             H1 H2 H3 H4 H5 H6 H7 H8 H9 H10 H11 H12 H13 H14 H15 H16 H17 H18 H19 H20 H21 H22 H23
1663             I1 I2 I3 I4 I5 I6 I7 I8 I9 I10 I11 I12 I13 I14 I15 I16 I17 I18 I19 I20 I21 I22 I23
1664             J1 J2 J3 J4 J5 J6 J7 J8 J9 J10 J11 J12 J13 J14 J15 J16 J17 J18 J19 J20 J21 J22 J23
1665             K1 K2 K3 K4 K5 K6 K7 K8 K9 K10 K11 K12 K13 K14 K15 K16 K17 K18 K19 K20 K21 K22 K23
1666             L1 L2 L3 L4 L5 L6 L7 L8 L9 L10 L11 L12 L13 L14 L15 L16 L17 L18 L19 L20 L21 L22 L23
1667             M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12 M13 M14 M15 M16 M17 M18 M19 M20 M21 M22 M23
1668             ));
1669              
1670             # AF point indices for 405/493 focus point (single-point AF) cameras equipped with Expeed 7 processor (eg. Z8 and Z9). Single-point AF array is 17 rows x 29 columns (ref 28)
1671             # - Auto Area AF uses 15 of the 17 rows (A-O) and 27 of the 29 columns (1-27), center is H14 (405 of the 493 focus points can be used by Auto-area AF)
1672             #
1673             my @afPoints405 = (qw(
1674             A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 A16 A17 A18 A19 A20 A21 A22 A23 A24 A25 A26 A27
1675             B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 B12 B13 B14 B15 B16 B17 B18 B19 B20 B21 B22 B23 B24 B25 B26 B27
1676             C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 C16 C17 C18 C19 C20 C21 C22 C23 C24 C25 C26 C27
1677             D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13 D14 D15 D16 D17 D18 D19 D20 D21 D22 D23 D24 D25 D26 D27
1678             E1 E2 E3 E4 E5 E6 E7 E8 E9 E10 E11 E12 E13 E14 E15 E16 E17 E18 E19 E20 E21 E22 E23 E24 E25 E26 E27
1679             F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27
1680             G1 G2 G3 G4 G5 G6 G7 G8 G9 G10 G11 G12 G13 G14 G15 G16 G17 G18 G19 G20 G21 G22 G23 G24 G25 G26 G27
1681             H1 H2 H3 H4 H5 H6 H7 H8 H9 H10 H11 H12 H13 H14 H15 H16 H17 H18 H19 H20 H21 H22 H23 H24 H25 H26 H27
1682             I1 I2 I3 I4 I5 I6 I7 I8 I9 I10 I11 I12 I13 I14 I15 I16 I17 I18 I19 I20 I21 I22 I23 I24 I25 I26 I27
1683             J1 J2 J3 J4 J5 J6 J7 J8 J9 J10 J11 J12 J13 J14 J15 J16 J17 J18 J19 J20 J21 J22 J23 J24 J25 J26 J27
1684             K1 K2 K3 K4 K5 K6 K7 K8 K9 K10 K11 K12 K13 K14 K15 K16 K17 K18 K19 K20 K21 K22 K23 K24 K25 K26 K27
1685             L1 L2 L3 L4 L5 L6 L7 L8 L9 L10 L11 L12 L13 L14 L15 L16 L17 L18 L19 L20 L21 L22 L23 L24 L25 L26 L27
1686             M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12 M13 M14 M15 M16 M17 M18 M19 M20 M21 M22 M23 M24 M25 M26 M27
1687             N1 N2 N3 N4 N5 N6 N7 N8 N9 N10 N11 N12 N13 N14 N15 N16 N17 N18 N19 N20 N21 N22 N23 N24 N25 N26 N27
1688             O1 O2 O3 O4 O5 O6 O7 O8 O9 O10 O11 O12 O13 O14 O15 O16 O17 O18 O19 O20 O21 O22 O23 O24 O25 O26 O27
1689             ));
1690              
1691             my %cropHiSpeed = ( #IB
1692             0 => 'Off',
1693             1 => '1.3x Crop', # (1.3x Crop, Large)
1694             2 => 'DX Crop', # (1.5x)
1695             3 => '5:4 Crop',
1696             4 => '3:2 Crop', # (1.2x, ref 36)
1697             6 => '16:9 Crop',
1698             8 => '2.7x Crop', #36 (D4/D500)
1699             9 => 'DX Movie 16:9 Crop', # (DX during movie recording, Large)
1700             10 => '1.3x Movie Crop', #36 (D4/D500)
1701             11 => 'FX Uncropped',
1702             12 => 'DX Uncropped',
1703             13 => '2.8x Movie Crop', #28 (D5/D6) 5584/1936
1704             14 => '1.4x Movie Crop', #28 (D5/D6) 5584/3856
1705             15 => '1.5x Movie Crop', #36 (D4/D500) 5600/3872
1706             17 => 'FX 1:1 Crop',
1707             18 => 'DX 1:1 Crop',
1708             OTHER => sub {
1709             my ($val, $inv, $conv) = @_;
1710             return undef if $inv;
1711             my @a = split ' ', $val;
1712             return "Unknown ($val)" unless @a == 7;
1713             $a[0] = $$conv{$a[0]} || "Unknown ($a[0])";
1714             return "$a[0] ($a[1]x$a[2] cropped to $a[3]x$a[4] at pixel $a[5],$a[6])";
1715             },
1716             );
1717              
1718             my %flashGroupOptionsMode = (
1719             0 => 'TTL',
1720             1 => 'Manual',
1721             2 => 'Auto',
1722             3 => 'Off',
1723             );
1724              
1725             my %nefCompression = ( #28 relocated to MakerNotes_0x51 at offset x'0a (Z9)
1726             1 => 'Lossy (type 1)', # (older models)
1727             2 => 'Uncompressed', #JD - D100 (even though TIFF compression is set!)
1728             3 => 'Lossless',
1729             4 => 'Lossy (type 2)',
1730             5 => 'Striped packed 12 bits', #IB
1731             6 => 'Uncompressed (reduced to 12 bit)', #IB
1732             7 => 'Unpacked 12 bits', #IB (padded to 16)
1733             8 => 'Small', #IB
1734             9 => 'Packed 12 bits', #IB (2 pixels in 3 bytes)
1735             10 => 'Packed 14 bits', #28 (4 pixels in 7 bytes, eg. D6 uncompressed 14 bit)
1736             13 => 'High Efficiency', #28
1737             14 => 'High Efficiency*', #28
1738             );
1739              
1740             my %noYes = ( 0 => 'No' , 1 => 'Yes', );
1741             my %offOn = ( 0 => 'Off', 1 => 'On' );
1742             my %onOff = ( 0 => 'On', 1 => 'Off' );
1743              
1744             # common attributes for writable BinaryData directories
1745             my %binaryDataAttrs = (
1746             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
1747             WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
1748             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
1749             WRITABLE => 1,
1750             FIRST_ENTRY => 0,
1751             );
1752              
1753             my %base64bin = ( ValueConv => 'Image::ExifTool::XMP::DecodeBase64($val)' );
1754             my %base64int32u = ( ValueConv => 'my $val=Image::ExifTool::XMP::DecodeBase64($val); unpack("V",$$val)' );
1755             my %base64bytes = ( ValueConv => 'my $val=Image::ExifTool::XMP::DecodeBase64($val); join(".",unpack("C*",$$val))' );
1756             my %base64double = (
1757             ValueConv => q{
1758             my $val=Image::ExifTool::XMP::DecodeBase64($val);
1759             my $saveOrder = GetByteOrder();
1760             SetByteOrder('II');
1761             $val = GetDouble($val,0);
1762             SetByteOrder($saveOrder);
1763             return $val;
1764             },
1765             );
1766             my %base64coord = (
1767             ValueConv => q{
1768             my $val=Image::ExifTool::XMP::DecodeBase64($val);
1769             my $saveOrder = GetByteOrder();
1770             SetByteOrder('II');
1771             $val = GetDouble($val,0) + GetDouble($val,8)/60 + GetDouble($val,16)/3600;
1772             SetByteOrder($saveOrder);
1773             return $val;
1774             },
1775             PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1)',
1776             );
1777             # Nikon maker note tags
1778             %Image::ExifTool::Nikon::Main = (
1779             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikon,
1780             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikon,
1781             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
1782             WRITABLE => 1,
1783             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
1784             PRINT_CONV => \&FormatString,
1785             0x0001 => { #2
1786             # the format differs for different models. for D70, this is a string '0210',
1787             # but for the E775 it is binary: "\x00\x01\x00\x00"
1788             Name => 'MakerNoteVersion',
1789             Writable => 'undef',
1790             Count => 4,
1791             # convert to string if binary
1792             ValueConv => '$_=$val; /^[\x00-\x09]/ and $_=join("",unpack("CCCC",$_)); $_',
1793             ValueConvInv => '$val',
1794             PrintConv => '$_=$val;s/^(\d{2})/$1\./;s/^0//;$_',
1795             PrintConvInv => '$_=$val;s/\.//;"0$_"',
1796             },
1797             0x0002 => {
1798             # this is the ISO actually used by the camera
1799             # (may be different than ISO setting if auto)
1800             Name => 'ISO',
1801             Writable => 'int16u',
1802             Count => 2,
1803             Priority => 0, # the EXIF ISO is more reliable
1804             Groups => { 2 => 'Image' },
1805             # D300 sets this to undef with 4 zero bytes when LO ISO is used - PH
1806             RawConv => '$val eq "\0\0\0\0" ? undef : $val',
1807             # first number is 1 for "Hi ISO" modes (H0.3, H0.7 and H1.0 on D80) - PH
1808             PrintConv => '$_=$val;s/^0 //;s/^1 (\d+)/Hi $1/;$_',
1809             PrintConvInv => '$_=$val;/^\d+/ ? "0 $_" : (s/Hi ?//i ? "1 $_" : $_)',
1810             },
1811             # Note: we attempt to fix the case of these string values (typically written in all caps)
1812             0x0003 => { Name => 'ColorMode', Writable => 'string' },
1813             0x0004 => { Name => 'Quality', Writable => 'string' },
1814             0x0005 => { Name => 'WhiteBalance', Writable => 'string' },
1815             0x0006 => { Name => 'Sharpness', Writable => 'string' },
1816             0x0007 => {
1817             Name => 'FocusMode',
1818             RawConv => '$$self{FocusMode} = $val',
1819             Writable => 'string',
1820             },
1821             # FlashSetting (better named FlashSyncMode, ref 28) values:
1822             # "Normal", "Slow", "Rear Slow", "RED-EYE", "RED-EYE SLOW"
1823             0x0008 => { Name => 'FlashSetting', Writable => 'string' },
1824             # FlashType observed values:
1825             # internal: "Built-in,TTL", "Built-in,RPT", "Comdr.", "NEW_TTL"
1826             # external: "Optional,TTL", "Optional,RPT", "Optional,M", "Comdr."
1827             # both: "Built-in,TTL&Comdr."
1828             # no flash: ""
1829             0x0009 => { Name => 'FlashType', Writable => 'string' }, #2 (count varies by model - PH)
1830             # 0x000a - rational values: 5.6 to 9.33 - found in Coolpix models - PH
1831             # (seems constant for a given camera model, but not correlated with scale factor)
1832             0x000b => { #2
1833             Name => 'WhiteBalanceFineTune',
1834             Writable => 'int16s',
1835             Count => -1, # older models write 1 value, newer DSLR's write 2 - PH
1836             },
1837             0x000c => { # (D1X)
1838             Name => 'WB_RBLevels',
1839             Writable => 'rational64u',
1840             Count => 4, # (not sure what the last 2 values are for)
1841             },
1842             0x000d => { #15
1843             Name => 'ProgramShift',
1844             Writable => 'undef',
1845             Count => 4,
1846             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1847             ValueConvInv => q{
1848             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1849             $a<-128 or $a>127 ? undef : pack("c4",$a,1,6,0);
1850             },
1851             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1852             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1853             },
1854             0x000e => {
1855             Name => 'ExposureDifference',
1856             Writable => 'undef',
1857             Count => 4,
1858             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1859             ValueConvInv => q{
1860             my $a = int($val*12 + ($val>0 ? 0.5 : -0.5));
1861             $a<-128 or $a>127 ? undef : pack("c4",$a,1,12,0);
1862             },
1863             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
1864             PrintConvInv => '$val',
1865             },
1866             0x000f => { Name => 'ISOSelection', Writable => 'string' }, #2
1867             0x0010 => {
1868             Name => 'DataDump',
1869             Writable => 0,
1870             Binary => 1,
1871             },
1872             0x0011 => {
1873             Name => 'PreviewIFD',
1874             Groups => { 1 => 'PreviewIFD', 2 => 'Image' },
1875             Flags => 'SubIFD',
1876             SubDirectory => {
1877             TagTable => 'Image::ExifTool::Nikon::PreviewIFD',
1878             Start => '$val',
1879             },
1880             },
1881             0x0012 => { #2 (camera setting: combination of command dial and menus - PH)
1882             Name => 'FlashExposureComp',
1883             Description => 'Flash Exposure Compensation',
1884             Writable => 'undef',
1885             Count => 4,
1886             # (includes the built-in compensation for FlashType "Built-in,TTL&Comdr.")
1887             Notes => q{
1888             may be set even if flash does not fire. Does not include the effect of
1889             flash bracketing.
1890             },
1891             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1892             ValueConvInv => q{
1893             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1894             $a<-128 or $a>127 ? undef : pack("c4",$a,1,6,0);
1895             },
1896             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1897             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1898             },
1899             # D70 - another ISO tag
1900             0x0013 => { #2
1901             Name => 'ISOSetting',
1902             Writable => 'int16u',
1903             Count => 2,
1904             PrintConv => '$_=$val;s/^0 //;$_',
1905             PrintConvInv => '"0 $val"',
1906             },
1907             0x0014 => [
1908             { #4
1909             Name => 'ColorBalanceA',
1910             Condition => '$format eq "undef" and $count == 2560',
1911             SubDirectory => {
1912             TagTable => 'Image::ExifTool::Nikon::ColorBalanceA',
1913             ByteOrder => 'BigEndian',
1914             },
1915             },
1916             { #IB
1917             Name => 'NRWData',
1918             Condition => '$$valPt =~ /^NRW 0100/',
1919             Drop => 1, # 'Drop' because it is large and not found in JPEG images
1920             SubDirectory => {
1921             TagTable => 'Image::ExifTool::Nikon::ColorBalanceB',
1922             },
1923             },
1924             { #IB
1925             Name => 'NRWData',
1926             Condition => '$$valPt =~ /^NRW /',
1927             Drop => 1, # 'Drop' because it is large and not found in JPEG images
1928             SubDirectory => {
1929             TagTable => 'Image::ExifTool::Nikon::ColorBalanceC',
1930             },
1931             },
1932             ],
1933             # 0x0015 - string[8]: "AUTO "
1934             # D70 Image boundary?? top x,y bot-right x,y
1935             0x0016 => { #2
1936             Name => 'ImageBoundary',
1937             Writable => 'int16u',
1938             Count => 4,
1939             },
1940             0x0017 => { #28
1941             Name => 'ExternalFlashExposureComp', #PH (setting from external flash unit)
1942             Writable => 'undef',
1943             Count => 4,
1944             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1945             ValueConvInv => q{
1946             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1947             $a<-128 or $a>127 ? undef : pack("c4",$a,1,6,0);
1948             },
1949             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1950             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1951             },
1952             0x0018 => { #5
1953             Name => 'FlashExposureBracketValue',
1954             Writable => 'undef',
1955             Count => 4,
1956             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1957             ValueConvInv => q{
1958             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1959             $a<-128 or $a>127 ? undef : pack("c4",$a,1,6,0);
1960             },
1961             PrintConv => 'sprintf("%.1f",$val)',
1962             PrintConvInv => '$val',
1963             },
1964             0x0019 => { #5
1965             Name => 'ExposureBracketValue',
1966             Writable => 'rational64s',
1967             PrintConv => '$val !~ /undef/ ? Image::ExifTool::Exif::PrintFraction($val) : "n/a" ', #undef observed for Z9 jpgs at C30/C60/C90 [data is 0/0 rather than the usual 0/6]
1968             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1969             },
1970             0x001a => { #PH
1971             Name => 'ImageProcessing',
1972             Writable => 'string',
1973             },
1974             0x001b => { #15
1975             Name => 'CropHiSpeed',
1976             Writable => 'int16u',
1977             Count => 7,
1978             PrintConv => \%cropHiSpeed,
1979             },
1980             0x001c => { #28 (D3 "the application of CSb6 to the selected metering mode")
1981             Name => 'ExposureTuning',
1982             Writable => 'undef',
1983             Count => 3,
1984             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1985             ValueConvInv => q{
1986             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1987             $a<-128 or $a>127 ? undef : pack("c3",$a,1,6);
1988             },
1989             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1990             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1991             },
1992             0x001d => { #4
1993             Name => 'SerialNumber',
1994             # Note: this has been known to change even if the serial number on the body
1995             # stays the same if some parts of the camera were replaced by Nikon service
1996             Writable => 'string',
1997             Protected => 1,
1998             Notes => q{
1999             this value is used as a key to decrypt other information -- writing this tag
2000             causes the other information to be re-encrypted with the new key
2001             },
2002             PrintConv => undef, # disable default PRINT_CONV
2003             },
2004             0x001e => { #14
2005             Name => 'ColorSpace',
2006             Writable => 'int16u',
2007             PrintConv => {
2008             1 => 'sRGB',
2009             2 => 'Adobe RGB',
2010             4 => 'BT.2100', #observed on Z8 with Tone Mode set to HLG
2011             },
2012             },
2013             0x001f => { #PH
2014             Name => 'VRInfo',
2015             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::VRInfo' },
2016             },
2017             0x0020 => { #16
2018             Name => 'ImageAuthentication',
2019             Writable => 'int8u',
2020             PrintConv => \%offOn,
2021             },
2022             0x0021 => { #PH
2023             Name => 'FaceDetect',
2024             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FaceDetect' },
2025             },
2026             0x0022 => { #21
2027             Name => 'ActiveD-Lighting',
2028             Writable => 'int16u',
2029             PrintConv => {
2030             0 => 'Off',
2031             1 => 'Low',
2032             3 => 'Normal',
2033             5 => 'High',
2034             7 => 'Extra High', #10
2035             8 => 'Extra High 1', #PH
2036             9 => 'Extra High 2', #PH
2037             10 => 'Extra High 3', #PH
2038             11 => 'Extra High 4', #PH
2039             0xffff => 'Auto', #10
2040             },
2041             },
2042             0x0023 => [
2043             { #PH (D300, but also found in D3,D3S,D3X,D90,D300S,D700,D3000,D5000)
2044             Name => 'PictureControlData',
2045             Condition => '$$valPt =~ /^01/',
2046             Writable => 'undef',
2047             Permanent => 0,
2048             Flags => [ 'Binary', 'Protected' ],
2049             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl' },
2050             },{ #28
2051             Name => 'PictureControlData',
2052             Condition => '$$valPt =~ /^02/',
2053             Writable => 'undef',
2054             Permanent => 0,
2055             Flags => [ 'Binary', 'Protected' ],
2056             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl2' },
2057             },{
2058             Name => 'PictureControlData',
2059             Condition => '$$valPt =~ /^03/',
2060             Writable => 'undef',
2061             Permanent => 0,
2062             Flags => [ 'Binary', 'Protected' ],
2063             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl3' },
2064             },{
2065             Name => 'PictureControlData',
2066             Writable => 'undef',
2067             Permanent => 0,
2068             Flags => [ 'Binary', 'Protected' ],
2069             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControlUnknown' },
2070             },
2071             ],
2072             0x0024 => { #JD
2073             Name => 'WorldTime',
2074             SubDirectory => {
2075             TagTable => 'Image::ExifTool::Nikon::WorldTime',
2076             # (CaptureNX does flip the byte order of this record)
2077             },
2078             },
2079             0x0025 => { #PH
2080             Name => 'ISOInfo',
2081             SubDirectory => {
2082             TagTable => 'Image::ExifTool::Nikon::ISOInfo',
2083             ByteOrder => 'BigEndian',
2084             },
2085             },
2086             0x002a => { #23 (this tag added with D3 firmware 1.10 -- also written by Nikon utilities)
2087             Name => 'VignetteControl',
2088             Writable => 'int16u',
2089             PrintConv => {
2090             0 => 'Off',
2091             1 => 'Low',
2092             3 => 'Normal',
2093             5 => 'High',
2094             },
2095             },
2096             0x002b => { #PH
2097             Name => 'DistortInfo',
2098             SubDirectory => {
2099             TagTable => 'Image::ExifTool::Nikon::DistortInfo',
2100             },
2101             },
2102             0x002c => { #29 (D7000)
2103             Name => 'UnknownInfo',
2104             SubDirectory => {
2105             TagTable => 'Image::ExifTool::Nikon::UnknownInfo',
2106             ByteOrder => 'BigEndian', #(NC)
2107             },
2108             },
2109             # 0x2d - "512 0 0","512 3 10","512 1 14",...
2110             0x0032 => { #PH
2111             Name => 'UnknownInfo2',
2112             SubDirectory => {
2113             TagTable => 'Image::ExifTool::Nikon::UnknownInfo2',
2114             ByteOrder => 'BigEndian', #(NC)
2115             },
2116             },
2117             0x0034 => { #forum9646
2118             Name => 'ShutterMode',
2119             Writable => 'int16u',
2120             RawConv => '$$self{ShutterMode} = $val',
2121             DataMember => 'ShutterMode',
2122             PrintConv => {
2123             0 => 'Mechanical',
2124             16 => 'Electronic',
2125             # 33 => ? seen for 1J2
2126             48 => 'Electronic Front Curtain',
2127             64 => 'Electronic (Movie)', #JanSkoda (Z6II)
2128             80 => 'Auto (Mechanical)', #JanSkoda (Z6II)
2129             81 => 'Auto (Electronic Front Curtain)', #JanSkoda (Z6II)
2130             96 => 'Electronic (High Speed)', #28 Z9 at C30/C60/C120 frame rates
2131             },
2132             },
2133             0x0035 => [{ #32
2134             Name => 'HDRInfo',
2135             Condition => '$count != 6',
2136             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::HDRInfo' },
2137             },{
2138             Name => 'HDRInfo2',
2139             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::HDRInfo2' },
2140             }],
2141             0x0037 => { #XavierJubier
2142             Name => 'MechanicalShutterCount',
2143             Writable => 'int32u',
2144             },
2145             0x0039 => {
2146             Name => 'LocationInfo',
2147             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LocationInfo' },
2148             },
2149             0x003d => { #IB
2150             Name => 'BlackLevel',
2151             Writable => 'int16u',
2152             Count => 4,
2153             # (may need to divide by 4 for some images, eg. D3300/D5300, 12 bit - ref IB)
2154             },
2155             0x003e => { #28
2156             Name => 'ImageSizeRAW',
2157             PrintConv => {
2158             1 => 'Large',
2159             2 => 'Medium',
2160             3 => 'Small',
2161             },
2162             },
2163             0x003f => { #https://github.com/darktable-org/darktable/issues/12282
2164             Name => 'WhiteBalanceFineTune',
2165             Writable => 'rational64s',
2166             Count => 2,
2167             },
2168             0x0044 => { #28
2169             Name => 'JPGCompression',
2170             RawConv => '($val) ? $val : undef', # undef for raw files
2171             PrintConv => {
2172             1 => 'Size Priority',
2173             3 => 'Optimal Quality',
2174             },
2175             },
2176             0x0045 => { #IB
2177             Name => 'CropArea',
2178             Notes => 'left, top, width, height',
2179             Writable => 'int16u',
2180             Count => 4,
2181             },
2182             0x004e => { #28
2183             Name => 'NikonSettings',
2184             Writable => 'undef',
2185             Permanent => 0,
2186             Flags => [ 'Binary', 'Protected' ],
2187             SubDirectory => { TagTable => 'Image::ExifTool::NikonSettings::Main' },
2188             },
2189             0x004f => { #IB (D850)
2190             Name => 'ColorTemperatureAuto',
2191             Writable => 'int16u',
2192             },
2193             0x0051 => { #28 (Z9)
2194             Name => 'MakerNotes0x51',
2195             Writable => 'undef',
2196             #Hidden => 1,
2197             Permanent => 0,
2198             Flags => [ 'Binary', 'Protected' ],
2199             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::MakerNotes0x51' },
2200             },
2201             #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)
2202             0x0056 => { #28 (Z9)
2203             Name => 'MakerNotes0x56',
2204             Writable => 'undef',
2205             #Hidden => 1,
2206             Permanent => 0,
2207             Flags => [ 'Binary', 'Protected' ],
2208             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::MakerNotes0x56' },
2209             },
2210             #0x005e #28 possibly DiffractionCompensation block? Certainly offset 0x04 within block contains tag DiffractionCompensation
2211             0x0080 => { Name => 'ImageAdjustment', Writable => 'string' },
2212             0x0081 => { Name => 'ToneComp', Writable => 'string' }, #2
2213             0x0082 => { Name => 'AuxiliaryLens', Writable => 'string' },
2214             0x0083 => {
2215             Name => 'LensType',
2216             Writable => 'int8u',
2217             # credit to Tom Christiansen (ref 7) for figuring this out...
2218             # (note that older models don't seem to set bits 4-7 (0xf0), so the
2219             # LensType may be different with different models, ref Kenneth Cochran)
2220             PrintConv => q[$_ = $val ? Image::ExifTool::DecodeBits($val,
2221             {
2222             0 => 'MF',
2223             1 => 'D',
2224             2 => 'G',
2225             3 => 'VR',
2226             4 => '1', #PH
2227             5 => 'FT-1', #PH/IB
2228             6 => 'E', #PH (electromagnetic aperture mechanism)
2229             7 => 'AF-P', #PH/IB
2230             }) : 'AF';
2231             # remove commas and change "D G" to just "G"
2232             s/,//g; s/\bD G\b/G/;
2233             s/ E\b// and s/^(G )?/E /; # put "E" at the start instead of "G"
2234             s/ 1// and $_ = "1 $_"; # put "1" at start
2235             s/FT-1 // and $_ .= ' FT-1'; # put "FT-1" at end
2236             return $_;
2237             ],
2238             PrintConvInv => q[
2239             my $bits = 0;
2240             $bits |= 0x01 if $val =~ /\bMF\b/i; # bit 0
2241             $bits |= 0x02 if $val =~ /\bD\b/i; # bit 1
2242             $bits |= 0x06 if $val =~ /\bG\b/i; # bits 1 and 2
2243             $bits |= 0x08 if $val =~ /\bVR\b/i; # bit 3
2244             $bits |= 0x10 if $val =~ /\b1\b/; # bit 4
2245             $bits |= 0x20 if $val =~ /\bFT-1/i; # bit 5
2246             $bits |= 0x80 if $val =~ /\bAF-P/i; # bit 7 (not used by all models)
2247             $bits |= 0x46 if $val =~ /\bE\b/i; # bits 1, 2 and 6
2248             return $bits;
2249             ],
2250             },
2251             0x0084 => { #2
2252             Name => "Lens",
2253             Writable => 'rational64u',
2254             Count => 4,
2255             # short focal, long focal, aperture at short focal, aperture at long focal
2256             PrintConv => \&Image::ExifTool::Exif::PrintLensInfo,
2257             PrintConvInv => \&Image::ExifTool::Exif::ConvertLensInfo,
2258             },
2259             0x0085 => {
2260             Name => 'ManualFocusDistance',
2261             Writable => 'rational64u',
2262             },
2263             0x0086 => {
2264             Name => 'DigitalZoom',
2265             Writable => 'rational64u',
2266             },
2267             0x0087 => { #5
2268             Name => 'FlashMode',
2269             Writable => 'int8u',
2270             PrintConv => {
2271             0 => 'Did Not Fire',
2272             1 => 'Fired, Manual', #14
2273             3 => 'Not Ready', #28
2274             #5 observed on Z9 firing remote SB-5000 via WR-R11a optical awl
2275             7 => 'Fired, External', #14
2276             8 => 'Fired, Commander Mode',
2277             9 => 'Fired, TTL Mode',
2278             18 => 'LED Light', #G.F. (movie LED light)
2279             },
2280             },
2281             0x0088 => [
2282             {
2283             Name => 'AFInfo',
2284             Condition => '$$self{Model} =~ /^NIKON D/i',
2285             SubDirectory => {
2286             TagTable => 'Image::ExifTool::Nikon::AFInfo',
2287             ByteOrder => 'BigEndian',
2288             },
2289             },
2290             {
2291             Name => 'AFInfo',
2292             SubDirectory => {
2293             TagTable => 'Image::ExifTool::Nikon::AFInfo',
2294             ByteOrder => 'LittleEndian',
2295             },
2296             },
2297             ],
2298             0x0089 => { #5
2299             Name => 'ShootingMode',
2300             Writable => 'int16u',
2301             # the meaning of bit 5 seems to change: For the D200 it indicates "Auto ISO" - PH
2302             Notes => 'for the D70, Bit 5 = Unused LE-NR Slowdown',
2303             # credit to Tom Christiansen (ref 7) for figuring this out...
2304             # The (new?) bit 5 seriously complicates our life here: after firmwareB's
2305             # 1.03, bit 5 turns on when you ask for BUT DO NOT USE the long-range
2306             # noise reduction feature, probably because even not using it, it still
2307             # slows down your drive operation to 50% (1.5fps max not 3fps). But no
2308             # longer does !$val alone indicate single-frame operation. - TC, D70
2309             # The following comments are from Warren Hatch:
2310             # Bits 4,6,8 indicate bracketing mode.
2311             # - all 0's => Bracketing Off
2312             # - bit 4 on with bits 6,8 off => Exposure Bracketing On
2313             # - bits 4,6 on => WB bracketing On
2314             # - 4,8 on => ADL Bracketing On
2315             # Bit 2 gives tethered status: Off=>Not Tethered; On=Tethered.
2316             # - that this simply indicates a camera is connected via a cord to a PC
2317             # (doesn't necessarily mean that the shutter was tripped by the computer)
2318             # Bits 0,1,3,7,9 relate to how the shutter is tripped in concert with the
2319             # Release Mode dial [although I cannot cause bit 7 to flip with any of my gear and
2320             # I suspect it is no longer used for the D500]. Regardless, the ReleaseMode tag
2321             # offers a superior decoding of this information for the D4s, D810 and D500.
2322             # Bit 5 indicates whether or not AutoISO is enabled.
2323             PrintConv => q[
2324             $_ = '';
2325             unless ($val & 0x87) {
2326             return 'Single-Frame' unless $val;
2327             $_ = 'Single-Frame, ';
2328             }
2329             return $_ . Image::ExifTool::DecodeBits($val,
2330             {
2331             0 => 'Continuous',
2332             1 => 'Delay',
2333             2 => 'PC Control',
2334             3 => 'Self-timer', #forum6281 (NC)
2335             4 => 'Exposure Bracketing',
2336             5 => $$self{Model}=~/D70\b/ ? 'Unused LE-NR Slowdown' : 'Auto ISO',
2337             6 => 'White-Balance Bracketing',
2338             7 => 'IR Control',
2339             8 => 'D-Lighting Bracketing', #forum6281 (NC)
2340             11 => 'Pre-capture', #28 Z9 pre-release burst
2341             });
2342             ],
2343             },
2344             # 0x008a - called "AutoBracketRelease" by ref 15 [but this seems wrong]
2345             # values: 0,255 (when writing NEF only), or 1,2 (when writing JPEG or JPEG+NEF)
2346             # --> makes odd, repeating pattern in sequential NEF images (ref 28)
2347             0x008b => { #8
2348             Name => 'LensFStops',
2349             ValueConv => 'my ($a,$b,$c)=unpack("C3",$val); $c ? $a*($b/$c) : 0',
2350             ValueConvInv => 'my $a=int($val*12+0.5);$a<256 ? pack("C4",$a,1,12,0) : undef',
2351             PrintConv => 'sprintf("%.2f", $val)',
2352             PrintConvInv => '$val',
2353             Writable => 'undef',
2354             Count => 4,
2355             },
2356             0x008c => {
2357             Name => 'ContrastCurve', #JD
2358             Writable => 'undef',
2359             Flags => [ 'Binary', 'Protected', 'Drop' ], # (drop because not found in Nikon JPEG's)
2360             },
2361             # ColorHue: MODE1/MODE1a=sRGB, MODE2=Adobe RGB, MODE3a=more saturated sRGB
2362             # --> should really be called ColorSpace or ColorMode, but that would conflict with other tags
2363             0x008d => { Name => 'ColorHue' , Writable => 'string' }, #2
2364             # SceneMode takes on the following values: PORTRAIT, PARTY/INDOOR, NIGHT PORTRAIT,
2365             # BEACH/SNOW, LANDSCAPE, SUNSET, NIGHT SCENE, MUSEUM, FIREWORKS, CLOSE UP, COPY,
2366             # BACK LIGHT, PANORAMA ASSIST, SPORT, DAWN/DUSK
2367             0x008f => { Name => 'SceneMode', Writable => 'string' }, #2
2368             # LightSource shows 3 values COLORED SPEEDLIGHT NATURAL.
2369             # (SPEEDLIGHT when flash goes. Have no idea about difference between other two.)
2370             0x0090 => { Name => 'LightSource', Writable => 'string' }, #2
2371             0x0091 => [ #18
2372             { #PH
2373             Condition => '$$valPt =~ /^0209/',
2374             Name => 'ShotInfoD40',
2375             SubDirectory => {
2376             TagTable => 'Image::ExifTool::Nikon::ShotInfoD40',
2377             DecryptStart => 4,
2378             ByteOrder => 'BigEndian',
2379             },
2380             },
2381             {
2382             Condition => '$$valPt =~ /^0208/',
2383             Name => 'ShotInfoD80',
2384             SubDirectory => {
2385             TagTable => 'Image::ExifTool::Nikon::ShotInfoD80',
2386             DecryptStart => 4,
2387             # (Capture NX can change the makernote byte order, but this stays big-endian)
2388             ByteOrder => 'BigEndian',
2389             },
2390             },
2391             { #PH (D90, firmware 1.00)
2392             Condition => '$$valPt =~ /^0213/',
2393             Name => 'ShotInfoD90',
2394             SubDirectory => {
2395             TagTable => 'Image::ExifTool::Nikon::ShotInfoD90',
2396             DecryptStart => 4,
2397             ByteOrder => 'BigEndian',
2398             },
2399             },
2400             { #PH (D3, firmware 0.37 and 1.00)
2401             Condition => '$$valPt =~ /^0210/ and $count == 5399',
2402             Name => 'ShotInfoD3a',
2403             SubDirectory => {
2404             TagTable => 'Image::ExifTool::Nikon::ShotInfoD3a',
2405             DecryptStart => 4,
2406             ByteOrder => 'BigEndian',
2407             },
2408             },
2409             { #PH (D3, firmware 1.10, 2.00 and 2.01 [count 5408], and 2.02 [count 5412])
2410             Condition => '$$valPt =~ /^0210/ and ($count == 5408 or $count == 5412)',
2411             Name => 'ShotInfoD3b',
2412             SubDirectory => {
2413             TagTable => 'Image::ExifTool::Nikon::ShotInfoD3b',
2414             DecryptStart => 4,
2415             ByteOrder => 'BigEndian',
2416             },
2417             },
2418             { #PH (D3X, firmware 1.00)
2419             Condition => '$$valPt =~ /^0214/ and $count == 5409',
2420             Name => 'ShotInfoD3X',
2421             SubDirectory => {
2422             TagTable => 'Image::ExifTool::Nikon::ShotInfoD3X',
2423             DecryptStart => 4,
2424             ByteOrder => 'BigEndian',
2425             },
2426             },
2427             { #PH (D3S, firmware 0.16 and 1.00)
2428             Condition => '$$valPt =~ /^0218/ and ($count == 5356 or $count == 5388)',
2429             Name => 'ShotInfoD3S',
2430             SubDirectory => {
2431             TagTable => 'Image::ExifTool::Nikon::ShotInfoD3S',
2432             DecryptStart => 4,
2433             ByteOrder => 'BigEndian',
2434             },
2435             },
2436             { #JD (D300, firmware 0.25 and 1.00)
2437             # D3 and D300 use the same version number, but the length is different
2438             Condition => '$$valPt =~ /^0210/ and $count == 5291',
2439             Name => 'ShotInfoD300a',
2440             SubDirectory => {
2441             TagTable => 'Image::ExifTool::Nikon::ShotInfoD300a',
2442             DecryptStart => 4,
2443             ByteOrder => 'BigEndian',
2444             },
2445             },
2446             { #PH (D300, firmware version 1.10)
2447             # yet again the same ShotInfoVersion for different data
2448             Condition => '$$valPt =~ /^0210/ and $count == 5303',
2449             Name => 'ShotInfoD300b',
2450             SubDirectory => {
2451             TagTable => 'Image::ExifTool::Nikon::ShotInfoD300b',
2452             DecryptStart => 4,
2453             ByteOrder => 'BigEndian',
2454             },
2455             },
2456             { #PH (D300S, firmware version 1.00)
2457             # yet again the same ShotInfoVersion for different data
2458             Condition => '$$valPt =~ /^0216/ and $count == 5311',
2459             Name => 'ShotInfoD300S',
2460             SubDirectory => {
2461             TagTable => 'Image::ExifTool::Nikon::ShotInfoD300S',
2462             DecryptStart => 4,
2463             ByteOrder => 'BigEndian',
2464             },
2465             },
2466             # 0225 - D600
2467             { #29 (D700 firmware version 1.02f)
2468             Condition => '$$valPt =~ /^0212/ and $count == 5312',
2469             Name => 'ShotInfoD700',
2470             SubDirectory => {
2471             TagTable => 'Image::ExifTool::Nikon::ShotInfoD700',
2472             DecryptStart => 4,
2473             ByteOrder => 'BigEndian',
2474             },
2475             },
2476             { #28 (D780 firmware version 1.00)
2477             Condition => '$$valPt =~ /^0245/',
2478             Name => 'ShotInfoD780',
2479             SubDirectory => {
2480             TagTable => 'Image::ExifTool::Nikon::ShotInfoD780',
2481             DecryptStart => 4,
2482             ByteOrder => 'LittleEndian',
2483             },
2484             },
2485             { #28 (D7500 firmware version 1.00h)
2486             Condition => '$$valPt =~ /^0242/',
2487             Name => 'ShotInfoD7500',
2488             SubDirectory => {
2489             TagTable => 'Image::ExifTool::Nikon::ShotInfoD7500',
2490             DecryptStart => 4,
2491             ByteOrder => 'LittleEndian',
2492             },
2493             },
2494             { #PH (D800 firmware 1.01a)
2495             Condition => '$$valPt =~ /^0222/',
2496             Name => 'ShotInfoD800',
2497             SubDirectory => {
2498             TagTable => 'Image::ExifTool::Nikon::ShotInfoD800',
2499             DecryptStart => 4,
2500             ByteOrder => 'BigEndian',
2501             },
2502             },
2503             { #28 (D810 firmware 1.01)
2504             Condition => '$$valPt =~ /^0233/',
2505             Name => 'ShotInfoD810',
2506             SubDirectory => {
2507             TagTable => 'Image::ExifTool::Nikon::ShotInfoD810',
2508             DecryptStart => 4,
2509             ByteOrder => 'LittleEndian',
2510             },
2511             },
2512             { #28 (D850 firmware 1.00b)
2513             Condition => '$$valPt =~ /^0243/',
2514             Name => 'ShotInfoD850',
2515             SubDirectory => {
2516             TagTable => 'Image::ExifTool::Nikon::ShotInfoD850',
2517             DecryptStart => 4,
2518             ByteOrder => 'LittleEndian',
2519             },
2520             },
2521             # 0217 - D3000
2522             # 0219 - D3100
2523             # 0224 - D3200
2524             { #PH
2525             Condition => '$$valPt =~ /^0215/ and $count == 6745',
2526             Name => 'ShotInfoD5000',
2527             SubDirectory => {
2528             TagTable => 'Image::ExifTool::Nikon::ShotInfoD5000',
2529             DecryptStart => 4,
2530             ByteOrder => 'BigEndian',
2531             },
2532             },
2533             { #PH
2534             Condition => '$$valPt =~ /^0221/ and $count == 8902',
2535             Name => 'ShotInfoD5100',
2536             SubDirectory => {
2537             TagTable => 'Image::ExifTool::Nikon::ShotInfoD5100',
2538             DecryptStart => 4,
2539             ByteOrder => 'BigEndian',
2540             },
2541             },
2542             { #PH
2543             Condition => '$$valPt =~ /^0226/ and $count == 11587',
2544             Name => 'ShotInfoD5200',
2545             SubDirectory => {
2546             TagTable => 'Image::ExifTool::Nikon::ShotInfoD5200',
2547             DecryptStart => 4,
2548             ByteOrder => 'BigEndian',
2549             },
2550             },
2551             { #29 (D7000 firmware version 1.01b)
2552             Condition => '$$valPt =~ /^0220/',
2553             Name => 'ShotInfoD7000',
2554             SubDirectory => {
2555             TagTable => 'Image::ExifTool::Nikon::ShotInfoD7000',
2556             DecryptStart => 4,
2557             ByteOrder => 'BigEndian',
2558             },
2559             },
2560             { # (D4 firmware version 1.00g)
2561             Condition => '$$valPt =~ /^0223/',
2562             Name => 'ShotInfoD4',
2563             SubDirectory => {
2564             TagTable => 'Image::ExifTool::Nikon::ShotInfoD4',
2565             DecryptStart => 4,
2566             ByteOrder => 'BigEndian',
2567             },
2568             },
2569             { # (D4S firmware version 1.00d and 1.01a)
2570             Condition => '$$valPt =~ /^0231/',
2571             Name => 'ShotInfoD4S',
2572             SubDirectory => {
2573             TagTable => 'Image::ExifTool::Nikon::ShotInfoD4S',
2574             DecryptStart => 4,
2575             ByteOrder => 'LittleEndian',
2576             },
2577             },
2578             { #28 (D500 firmware version 1.00 and D5 firmware version 1.10a)
2579             Condition => '$$valPt =~ /^023[89]/',
2580             Name => 'ShotInfoD500',
2581             SubDirectory => {
2582             TagTable => 'Image::ExifTool::Nikon::ShotInfoD500',
2583             DecryptStart => 4,
2584             ByteOrder => 'LittleEndian',
2585             },
2586             },
2587             { # (D6 firmware version 1.00, ref 28)
2588             Condition => '$$valPt =~ /^0246/',
2589             Name => 'ShotInfoD6',
2590             SubDirectory => {
2591             TagTable => 'Image::ExifTool::Nikon::ShotInfoD6',
2592             DecryptStart => 4,
2593             ByteOrder => 'LittleEndian',
2594             },
2595             },
2596             { # (D610 firmware version 1.00)
2597             Condition => '$$valPt =~ /^0232/',
2598             Name => 'ShotInfoD610',
2599             SubDirectory => {
2600             TagTable => 'Image::ExifTool::Nikon::ShotInfoD610',
2601             DecryptStart => 4,
2602             ByteOrder => 'BigEndian',
2603             },
2604             },
2605             { # (Z6_3 firmware version 1.00, ref 28)
2606             Condition => '$$valPt =~ /^08(09|10|11)/', #0809=Z6iii 0810=Z50ii #0811=Z5ii
2607             Name => 'ShotInfoZ6III',
2608             SubDirectory => {
2609             TagTable => 'Image::ExifTool::Nikon::ShotInfoZ6III',
2610             DecryptStart => 4,
2611             ByteOrder => 'LittleEndian',
2612             },
2613             },
2614             { # (Z6_2 firmware version 1.00 and Z7_2 firmware versions 1.00 & 1.01, ref 28)
2615             # 0800=Z6/Z7 0801=Z50 0802=Z5 0803=Z6II/Z7II 0804=Zfc 0807=Z30 0808=Zf
2616             Condition => '$$valPt =~ /^080[0123478]/',
2617             Name => 'ShotInfoZ7II',
2618             SubDirectory => {
2619             TagTable => 'Image::ExifTool::Nikon::ShotInfoZ7II',
2620             DecryptStart => 4,
2621             ByteOrder => 'LittleEndian',
2622             },
2623             },
2624             { # (Z8 firmware version 1.00 ref 28)
2625             Condition => '$$valPt =~ /^0806/',
2626             Name => 'ShotInfoZ8',
2627             SubDirectory => {
2628             TagTable => 'Image::ExifTool::Nikon::ShotInfoZ8',
2629             DecryptStart => 4,
2630             ByteOrder => 'LittleEndian',
2631             },
2632             },
2633             { # (Z9 firmware version 1.00 ref 28)
2634             Condition => '$$valPt =~ /^0805/',
2635             Name => 'ShotInfoZ9',
2636             SubDirectory => {
2637             TagTable => 'Image::ExifTool::Nikon::ShotInfoZ9',
2638             DecryptStart => 4,
2639             ByteOrder => 'LittleEndian',
2640             },
2641             },
2642             { # D7100=0227
2643             Condition => '$$valPt =~ /^0[28]/',
2644             Name => 'ShotInfo02xx',
2645             Drop => 50000, # drop if too large (>64k for Z6iii)
2646             SubDirectory => {
2647             TagTable => 'Image::ExifTool::Nikon::ShotInfo',
2648             ProcessProc => \&ProcessNikonEncrypted,
2649             WriteProc => \&ProcessNikonEncrypted,
2650             DecryptStart => 4,
2651             ByteOrder => 'BigEndian',
2652             },
2653             },
2654             {
2655             Name => 'ShotInfoUnknown',
2656             Writable => 0,
2657             SubDirectory => {
2658             TagTable => 'Image::ExifTool::Nikon::ShotInfo',
2659             ByteOrder => 'BigEndian',
2660             },
2661             },
2662             ],
2663             0x0092 => { #2
2664             Name => 'HueAdjustment',
2665             Writable => 'int16s',
2666             },
2667             # 0x0093 - ref 15 calls this Saturation, but this is wrong - PH
2668             0x0093 => { #21
2669             Name => 'NEFCompression',
2670             Writable => 'int16u',
2671             SeparateTable => 'NEFCompression',
2672             PrintConv => \%nefCompression,
2673             },
2674             0x0094 => { Name => 'SaturationAdj', Writable => 'int16s' },
2675             0x0095 => { Name => 'NoiseReduction', Writable => 'string' }, # ("Off" or "FPNR"=long exposure NR)
2676             0x0096 => { # (not found in NRW files, but also not in all NEF's)
2677             Name => 'NEFLinearizationTable', # same table as DNG LinearizationTable (ref JD)
2678             Writable => 'undef',
2679             Flags => [ 'Binary', 'Protected' ],
2680             },
2681             0x0097 => [ #4
2682             # (NOTE: these are byte-swapped by NX when byte order changes)
2683             {
2684             Condition => '$$valPt =~ /^0100/', # (D100 and Coolpix models)
2685             Name => 'ColorBalance0100',
2686             SubDirectory => {
2687             Start => '$valuePtr + 72',
2688             TagTable => 'Image::ExifTool::Nikon::ColorBalance1',
2689             },
2690             },
2691             {
2692             Condition => '$$valPt =~ /^0102/', # (D2H)
2693             Name => 'ColorBalance0102',
2694             SubDirectory => {
2695             Start => '$valuePtr + 10',
2696             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2697             },
2698             },
2699             {
2700             Condition => '$$valPt =~ /^0103/', # (D70/D70s)
2701             Name => 'ColorBalance0103',
2702             # D70: at file offset 'tag-value + base + 20', 4 16 bits numbers,
2703             # v[0]/v[1] , v[2]/v[3] are the red/blue multipliers.
2704             SubDirectory => {
2705             Start => '$valuePtr + 20',
2706             TagTable => 'Image::ExifTool::Nikon::ColorBalance3',
2707             },
2708             },
2709             {
2710             Condition => '$$valPt =~ /^0205/', # (D50)
2711             Name => 'ColorBalance0205',
2712             SubDirectory => {
2713             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2714             ProcessProc => \&ProcessNikonEncrypted,
2715             WriteProc => \&ProcessNikonEncrypted,
2716             DecryptStart => 4,
2717             DirOffset => 14, # (start of directory relative to DecryptStart)
2718             },
2719             },
2720             { # (D3/D3X/D300/D700=0209,D300S=0212,D3S=0214)
2721             Condition => '$$valPt =~ /^02(09|12|14)/',
2722             Name => 'ColorBalance0209',
2723             SubDirectory => {
2724             TagTable => 'Image::ExifTool::Nikon::ColorBalance4',
2725             ProcessProc => \&ProcessNikonEncrypted,
2726             WriteProc => \&ProcessNikonEncrypted,
2727             DecryptStart => 284,
2728             DirOffset => 10,
2729             },
2730             },
2731             { # (D2X/D2Xs=0204,D2Hs=0206,D200=0207,D40/D40X/D80=0208,D60=0210)
2732             Condition => '$$valPt =~ /^02(\d{2})/ and $1 < 11',
2733             Name => 'ColorBalance02',
2734             SubDirectory => {
2735             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2736             ProcessProc => \&ProcessNikonEncrypted,
2737             WriteProc => \&ProcessNikonEncrypted,
2738             DecryptStart => 284,
2739             DirOffset => 6,
2740             },
2741             },
2742             {
2743             Condition => '$$valPt =~ /^0211/', # (D90/D5000)
2744             Name => 'ColorBalance0211',
2745             SubDirectory => {
2746             TagTable => 'Image::ExifTool::Nikon::ColorBalance4',
2747             ProcessProc => \&ProcessNikonEncrypted,
2748             WriteProc => \&ProcessNikonEncrypted,
2749             DecryptStart => 284,
2750             DirOffset => 16,
2751             },
2752             },
2753             {
2754             Condition => '$$valPt =~ /^0213/', # (D3000)
2755             Name => 'ColorBalance0213',
2756             SubDirectory => {
2757             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2758             ProcessProc => \&ProcessNikonEncrypted,
2759             WriteProc => \&ProcessNikonEncrypted,
2760             DecryptStart => 284,
2761             DirOffset => 10,
2762             },
2763             },
2764             { # (D3100=0215,D7000/D5100=0216,D4/D600/D800/D800E/D3200=0217)
2765             Condition => '$$valPt =~ /^021[567]/',
2766             Name => 'ColorBalance0215',
2767             SubDirectory => {
2768             TagTable => 'Image::ExifTool::Nikon::ColorBalance4',
2769             ProcessProc => \&ProcessNikonEncrypted,
2770             WriteProc => \&ProcessNikonEncrypted,
2771             DecryptStart => 284,
2772             DirOffset => 4,
2773             },
2774             },
2775             { #PH (NC)
2776             # (D5300=0219, D3300=0221, D4S=0222, D750/D810=0223, D3400/D3500/D5500/D5600/D7200=0224)
2777             Condition => '$$valPt =~ /^02(19|2[1234])/',
2778             Name => 'ColorBalance0219',
2779             SubDirectory => {
2780             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2781             ProcessProc => \&ProcessNikonEncrypted,
2782             WriteProc => \&ProcessNikonEncrypted,
2783             DecryptStart => 4,
2784             DirOffset => 0x7c,
2785             },
2786             },
2787             { # (D610/Df=0220, CoolpixA=0601)
2788             Name => 'ColorBalanceUnknown1',
2789             Condition => '$$valPt =~ /^0(220|6)/',
2790             SubDirectory => {
2791             TagTable => 'Image::ExifTool::Nikon::ColorBalanceUnknown',
2792             ProcessProc => \&ProcessNikonEncrypted,
2793             WriteProc => \&ProcessNikonEncrypted, # (necessary to recrypt this if serial number changed)
2794             DecryptStart => 284,
2795             },
2796             },
2797             { # (D5200/D7200=0218, D5/D500=0225, D7500=0226, D850=0227, D6/D780=0228,
2798             # 1J1/1J2/1V1=0400, 1V2=0401, 1J3/1S1=0402, 1AW1=0403, Z6/Z7=0800)
2799             Name => 'ColorBalanceUnknown2',
2800             Condition => '$$valPt =~ /^0(18|[248])/',
2801             SubDirectory => {
2802             TagTable => 'Image::ExifTool::Nikon::ColorBalanceUnknown2',
2803             ProcessProc => \&ProcessNikonEncrypted,
2804             WriteProc => \&ProcessNikonEncrypted, # (necessary to recrypt this if serial number changed)
2805             DecryptStart => 4,
2806             },
2807             },
2808             {
2809             # (CoolpixP7700/P7800=0500, CoolpixP330/P520=0502)
2810             Name => 'ColorBalanceUnknown',
2811             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::ColorBalanceUnknown' },
2812             },
2813             ],
2814             0x0098 => [
2815             { #8
2816             Condition => '$$valPt =~ /^0100/', # D100, D1X - PH
2817             Name => 'LensData0100',
2818             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LensData00' },
2819             },
2820             { #8
2821             Condition => '$$valPt =~ /^0101/', # D70, D70s - PH
2822             Name => 'LensData0101',
2823             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LensData01' },
2824             },
2825             # note: this information is encrypted if the version is 02xx
2826             { #8
2827             # 0201 - D200, D2Hs, D2X and D2Xs
2828             # 0202 - D40, D40X and D80
2829             # 0203 - D300
2830             Condition => '$$valPt =~ /^020[1-3]/',
2831             Name => 'LensData0201',
2832             SubDirectory => {
2833             TagTable => 'Image::ExifTool::Nikon::LensData01',
2834             ProcessProc => \&ProcessNikonEncrypted,
2835             WriteProc => \&ProcessNikonEncrypted,
2836             DecryptStart => 4,
2837             },
2838             },
2839             { #PH
2840             Condition => '$$valPt =~ /^0204/', # D90, D7000
2841             Name => 'LensData0204',
2842             SubDirectory => {
2843             TagTable => 'Image::ExifTool::Nikon::LensData0204',
2844             ProcessProc => \&ProcessNikonEncrypted,
2845             WriteProc => \&ProcessNikonEncrypted,
2846             DecryptStart => 4,
2847             },
2848             },
2849             {
2850             Condition => '$$valPt =~ /^040[01]/', # 0=1J1/1V1, 1=1J2
2851             Name => 'LensData0400',
2852             SubDirectory => {
2853             TagTable => 'Image::ExifTool::Nikon::LensData0400',
2854             ProcessProc => \&ProcessNikonEncrypted,
2855             WriteProc => \&ProcessNikonEncrypted,
2856             DecryptStart => 4,
2857             },
2858             },
2859             {
2860             Condition => '$$valPt =~ /^0402/', # 1J3/1S1/1V2
2861             Name => 'LensData0402',
2862             SubDirectory => {
2863             TagTable => 'Image::ExifTool::Nikon::LensData0402',
2864             ProcessProc => \&ProcessNikonEncrypted,
2865             WriteProc => \&ProcessNikonEncrypted,
2866             DecryptStart => 4,
2867             },
2868             },
2869             {
2870             Condition => '$$valPt =~ /^0403/', # 1J4,1J5
2871             Name => 'LensData0403',
2872             SubDirectory => {
2873             TagTable => 'Image::ExifTool::Nikon::LensData0403',
2874             ProcessProc => \&ProcessNikonEncrypted,
2875             WriteProc => \&ProcessNikonEncrypted,
2876             DecryptStart => 4,
2877             },
2878             },
2879             {
2880             Condition => '$$valPt =~ /^080[012]/', # Z6/Z7/Z9
2881             Name => 'LensData0800',
2882             SubDirectory => {
2883             TagTable => 'Image::ExifTool::Nikon::LensData0800',
2884             ProcessProc => \&ProcessNikonEncrypted,
2885             WriteProc => \&ProcessNikonEncrypted,
2886             DecryptStart => 4,
2887             ByteOrder => 'LittleEndian',
2888             },
2889             },
2890             {
2891             Name => 'LensDataUnknown',
2892             SubDirectory => {
2893             TagTable => 'Image::ExifTool::Nikon::LensDataUnknown',
2894             ProcessProc => \&ProcessNikonEncrypted,
2895             WriteProc => \&ProcessNikonEncrypted,
2896             DecryptStart => 4,
2897             },
2898             },
2899             ],
2900             0x0099 => { #2/15
2901             Name => 'RawImageCenter',
2902             Writable => 'int16u',
2903             Count => 2,
2904             },
2905             0x009a => { #10
2906             Name => 'SensorPixelSize',
2907             Writable => 'rational64u',
2908             Count => 2,
2909             PrintConv => '$val=~s/ / x /;"$val um"',
2910             PrintConvInv => '$val=~tr/a-zA-Z/ /;$val',
2911             },
2912             0x009c => { #14
2913             # L2/L3 has these modes (from owner's manual): - PH
2914             # Portrait Assist: FACE-PRIORITY AF,PORTRAIT,PORTRAIT LEFT,PORTRAIT RIGHT,
2915             # PORTRAIT CLOSE-UP,PORTRAIT COUPLE,PORTRAIT-FIGURE
2916             # Landscape Assist:LANDSCAPE,SCENIC VIEW,ARCHITECTURE,GROUP RIGHT,GROUP LEFT
2917             # Sports Assist: SPORTS,SPORT SPECTATOR,SPORT COMPOSITE
2918             # P7100 has test modes: - PH
2919             # CREATIVE MONOCHROME,PAINTING,CROSS PROCESS,SOFT,NOSTALGIC SEPIA,
2920             # HIGH KEY,LOW KEY,SELECTIVE COLOR,ZOOM EXPOSURE EXP.,DEFOCUS DURING
2921             Name => 'SceneAssist',
2922             Writable => 'string',
2923             },
2924             0x009d => { #NealKrawetz
2925             Name => 'DateStampMode',
2926             Writable => 'int16u',
2927             Notes => 'feature to imprint date/time on image',
2928             PrintConv => { #PH
2929             0 => 'Off',
2930             1 => 'Date & Time',
2931             2 => 'Date',
2932             3 => 'Date Counter', # (NC) (D3500)
2933             },
2934             },
2935             0x009e => { #JD
2936             Name => 'RetouchHistory',
2937             Writable => 'int16u',
2938             Count => 10,
2939             # trim off extra "None" values
2940             ValueConv => '$val=~s/( 0)+$//; $val',
2941             ValueConvInv => 'my $n=($val=~/ \d+/g);$n < 9 ? $val . " 0" x (9-$n) : $val',
2942             PrintConvColumns => 2,
2943             PrintConv => [
2944             \%retouchValues,
2945             \%retouchValues,
2946             \%retouchValues,
2947             \%retouchValues,
2948             \%retouchValues,
2949             \%retouchValues,
2950             \%retouchValues,
2951             \%retouchValues,
2952             \%retouchValues,
2953             \%retouchValues,
2954             ],
2955             },
2956             0x00a0 => { Name => 'SerialNumber', Writable => 'string' }, #2
2957             0x00a2 => { # size of compressed image data plus EOI segment (ref 10)
2958             Name => 'ImageDataSize',
2959             Writable => 'int32u',
2960             },
2961             # 0x00a3 - int8u: 0 (All DSLR's but D1,D1H,D1X,D100)
2962             # 0x00a4 - version number found only in NEF images from DSLR models except the
2963             # D1,D1X,D2H and D100. Value is "0200" for all available samples except images
2964             # edited by Nikon Capture Editor 4.3.1 W and 4.4.2 which have "0100" - PH
2965             0x00a5 => { #15
2966             Name => 'ImageCount',
2967             Writable => 'int32u',
2968             },
2969             0x00a6 => { #15
2970             Name => 'DeletedImageCount',
2971             Writable => 'int32u',
2972             },
2973             # the sum of 0xa5 and 0xa6 is equal to 0xa7 ShutterCount (D2X,D2Hs,D2H,D200, ref 10)
2974             0x00a7 => { # Number of shots taken by camera so far (ref 2)
2975             Name => 'ShutterCount',
2976             Writable => 'int32u',
2977             Protected => 1,
2978             PrintConv => '$val == 4294965247 ? "n/a" : $val',
2979             PrintConvInv => '$val eq "n/a" ? 4294965247 : $val',
2980             Notes => q{
2981             includes both mechanical and electronic shutter activations for models with
2982             this feature. This value is used as a key to decrypt other information, and
2983             writing this tag causes the other information to be re-encrypted with the
2984             new key
2985             },
2986             },
2987             0x00a8 => [#JD
2988             {
2989             Name => 'FlashInfo0100',
2990             Condition => '$$valPt =~ /^010[01]/',
2991             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0100' },
2992             },
2993             {
2994             Name => 'FlashInfo0102',
2995             Condition => '$$valPt =~ /^0102/',
2996             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0102' },
2997             },
2998             {
2999             Name => 'FlashInfo0103',
3000             # (0104 for D7000, 0105 for D800)
3001             Condition => '$$valPt =~ /^010[345]/',
3002             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0103' },
3003             },
3004             {
3005             Name => 'FlashInfo0106', # (Df, D610, D3300, D5300, D7100, Coolpix A)
3006             Condition => '$$valPt =~ /^0106/',
3007             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0106' },
3008             },
3009             {
3010             Name => 'FlashInfo0107', # (0107 for D4S/D750/D810/D5500/D7200, 0108 for D5/D500/D3400)
3011             Condition => '$$valPt =~ /^010[78]/',
3012             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0107' },
3013             },
3014             {
3015             Name => 'FlashInfo0300', # (Z7II)
3016             Condition => '$$valPt =~ /^030[01]/',
3017             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0300' },
3018             },
3019             {
3020             Name => 'FlashInfoUnknown',
3021             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfoUnknown' },
3022             },
3023             ],
3024             0x00a9 => { Name => 'ImageOptimization',Writable => 'string' },#2
3025             0x00aa => { Name => 'Saturation', Writable => 'string' }, #2
3026             0x00ab => { Name => 'VariProgram', Writable => 'string' }, #2 (scene mode for DSLR's - PH)
3027             0x00ac => { Name => 'ImageStabilization',Writable=> 'string' }, #14
3028             0x00ad => { Name => 'AFResponse', Writable => 'string' }, #14
3029             0x00b0 => [{ #PH
3030             Name => 'MultiExposure',
3031             Condition => '$$valPt =~ /^0100/',
3032             SubDirectory => {
3033             TagTable => 'Image::ExifTool::Nikon::MultiExposure',
3034             # Note: this endianness varies with model, but Nikon software may change
3035             # metadata endianness (although it is unknown how it affects this record),
3036             # so for now don't specify ByteOrder although it may be wrong if the
3037             # file is rewritten by Nikon software --> see comments for FileInfo
3038             },
3039             },{
3040             Name => 'MultiExposure',
3041             Condition => '$$valPt =~ /^0101/',
3042             SubDirectory => {
3043             TagTable => 'Image::ExifTool::Nikon::MultiExposure',
3044             ByteOrder => 'LittleEndian',
3045             },
3046             },{
3047             Name => 'MultiExposure2',
3048             Condition => '$$valPt =~ /^010[23]/', # 0102 is NC (PH)
3049             SubDirectory => {
3050             TagTable => 'Image::ExifTool::Nikon::MultiExposure2',
3051             },
3052             }],
3053             0x00b1 => { #14/PH/JD (D80)
3054             Name => 'HighISONoiseReduction',
3055             Writable => 'int16u',
3056             PrintConv => {
3057             0 => 'Off',
3058             1 => 'Minimal', # for high ISO (>800) when setting is "Off"
3059             2 => 'Low', # Low,Normal,High take effect for ISO > 400
3060             3 => 'Medium Low',
3061             4 => 'Normal',
3062             5 => 'Medium High',
3063             6 => 'High',
3064             },
3065             },
3066             # 0x00b2 (string: "NORMAL ", 0xc3's, 0xff's or 0x20's)
3067             0x00b3 => { #14
3068             Name => 'ToningEffect',
3069             Writable => 'string',
3070             },
3071             0x00b6 => { #PH
3072             Name => 'PowerUpTime',
3073             Groups => { 2 => 'Time' },
3074             Shift => 'Time',
3075             # not clear whether "powered up" means "turned on" or "power applied" - PH
3076             Notes => 'date/time when camera was last powered up',
3077             Writable => 'undef',
3078             # must use RawConv so byte order is correct
3079             RawConv => sub {
3080             my $val = shift;
3081             return $val if length $val < 7;
3082             my $shrt = GetByteOrder() eq 'II' ? 'v' : 'n';
3083             my @date = unpack("${shrt}C5", $val);
3084             return sprintf('%.4d:%.2d:%.2d %.2d:%.2d:%.2d', @date);
3085             },
3086             RawConvInv => sub {
3087             my $val = shift;
3088             my $shrt = GetByteOrder() eq 'II' ? 'v' : 'n';
3089             my @date = ($val =~ /\d+/g);
3090             return pack("${shrt}C6", @date, 0);
3091             },
3092             PrintConv => '$self->ConvertDateTime($val)',
3093             PrintConvInv => '$self->InverseDateTime($val,0)',
3094             },
3095             0x00b7 => [{
3096             Name => 'AFInfo2',
3097             # LiveView-enabled DSLRs introduced starting in 2007 (D3/D300)
3098             Condition => '$$valPt =~ /^0100/',
3099             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0100' },
3100             },{
3101             Name => 'AFInfo2',
3102             # All Expeed 5 processor and most Expeed 4 processor models from 2016 - D5, D500, D850, D3400, D3500, D7500 (D5600 is v0100)
3103             Condition => '$$valPt =~ /^0101/',
3104             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0101' },
3105             },{
3106             Name => 'AFInfo2',
3107             # Nikon 1 Series cameras
3108             Condition => '$$valPt =~ /^020[01]/',
3109             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0200' },
3110             },{
3111             Name => 'AFInfo2',
3112             # Expeed 6 processor models - D6, D780, Z5, Z6, Z7, Z30, Z50, Z6_2, Z7_2 and Zfc
3113             Condition => '$$valPt =~ /^030[01]/',
3114             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0300' },
3115             },{
3116             Name => 'AFInfo2',
3117             # Expeed 7 processor models - Z8 & Z9 (AFInfo2Version 0400), Z6iii & Zf (AFInfo2Version 0401)
3118             # and Z50ii (AFInfo2Version 0402)
3119             Condition => '$$valPt =~ /^040[012]/',
3120             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0400' },
3121             }],
3122             0x00b8 => [{ #PH
3123             Name => 'FileInfo',
3124             # unfortunately, some newer models write this as little-endian
3125             # (and CaptureNX can change the byte order of the maker notes,
3126             # but leaves this structure unchanged)
3127             # - it will be an ongoing pain to keep this list of models up-to-date,
3128             # so if only one ordering yields valid DirectoryNumber and FileNumber values,
3129             # use it, otherwise default to a-priori knowledge of the camera model
3130             # (assume that a valid DirectoryNumber is 100-999, and a valid FileNumber
3131             # is 0000-9999, although I have some samples with a DirectoryNumber of 99)
3132             Condition => q{
3133             if (length($$valPt) >= 0) {
3134             my ($dir, $file) = unpack('x6vv', $$valPt);
3135             my $littleEndian = ($dir >= 100 and $dir <= 999 and $file <= 9999);
3136             ($dir, $file) = unpack('x6nn', $$valPt);
3137             my $bigEndian = ($dir >= 100 and $dir <= 999 and $file <= 9999);
3138             return $littleEndian if $littleEndian xor $bigEndian;
3139             }
3140             return $$self{Model} =~ /^NIKON (D4S|D750|D810|D3300|D5200|D5300|D5500|D7100)$/;
3141             },
3142             SubDirectory => {
3143             TagTable => 'Image::ExifTool::Nikon::FileInfo',
3144             ByteOrder => 'LittleEndian',
3145             },
3146             },{
3147             Name => 'FileInfo',
3148             SubDirectory => {
3149             TagTable => 'Image::ExifTool::Nikon::FileInfo',
3150             ByteOrder => 'BigEndian',
3151             },
3152             }],
3153             0x00b9 => { #28
3154             Name => 'AFTune',
3155             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFTune' },
3156             },
3157             # 0x00ba - custom curve data? (ref 28?) (only in NEF images)
3158             0x00bb => { #forum6281
3159             Name => 'RetouchInfo',
3160             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::RetouchInfo' },
3161             },
3162             # 0x00bc - NEFThumbnail? (forum6281)
3163             0x00bd => { #PH (P6000)
3164             Name => 'PictureControlData',
3165             Writable => 'undef',
3166             Permanent => 0,
3167             Flags => [ 'Binary', 'Protected' ],
3168             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl' },
3169             },
3170             0x00bf => {
3171             Name => 'SilentPhotography',
3172             PrintConv => \%offOn,
3173             },
3174             0x00c3 => {
3175             Name => 'BarometerInfo',
3176             SubDirectory => {
3177             TagTable => 'Image::ExifTool::Nikon::BarometerInfo',
3178             # (little-endian in II EXIF, big-endian in MOV)
3179             },
3180             },
3181             0x0e00 => {
3182             Name => 'PrintIM',
3183             Description => 'Print Image Matching',
3184             Writable => 0,
3185             SubDirectory => {
3186             TagTable => 'Image::ExifTool::PrintIM::Main',
3187             },
3188             },
3189             # 0x0e01 - In D70 NEF files produced by Nikon Capture, the data for this tag extends 4 bytes
3190             # past the end of the maker notes. Very odd. I hope these 4 bytes aren't useful because
3191             # they will get lost by any utility that blindly copies the maker notes (not ExifTool) - PH
3192             0x0e01 => {
3193             Name => 'NikonCaptureData',
3194             Writable => 'undef',
3195             Permanent => 0,
3196             # (Drop because may be too large for JPEG images)
3197             Flags => [ 'Binary', 'Protected', 'Drop' ],
3198             Notes => q{
3199             this data is dropped when copying Nikon MakerNotes since it may be too large
3200             to fit in the EXIF segment of a JPEG image, but it may be copied as a block
3201             into existing Nikon MakerNotes later if desired
3202             },
3203             SubDirectory => {
3204             DirName => 'NikonCapture',
3205             TagTable => 'Image::ExifTool::NikonCapture::Main',
3206             },
3207             },
3208             # 0x0e05 written by Nikon Capture to NEF files, values of 1 and 2 - PH
3209             0x0e09 => { #12
3210             Name => 'NikonCaptureVersion',
3211             Writable => 'string',
3212             Permanent => 0,
3213             PrintConv => undef, # (avoid applying default print conversion to string)
3214             },
3215             # 0x0e0e is in D70 Nikon Capture files (not out-of-the-camera D70 files) - PH
3216             0x0e0e => { #PH
3217             Name => 'NikonCaptureOffsets',
3218             Writable => 'undef',
3219             Permanent => 0,
3220             SubDirectory => {
3221             TagTable => 'Image::ExifTool::Nikon::CaptureOffsets',
3222             Validate => '$val =~ /^0100/',
3223             Start => '$valuePtr + 4',
3224             },
3225             },
3226             0x0e10 => { #17
3227             Name => 'NikonScanIFD',
3228             Groups => { 1 => 'NikonScan', 2 => 'Image' },
3229             Flags => 'SubIFD',
3230             SubDirectory => {
3231             TagTable => 'Image::ExifTool::Nikon::Scan',
3232             Start => '$val',
3233             },
3234             },
3235             0x0e13 => [{ # PH/https://exiftool.org/forum/index.php/topic,2737.0.html
3236             Name => 'NikonCaptureEditVersions',
3237             Condition => '$self->Options("ExtractEmbedded")',
3238             Notes => q{
3239             the L option may be used to decode settings from the stored
3240             edit versions, otherwise this is extracted as a binary data block
3241             },
3242             Writable => 'undef',
3243             Permanent => 0,
3244             Drop => 1, # (may be too large for JPEG images)
3245             SubDirectory => {
3246             DirName => 'NikonCaptureEditVersions',
3247             TagTable => 'Image::ExifTool::NikonCapture::Main',
3248             ProcessProc => \&ProcessNikonCaptureEditVersions,
3249             WriteProc => sub { return undef }, # (writing not yet supported)
3250             },
3251             },{
3252             Name => 'NikonCaptureEditVersions',
3253             Writable => 'undef',
3254             Permanent => 0,
3255             Flags => [ 'Binary', 'Protected', 'Drop' ],
3256             }],
3257             0x0e1d => { #JD
3258             Name => 'NikonICCProfile',
3259             Flags => [ 'Binary', 'Protected' ],
3260             Writable => 'undef', # must be defined here so tag will be extracted if specified
3261             WriteCheck => q{
3262             require Image::ExifTool::ICC_Profile;
3263             return Image::ExifTool::ICC_Profile::ValidateICC(\$val);
3264             },
3265             SubDirectory => {
3266             DirName => 'NikonICCProfile',
3267             TagTable => 'Image::ExifTool::ICC_Profile::Main',
3268             },
3269             },
3270             0x0e1e => { #PH
3271             Name => 'NikonCaptureOutput',
3272             Writable => 'undef',
3273             Permanent => 0,
3274             Flags => [ 'Binary', 'Protected' ],
3275             SubDirectory => {
3276             TagTable => 'Image::ExifTool::Nikon::CaptureOutput',
3277             Validate => '$val =~ /^0100/',
3278             },
3279             },
3280             0x0e22 => { #28
3281             Name => 'NEFBitDepth',
3282             Writable => 'int16u',
3283             Count => 4,
3284             Protected => 1,
3285             PrintConv => {
3286             '0 0 0 0' => 'n/a (JPEG)',
3287             '8 8 8 0' => '8 x 3', # TIFF RGB
3288             '16 16 16 0' => '16 x 3', # TIFF 16-bit RGB
3289             '12 0 0 0' => 12,
3290             '14 0 0 0' => 14,
3291             },
3292             },
3293             );
3294              
3295             # NikonScan IFD entries (ref 17)
3296             %Image::ExifTool::Nikon::Scan = (
3297             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
3298             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
3299             WRITE_GROUP => 'NikonScan',
3300             WRITABLE => 1,
3301             GROUPS => { 0 => 'MakerNotes', 1 => 'NikonScan', 2 => 'Image' },
3302             VARS => { MINOR_ERRORS => 1 }, # this IFD is non-essential and often corrupted
3303             NOTES => 'This information is written by the Nikon Scan software.',
3304             0x02 => { Name => 'FilmType', Writable => 'string', },
3305             0x40 => { Name => 'MultiSample', Writable => 'string' },
3306             0x41 => { Name => 'BitDepth', Writable => 'int16u' },
3307             0x50 => {
3308             Name => 'MasterGain',
3309             Writable => 'rational64s',
3310             PrintConv => 'sprintf("%.2f",$val)',
3311             PrintConvInv => '$val',
3312             },
3313             0x51 => {
3314             Name => 'ColorGain',
3315             Writable => 'rational64s',
3316             Count => 3,
3317             PrintConv => 'sprintf("%.2f %.2f %.2f",split(" ",$val))',
3318             PrintConvInv => '$val',
3319             },
3320             0x60 => {
3321             Name => 'ScanImageEnhancer',
3322             Writable => 'int32u',
3323             PrintConv => \%offOn,
3324             },
3325             0x100 => { Name => 'DigitalICE', Writable => 'string' },
3326             0x110 => {
3327             Name => 'ROCInfo',
3328             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::ROC' },
3329             },
3330             0x120 => {
3331             Name => 'GEMInfo',
3332             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::GEM' },
3333             },
3334             0x200 => { Name => 'DigitalDEEShadowAdj', Writable => 'int32u' },
3335             0x201 => { Name => 'DigitalDEEThreshold', Writable => 'int32u' },
3336             0x202 => { Name => 'DigitalDEEHighlightAdj',Writable => 'int32u' },
3337             );
3338              
3339             # ref 17
3340             %Image::ExifTool::Nikon::ROC = (
3341             %binaryDataAttrs,
3342             FORMAT => 'int32u',
3343             GROUPS => { 0 => 'MakerNotes', 1 => 'NikonScan', 2 => 'Image' },
3344             0 => {
3345             Name => 'DigitalROC',
3346             ValueConv => '$val / 10',
3347             ValueConvInv => 'int($val * 10)',
3348             },
3349             );
3350              
3351             # ref 17
3352             %Image::ExifTool::Nikon::GEM = (
3353             %binaryDataAttrs,
3354             FORMAT => 'int32u',
3355             GROUPS => { 0 => 'MakerNotes', 1 => 'NikonScan', 2 => 'Image' },
3356             0 => {
3357             Name => 'DigitalGEM',
3358             ValueConv => '$val<95 ? $val/20-1 : 4',
3359             ValueConvInv => '$val == 4 ? 95 : int(($val + 1) * 20)',
3360             },
3361             );
3362              
3363             # Vibration Reduction information - PH (D300)
3364             %Image::ExifTool::Nikon::VRInfo = (
3365             %binaryDataAttrs,
3366             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3367             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3368             0 => {
3369             Name => 'VRInfoVersion',
3370             Format => 'undef[4]',
3371             Writable => 0,
3372             },
3373             4 => {
3374             Name => 'VibrationReduction',
3375             PrintConv => {
3376             0 => 'n/a', # (1V1 with a non-VR lens)
3377             1 => 'On',
3378             2 => 'Off',
3379             },
3380             },
3381             # 5 - values: 0, 1 (VR On), 2 (VR Off)
3382             6 => [{
3383             Name => 'VRMode',
3384             PrintConv => {
3385             0 => 'Off',
3386             1 => 'Normal', #39 (was 'Sport')
3387             3 => 'Sport', #39 (was 'Normal')
3388             },
3389             %infoZSeries,
3390             },{
3391             Name => 'VRMode',
3392             PrintConv => {
3393             0 => 'Normal',
3394             1 => 'On (1)', #PH (NC)
3395             2 => 'Active', # (1J1)
3396             3 => 'Sport', #PH (Z7)
3397             },
3398             }],
3399             # 7 - values: 0, 1
3400             8 => { #39
3401             Name => 'VRType',
3402             PrintConv => {
3403             2 => 'In-body', # (IBIS)
3404             3 => 'In-body + Lens', # (IBIS + VR)
3405             },
3406             },
3407             );
3408              
3409             # Face detection information - PH (S8100)
3410             %Image::ExifTool::Nikon::FaceDetect = (
3411             %binaryDataAttrs,
3412             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
3413             FORMAT => 'int16u',
3414             DATAMEMBER => [ 0x03 ],
3415             0x01 => {
3416             Name => 'FaceDetectFrameSize',
3417             Format => 'int16u[2]',
3418             },
3419             0x03 => {
3420             Name => 'FacesDetected',
3421             DataMember => 'FacesDetected',
3422             RawConv => '$$self{FacesDetected} = $val',
3423             },
3424             0x04 => {
3425             Name => 'Face1Position',
3426             Format => 'int16u[4]',
3427             RawConv => '$$self{FacesDetected} < 1 ? undef : $val',
3428             Notes => q{
3429             top, left, width and height of face detect area in coordinates of
3430             FaceDetectFrameSize
3431             },
3432             },
3433             0x08 => {
3434             Name => 'Face2Position',
3435             Format => 'int16u[4]',
3436             RawConv => '$$self{FacesDetected} < 2 ? undef : $val',
3437             },
3438             0x0c => {
3439             Name => 'Face3Position',
3440             Format => 'int16u[4]',
3441             RawConv => '$$self{FacesDetected} < 3 ? undef : $val',
3442             },
3443             0x10 => {
3444             Name => 'Face4Position',
3445             Format => 'int16u[4]',
3446             RawConv => '$$self{FacesDetected} < 4 ? undef : $val',
3447             },
3448             0x14 => {
3449             Name => 'Face5Position',
3450             Format => 'int16u[4]',
3451             RawConv => '$$self{FacesDetected} < 5 ? undef : $val',
3452             },
3453             0x18 => {
3454             Name => 'Face6Position',
3455             Format => 'int16u[4]',
3456             RawConv => '$$self{FacesDetected} < 6 ? undef : $val',
3457             },
3458             0x1c => {
3459             Name => 'Face7Position',
3460             Format => 'int16u[4]',
3461             RawConv => '$$self{FacesDetected} < 7 ? undef : $val',
3462             },
3463             0x20 => {
3464             Name => 'Face8Position',
3465             Format => 'int16u[4]',
3466             RawConv => '$$self{FacesDetected} < 8 ? undef : $val',
3467             },
3468             0x24 => {
3469             Name => 'Face9Position',
3470             Format => 'int16u[4]',
3471             RawConv => '$$self{FacesDetected} < 9 ? undef : $val',
3472             },
3473             0x28 => {
3474             Name => 'Face10Position',
3475             Format => 'int16u[4]',
3476             RawConv => '$$self{FacesDetected} < 10 ? undef : $val',
3477             },
3478             0x2c => {
3479             Name => 'Face11Position',
3480             Format => 'int16u[4]',
3481             RawConv => '$$self{FacesDetected} < 11 ? undef : $val',
3482             },
3483             0x30 => {
3484             Name => 'Face12Position',
3485             Format => 'int16u[4]',
3486             RawConv => '$$self{FacesDetected} < 12 ? undef : $val',
3487             },
3488             );
3489              
3490             # Picture Control information - PH (D300,P6000)
3491             %Image::ExifTool::Nikon::PictureControl = (
3492             %binaryDataAttrs,
3493             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3494             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3495             0 => {
3496             Name => 'PictureControlVersion',
3497             Format => 'undef[4]',
3498             Writable => 0,
3499             },
3500             4 => {
3501             Name => 'PictureControlName',
3502             Format => 'string[20]',
3503             # make lower case with a leading capital for each word
3504             PrintConv => \&FormatString,
3505             PrintConvInv => 'uc($val)',
3506             },
3507             24 => {
3508             Name => 'PictureControlBase',
3509             Format => 'string[20]',
3510             PrintConv => \&FormatString,
3511             PrintConvInv => 'uc($val)',
3512             },
3513             # beginning at byte 44, there is some interesting information.
3514             # here are the observed bytes for each PictureControlMode:
3515             # 44 45 46 47 48 49 50 51 52 53 54 55 56 57
3516             # STANDARD 00 01 00 00 00 80 83 80 80 80 80 ff ff ff
3517             # NEUTRAL 03 c2 00 00 00 ff 82 80 80 80 80 ff ff ff
3518             # VIVID 00 c3 00 00 00 80 84 80 80 80 80 ff ff ff
3519             # MONOCHROME 06 4d 00 01 02 ff 82 80 80 ff ff 80 80 ff
3520             # Neutral2 03 c2 01 00 02 ff 80 7f 81 00 7f ff ff ff (custom)
3521             # (note that up to 9 different custom picture controls can be stored)
3522             # --> bytes 44 and 45 are swapped if CaptureNX changes the byte order
3523             #
3524             48 => { #21
3525             Name => 'PictureControlAdjust',
3526             PrintConv => {
3527             0 => 'Default Settings',
3528             1 => 'Quick Adjust',
3529             2 => 'Full Control',
3530             },
3531             },
3532             49 => {
3533             Name => 'PictureControlQuickAdjust',
3534             # settings: -2 to +2 (n/a for Neutral and Monochrome modes)
3535             DelValue => 0xff,
3536             ValueConv => '$val - 0x80',
3537             ValueConvInv => '$val + 0x80',
3538             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3539             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3540             },
3541             50 => {
3542             Name => 'Sharpness',
3543             # settings: 0 to 9, Auto
3544             ValueConv => '$val - 0x80',
3545             ValueConvInv => '$val + 0x80',
3546             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"No Sharpening","%d")',
3547             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3548             },
3549             51 => {
3550             Name => 'Contrast',
3551             # settings: -3 to +3, Auto
3552             ValueConv => '$val - 0x80',
3553             ValueConvInv => '$val + 0x80',
3554             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3555             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3556             },
3557             52 => {
3558             Name => 'Brightness',
3559             # settings: -1 to +1
3560             ValueConv => '$val - 0x80',
3561             ValueConvInv => '$val + 0x80',
3562             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3563             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3564             },
3565             53 => {
3566             Name => 'Saturation',
3567             # settings: -3 to +3, Auto (n/a for Monochrome mode)
3568             DelValue => 0xff,
3569             ValueConv => '$val - 0x80',
3570             ValueConvInv => '$val + 0x80',
3571             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3572             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3573             },
3574             54 => {
3575             Name => 'HueAdjustment',
3576             # settings: -3 to +3 (n/a for Monochrome mode)
3577             DelValue => 0xff,
3578             ValueConv => '$val - 0x80',
3579             ValueConvInv => '$val + 0x80',
3580             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None")',
3581             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3582             },
3583             55 => {
3584             Name => 'FilterEffect',
3585             # settings: Off,Yellow,Orange,Red,Green (n/a for color modes)
3586             DelValue => 0xff,
3587             PrintHex => 1,
3588             PrintConv => {
3589             0x80 => 'Off',
3590             0x81 => 'Yellow',
3591             0x82 => 'Orange',
3592             0x83 => 'Red',
3593             0x84 => 'Green',
3594             0xff => 'n/a',
3595             },
3596             },
3597             56 => {
3598             Name => 'ToningEffect',
3599             # settings: B&W,Sepia,Cyanotype,Red,Yellow,Green,Blue-Green,Blue,
3600             # Purple-Blue,Red-Purple (n/a for color modes)
3601             DelValue => 0xff,
3602             PrintHex => 1,
3603             PrintConvColumns => 2,
3604             PrintConv => {
3605             0x80 => 'B&W',
3606             0x81 => 'Sepia',
3607             0x82 => 'Cyanotype',
3608             0x83 => 'Red',
3609             0x84 => 'Yellow',
3610             0x85 => 'Green',
3611             0x86 => 'Blue-green',
3612             0x87 => 'Blue',
3613             0x88 => 'Purple-blue',
3614             0x89 => 'Red-purple',
3615             0xff => 'n/a',
3616             # 0x04 - seen for D810 (PH)
3617             },
3618             },
3619             57 => { #21
3620             Name => 'ToningSaturation',
3621             # settings: B&W,Sepia,Cyanotype,Red,Yellow,Green,Blue-Green,Blue,
3622             # Purple-Blue,Red-Purple (n/a unless ToningEffect is used)
3623             DelValue => 0xff,
3624             ValueConv => '$val - 0x80',
3625             ValueConvInv => '$val + 0x80',
3626             PrintConv => '$val==0x7f ? "n/a" : $val',
3627             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3628             },
3629             );
3630              
3631             # Picture Control information V2 (ref 28)
3632             %Image::ExifTool::Nikon::PictureControl2 = (
3633             %binaryDataAttrs,
3634             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3635             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3636             0 => {
3637             Name => 'PictureControlVersion',
3638             Format => 'undef[4]',
3639             Writable => 0,
3640             },
3641             4 => {
3642             Name => 'PictureControlName',
3643             Format => 'string[20]',
3644             # make lower case with a leading capital for each word
3645             PrintConv => \&FormatString,
3646             PrintConvInv => 'uc($val)',
3647             },
3648             24 => {
3649             Name => 'PictureControlBase',
3650             Format => 'string[20]',
3651             PrintConv => \&FormatString,
3652             PrintConvInv => 'uc($val)',
3653             },
3654             # beginning at byte 44, there is some interesting information.
3655             # here are the observed bytes for each PictureControlMode:
3656             # 44 45 46 47 48 49 50 51 52 53 54 55 56 57
3657             # STANDARD 00 01 00 00 00 80 83 80 80 80 80 ff ff ff
3658             # NEUTRAL 03 c2 00 00 00 ff 82 80 80 80 80 ff ff ff
3659             # VIVID 00 c3 00 00 00 80 84 80 80 80 80 ff ff ff
3660             # MONOCHROME 06 4d 00 01 02 ff 82 80 80 ff ff 80 80 ff
3661             # Neutral2 03 c2 01 00 02 ff 80 7f 81 00 7f ff ff ff (custom)
3662             # (note that up to 9 different custom picture controls can be stored)
3663             # --> bytes 44 and 45 are swapped if CaptureNX changes the byte order
3664             #
3665             48 => { #21
3666             Name => 'PictureControlAdjust',
3667             PrintConv => {
3668             0 => 'Default Settings',
3669             1 => 'Quick Adjust',
3670             2 => 'Full Control',
3671             },
3672             },
3673             49 => {
3674             Name => 'PictureControlQuickAdjust',
3675             # settings: -2 to +2 (n/a for Neutral and Monochrome modes)
3676             DelValue => 0xff,
3677             ValueConv => '$val - 0x80',
3678             ValueConvInv => '$val + 0x80',
3679             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3680             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3681             },
3682             51 => {
3683             Name => 'Sharpness',
3684             DelValue => 0xff,
3685             ValueConv => '$val - 0x80',
3686             ValueConvInv => '$val + 0x80',
3687             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3688             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3689             },
3690             53 => {
3691             Name => 'Clarity',
3692             DelValue => 0xff,
3693             ValueConv => '$val - 0x80',
3694             ValueConvInv => '$val + 0x80',
3695             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3696             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv2($val,4)',
3697             },
3698             55 => {
3699             Name => 'Contrast',
3700             DelValue => 0xff,
3701             ValueConv => '$val - 0x80',
3702             ValueConvInv => '$val + 0x80',
3703             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3704             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3705             },
3706             57 => { #21
3707             Name => 'Brightness',
3708             # settings: -1 to +1
3709             ValueConv => '$val - 0x80',
3710             ValueConvInv => '$val + 0x80',
3711             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,undef,"%.2f",4)',
3712             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3713             },
3714             59 => {
3715             Name => 'Saturation',
3716             DelValue => 0xff,
3717             ValueConv => '$val - 0x80',
3718             ValueConvInv => '$val + 0x80',
3719             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3720             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3721             },
3722             61 => {
3723             Name => 'Hue',
3724             DelValue => 0xff,
3725             ValueConv => '$val - 0x80',
3726             ValueConvInv => '$val + 0x80',
3727             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3728             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3729             },
3730             63 => {
3731             Name => 'FilterEffect',
3732             # settings: Off,Yellow,Orange,Red,Green (n/a for color modes)
3733             DelValue => 0xff,
3734             PrintHex => 1,
3735             PrintConv => {
3736             0x80 => 'Off',
3737             0x81 => 'Yellow',
3738             0x82 => 'Orange',
3739             0x83 => 'Red',
3740             0x84 => 'Green',
3741             0xff => 'n/a',
3742             },
3743             },
3744             64 => {
3745             Name => 'ToningEffect',
3746             # settings: B&W,Sepia,Cyanotype,Red,Yellow,Green,Blue-Green,Blue,
3747             # Purple-Blue,Red-Purple (n/a for color modes)
3748             DelValue => 0xff,
3749             PrintHex => 1,
3750             PrintConvColumns => 2,
3751             PrintConv => {
3752             0x80 => 'B&W',
3753             0x81 => 'Sepia',
3754             0x82 => 'Cyanotype',
3755             0x83 => 'Red',
3756             0x84 => 'Yellow',
3757             0x85 => 'Green',
3758             0x86 => 'Blue-green',
3759             0x87 => 'Blue',
3760             0x88 => 'Purple-blue',
3761             0x89 => 'Red-purple',
3762             0xff => 'n/a',
3763             },
3764             },
3765             65 => {
3766             Name => 'ToningSaturation',
3767             DelValue => 0xff,
3768             ValueConv => '$val - 0x80', #$val == 0x7f (n/a) for "B&W"
3769             ValueConvInv => '$val + 0x80',
3770             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3771             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3772              
3773             },
3774             );
3775              
3776             # Picture Control information V3 (ref PH, Z7)
3777             %Image::ExifTool::Nikon::PictureControl3 = (
3778             %binaryDataAttrs,
3779             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3780             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3781             0 => {
3782             Name => 'PictureControlVersion',
3783             Format => 'undef[4]',
3784             Writable => 0,
3785             },
3786             8 => {
3787             Name => 'PictureControlName',
3788             Format => 'string[20]',
3789             # make lower case with a leading capital for each word
3790             PrintConv => \&FormatString,
3791             PrintConvInv => 'uc($val)',
3792             },
3793             # 48 - looks like PictureControl2 byte 45
3794             28 => {
3795             Name => 'PictureControlBase',
3796             Format => 'string[20]',
3797             PrintConv => \&FormatString,
3798             PrintConvInv => 'uc($val)',
3799             },
3800             54 => { # (NC)
3801             Name => 'PictureControlAdjust',
3802             PrintConv => {
3803             0 => 'Default Settings',
3804             1 => 'Quick Adjust',
3805             2 => 'Full Control',
3806             },
3807             },
3808             55 => { # (NC)
3809             Name => 'PictureControlQuickAdjust',
3810             DelValue => 0xff,
3811             ValueConv => '$val - 0x80',
3812             ValueConvInv => '$val + 0x80',
3813             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3814             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3815             },
3816             57 => {
3817             Name => 'Sharpness',
3818             DelValue => 0xff,
3819             ValueConv => '$val - 0x80',
3820             ValueConvInv => '$val + 0x80',
3821             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3822             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3823             },
3824             59 => {
3825             Name => 'MidRangeSharpness',
3826             DelValue => 0xff,
3827             ValueConv => '$val - 0x80',
3828             ValueConvInv => '$val + 0x80',
3829             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3830             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3831             },
3832             61 => {
3833             Name => 'Clarity',
3834             DelValue => 0xff,
3835             ValueConv => '$val - 0x80',
3836             ValueConvInv => '$val + 0x80',
3837             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3838             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv2($val,4)',
3839             },
3840             63 => {
3841             Name => 'Contrast',
3842             DelValue => 0xff,
3843             ValueConv => '$val - 0x80',
3844             ValueConvInv => '$val + 0x80',
3845             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3846             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3847             },
3848             65 => { #21
3849             Name => 'Brightness',
3850             ValueConv => '$val - 0x80',
3851             ValueConvInv => '$val + 0x80',
3852             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,undef,"%.2f",4)',
3853             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3854             },
3855             67 => {
3856             Name => 'Saturation',
3857             DelValue => 0xff,
3858             ValueConv => '$val - 0x80',
3859             ValueConvInv => '$val + 0x80',
3860             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3861             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3862             },
3863             69 => {
3864             Name => 'Hue',
3865             DelValue => 0xff,
3866             ValueConv => '$val - 0x80',
3867             ValueConvInv => '$val + 0x80',
3868             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3869             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3870             },
3871             71 => { # (NC)
3872             Name => 'FilterEffect',
3873             DelValue => 0xff,
3874             PrintHex => 1,
3875             PrintConv => {
3876             0x80 => 'Off',
3877             0x81 => 'Yellow',
3878             0x82 => 'Orange',
3879             0x83 => 'Red',
3880             0x84 => 'Green',
3881             0xff => 'n/a',
3882             },
3883             },
3884             72 => { # (NC)
3885             Name => 'ToningEffect',
3886             DelValue => 0xff,
3887             PrintHex => 1,
3888             PrintConvColumns => 2,
3889             PrintConv => {
3890             0x80 => 'B&W',
3891             0x81 => 'Sepia',
3892             0x82 => 'Cyanotype',
3893             0x83 => 'Red',
3894             0x84 => 'Yellow',
3895             0x85 => 'Green',
3896             0x86 => 'Blue-green',
3897             0x87 => 'Blue',
3898             0x88 => 'Purple-blue',
3899             0x89 => 'Red-purple',
3900             0xff => 'n/a',
3901             },
3902             },
3903             73 => { # (NC)
3904             Name => 'ToningSaturation',
3905             DelValue => 0xff,
3906             ValueConv => '$val - 0x80',
3907             ValueConvInv => '$val + 0x80',
3908             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3909             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3910              
3911             },
3912             );
3913              
3914             # Unknown Picture Control information
3915             %Image::ExifTool::Nikon::PictureControlUnknown = (
3916             %binaryDataAttrs,
3917             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3918             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3919             0 => {
3920             Name => 'PictureControlVersion',
3921             Format => 'undef[4]',
3922             Writable => 0,
3923             },
3924             );
3925              
3926             # World Time information - JD (D300)
3927             %Image::ExifTool::Nikon::WorldTime = (
3928             %binaryDataAttrs,
3929             GROUPS => { 0 => 'MakerNotes', 2 => 'Time' },
3930             0 => {
3931             Name => 'TimeZone',
3932             Format => 'int16s',
3933             PrintConv => q{
3934             my $sign = $val < 0 ? '-' : '+';
3935             my $h = int(abs($val) / 60);
3936             sprintf("%s%.2d:%.2d", $sign, $h, abs($val)-60*$h);
3937             },
3938             PrintConvInv => q{
3939             $val =~ /Z$/ and return 0;
3940             $val =~ /([-+])(\d{1,2}):?(\d{2})$/ and return $1 . ($2 * 60 + $3);
3941             $val =~ /^(\d{2})(\d{2})$/ and return $1 * 60 + $2;
3942             return undef;
3943             },
3944             },
3945             2 => {
3946             Name => 'DaylightSavings',
3947             PrintConv => { 0 => 'No', 1 => 'Yes' },
3948             },
3949             3 => {
3950             Name => 'DateDisplayFormat',
3951             PrintConv => {
3952             0 => 'Y/M/D',
3953             1 => 'M/D/Y',
3954             2 => 'D/M/Y',
3955             },
3956             },
3957             );
3958              
3959             # ISO information - PH (D300)
3960             %Image::ExifTool::Nikon::ISOInfo = (
3961             %binaryDataAttrs,
3962             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3963             0 => {
3964             Name => 'ISO',
3965             Notes => 'val = 100 * 2**(raw/12-5)',
3966             Priority => 0, # because people like to see rounded-off values if they exist
3967             ValueConv => '100*exp(($val/12-5)*log(2))',
3968             ValueConvInv => '(log($val/100)/log(2)+5)*12',
3969             PrintConv => 'int($val + 0.5)',
3970             PrintConvInv => '$val',
3971             },
3972             # 1 - 0x01
3973             # 2 - 0x0c (probably the ISO divisor above)
3974             # 3 - 0x00
3975             4 => {
3976             Name => 'ISOExpansion',
3977             Format => 'int16u',
3978             PrintHex => 1,
3979             PrintConvColumns => 2,
3980             PrintConv => {
3981             0x000 => 'Off',
3982             0x101 => 'Hi 0.3',
3983             0x102 => 'Hi 0.5',
3984             0x103 => 'Hi 0.7',
3985             0x104 => 'Hi 1.0',
3986             0x105 => 'Hi 1.3', # (Hi 1.3-1.7 may be possible with future models)
3987             0x106 => 'Hi 1.5',
3988             0x107 => 'Hi 1.7',
3989             0x108 => 'Hi 2.0', #(NC) - D3 should have this mode
3990             0x109 => 'Hi 2.3', #IB
3991             0x10a => 'Hi 2.5', #IB
3992             0x10b => 'Hi 2.7', #IB
3993             0x10c => 'Hi 3.0', #IB
3994             0x10d => 'Hi 3.3', #IB
3995             0x10e => 'Hi 3.5', #IB
3996             0x10f => 'Hi 3.7', #IB
3997             0x110 => 'Hi 4.0', #IB
3998             0x111 => 'Hi 4.3', #IB
3999             0x112 => 'Hi 4.5', #IB
4000             0x113 => 'Hi 4.7', #IB
4001             0x114 => 'Hi 5.0', #IB
4002             0x201 => 'Lo 0.3',
4003             0x202 => 'Lo 0.5',
4004             0x203 => 'Lo 0.7',
4005             0x204 => 'Lo 1.0',
4006             },
4007             },
4008             # bytes 6-11 same as 0-4 in my samples (why is this duplicated?)
4009             6 => {
4010             Name => 'ISO2',
4011             Notes => 'val = 100 * 2**(raw/12-5)',
4012             ValueConv => '100*exp(($val/12-5)*log(2))',
4013             ValueConvInv => '(log($val/100)/log(2)+5)*12',
4014             PrintConv => 'int($val + 0.5)',
4015             PrintConvInv => '$val',
4016             },
4017             # 7 - 0x01
4018             # 8 - 0x0c (probably the ISO divisor above)
4019             # 9 - 0x00
4020             10 => {
4021             Name => 'ISOExpansion2',
4022             Format => 'int16u',
4023             PrintHex => 1,
4024             PrintConvColumns => 2,
4025             PrintConv => {
4026             0x000 => 'Off',
4027             0x101 => 'Hi 0.3',
4028             0x102 => 'Hi 0.5',
4029             0x103 => 'Hi 0.7',
4030             0x104 => 'Hi 1.0',
4031             0x105 => 'Hi 1.3', # (Hi 1.3-1.7 may be possible with future models)
4032             0x106 => 'Hi 1.5',
4033             0x107 => 'Hi 1.7',
4034             0x108 => 'Hi 2.0', #(NC) - D3 should have this mode
4035             0x201 => 'Lo 0.3',
4036             0x202 => 'Lo 0.5',
4037             0x203 => 'Lo 0.7',
4038             0x204 => 'Lo 1.0',
4039             },
4040             },
4041             # bytes 12-13: 00 00
4042             );
4043              
4044             # distortion information - PH (D5000)
4045             %Image::ExifTool::Nikon::DistortInfo = (
4046             %binaryDataAttrs,
4047             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4048             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
4049             0 => {
4050             Name => 'DistortionVersion',
4051             Format => 'undef[4]',
4052             Writable => 0,
4053             Unknown => 1,
4054             },
4055             4 => {
4056             Name => 'AutoDistortionControl',
4057             PrintConv => {
4058             0 => 'Off',
4059             1 => 'On',
4060             2 => 'On (underwater)', # (1AW1)
4061             },
4062             },
4063             );
4064              
4065             # unknown information - PH (D7000)
4066             %Image::ExifTool::Nikon::UnknownInfo = (
4067             %binaryDataAttrs,
4068             FORMAT => 'int32u',
4069             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4070             0 => {
4071             Name => 'UnknownInfoVersion',
4072             Condition => '$$valPt =~ /^\d{4}/',
4073             Format => 'undef[4]',
4074             Writable => 0,
4075             Unknown => 1,
4076             },
4077             # (bytes 6/7 and 8/9 are swapped if CaptureNX changes the byte order)
4078             );
4079              
4080             # more unknown information - PH (D7000)
4081             %Image::ExifTool::Nikon::UnknownInfo2 = (
4082             %binaryDataAttrs,
4083             FORMAT => 'int32u',
4084             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4085             0 => {
4086             Name => 'UnknownInfo2Version',
4087             Condition => '$$valPt =~ /^\d{4}/',
4088             Format => 'undef[4]',
4089             Writable => 0,
4090             Unknown => 1,
4091             },
4092             # (byte 4 may be changed from 1 to 0 when rewritten by CaptureNX)
4093             );
4094              
4095             # Nikon AF information (ref 13)
4096             %Image::ExifTool::Nikon::AFInfo = (
4097             %binaryDataAttrs,
4098             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4099             0 => {
4100             Name => 'AFAreaMode',
4101             PrintConv => {
4102             0 => 'Single Area',
4103             1 => 'Dynamic Area',
4104             2 => 'Dynamic Area (closest subject)',
4105             3 => 'Group Dynamic',
4106             4 => 'Single Area (wide)',
4107             5 => 'Dynamic Area (wide)',
4108             },
4109             },
4110             1 => {
4111             Name => 'AFPoint',
4112             Notes => 'in some focus modes this value is not meaningful',
4113             PrintConvColumns => 2,
4114             PrintConv => {
4115             0 => 'Center',
4116             1 => 'Top',
4117             2 => 'Bottom',
4118             3 => 'Mid-left',
4119             4 => 'Mid-right',
4120             5 => 'Upper-left',
4121             6 => 'Upper-right',
4122             7 => 'Lower-left',
4123             8 => 'Lower-right',
4124             9 => 'Far Left',
4125             10 => 'Far Right',
4126             # (have also seen values of 11 and 12 when AFPointsInFocus is "(none)" - PH S3500)
4127             },
4128             },
4129             2 => {
4130             Name => 'AFPointsInFocus',
4131             Format => 'int16u',
4132             PrintConvColumns => 2,
4133             PrintConv => \%afPoints11,
4134             },
4135             );
4136              
4137             %Image::ExifTool::Nikon::AFInfo2V0100 = (
4138             %binaryDataAttrs,
4139             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4140             DATAMEMBER => [ 0, 4, 6 ],
4141             NOTES => q{
4142             AF information for Nikon cameras with LiveView that were introduced 2007
4143             thru 2015 (and the D5600 in 2016), including D3, D4, D3000, D3100-D3300,
4144             D5000-D5600, D6x0, D700, D7000, D7100, D810
4145             },
4146             0 => {
4147             Name => 'AFInfo2Version',
4148             Format => 'undef[4]',
4149             Writable => 0,
4150             RawConv => '$$self{AFInfo2Version} = $val',
4151             },
4152             4 => {
4153             Name => 'AFDetectionMethod', #specifies phase detect or contrast detect
4154             RawConv => '$$self{AFDetectionMethod} = $val',
4155             PrintConv => \%aFDetectionMethod ,
4156             },
4157             5 => [
4158             {
4159             Name => 'AFAreaMode',
4160             Condition => '$$self{AFDetectionMethod} == 0',
4161             PrintConv => \%aFAreaModePD, #phase detect
4162             },
4163             {
4164             Name => 'AFAreaMode',
4165             PrintConv => \%aFAreaModeCD, #contrast detect
4166             },
4167             ],
4168             6 => {
4169             Name => 'FocusPointSchema',
4170             RawConv => '$$self{FocusPointSchema} = $val',
4171             #Hidden => 1,
4172             PrintConv => {
4173             0 => 'Off', # LiveView or manual focus or no focus
4174             1 => '51-point', # (D3/D3S/D3X/D4/D4S/D300/D300S/D700/D750/D800/D800E/D810/D7100/D7200)
4175             2 => '11-point', # (D90/D3000/D3100/D3200/D3300/D5000/D5100)
4176             3 => '39-point', # (D600/D610/D5200/D5300/D5500/D5600/D7000/Df)
4177             },
4178             },
4179             7 => [
4180             { #PH/JD
4181             Name => 'PrimaryAFPoint',
4182             Condition => '$$self{FocusPointSchema} == 1', #51 focus-point models
4183             Notes => q{
4184             models with 51-point AF -- 5 rows (A-E) and 11 columns (1-11): D3, D3S, D3X,
4185             D4, D4S, D300, D300S, D700, D750, D800, D800E, D810, D7100 and D7200
4186             },
4187             PrintConvColumns => 5,
4188             PrintConv => {
4189             0 => '(none)',
4190             %afPoints51,
4191             1 => 'C6 (Center)', # (add " (Center)" to central point)
4192             },
4193             },{ #10
4194             Name => 'PrimaryAFPoint',
4195             Notes => 'models with 11-point AF: D90, D3000-D3300, D5000 and D5100',
4196             Condition => '$$self{FocusPointSchema} == 2', #11 focus-point models
4197             PrintConvColumns => 2,
4198             PrintConv => {
4199             0 => '(none)',
4200             1 => 'Center',
4201             2 => 'Top',
4202             3 => 'Bottom',
4203             4 => 'Mid-left',
4204             5 => 'Upper-left',
4205             6 => 'Lower-left',
4206             7 => 'Far Left',
4207             8 => 'Mid-right',
4208             9 => 'Upper-right',
4209             10 => 'Lower-right',
4210             11 => 'Far Right',
4211             },
4212             },{ #29
4213             Name => 'PrimaryAFPoint',
4214             Condition => '$$self{FocusPointSchema} == 3', #39 focus-point models
4215             Notes => 'models with 39-point AF: D600, D610, D5200-D5600, D7000 and Df',
4216             PrintConvColumns => 5,
4217             PrintConv => {
4218             0 => '(none)',
4219             %afPoints39,
4220             1 => 'C6 (Center)', # (add " (Center)" to central point)
4221             },
4222             },
4223             {
4224             Name => 'PrimaryAFPoint',
4225             Condition => '$$self{FocusPointSchema} == 0', #LiveView or manual focus or no focus (reporting only for purposes of backward compatibility with v13.19 and earlier)
4226             PrintConv => { 0 => '(none)', },
4227             },
4228             ],
4229             8 => [
4230             { #JD/PH
4231             Name => 'AFPointsUsed',
4232             Condition => '$$self{FocusPointSchema} == 1', # 51 focus-point models
4233             Notes => q{
4234             models with 51-point AF -- 5 rows: A1-9, B1-11, C1-11, D1-11, E1-9. Center
4235             point is C6
4236             },
4237             Format => 'undef[7]',
4238             ValueConv => 'join(" ", unpack("H2"x7, $val))',
4239             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4240             PrintConv => sub { PrintAFPoints(shift, \%afPoints51) },
4241             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints51) },
4242             },
4243             { #10
4244             Name => 'AFPointsUsed',
4245             Condition => '$$self{FocusPointSchema} == 2', # 11 focus-point models
4246             Notes => 'models with 11-point AF',
4247             # read as int16u in little-endian byte order
4248             Format => 'undef[2]',
4249             ValueConv => 'unpack("v",$val)',
4250             ValueConvInv => 'pack("v",$val)',
4251             PrintConvColumns => 2,
4252             PrintConv => {
4253             0 => '(none)',
4254             0x7ff => 'All 11 Points',
4255             BITMASK => {
4256             0 => 'Center',
4257             1 => 'Top',
4258             2 => 'Bottom',
4259             3 => 'Mid-left',
4260             4 => 'Upper-left',
4261             5 => 'Lower-left',
4262             6 => 'Far Left',
4263             7 => 'Mid-right',
4264             8 => 'Upper-right',
4265             9 => 'Lower-right',
4266             10 => 'Far Right',
4267             },
4268             },
4269             },
4270             { #29/PH
4271             Name => 'AFPointsUsed',
4272             Condition => '$$self{FocusPointSchema} == 3', # 39 focus-point models
4273             Notes => q{
4274             models with 39-point AF -- 5 rows: A1-3, B1-11, C1-11, D1-11, E1-3. Center
4275             point is C6
4276             },
4277             Format => 'undef[5]',
4278             ValueConv => 'join(" ", unpack("H2"x5, $val))',
4279             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4280             PrintConv => sub { PrintAFPoints(shift, \%afPoints39) },
4281             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints39) },
4282             },
4283             {
4284             Name => 'AFPointsUsed',
4285             Condition => '$$self{FocusPointSchema} == 0', #LiveView or manual focus or no focus (reporting only for purposes of backward compatibility with v13.19 and earlier)
4286             PrintConv => { 0 => '(none)', },
4287             },
4288             ],
4289             0x10 => { #PH (D90 and D5000)
4290             Name => 'AFImageWidth',
4291             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4292             Format => 'int16u',
4293             RawConv => '$val ? $val : undef',
4294             Notes => 'this and the following tags are valid only for contrast-detect AF',
4295             },
4296             0x12 => { #PH
4297             Name => 'AFImageHeight',
4298             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4299             Format => 'int16u',
4300             RawConv => '$val ? $val : undef',
4301             },
4302             0x14 => { #PH
4303             Name => 'AFAreaXPosition',
4304             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4305             Notes => 'center of AF area in AFImage coordinates',
4306             Format => 'int16u',
4307             RawConv => '$val ? $val : undef',
4308             },
4309             0x16 => { #PH
4310             Name => 'AFAreaYPosition',
4311             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4312             Format => 'int16u',
4313             RawConv => '$val ? $val : undef',
4314             },
4315             0x18 => { #PH
4316             Name => 'AFAreaWidth',
4317             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4318             Format => 'int16u',
4319             Notes => 'size of AF area in AFImage coordinates',
4320             RawConv => '$val ? $val : undef',
4321             },
4322             0x1a => { #PH
4323             Name => 'AFAreaHeight',
4324             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4325             Format => 'int16u',
4326             RawConv => '$val ? $val : undef',
4327             },
4328             0x1c => [
4329             { #PH
4330             Name => 'ContrastDetectAFInFocus',
4331             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4332             PrintConv => { 0 => 'No', 1 => 'Yes' },
4333             },{ #PH (D500, see forum11190)
4334             Name => 'AFPointsSelected',
4335             Condition => '$$self{FocusPointSchema} == 7',
4336             Format => 'undef[20]',
4337             ValueConv => 'join(" ", unpack("H2"x20, $val))',
4338             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4339             PrintConv => sub { PrintAFPoints(shift, \%afPoints153) },
4340             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints153) },
4341             },
4342             # (#28) this is incorrect - [observed values 0, 1, 16, 64, 128, 1024 (mostly 0 & 1), but not tied to the display of focus point in NXStudio]
4343             #{ #PH (D3400) (NC "selected")
4344             # Name => 'AFPointsSelected',
4345             # Condition => '$$self{FocusPointSchema} == 2',
4346             # Format => 'int16u',
4347             # PrintConv => \%afPoints11,
4348             #},
4349             ],
4350             );
4351              
4352             %Image::ExifTool::Nikon::AFInfo2V0101 = (
4353             %binaryDataAttrs,
4354             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4355             DATAMEMBER => [ 0, 4, 5, 6 ],
4356             NOTES => q{
4357             AF information for Nikon cameras D5, D500, D850, D3400, D3500 and D7500
4358             },
4359             0 => {
4360             Name => 'AFInfo2Version',
4361             Format => 'undef[4]',
4362             Writable => 0,
4363             RawConv => '$$self{AFInfo2Version} = $val',
4364             },
4365             4 => {
4366             Name => 'AFDetectionMethod',
4367             RawConv => '$$self{AFDetectionMethod} = $val',
4368             PrintConv => \%aFDetectionMethod,
4369             },
4370             5 => [
4371             {
4372             Name => 'AFAreaMode',
4373             Condition => '$$self{AFDetectionMethod} == 0',
4374             RawConv => '$$self{AFAreaMode} = $val',
4375             PrintConv => \%aFAreaModePD, #phase detect
4376             },
4377             {
4378             Name => 'AFAreaMode',
4379             RawConv => '$$self{AFAreaMode} = $val',
4380             PrintConv => \%aFAreaModeCD, #contrast detect
4381             },
4382             ],
4383             6 => {
4384             Name => 'FocusPointSchema',
4385             RawConv => '$$self{FocusPointSchema} = $val',
4386             #Hidden => 1,
4387             PrintConv => {
4388             0 => 'Off', # LiveView or manual focus or no focus
4389             1 => '51-point', # (D7500)
4390             2 => '11-point', # (D3400/D3500)
4391             7 => '153-point', # (D5/D500/D850) 153 focus points (17 columns x 9 rows) - of these 55 are user selectable (11 columns x 5 rows)
4392             },
4393             },
4394             8 => [
4395             { #JD/PH
4396             Name => 'AFPointsUsed',
4397             Condition => '$$self{FocusPointSchema} == 1', #51 focus-point models
4398             Notes => q{
4399             models with 51-point AF -- 5 rows: A1-9, B1-11, C1-11, D1-11, E1-9. Center
4400             point is C6
4401             },
4402             Format => 'undef[7]',
4403             ValueConv => 'join(" ", unpack("H2"x7, $val))',
4404             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4405             PrintConv => sub { PrintAFPoints(shift, \%afPoints51) },
4406             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints51) },
4407             },{ #10
4408             Name => 'AFPointsUsed',
4409             Condition => '$$self{FocusPointSchema} == 2', #11 focus-point models
4410             Notes => 'models with 11-point AF',
4411             # read as int16u in little-endian byte order
4412             Format => 'undef[2]',
4413             ValueConv => 'unpack("v",$val)',
4414             ValueConvInv => 'pack("v",$val)',
4415             PrintConvColumns => 2,
4416             PrintConv => {
4417             0 => '(none)',
4418             0x7ff => 'All 11 Points',
4419             BITMASK => {
4420             0 => 'Center',
4421             1 => 'Top',
4422             2 => 'Bottom',
4423             3 => 'Mid-left',
4424             4 => 'Upper-left',
4425             5 => 'Lower-left',
4426             6 => 'Far Left',
4427             7 => 'Mid-right',
4428             8 => 'Upper-right',
4429             9 => 'Lower-right',
4430             10 => 'Far Right',
4431             },
4432             },
4433             },
4434             { #PH (D5,D500, D850)
4435             Name => 'AFPointsUsed', #when focus is not obtained, will report '(none)' otherwise will report a single point from among AFPointsSelected
4436             Condition => '$$self{FocusPointSchema} == 7', #153 focus-point models
4437             Notes => q{
4438             models with 153-point AF -- 9 rows (A-I) and 17 columns (1-17). Center
4439             point is E9
4440             },
4441             Format => 'undef[20]',
4442             ValueConv => 'join(" ", unpack("H2"x20, $val))',
4443             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4444             PrintConv => sub { PrintAFPoints(shift, \%afPoints153) },
4445             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints153) },
4446             },{
4447             Name => 'AFPointsUsed',
4448             Condition => '$$self{FocusPointSchema} == 0', #LiveView or manual focus or no focus (reporting only for purposes of backward compatibility with v13.19 and earlier)
4449             PrintConv => { 0 => '(none)', },
4450             },
4451             ],
4452             0x1c => [
4453             {#PH
4454             Name => 'ContrastDetectAFInFocus',
4455             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4456             PrintConv => { 0 => 'No', 1 => 'Yes' },
4457             },
4458             { #JD/PH
4459             Name => 'AFPointsUsed',
4460             Condition => '$$self{FocusPointSchema} == 1 and
4461             ($$self{AFAreaMode} == 8 or $$self{AFAreaMode} == 9 or $$self{AFAreaMode} == 13 )', #phase detect 51 focus-point models
4462             Format => 'undef[7]',
4463             ValueConv => 'join(" ", unpack("H2"x7, $val))',
4464             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4465             PrintConv => sub { PrintAFPoints(shift, \%afPoints51) },
4466             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints51) },
4467             },{ #PH (D500, see forum11190)
4468             Name => 'AFPointsSelected', # where the viewfinder AF point(s) were positioned when initiating focus in AFAreaMode 3D-tracking Group-area
4469             # will contain a value regardless of whether or not focus was obtained
4470             # reflects the focus points displayed by NXStudio when AFAreaMode is Group-area
4471             Condition => '$$self{FocusPointSchema} == 7 and
4472             ($$self{AFAreaMode} == 8 or $$self{AFAreaMode} == 9 or $$self{AFAreaMode} == 13 )', #phase detect 153 focus-point models in Auto-area/3D-tracking/Group-area
4473             Format => 'undef[20]',
4474             ValueConv => 'join(" ", unpack("H2"x20, $val))',
4475             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4476             PrintConv => sub { PrintAFPoints(shift, \%afPoints153) },
4477             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints153) },
4478             },
4479             ],
4480             0x30 => [
4481             { #PH (D7500) (NC "in focus")
4482             Name => 'AFPointsInFocus', # refelcts the focus point(s) displayed by NXStudio when AFAreaMode is Auto-area or 3D-tracking.
4483             # erroneously named as there is no assurance the reported points are in focus
4484             Condition => '$$self{FocusPointSchema} == 1', #51 focus-point models
4485             Format => 'undef[7]',
4486             ValueConv => 'join(" ", unpack("H2"x7, $val))',
4487             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4488             PrintConv => sub { PrintAFPoints(shift, \%afPoints51) },
4489             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints51) },
4490             },{ #PH (D500, see forum11190)
4491             Name => 'AFPointsInFocus',
4492             Condition => '$$self{FocusPointSchema} == 7', #153 focus-point models
4493             Notes => 'AF points in focus at the time time image was captured',
4494             Format => 'undef[20]',
4495             ValueConv => 'join(" ", unpack("H2"x20, $val))',
4496             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4497             PrintConv => sub { PrintAFPoints(shift, \%afPoints153) },
4498             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints153) },
4499             },
4500             ],
4501             0x44 => [ #AFInfoVersion 0100 use 0x08 for this tag. v0101 could do that as well. The difference is that when Group-area fails to focus..
4502             #...this code (incorrectly) reports a value for PrimaryAFPoint. Moving this code to the 0x08 slot would correctly report '(none)'...
4503             #...leaving it here for now for compatibility purposes
4504             { #PH/JD
4505             Name => 'PrimaryAFPoint',
4506             Condition => '$$self{FocusPointSchema} == 1', #51 focus-point models
4507             Notes => q{
4508             models with 51-point AF -- 5 rows (A-E) and 11 columns (1-11): D7500
4509             },
4510             PrintConvColumns => 5,
4511             PrintConv => {
4512             0 => '(none)',
4513             %afPoints51,
4514             1 => 'C6 (Center)', # (add " (Center)" to central point)
4515             },
4516             },{ #10
4517             Name => 'PrimaryAFPoint',
4518             Notes => 'models with 11-point AF: D3400, D3500',
4519             Condition => '$$self{FocusPointSchema} == 2', #11 focus-point models
4520             PrintConvColumns => 2,
4521             PrintConv => {
4522             0 => '(none)',
4523             1 => 'Center',
4524             2 => 'Top',
4525             3 => 'Bottom',
4526             4 => 'Mid-left',
4527             5 => 'Upper-left',
4528             6 => 'Lower-left',
4529             7 => 'Far Left',
4530             8 => 'Mid-right',
4531             9 => 'Upper-right',
4532             10 => 'Lower-right',
4533             11 => 'Far Right',
4534             },
4535             },{ #PH
4536             Name => 'PrimaryAFPoint',
4537             Condition => '$$self{FocusPointSchema} == 7', #153 focus-point models
4538             Notes => q{
4539             Nikon models with 153-point AF -- 9 rows (A-I) and 17 columns (1-17): D5,
4540             D500 and D850
4541             },
4542             PrintConvColumns => 5,
4543             PrintConv => {
4544             0 => '(none)',
4545             %afPoints153,
4546             1 => 'E9 (Center)',
4547             },
4548             },{
4549             Name => 'PrimaryAFPoint',
4550             Condition => '$$self{FocusPointSchema} == 0', #LiveView or manual focus or no focus (reporting only for purposes of backward compatibility with v13.19 and earlier)
4551             PrintConv => { 0 => '(none)', },
4552             },
4553             ],
4554             0x46 => { #PH
4555             Name => 'AFImageWidth',
4556             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4557             Format => 'int16u',
4558             RawConv => '$val ? $val : undef',
4559             Notes => 'this and the following tags are valid only for contrast-detect AF',
4560             },
4561             0x48 => { #PH
4562             Name => 'AFImageHeight',
4563             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4564             Format => 'int16u',
4565             RawConv => '$val ? $val : undef',
4566             },
4567             0x4a => { #PH
4568             Name => 'AFAreaXPosition',
4569             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4570             Notes => 'center of AF area in AFImage coordinates',
4571             Format => 'int16u',
4572             RawConv => '$val ? $val : undef',
4573             },
4574             0x4c => { #PH
4575             Name => 'AFAreaYPosition',
4576             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4577             Format => 'int16u',
4578             RawConv => '$val ? $val : undef',
4579             },
4580             0x4e => { #PH
4581             Name => 'AFAreaWidth',
4582             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4583             Format => 'int16u',
4584             Notes => 'size of AF area in AFImage coordinates',
4585             RawConv => '$val ? $val : undef',
4586             },
4587             0x50 => { #PH
4588             Name => 'AFAreaHeight',
4589             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4590             Format => 'int16u',
4591             RawConv => '$val ? $val : undef',
4592             },
4593             0x52 => {
4594             Name => 'ContrastDetectAFInFocus',
4595             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4596             PrintConv => { 0 => 'No', 1 => 'Yes' },
4597             },
4598             );
4599              
4600             %Image::ExifTool::Nikon::AFInfo2V0200 = (
4601             %binaryDataAttrs,
4602             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4603             DATAMEMBER => [ 0, 6 ],
4604             NOTES => q{
4605             AF information for Nikon 1 series cameras: Nikon 1 V1, V2, V3, J1, J2, J3,
4606             S1, S2 AW1.
4607             },
4608             0 => {
4609             Name => 'AFInfo2Version',
4610             Format => 'undef[4]',
4611             Writable => 0,
4612             RawConv => '$$self{AFInfo2Version} = $val',
4613             },
4614             5 => {
4615             Name => 'AFAreaMode',
4616             PrintConv => {
4617             128 => 'Single', #PH (1J1,1J2,1J3,1J4,1S1,1S2,1V2,1V3)
4618             129 => 'Auto (41 points)', #PH (1J1,1J2,1J3,1J4,1S1,1S2,1V1,1V2,1V3,AW1)
4619             130 => 'Subject Tracking (41 points)', #PH (1J1,1J4,1J3)
4620             131 => 'Face Priority (41 points)', #PH (1J1,1J3,1S1,1V2,AW1)
4621             # 134 - seen for 1V1[PhaseDetectAF=0] (PH)
4622             # 135 - seen for 1J2[PhaseDetectAF=4] (PH)
4623             },
4624             },
4625             6 => {
4626             Name => 'PhaseDetectAF', #JD(AutoFocus), PH(PhaseDetectAF)
4627             Notes => 'PrimaryAFPoint and AFPointsUsed below are only valid when this is On',
4628             RawConv => '$$self{PhaseDetectAF} = $val',
4629             PrintConv => {
4630             # [observed AFAreaMode values in square brackets for each PhaseDetectAF value]
4631             4 => 'On (73-point)', #PH (1J1[128/129],1J2[128/129/135],1J3/1S1/1V2[128/129/131],1V1[129],AW1[129/131])
4632             5 => 'On (5)', #PH (1S2[128/129], 1J4/1V3[129])
4633             6 => 'On (105-point)', #PH (1J4/1V3[128/130])
4634             },
4635             },
4636             7 => [
4637             { #PH
4638             Name => 'PrimaryAFPoint',
4639             Condition => '$$self{PhaseDetectAF} == 4',
4640             Notes => 'Nikon 1 models with older 135-point AF and 73-point phase-detect AF',
4641             PrintConvColumns => 5,
4642             PrintConv => {
4643             0 => '(none)',
4644             %afPoints135,
4645             1 => 'E8 (Center)', # (add " (Center)" to central point)
4646             },
4647             },
4648             { #PH (NC)
4649             Name => 'PrimaryAFPoint',
4650             Condition => '$$self{PhaseDetectAF} == 5',
4651             Notes => q{
4652             Nikon 1 models with newer 135-point AF and 73-point phase-detect AF -- 9
4653             rows (B-J) and 15 columns (1-15), inside a grid of 11 rows by 15 columns.
4654             The points are numbered sequentially, with F8 at the center
4655             },
4656             PrintConv => {
4657             0 => '(none)',
4658             82 => 'F8 (Center)',
4659             OTHER => sub {
4660             my ($val, $inv) = @_;
4661             return GetAFPointGrid($val, 15, $inv);
4662             },
4663             },
4664             },
4665             { #PH
4666             Name => 'PrimaryAFPoint',
4667             Condition => '$$self{PhaseDetectAF} == 6',
4668             Notes => q{
4669             Nikon 1 models with 171-point AF and 105-point phase-detect AF -- 9 rows
4670             (B-J) and 19 columns (2-20), inside a grid of 11 rows by 21 columns. The
4671             points are numbered sequentially, with F11 at the center
4672             },
4673             PrintConv => {
4674             0 => '(none)',
4675             #22 => 'B2 (Top-left)',
4676             #40 => 'B20 (Top-right)',
4677             115 => 'F11 (Center)',
4678             #190 => 'J2 (Bottom-left)',
4679             #208 => 'J20 (Bottom-right)',
4680             OTHER => sub {
4681             my ($val, $inv) = @_;
4682             return GetAFPointGrid($val, 21, $inv);
4683             },
4684             },
4685             },
4686             ],
4687             8 => [
4688             { #PH (1AW1,1J1,1J2,1J3,1S1,1V1,1V2)
4689             Name => 'AFPointsUsed',
4690             Condition => '$$self{PhaseDetectAF} == 4',
4691             Notes => q{
4692             older models with 135-point AF -- 9 rows (A-I) and 15 columns (1-15).
4693             Center point is E8. The odd-numbered columns, columns 2 and 14, and the
4694             remaining corner points are not used for 41-point AF mode
4695             },
4696             Format => 'undef[17]',
4697             ValueConv => 'join(" ", unpack("H2"x17, $val))',
4698             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4699             PrintConv => sub { PrintAFPoints(shift, \%afPoints135) },
4700             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints135) },
4701             },
4702             { #PH (1S2)
4703             Name => 'AFPointsUsed',
4704             Condition => '$$self{PhaseDetectAF} == 5',
4705             Notes => q{
4706             newer models with 135-point AF -- 9 rows (B-J) and 15 columns (1-15). Center
4707             point is F8
4708             },
4709             Format => 'undef[21]',
4710             ValueConv => 'join(" ", unpack("H2"x21, $val))',
4711             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4712             PrintConv => sub { PrintAFPointsGrid(shift, 15) },
4713             PrintConvInv => sub { PrintAFPointsGridInv(shift, 15, 21) },
4714             },
4715             { #PH (1J4,1V3)
4716             Name => 'AFPointsUsed',
4717             Condition => '$$self{PhaseDetectAF} == 6',
4718             Notes => q{
4719             models with 171-point AF -- 9 rows (B-J) and 19 columns (2-20). Center
4720             point is F10
4721             },
4722             Format => 'undef[29]',
4723             ValueConv => 'join(" ", unpack("H2"x29, $val))',
4724             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4725             PrintConv => sub { PrintAFPointsGrid(shift, 21) },
4726             PrintConvInv => sub { PrintAFPointsGridInv(shift, 21, 29) },
4727             },
4728             ],
4729             );
4730              
4731             %Image::ExifTool::Nikon::AFInfo2V0300 = (
4732             %binaryDataAttrs,
4733             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4734             DATAMEMBER => [ 0, 4, 6, 7, 46, 48 ],
4735             NOTES => q{
4736             AF information for Nikon cameras with the Expeed 6 processor: D6, D780, Z5,
4737             Z6, Z6ii, Z7, Z7ii, Z50 and Zfc.
4738             },
4739             0 => {
4740             Name => 'AFInfo2Version',
4741             Format => 'undef[4]',
4742             Writable => 0,
4743             RawConv => '$$self{AFInfo2Version} = $val',
4744             },
4745             4 => {
4746             Name => 'AFDetectionMethod',
4747             RawConv => '$$self{AFDetectionMethod} = $val',
4748             PrintConv => \%aFDetectionMethod ,
4749             },
4750             5 => [
4751             {
4752             Name => 'AFAreaMode',
4753             Condition => '$$self{AFDetectionMethod} == 0',
4754             PrintConv => \%aFAreaModePD, #phase detect
4755             },
4756             {
4757             Name => 'AFAreaMode',
4758             PrintConv => \%aFAreaModeCD, #contrast detect
4759             },
4760             ],
4761             6 => {
4762             Name => 'FocusPointSchema',
4763             RawConv => '$$self{FocusPointSchema} = $val',
4764             #Hidden => 1,
4765             PrintConv => {
4766             0 => 'Off', # LiveView or manual focus or no focus
4767             1 => '51-point', # (D780) 51 points through the viewfinder, 81/273 points in LiveView
4768             8 => '81-point', # (Z6/Z6ii/Z7/Z7ii/Z30/Z50/Z50ii/Zfc/D780) 81-points refers to the number of auto-area focus points arranged as a 9x9 grid. Number of single-point focus points vary by model.
4769             9 => '105-point', # (D6) arranged as a 15 column x 9 row grid
4770             },
4771             },
4772             7 => {
4773             Name => 'AFCoordinatesAvailable', #0 => 'AFPointsUsed is populated' 1 => 'AFAreaXPosition & AFAreaYPosition are populated'
4774             RawConv => '$$self{AFCoordinatesAvailable} = $val',
4775             PrintConv => \%noYes ,
4776             },
4777             0x0a => [
4778             { #JD/PH
4779             Name => 'AFPointsUsed',
4780             Condition => '$$self{FocusPointSchema} == 1 and $$self{AFCoordinatesAvailable} == 0', #D780 when AFAreaXYPositions are not populated
4781             Notes => q{
4782             models with 51-point AF -- 5 rows: A1-9, B1-11, C1-11, D1-11, E1-9. Center
4783             point is C6
4784             },
4785             Format => 'undef[7]',
4786             ValueConv => 'join(" ", unpack("H2"x7, $val))',
4787             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4788             PrintConv => sub { PrintAFPoints(shift, \%afPoints51) },
4789             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints51) },
4790             },{
4791             Name => 'AFPointsUsed',
4792             Condition => '$$self{FocusPointSchema} == 8 and $$self{AFCoordinatesAvailable} == 0', # Z6/Z6ii/Z7/Z7ii/Z50/Z50ii/Zfc/D780 when AFAreaXYPositions are not populated
4793             Notes => q{
4794             models with hybrid detect AF have 81 auto-area points -- 9 rows (A-I) and 9 columns (1-9). Center point is E5
4795             },
4796             Format => 'undef[11]',
4797             ValueConv => 'join(" ", unpack("H2"x11, $val))',
4798             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4799             PrintConv => sub { PrintAFPoints(shift, \%afPoints81) },
4800             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints81) },
4801             },{
4802             Name => 'AFPointsUsed',
4803             Condition => '$$self{FocusPointSchema} == 9 and $$self{AFCoordinatesAvailable} == 0', # D6 focus-point model when AFAreaXYPositions are not populated
4804             Format => 'undef[14]',
4805             ValueConv => 'join(" ", unpack("H2"x14, $val))',
4806             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4807             PrintConv => sub { PrintAFPoints(shift, \%afPoints105) },
4808             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints105) },
4809             },
4810             ],
4811             0x2a => { #PH (Z7)
4812             Name => 'AFImageWidth',
4813             Format => 'int16u',
4814             RawConv => '$val ? $val : undef',
4815             },
4816             0x2c => { #PH (Z7)
4817             Name => 'AFImageHeight',
4818             Format => 'int16u',
4819             RawConv => '$val ? $val : undef',
4820             },
4821             0x2e => { #PH (Z7)
4822             Name => 'AFAreaXPosition',
4823             Condition => '$$self{AFCoordinatesAvailable} == 1', # is field populated?
4824             RawConv => '$$self{AFAreaXPosition} = $val',
4825             Format => 'int16u', # (decodes same byte as 0x2f)
4826             },
4827             0x2f => [
4828             {
4829             Name => 'FocusPositionHorizontal', # 209/231 focus point cameras
4830             Condition => '$$self{Model} =~ /^NIKON (Z 30|Z 50|Z fc)\b/i and $$self{AFAreaXPosition}', #models Z30, Z50, Zfc
4831             ValueConv => 'int($$self{AFAreaXPosition} / 260 )', #divisor is an estimate (chosen to cause center point to report 'C')
4832             PrintConv => sub { my ($val) = @_; PrintAFPointsLeftRight($val, 19 ) },
4833             },{
4834             Name => 'FocusPositionHorizontal', #273/299 focus point cameras
4835             Condition => '$$self{Model} =~ /^NIKON (Z 5|Z 6|Z 6_2|D780)\b/i and $$self{AFAreaXPosition}', #models Z5, Z6, Z6ii, D780
4836             ValueConv => 'int($$self{AFAreaXPosition} / 260 )', #divisor is an estimate (chosen to cause center point to report 'C')
4837             PrintConv => sub { my ($val) = @_; PrintAFPointsLeftRight($val, 21 ) },
4838             },{
4839             Name => 'FocusPositionHorizontal', #405/493 focus point cameras
4840             Condition => '$$self{Model} =~ /^NIKON (Z 7|Z 7_2)\b/i and $$self{AFAreaXPosition}', #models Z7/Z7ii
4841             ValueConv => 'int($$self{AFAreaXPosition} / 260 )', #divisor is the measured horizontal pixel separation between adjacent points
4842             PrintConv => sub { my ($val) = @_; PrintAFPointsLeftRight($val, 29 ) },
4843             },
4844             #the only other AFInfoVersion 03xx camera is the D6. It allows the LiveView focus point to positioned anywhere in the frame, rendering this tag somewhat meaningless for that camera
4845             ],
4846             0x30 => { #PH (Z7)
4847             Name => 'AFAreaYPosition',
4848             Condition => '$$self{AFCoordinatesAvailable} == 1', # is field populated?
4849             RawConv => '$$self{AFAreaYPosition} = $val',
4850             Format => 'int16u', # (decodes same byte as 0x31)
4851             },
4852             0x31 => [
4853             {
4854             Name => 'FocusPositionVertical', # 209/233 focus point cameras
4855             Condition => '$$self{Model} =~ /^NIKON (Z 30|Z 50|Z fc)\b/i and $$self{AFAreaYPosition}', #models Z30, Z50, Zfc
4856             ValueConv => 'int($$self{AFAreaYPosition} / 286 )', #divisor is an estimate (chosen to cause center point to report 'C')
4857             PrintConv => sub { my ($val) = @_; PrintAFPointsUpDown($val, 11 ) },
4858             },{
4859             Name => 'FocusPositionVertical', # 273/299 focus point cameras
4860             Condition => '$$self{Model} =~ /^NIKON (Z 5|Z 6|Z 6_2|D780)\b/i and $$self{AFAreaYPosition}', #models Z5, Z6, Z6ii, D780
4861             ValueConv => 'int($$self{AFAreaYPosition} / 286 )', #divisor is an estimate (chosen to cause center point to report 'C')
4862             PrintConv => sub { my ($val) = @_; PrintAFPointsUpDown($val, 13 ) },
4863             },{
4864             Name => 'FocusPositionVertical', # 405/493 focus point cameras
4865             Condition => '$$self{Model} =~ /^NIKON (Z 7|Z 7_2)\b/i and $$self{AFAreaYPosition}', #models Z7/Z7ii
4866             ValueConv => 'int($$self{AFAreaYPosition} / 292 )', #divisor is the measured vertical pixel separation between adjacent points
4867             PrintConv => sub { my ($val) = @_; PrintAFPointsUpDown($val, 17 ) },
4868             },
4869             ],
4870             0x32 => { #PH
4871             Name => 'AFAreaWidth',
4872             Format => 'int16u',
4873             RawConv => '$val ? $val : undef',
4874             },
4875             0x34 => { #PH
4876             Name => 'AFAreaHeight',
4877             Format => 'int16u',
4878             RawConv => '$val ? $val : undef',
4879             },
4880             0x38 =>[
4881             { #PH/JD
4882             Name => 'PrimaryAFPoint',
4883             Condition => '$$self{FocusPointSchema} == 1 and $$self{AFCoordinatesAvailable} == 0', #51 focus-point models when AFAreaXYPositions are not populated
4884             Notes => q{
4885             models with 51-point AF -- 5 rows (A-E) and 11 columns (1-11): D3, D3S, D3X,
4886             D4, D4S, D300, D300S, D700, D750, D800, D800E, D810, D7100 and D7200
4887             },
4888             PrintConvColumns => 5,
4889             PrintConv => {
4890             0 => '(none)',
4891             %afPoints51,
4892             1 => 'C6 (Center)', # (add " (Center)" to central point)
4893             },
4894             },{
4895             Name => 'PrimaryAFPoint',
4896             Condition => '$$self{FocusPointSchema} == 8 and $$self{AFCoordinatesAvailable} == 0', # Z6/Z6ii/Z7/Z7ii/Z50/Z50ii/Zfc/D780 when AFAreaXYPositions are not populated
4897             Notes => q{
4898             models with hybrid detect AF have 81 auto-area points -- 9 rows (A-I) and 9 columns (1-9). Center point is E5
4899             },
4900             PrintConvColumns => 5,
4901             PrintConv => {
4902             0 => '(none)',
4903             %afPoints81,
4904             1 => 'E5 (Center)', # (add " (Center)" to central point)
4905             },
4906             },{ #28
4907             Name => 'PrimaryAFPoint',
4908             Condition => '$$self{FocusPointSchema} == 9 and $$self{AFCoordinatesAvailable} == 0', #153 focus-point models when AFAreaXYPositions are not populated
4909             Notes => q{
4910             Nikon models with 105-point AF -- 7 rows (A-G) and 15 columns (1-15): D6
4911             },
4912             PrintConvColumns => 5,
4913             PrintConv => {
4914             0 => '(none)',
4915             %afPoints105,
4916             1 => 'D8 (Center)',
4917             },
4918             },
4919             ]
4920             );
4921              
4922             %Image::ExifTool::Nikon::AFInfo2V0400 = (
4923             %binaryDataAttrs,
4924             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4925             DATAMEMBER => [ 0, 4, 5, 7, 66, 68 ],
4926             NOTES => q{
4927             AF information for Nikon cameras with the Expeed 7 processor: The Zf, Z6_3,
4928             Z8, Z9, Z50_2 and Z5_2.
4929             },
4930             0 => {
4931             Name => 'AFInfo2Version',
4932             Format => 'undef[4]',
4933             Writable => 0,
4934             RawConv => '$$self{AFInfo2Version} = $val',
4935             },
4936             4 => {
4937             Name => 'AFDetectionMethod',
4938             RawConv => '$$self{AFDetectionMethod} = $val',
4939             PrintConv => \%aFDetectionMethod ,
4940             },
4941             5 => {
4942             Name => 'AFAreaMode', #reflects the mode active when the shutter is tripped, not the position of the Focus Mode button (which is recorded in MenuSettingsZ9 tag also named AfAreaMode)
4943             RawConv => '$$self{AFAreaModeUsed} = $val',
4944             PrintConv => {
4945             192 => 'Pinpoint',
4946             193 => 'Single',
4947             195 => 'Wide (S)',
4948             196 => 'Wide (L)',
4949             197 => 'Auto',
4950             204 => 'Dynamic Area (S)',
4951             205 => 'Dynamic Area (M)',
4952             206 => 'Dynamic Area (L)',
4953             207 => '3D-tracking',
4954             208 => 'Wide (C1/C2)',
4955             },
4956             },
4957             7 => {
4958             Name => 'AFCoordinatesAvailable', #0 => 'AFPointsUsed is populated' 1 => 'AFAreaXPosition & AFAreaYPosition are populated'
4959             RawConv => '$$self{AFCoordinatesAvailable} = $val',
4960             PrintConv => \%noYes ,
4961             },
4962             10 => [{
4963             # valid only for AFAreaModes where the camera selects the focus point (i.e., AutoArea & 3D-Tracking)
4964             # and the camera has yet to determine a focus target (in these cases tags AFAreaXPosition and AFAreaYPosition will be zeroes)
4965             Name => 'AFPointsUsed', # Z8 and Z9 (AFInfo2Version 0400)
4966             Condition => '$$self{Model} =~ /^NIKON (Z 8|Z 9)\b/i and ($$self{AFAreaModeUsed} == 197 or $$self{AFAreaModeUsed} == 207)',
4967             Format => 'undef[51]',
4968             Notes => 'either AFPointsUsed or AFAreaX/YPosition will be set, but not both',
4969             ValueConv => 'join(" ", unpack("H2"x51, $val))',
4970             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4971             PrintConv => sub { PrintAFPoints(shift, \@afPoints405) }, #full-frame sensor, 45MP, auto-area focus point configuration
4972             PrintConvInv => sub { PrintAFPointsInv(shift, \@afPoints405) },
4973             },{
4974             Name => 'AFPointsUsed', # Z6iii & Zf (AFInfo2Version 0401) and Z5ii (AFInfo2Version 0402)
4975             Condition => '$$self{Model} =~ /^NIKON (Z6_3|Z f|Z5_2)\b/i and ($$self{AFAreaModeUsed} == 197 or $$self{AFAreaModeUsed} == 207)',
4976             Format => 'undef[38]',
4977             ValueConv => 'join(" ", unpack("H2"x38, $val))',
4978             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4979             PrintConv => sub { PrintAFPoints(shift, \@afPoints299) },
4980             PrintConvInv => sub { PrintAFPointsInv(shift, \@afPoints299) }, #full-frame sensor, 24MP, auto-area focus point configuration
4981             },{
4982             Name => 'AFPointsUsed', # Z50ii (AFInfo2Version 0402)
4983             Condition => '$$self{Model} =~ /^NIKON Z50_2\b/i and ($$self{AFAreaModeUsed} == 197 or $$self{AFAreaModeUsed} == 207)',
4984             Format => 'undef[29]',
4985             ValueConv => 'join(" ", unpack("H2"x29, $val))',
4986             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4987             PrintConv => sub { PrintAFPoints(shift, \@afPoints231) },
4988             PrintConvInv => sub { PrintAFPointsInv(shift, \@afPoints231) }, #crop sensor, 21MP, auto-area focus point configuration
4989             }],
4990             0x3e => {
4991             Name => 'AFImageWidth',
4992             Format => 'int16u',
4993             RawConv => '$val ? $val : undef',
4994             },
4995             0x40 => {
4996             Name => 'AFImageHeight',
4997             Format => 'int16u',
4998             RawConv => '$val ? $val : undef',
4999             },
5000             0x42 => { #28
5001             Name => 'AFAreaXPosition', #top left image corner is the origin
5002             Condition => '$$self{AFCoordinatesAvailable} == 1', # is field populated?
5003             RawConv => '$$self{AFAreaXPosition} = $val',
5004             Format => 'int16u', # (decodes same byte as 0x43)
5005             },
5006             0x43 => [
5007             {
5008             Name => 'FocusPositionHorizontal', # 209/231 focus point cameras
5009             Condition => '$$self{Model} =~ /^NIKON Z50_2\b/i and $$self{AFAreaXPosition} and $$self{AFAreaXPosition} != 0', #model Z50ii
5010             ValueConv => 'int($$self{AFAreaXPosition} / 260 )', #divisor is the estimated separation between adjacent points (informed by the measured Z7ii separation)
5011             PrintConv => sub { my ($val) = @_; PrintAFPointsLeftRight($val, 19 ) },
5012             },{
5013             Name => 'FocusPositionHorizontal', #273/299 focus point cameras
5014             Condition => '$$self{Model} =~ /^NIKON (Z6_3|Z f|Z5_2)\b/i and $$self{AFAreaXPosition} and $$self{AFAreaXPosition} != 0', #models Z6iii, Zf & Z5ii
5015             ValueConv => 'int($$self{AFAreaXPosition} / 260 )', #divisor is the estimated separation between adjacent points (informed by the measured Z7ii separation)
5016             PrintConv => sub { my ($val) = @_; PrintAFPointsLeftRight($val, 21 ) },
5017             },{
5018             Name => 'FocusPositionHorizontal', #405/493 focus point cameras
5019             Condition => '$$self{Model} =~ /^NIKON (Z 8|Z 9)\b/i and $$self{AFAreaXPosition} and $$self{AFAreaXPosition} != 0', #models Z8 and Z9
5020             ValueConv => 'int($$self{AFAreaXPosition} / 260 )', #divisor is the measured horizontal pixel separation between adjacent points
5021             PrintConv => sub { my ($val) = @_; PrintAFPointsLeftRight($val, 29 ) },
5022             },
5023             ],
5024             0x44 => { #28
5025             Name => 'AFAreaYPosition',
5026             Condition => '$$self{AFCoordinatesAvailable} == 1', # is field populated?
5027             RawConv => '$$self{AFAreaYPosition} = $val',
5028             Format => 'int16u', # (decodes same byte as 0x45)
5029             },
5030             0x45 => [
5031             {
5032             Name => 'FocusPositionVertical', # 209/233 focus point cameras
5033             Condition => '$$self{Model} =~ /^NIKON Z50_2\b/i and $$self{AFAreaYPosition} and $$self{AFAreaYPosition} != 0', #model Z50ii
5034             ValueConv => 'int($$self{AFAreaYPosition} / 286 )', #divisor chosen to cause center point report 'C'
5035             PrintConv => sub { my ($val) = @_; PrintAFPointsUpDown($val, 11 ) },
5036             },{
5037             Name => 'FocusPositionVertical', #273/299 focus point cameras
5038             Condition => '$$self{Model} =~ /^NIKON (Z6_3|Z f|Z5_2)\b/i and $$self{AFAreaYPosition} and $$self{AFAreaYPosition} != 0', #models Z6iii, Zf & Z5ii
5039             ValueConv => 'int($$self{AFAreaYPosition} / 286 )', #divisor chosen to cause center point report 'C'
5040             PrintConv => sub { my ($val) = @_; PrintAFPointsUpDown($val, 13 ) },
5041             },{
5042             Name => 'FocusPositionVertical', #405/493 focus point cameras
5043             Condition => '$$self{Model} =~ /^NIKON (Z 8|Z 9)\b/i and $$self{AFAreaYPosition} and $$self{AFAreaYPosition} != 0', #models Z8 and Z9
5044             ValueConv => 'int($$self{AFAreaYPosition} / 292 )', #divisor is the measured vertical pixel separation between adjacent points
5045             PrintConv => sub { my ($val) = @_; PrintAFPointsUpDown($val, 17 ) },
5046             },
5047             ],
5048             0x46 => {
5049             Name => 'AFAreaWidth',
5050             Format => 'int16u',
5051             Notes => 'size of AF area in AFImage pixels',
5052             RawConv => '$val ? $val : undef',
5053             },
5054             0x48 => {
5055             Name => 'AFAreaHeight',
5056             Format => 'int16u',
5057             RawConv => '$val ? $val : undef',
5058             },
5059             0x4a => {
5060             Name => 'FocusResult',
5061             # in Manual Foucs mode, reflects the state of viewfinder focus indicator.
5062             # In AF-C or AF-S, reflects the result of the last AF operation.
5063             PrintConv => { 0=> "Out of Focus", 1=>"Focus"},
5064             },
5065             );
5066              
5067             # Nikon AF fine-tune information (ref 28)
5068             %Image::ExifTool::Nikon::AFTune = (
5069             %binaryDataAttrs,
5070             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5071             0 => {
5072             Name => 'AFFineTune',
5073             PrintConv => {
5074             0 => 'Off',
5075             # (don't know what the difference between 1 and 2 is)
5076             1 => 'On (1)',
5077             2 => 'On (2)',
5078             3 => 'On (Zoom)', #28
5079             },
5080             },
5081             1 => {
5082             Name => 'AFFineTuneIndex',
5083             Notes => 'index of saved lens',
5084             PrintConv => '$val == 255 ? "n/a" : $val',
5085             PrintConvInv => '$val eq "n/a" ? 255 : $val',
5086             },
5087             2 => {
5088             # when AFFineTune = 3 (indicating a zoom lens), this Tag stores the tuning adjustment for the wide end of the zoom range (ref 28)
5089             Name => 'AFFineTuneAdj',
5090             Priority => 0, # so other value takes priority if it exists
5091             Notes => 'may only be valid for saved lenses',
5092             Format => 'int8s',
5093             PrintConv => '$val > 0 ? "+$val" : $val',
5094             PrintConvInv => '$val',
5095             },
5096             3 => {
5097             Name => 'AFFineTuneAdjTele',
5098             # should probably insert a Condition that restricts this to AFFineTune = 3 (ref 28)
5099             Notes => 'only valid for zoom lenses (ie, AFTune=3)',
5100             Format => 'int8s',
5101             PrintConv => '$val > 0 ? "+$val" : $val',
5102             PrintConvInv => '$val',
5103             },
5104             );
5105              
5106             # Nikon NEF processing information (ref forum6281)
5107             %Image::ExifTool::Nikon::RetouchInfo = (
5108             %binaryDataAttrs,
5109             FORMAT => 'int8s',
5110             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5111             DATAMEMBER => [ 0 ],
5112             0 => {
5113             Name => 'RetouchInfoVersion',
5114             Format => 'undef[4]',
5115             Writable => 0,
5116             RawConv => '$$self{RetouchInfoVersion} = $val',
5117             },
5118             # 4 - RetouchExposureComp (+$val/6 or -$val/6?)
5119             5 => {
5120             Name => 'RetouchNEFProcessing',
5121             Condition => '$$self{RetouchInfoVersion} ge "0200"',
5122             PrintConv => {
5123             -1 => 'Off',
5124             1 => 'On',
5125             },
5126             },
5127             );
5128              
5129             # Nikon File information - D60, D3 and D300 (ref PH)
5130             %Image::ExifTool::Nikon::FileInfo = (
5131             %binaryDataAttrs,
5132             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
5133             FORMAT => 'int16u',
5134             0 => {
5135             Name => 'FileInfoVersion',
5136             Format => 'undef[4]',
5137             Writable => 0,
5138             },
5139             2 => 'MemoryCardNumber',
5140             3 => {
5141             Name => 'DirectoryNumber',
5142             PrintConv => 'sprintf("%.3d", $val)',
5143             PrintConvInv => '$val',
5144             },
5145             4 => {
5146             Name => 'FileNumber',
5147             PrintConv => 'sprintf("%.4d", $val)',
5148             PrintConvInv => '$val',
5149             },
5150             );
5151              
5152             # ref PH
5153             %Image::ExifTool::Nikon::BarometerInfo = (
5154             %binaryDataAttrs,
5155             GROUPS => { 0 => 'MakerNotes', 2 => 'Location' },
5156             0 => {
5157             Name => 'BarometerInfoVersion',
5158             Format => 'undef[4]',
5159             Writable => 0,
5160             },
5161             6 => {
5162             Name => 'Altitude',
5163             Format => 'int32s',
5164             PrintConv => '"$val m"', # (always stored as metres)
5165             PrintConvInv => '$val=~s/\s*m$//; $val',
5166             },
5167             # 10: int16u - values: 0 (display in metres?), 18 (display in feet?)
5168             );
5169              
5170             # ref PH
5171             %Image::ExifTool::Nikon::CaptureOffsets = (
5172             PROCESS_PROC => \&ProcessNikonCaptureOffsets,
5173             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5174             # (note that these are duplicates of offsets in the normal TIFF structure,
5175             # and that these offsets are not updated when ExifTool rewrites the file)
5176             1 => 'IFD0_Offset',
5177             2 => 'PreviewIFD_Offset',
5178             3 => 'SubIFD_Offset',
5179             );
5180              
5181             # ref PH (Written by capture NX)
5182             %Image::ExifTool::Nikon::CaptureOutput = (
5183             %binaryDataAttrs,
5184             FORMAT => 'int32u',
5185             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
5186             # 1 = 1
5187             2 => 'OutputImageWidth',
5188             3 => 'OutputImageHeight',
5189             4 => 'OutputResolution',
5190             # 5 = 1
5191             );
5192              
5193             # ref IB
5194             %Image::ExifTool::Nikon::ColorBalanceA = (
5195             %binaryDataAttrs,
5196             FORMAT => 'int16u',
5197             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5198             624 => { #4
5199             Name => 'WB_RBLevels',
5200             Notes => 'as shot', #IB
5201             Format => 'int16u[2]',
5202             Protected => 1,
5203             },
5204             626 => {
5205             Name => 'WB_RBLevelsAuto',
5206             Format => 'int16u[2]',
5207             Protected => 1,
5208             },
5209             628 => {
5210             Name => 'WB_RBLevelsDaylight',
5211             Notes => 'red/blue levels for 0,+3,+2,+1,-1,-2,-3',
5212             Format => 'int16u[14]',
5213             Protected => 1,
5214             },
5215             642 => {
5216             Name => 'WB_RBLevelsIncandescent',
5217             Format => 'int16u[14]',
5218             Protected => 1,
5219             },
5220             656 => {
5221             Name => 'WB_RBLevelsFluorescent',
5222             Format => 'int16u[6]',
5223             Notes => 'red/blue levels for fluorescent W,N,D',
5224             Protected => 1,
5225             },
5226             662 => {
5227             Name => 'WB_RBLevelsCloudy',
5228             Format => 'int16u[14]',
5229             Protected => 1,
5230             },
5231             676 => {
5232             Name => 'WB_RBLevelsFlash',
5233             Format => 'int16u[14]',
5234             Protected => 1,
5235             },
5236             690 => {
5237             Name => 'WB_RBLevelsShade',
5238             Condition => '$$self{Model} ne "E8700"',
5239             Notes => 'not valid for E8700',
5240             Format => 'int16u[14]',
5241             Protected => 1,
5242             },
5243             );
5244              
5245             my %nrwLevels = (
5246             Format => 'int32u[4]',
5247             Protected => 1,
5248             ValueConv => 'my @a=split " ",$val;$a[0]*=2;$a[3]*=2;"@a"',
5249             ValueConvInv => 'my @a=split " ",$val;$a[0]/=2;$a[3]/=2;"@a"',
5250             );
5251              
5252             # (ref IB)
5253             %Image::ExifTool::Nikon::ColorBalanceB = (
5254             %binaryDataAttrs,
5255             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5256             NOTES => 'Color balance tags used by the P6000.',
5257             0x0004 => {
5258             Name => 'ColorBalanceVersion',
5259             Format => 'undef[4]',
5260             },
5261             0x13e8 => { Name => 'WB_RGGBLevels', %nrwLevels },
5262             0x13f8 => { Name => 'WB_RGGBLevelsDaylight', %nrwLevels },
5263             0x1408 => { Name => 'WB_RGGBLevelsCloudy', %nrwLevels },
5264             0x1428 => { Name => 'WB_RGGBLevelsTungsten', %nrwLevels },
5265             0x1438 => { Name => 'WB_RGGBLevelsFluorescentW',%nrwLevels },
5266             0x1448 => { Name => 'WB_RGGBLevelsFlash', %nrwLevels },
5267             0x1468 => { Name => 'WB_RGGBLevelsCustom', %nrwLevels, Notes => 'all zero if preset WB not used' },
5268             0x1478 => { Name => 'WB_RGGBLevelsAuto', %nrwLevels },
5269             );
5270              
5271             # (ref IB)
5272             %Image::ExifTool::Nikon::ColorBalanceC = (
5273             %binaryDataAttrs,
5274             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5275             DATAMEMBER => [ 4 ],
5276             NOTES => 'Color balance tags used by the P1000, P7000, P7100 and B700.',
5277             0x0004 => {
5278             Name => 'ColorBalanceVersion',
5279             Format => 'undef[4]',
5280             RawConv => '$$self{ColorBalanceVersion} = $val',
5281             },
5282             0x0020 => { Name => 'BlackLevel', Format => 'int16u' },
5283             0x0038 => { Name => 'WB_RGGBLevels', %nrwLevels },
5284             0x004c => { Name => 'WB_RGGBLevelsDaylight', %nrwLevels },
5285             0x0060 => { Name => 'WB_RGGBLevelsCloudy', %nrwLevels },
5286             0x0074 => {
5287             Name => 'WB_RGGBLevelsShade',
5288             Condition => '$$self{ColorBalanceVersion} ge "0104"',
5289             Notes => 'valid only for some models',
5290             %nrwLevels,
5291             },
5292             0x0088 => { Name => 'WB_RGGBLevelsTungsten', %nrwLevels },
5293             0x009c => { Name => 'WB_RGGBLevelsFluorescentW',%nrwLevels },
5294             0x00b0 => { Name => 'WB_RGGBLevelsFluorescentN',%nrwLevels },
5295             0x00c4 => { Name => 'WB_RGGBLevelsFluorescentD',%nrwLevels },
5296             0x00d8 => { Name => 'WB_RGGBLevelsHTMercury', %nrwLevels },
5297             0x0100 => { Name => 'WB_RGGBLevelsCustom', %nrwLevels, Notes => 'all zero if preset WB not used' },
5298             0x0114 => { Name => 'WB_RGGBLevelsAuto', %nrwLevels },
5299             );
5300              
5301             # ref 4
5302             %Image::ExifTool::Nikon::ColorBalance1 = (
5303             %binaryDataAttrs,
5304             FORMAT => 'int16u',
5305             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5306             0 => {
5307             Name => 'WB_RBGGLevels',
5308             Format => 'int16u[4]',
5309             Protected => 1,
5310             },
5311             );
5312              
5313             # ref 4
5314             %Image::ExifTool::Nikon::ColorBalance2 = (
5315             %binaryDataAttrs,
5316             FORMAT => 'int16u',
5317             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5318             NOTES => 'This information is encrypted for most camera models.',
5319             0 => {
5320             Name => 'WB_RGGBLevels',
5321             Format => 'int16u[4]',
5322             Protected => 1,
5323             },
5324             );
5325              
5326             # ref 4
5327             %Image::ExifTool::Nikon::ColorBalance3 = (
5328             %binaryDataAttrs,
5329             FORMAT => 'int16u',
5330             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5331             0 => {
5332             Name => 'WB_RGBGLevels',
5333             Format => 'int16u[4]',
5334             Protected => 1,
5335             },
5336             );
5337              
5338             # ref 4
5339             %Image::ExifTool::Nikon::ColorBalance4 = (
5340             %binaryDataAttrs,
5341             FORMAT => 'int16u',
5342             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5343             0 => {
5344             Name => 'WB_GRBGLevels',
5345             Format => 'int16u[4]',
5346             Protected => 1,
5347             },
5348             );
5349              
5350             %Image::ExifTool::Nikon::ColorBalanceUnknown = (
5351             %binaryDataAttrs,
5352             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5353             0 => {
5354             Name => 'ColorBalanceVersion',
5355             Format => 'undef[4]',
5356             },
5357             );
5358              
5359             %Image::ExifTool::Nikon::ColorBalanceUnknown2 = (
5360             %binaryDataAttrs,
5361             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5362             FORMAT => 'int16u',
5363             0 => {
5364             Name => 'ColorBalanceVersion',
5365             Format => 'undef[4]',
5366             },
5367             );
5368              
5369             %Image::ExifTool::Nikon::Type2 = (
5370             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
5371             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
5372             WRITABLE => 1,
5373             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5374             0x0003 => 'Quality',
5375             0x0004 => 'ColorMode',
5376             0x0005 => 'ImageAdjustment',
5377             0x0006 => 'CCDSensitivity',
5378             0x0007 => 'WhiteBalance',
5379             0x0008 => 'Focus',
5380             0x000A => 'DigitalZoom',
5381             0x000B => 'Converter',
5382             );
5383              
5384             # these are standard EXIF tags, but they are duplicated here so we can
5385             # set the family 0 group to 'MakerNotes' and set the MINOR_ERRORS flag
5386             %Image::ExifTool::Nikon::PreviewIFD = (
5387             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
5388             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
5389             GROUPS => { 0 => 'MakerNotes', 1 => 'PreviewIFD', 2 => 'Image'},
5390             VARS => { MINOR_ERRORS => 1 }, # this IFD is non-essential and often corrupted
5391             # (these tags are priority 0 by default because PreviewIFD is flagged in LOW_PRIORITY_DIR)
5392             0xfe => { # (not used by Nikon, but SRW images also use this table)
5393             Name => 'SubfileType',
5394             DataMember => 'SubfileType',
5395             RawConv => '$$self{SubfileType} = $val',
5396             PrintConv => \%Image::ExifTool::Exif::subfileType,
5397             },
5398             0x103 => {
5399             Name => 'Compression',
5400             SeparateTable => 'EXIF Compression',
5401             PrintConv => \%Image::ExifTool::Exif::compression,
5402             },
5403             0x11a => 'XResolution',
5404             0x11b => 'YResolution',
5405             0x128 => {
5406             Name => 'ResolutionUnit',
5407             PrintConv => {
5408             1 => 'None',
5409             2 => 'inches',
5410             3 => 'cm',
5411             },
5412             },
5413             0x201 => {
5414             Name => 'PreviewImageStart',
5415             Flags => [ 'IsOffset', 'Permanent' ],
5416             OffsetPair => 0x202,
5417             DataTag => 'PreviewImage',
5418             Writable => 'int32u',
5419             WriteGroup => 'MakerNotes',
5420             Protected => 2,
5421             },
5422             0x202 => {
5423             Name => 'PreviewImageLength',
5424             Flags => 'Permanent' ,
5425             OffsetPair => 0x201,
5426             DataTag => 'PreviewImage',
5427             Writable => 'int32u',
5428             WriteGroup => 'MakerNotes',
5429             Protected => 2,
5430             },
5431             0x213 => {
5432             Name => 'YCbCrPositioning',
5433             PrintConv => {
5434             1 => 'Centered',
5435             2 => 'Co-sited',
5436             },
5437             },
5438             );
5439              
5440             # these are duplicated enough times to make it worthwhile to define them centrally
5441             my %nikonApertureConversions = (
5442             ValueConv => '2**($val/24)',
5443             ValueConvInv => '$val>0 ? 24*log($val)/log(2) : 0',
5444             PrintConv => 'sprintf("%.1f",$val)',
5445             PrintConvInv => '$val',
5446             );
5447              
5448             my %nikonFocalConversions = (
5449             ValueConv => '5 * 2**($val/24)',
5450             ValueConvInv => '$val>0 ? 24*log($val/5)/log(2) : 0',
5451             PrintConv => 'sprintf("%.1f mm",$val)',
5452             PrintConvInv => '$val=~s/\s*mm$//;$val',
5453             );
5454              
5455             # Version 100 Nikon lens data
5456             %Image::ExifTool::Nikon::LensData00 = (
5457             %binaryDataAttrs,
5458             NOTES => 'This structure is used by the D100, and D1X with firmware version 1.1.',
5459             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5460             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
5461             0x00 => {
5462             Name => 'LensDataVersion',
5463             Format => 'undef[4]',
5464             Writable => 0,
5465             },
5466             0x06 => { #8
5467             Name => 'LensIDNumber',
5468             Notes => 'see LensID values below',
5469             },
5470             0x07 => { #8
5471             Name => 'LensFStops',
5472             ValueConv => '$val / 12',
5473             ValueConvInv => '$val * 12',
5474             PrintConv => 'sprintf("%.2f", $val)',
5475             PrintConvInv => '$val',
5476             },
5477             0x08 => { #8/9
5478             Name => 'MinFocalLength',
5479             %nikonFocalConversions,
5480             },
5481             0x09 => { #8/9
5482             Name => 'MaxFocalLength',
5483             %nikonFocalConversions,
5484             },
5485             0x0a => { #8
5486             Name => 'MaxApertureAtMinFocal',
5487             %nikonApertureConversions,
5488             },
5489             0x0b => { #8
5490             Name => 'MaxApertureAtMaxFocal',
5491             %nikonApertureConversions,
5492             },
5493             0x0c => 'MCUVersion', #8 (MCU = Micro Controller Unit)
5494             );
5495              
5496             # Nikon lens data (note: needs decrypting if LensDataVersion is 020x)
5497             %Image::ExifTool::Nikon::LensData01 = (
5498             %binaryDataAttrs,
5499             NOTES => q{
5500             Nikon encrypts the LensData information below if LensDataVersion is 0201 or
5501             higher, but the decryption algorithm is known so the information can be
5502             extracted.
5503             },
5504             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5505             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
5506             0x00 => {
5507             Name => 'LensDataVersion',
5508             Format => 'string[4]',
5509             Writable => 0,
5510             },
5511             0x04 => { #8
5512             Name => 'ExitPupilPosition',
5513             ValueConv => '$val ? 2048 / $val : $val',
5514             ValueConvInv => '$val ? 2048 / $val : $val',
5515             PrintConv => 'sprintf("%.1f mm",$val)',
5516             PrintConvInv => '$val=~s/\s*mm$//; $val',
5517             },
5518             0x05 => { #8
5519             Name => 'AFAperture',
5520             %nikonApertureConversions,
5521             },
5522             0x08 => { #8
5523             # this seems to be 2 values: the upper nibble gives the far focus
5524             # range and the lower nibble gives the near focus range. The values
5525             # are in the range 1-N, where N is lens-dependent. A value of 0 for
5526             # the far focus range indicates infinity. (ref JD)
5527             Name => 'FocusPosition',
5528             PrintConv => 'sprintf("0x%02x", $val)',
5529             PrintConvInv => '$val',
5530             },
5531             0x09 => { #8/9
5532             # With older AF lenses this does not work... (ref 13)
5533             # eg) AF Nikkor 50mm f/1.4 => 48 (0x30)
5534             # AF Zoom-Nikkor 35-105mm f/3.5-4.5 => @35mm => 15 (0x0f), @105mm => 141 (0x8d)
5535             Notes => 'this focus distance is approximate, and not very accurate for some lenses',
5536             Name => 'FocusDistance',
5537             ValueConv => '0.01 * 10**($val/40)', # in m
5538             ValueConvInv => '$val>0 ? 40*log($val*100)/log(10) : 0',
5539             PrintConv => '$val ? sprintf("%.2f m",$val) : "inf"',
5540             PrintConvInv => '$val eq "inf" ? 0 : $val =~ s/\s*m$//, $val',
5541             },
5542             0x0a => { #8/9
5543             Name => 'FocalLength',
5544             Priority => 0,
5545             %nikonFocalConversions,
5546             },
5547             0x0b => { #8
5548             Name => 'LensIDNumber',
5549             Notes => 'see LensID values below',
5550             },
5551             0x0c => { #8
5552             Name => 'LensFStops',
5553             ValueConv => '$val / 12',
5554             ValueConvInv => '$val * 12',
5555             PrintConv => 'sprintf("%.2f", $val)',
5556             PrintConvInv => '$val',
5557             },
5558             0x0d => { #8/9
5559             Name => 'MinFocalLength',
5560             %nikonFocalConversions,
5561             },
5562             0x0e => { #8/9
5563             Name => 'MaxFocalLength',
5564             %nikonFocalConversions,
5565             },
5566             0x0f => { #8
5567             Name => 'MaxApertureAtMinFocal',
5568             %nikonApertureConversions,
5569             },
5570             0x10 => { #8
5571             Name => 'MaxApertureAtMaxFocal',
5572             %nikonApertureConversions,
5573             },
5574             0x11 => 'MCUVersion', #8 (MCU = Micro Controller Unit)
5575             0x12 => { #8
5576             Name => 'EffectiveMaxAperture',
5577             %nikonApertureConversions,
5578             },
5579             );
5580              
5581             # Nikon lens data (note: needs decrypting)
5582             %Image::ExifTool::Nikon::LensData0204 = (
5583             %binaryDataAttrs,
5584             NOTES => q{
5585             Nikon encrypts the LensData information below if LensDataVersion is 0201 or
5586             higher, but the decryption algorithm is known so the information can be
5587             extracted.
5588             },
5589             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5590             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
5591             0x00 => {
5592             Name => 'LensDataVersion',
5593             Format => 'string[4]',
5594             Writable => 0,
5595             },
5596             0x04 => { #8
5597             Name => 'ExitPupilPosition',
5598             ValueConv => '$val ? 2048 / $val : $val',
5599             ValueConvInv => '$val ? 2048 / $val : $val',
5600             PrintConv => 'sprintf("%.1f mm",$val)',
5601             PrintConvInv => '$val=~s/\s*mm$//; $val',
5602             },
5603             0x05 => { #8
5604             Name => 'AFAperture',
5605             %nikonApertureConversions,
5606             },
5607             0x08 => { #8
5608             # this seems to be 2 values: the upper nibble gives the far focus
5609             # range and the lower nibble gives the near focus range. The values
5610             # are in the range 1-N, where N is lens-dependent. A value of 0 for
5611             # the far focus range indicates infinity. (ref JD)
5612             Name => 'FocusPosition',
5613             PrintConv => 'sprintf("0x%02x", $val)',
5614             PrintConvInv => '$val',
5615             },
5616             # --> extra byte at position 0x09 in this version of LensData (PH)
5617             0x0a => { #8/9
5618             # With older AF lenses this does not work... (ref 13)
5619             # eg) AF Nikkor 50mm f/1.4 => 48 (0x30)
5620             # AF Zoom-Nikkor 35-105mm f/3.5-4.5 => @35mm => 15 (0x0f), @105mm => 141 (0x8d)
5621             Notes => 'this focus distance is approximate, and not very accurate for some lenses',
5622             Name => 'FocusDistance',
5623             ValueConv => '0.01 * 10**($val/40)', # in m
5624             ValueConvInv => '$val>0 ? 40*log($val*100)/log(10) : 0',
5625             PrintConv => '$val ? sprintf("%.2f m",$val) : "inf"',
5626             PrintConvInv => '$val eq "inf" ? 0 : $val =~ s/\s*m$//, $val',
5627             },
5628             0x0b => { #8/9
5629             Name => 'FocalLength',
5630             Priority => 0,
5631             %nikonFocalConversions,
5632             },
5633             0x0c => { #8
5634             Name => 'LensIDNumber',
5635             Notes => 'see LensID values below',
5636             },
5637             0x0d => { #8
5638             Name => 'LensFStops',
5639             ValueConv => '$val / 12',
5640             ValueConvInv => '$val * 12',
5641             PrintConv => 'sprintf("%.2f", $val)',
5642             PrintConvInv => '$val',
5643             },
5644             0x0e => { #8/9
5645             Name => 'MinFocalLength',
5646             %nikonFocalConversions,
5647             },
5648             0x0f => { #8/9
5649             Name => 'MaxFocalLength',
5650             %nikonFocalConversions,
5651             },
5652             0x10 => { #8
5653             Name => 'MaxApertureAtMinFocal',
5654             %nikonApertureConversions,
5655             },
5656             0x11 => { #8
5657             Name => 'MaxApertureAtMaxFocal',
5658             %nikonApertureConversions,
5659             },
5660             0x12 => 'MCUVersion', #8 (MCU = Micro Controller Unit)
5661             0x13 => { #8
5662             Name => 'EffectiveMaxAperture',
5663             %nikonApertureConversions,
5664             },
5665             );
5666              
5667             # Nikon lens data version 0400 (note: needs decrypting) (ref PH)
5668             %Image::ExifTool::Nikon::LensData0400 = (
5669             %binaryDataAttrs,
5670             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5671             NOTES => 'Tags extracted from the encrypted lens data of the Nikon 1J1/1V1/1J2.',
5672             0x00 => {
5673             Name => 'LensDataVersion',
5674             Format => 'string[4]',
5675             Writable => 0,
5676             },
5677             0x18a => { #PH
5678             Name => 'LensModel',
5679             Format => 'string[64]',
5680             },
5681             );
5682              
5683             # Nikon lens data version 0402 (note: needs decrypting) (ref PH)
5684             %Image::ExifTool::Nikon::LensData0402 = (
5685             %binaryDataAttrs,
5686             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5687             NOTES => 'Tags extracted from the encrypted lens data of the Nikon 1J3/1S1/1V2.',
5688             0x00 => {
5689             Name => 'LensDataVersion',
5690             Format => 'string[4]',
5691             Writable => 0,
5692             },
5693             0x18b => { #PH
5694             Name => 'LensModel',
5695             Format => 'string[64]',
5696             },
5697             );
5698              
5699             # Nikon lens data version 0403 (note: needs decrypting) (ref PH)
5700             %Image::ExifTool::Nikon::LensData0403 = (
5701             %binaryDataAttrs,
5702             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5703             NOTES => 'Tags extracted from the encrypted lens data of the Nikon 1J4/1J5.',
5704             0x00 => {
5705             Name => 'LensDataVersion',
5706             Format => 'string[4]',
5707             Writable => 0,
5708             },
5709             0x2ac => { #PH
5710             Name => 'LensModel',
5711             Format => 'string[64]',
5712             },
5713             );
5714              
5715             # Nikon Z lens data (note: needs decrypting) (ref PH, based on LensData0204)
5716             %Image::ExifTool::Nikon::LensData0800 = (
5717             %binaryDataAttrs,
5718             NOTES => 'Tags found in the encrypted LensData from cameras such as the Z6 and Z7.',
5719             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5720             DATAMEMBER => [ 0x03, 0x2f, 0x30, 0x4c, 0x56, 0x58 ],
5721             0x00 => {
5722             Name => 'LensDataVersion',
5723             Format => 'string[4]',
5724             Writable => 0,
5725             },
5726             0x03 => { # look forward to see if new old data exists...
5727             Name => 'OldLensData',
5728             Format => 'undef[17]',
5729             RawConv => '$$self{OldLensData} = 1 unless $val =~ /^.\0+$/s; undef',
5730             #Hidden => 1,
5731             },
5732             0x04 => {
5733             Name => 'ExitPupilPosition',
5734             Condition => '$$self{OldLensData}',
5735             ValueConv => '$val ? 2048 / $val : $val',
5736             ValueConvInv => '$val ? 2048 / $val : $val',
5737             PrintConv => 'sprintf("%.1f mm",$val)',
5738             PrintConvInv => '$val=~s/\s*mm$//; $val',
5739             },
5740             0x05 => {
5741             Name => 'AFAperture',
5742             Condition => '$$self{OldLensData}',
5743             %nikonApertureConversions,
5744             },
5745             # --> another extra byte at position 0x08 in this version of LensData (PH)
5746             #0x09 => {
5747             # 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
5748             # Condition => '$$self{OldLensData}',
5749             # PrintConv => 'sprintf("0x%02x", $val)',
5750             # PrintConvInv => '$val',
5751             #},
5752             0x0b => {
5753             Notes => 'this focus distance is approximate, and not very accurate for some lenses',
5754             Name => 'FocusDistance',
5755             Condition => '$$self{OldLensData}',
5756             ValueConv => '0.01 * 10**($val/40)', # in m
5757             ValueConvInv => '$val>0 ? 40*log($val*100)/log(10) : 0',
5758             PrintConv => '$val ? sprintf("%.2f m",$val) : "inf"',
5759             PrintConvInv => '$val eq "inf" ? 0 : $val =~ s/\s*m$//, $val',
5760             },
5761             0x0c => {
5762             Name => 'FocalLength',
5763             Condition => '$$self{OldLensData}',
5764             Priority => 0,
5765             %nikonFocalConversions,
5766             },
5767             0x0d => {
5768             Name => 'LensIDNumber',
5769             Condition => '$$self{OldLensData}',
5770             Notes => 'see LensID values below',
5771             },
5772             0x0e => {
5773             Name => 'LensFStops',
5774             Condition => '$$self{OldLensData}',
5775             ValueConv => '$val / 12',
5776             ValueConvInv => '$val * 12',
5777             PrintConv => 'sprintf("%.2f", $val)',
5778             PrintConvInv => '$val',
5779             },
5780             0x0f => {
5781             Name => 'MinFocalLength',
5782             Condition => '$$self{OldLensData}',
5783             %nikonFocalConversions,
5784             },
5785             0x10 => {
5786             Name => 'MaxFocalLength',
5787             Condition => '$$self{OldLensData}',
5788             %nikonFocalConversions,
5789             },
5790             0x11 => {
5791             Name => 'MaxApertureAtMinFocal',
5792             Condition => '$$self{OldLensData}',
5793             %nikonApertureConversions,
5794             },
5795             0x12 => {
5796             Name => 'MaxApertureAtMaxFocal',
5797             Condition => '$$self{OldLensData}',
5798             %nikonApertureConversions,
5799             },
5800             0x13 => {
5801             Name => 'MCUVersion',
5802             Condition => '$$self{OldLensData}',
5803             },
5804             0x14 => {
5805             Name => 'EffectiveMaxAperture',
5806             Condition => '$$self{OldLensData}',
5807             %nikonApertureConversions,
5808             },
5809             #
5810             # ---- new LensData tags used by Nikkor Z cameras (ref PH/28). ----
5811             # (some fields are strictly for Z-series lenses, others apply to legacy F-mount as well, ref 28)
5812             #
5813             0x2f => { # look forward to see if new lens data exists...
5814             Name => 'NewLensData',
5815             Format => 'undef[17]',
5816             RawConv => '$$self{NewLensData} = 1 unless $val =~ /^.\0+$/s; undef',
5817             ##Hidden => 1,
5818             },
5819             0x30 => { #PH
5820             Name => 'LensID',
5821             Condition => '$$self{NewLensData}',
5822             Notes => 'tags from here onward used for Nikkor Z lenses only',
5823             Format => 'int16u',
5824             RawConv => '$$self{LensID} = $val', #28 non-zero = > Native Z lens; 0 => DSLR lens via FTZ style adapter or non-Nikon Z-mount lens (or no lens attached)
5825             PrintConv => {
5826             1 => 'Nikkor Z 24-70mm f/4 S',
5827             2 => 'Nikkor Z 14-30mm f/4 S',
5828             4 => 'Nikkor Z 35mm f/1.8 S',
5829             8 => 'Nikkor Z 58mm f/0.95 S Noct', #IB
5830             9 => 'Nikkor Z 50mm f/1.8 S',
5831             11 => 'Nikkor Z DX 16-50mm f/3.5-6.3 VR',
5832             12 => 'Nikkor Z DX 50-250mm f/4.5-6.3 VR',
5833             13 => 'Nikkor Z 24-70mm f/2.8 S',
5834             14 => 'Nikkor Z 85mm f/1.8 S',
5835             15 => 'Nikkor Z 24mm f/1.8 S', #IB
5836             16 => 'Nikkor Z 70-200mm f/2.8 VR S', #IB
5837             17 => 'Nikkor Z 20mm f/1.8 S', #IB
5838             18 => 'Nikkor Z 24-200mm f/4-6.3 VR', #IB
5839             21 => 'Nikkor Z 50mm f/1.2 S', #IB
5840             22 => 'Nikkor Z 24-50mm f/4-6.3', #IB
5841             23 => 'Nikkor Z 14-24mm f/2.8 S', #IB
5842             24 => 'Nikkor Z MC 105mm f/2.8 VR S', #IB
5843             25 => 'Nikkor Z 40mm f/2', #28
5844             26 => 'Nikkor Z DX 18-140mm f/3.5-6.3 VR', #IB
5845             27 => 'Nikkor Z MC 50mm f/2.8', #IB
5846             28 => 'Nikkor Z 100-400mm f/4.5-5.6 VR S', #28
5847             29 => 'Nikkor Z 28mm f/2.8', #IB
5848             30 => 'Nikkor Z 400mm f/2.8 TC VR S', #28
5849             31 => 'Nikkor Z 24-120mm f/4 S', #github250
5850             32 => 'Nikkor Z 800mm f/6.3 VR S', #28
5851             35 => 'Nikkor Z 28-75mm f/2.8', #IB
5852             36 => 'Nikkor Z 400mm f/4.5 VR S', #IB
5853             37 => 'Nikkor Z 600mm f/4 TC VR S', #28
5854             38 => 'Nikkor Z 85mm f/1.2 S', #28
5855             39 => 'Nikkor Z 17-28mm f/2.8', #IB
5856             40 => 'Nikkor Z 26mm f/2.8', #28
5857             41 => 'Nikkor Z DX 12-28mm f/3.5-5.6 PZ VR', #28
5858             42 => 'Nikkor Z 180-600mm f/5.6-6.3 VR', #30
5859             43 => 'Nikkor Z DX 24mm f/1.7', #28
5860             44 => 'Nikkor Z 70-180mm f/2.8', #28
5861             45 => 'Nikkor Z 600mm f/6.3 VR S', #28
5862             46 => 'Nikkor Z 135mm f/1.8 S Plena', #28
5863             47 => 'Nikkor Z 35mm f/1.2 S', #28
5864             48 => 'Nikkor Z 28-400mm f/4-8 VR', #30
5865             49 => 'Nikkor Z 28-135mm f/4 PZ', #28
5866             51 => 'Nikkor Z 35mm f/1.4', #28
5867             52 => 'Nikkor Z 50mm f/1.4', #28
5868             2305 => 'Laowa FFII 10mm F2.8 C&D Dreamer', #30
5869             32768 => 'Nikkor Z 400mm f/2.8 TC VR S TC-1.4x', #28
5870             32769 => 'Nikkor Z 600mm f/4 TC VR S TC-1.4x', #28
5871             },
5872             },
5873             0x34 => { #28
5874             Name => 'LensFirmwareVersion',
5875             Condition => '$$self{LensID} and $$self{LensID} != 0', #only valid for Z-mount lenses
5876             Format => 'int16u', #4 bits each for version, release amd modification in VRM scheme.
5877             PrintConv => q{
5878             my $version = int($val / 256);
5879             my $release = int(($val - 256 * $version)/16);
5880             my $modification = $val - (256 * $version + 16 * $release);
5881             return sprintf("%.0f.%.0f.%.0f", $version,$release,$modification);
5882             },
5883             },
5884             0x36 => { #PH
5885             Name => 'MaxAperture',
5886             Condition => '$$self{NewLensData}',
5887             Format => 'int16u',
5888             Priority => 0,
5889             ValueConv => '2**($val/384-1)',
5890             ValueConvInv => '384*(log($val)/log(2)+1)',
5891             PrintConv => 'sprintf("%.1f",$val)',
5892             PrintConvInv => '$val',
5893             },
5894             0x38 => { #PH
5895             Name => 'FNumber',
5896             Condition => '$$self{NewLensData}',
5897             Format => 'int16u',
5898             Priority => 0,
5899             ValueConv => '2**($val/384-1)',
5900             ValueConvInv => '384*(log($val)/log(2)+1)',
5901             PrintConv => 'sprintf("%.1f",$val)',
5902             PrintConvInv => '$val',
5903             },
5904             0x3c => { #PH
5905             Name => 'FocalLength',
5906             Condition => '$$self{NewLensData}',
5907             Format => 'int16u',
5908             Priority => 0,
5909             PrintConv => '"$val mm"',
5910             PrintConvInv => '$val=~s/\s*mm$//;$val',
5911             },
5912             0x4c => { #28
5913             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.
5914             Format => 'int8u',
5915             Condition => '$$self{LensID} and $$self{LensID} != 0 and $$self{FocusMode} ne "Manual"',
5916             RawConv => '$$self{FocusDistanceRangeWidth} = $val',
5917             Unknown => 1,
5918             },
5919             0x4e => { #28
5920             Name => 'FocusDistance',
5921             Format => 'int16u',
5922             Condition => '$$self{LensID} and $$self{LensID} != 0', #only valid for Z-mount lenses
5923             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
5924             ValueConv => '2**(($val-80)/12)', # in m #slighly more accurate than the legacy calcualtion of '0.01 * 10**($val/40)'. Tested at all focus positions using the 105mm,70-200mm & 600mm
5925             ValueConvInv => '$val>0 ? log(12*($val+80)/log(2) : 0', #was '$val>0 ? 40*log($val*100)/log(10) : 0'
5926             PrintConv => q{
5927             (defined $$self{FocusStepsFromInfinity} and $$self{FocusStepsFromInfinity} eq 0) ? "Inf" : $val < 100 ? $val < 10 ? $val < 1 ? $val < 0.35 ? sprintf("%.4f m", $val): sprintf("%.3f m", $val): sprintf("%.2f m", $val) : sprintf("%.1f m", $val) : sprintf("%.0f m", $val),
5928             },
5929             },
5930             0x56 => { #28 #not valid for focus mode M
5931             Name => 'LensDriveEnd', # byte contains: 1 at CFD/MOD; 2 at Infinity; 0 otherwise
5932             Condition => '$$self{LensID} and $$self{LensID} != 0 and $$self{FocusMode} ne "Manual"', #valid for Z-mount lenses in focus modes other than M
5933             Format => 'int8u',
5934             RawConv => 'unless (defined $$self{FocusDistanceRangeWidth} and not $$self{FocusDistanceRangeWidth}) { if ($val == 0 ) {$$self{LensDriveEnd} = "No"} else { $$self{LensDriveEnd} = "CFD"} } else{ $$self{LensDriveEnd} = "Inf"}',
5935             Unknown => 1,
5936             },
5937             0x58 => { #28
5938             Name => 'FocusStepsFromInfinity',
5939             Condition => '$$self{LensID} and $$self{LensID} != 0', #valid for Z-mount lenses in both AF and manual focus modes
5940             Format => 'int8u',
5941             RawConv => '$$self{FocusStepsFromInfinity} = $val', # 0 at Infinity, otherwise a small positive number monotonically increasing towards CFD.
5942             Unknown => 1,
5943             },
5944             0x5a => { #28
5945             Name => 'LensPositionAbsolute', # <=0 at infinity. Typical value at CFD might be 58000. Only valid for Z-mount lenses.
5946             Condition => '$$self{LensID} and $$self{LensID} != 0', # Only valid for Z-mount lenses.
5947             Format => 'int32s',
5948             #Unknown => 1,
5949             },
5950             0x5f => { #28
5951             Name => 'LensMountType',
5952             Format => 'int8u',
5953             Mask => 0x01,
5954             PrintConv => {
5955             0 => 'Z-mount',
5956             1 => 'F-mount',
5957             },
5958             },
5959             );
5960              
5961             # Unknown Nikon lens data (note: data may need decrypting after byte 4)
5962             %Image::ExifTool::Nikon::LensDataUnknown = (
5963             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
5964             FIRST_ENTRY => 0,
5965             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5966             0x00 => {
5967             Name => 'LensDataVersion',
5968             Format => 'string[4]',
5969             },
5970             );
5971              
5972             # shot information (encrypted in some cameras) - ref 18
5973             %Image::ExifTool::Nikon::ShotInfo = (
5974             %binaryDataAttrs,
5975             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5976             DATAMEMBER => [ 0 ],
5977             NOTES => q{
5978             This information is encrypted for ShotInfoVersion 02xx, and some tags are
5979             only valid for specific models.
5980             },
5981             0x00 => {
5982             Name => 'ShotInfoVersion',
5983             Format => 'string[4]',
5984             Writable => 0,
5985             RawConv => '$$self{ShotInfoVersion} = $val; $val =~ /^\d+$/ ? $val : undef',
5986             },
5987             0x04 => {
5988             Name => 'FirmwareVersion',
5989             Format => 'string[5]',
5990             Writable => 0,
5991             RawConv => '$val =~ /^\d\.\d+.$/ ? $val : undef',
5992             },
5993             0x10 => {
5994             Name => 'DistortionControl',
5995             Condition => '$$self{Model} =~ /P6000\b/',
5996             Notes => 'P6000',
5997             PrintConv => \%offOn,
5998             },
5999             0x66 => {
6000             Name => 'VR_0x66',
6001             Condition => '$$self{ShotInfoVersion} eq "0204"',
6002             Format => 'int8u',
6003             Unknown => 1,
6004             Notes => 'D2X, D2Xs (unverified)',
6005             PrintConv => {
6006             0 => 'Off',
6007             1 => 'On (normal)',
6008             2 => 'On (active)',
6009             },
6010             },
6011             # 6a, 6e not correct for 0103 (D70), 0207 (D200)
6012             0x6a => {
6013             Name => 'ShutterCount',
6014             Condition => '$$self{ShotInfoVersion} eq "0204"',
6015             Format => 'int32u',
6016             Priority => 0,
6017             Notes => 'D2X, D2Xs',
6018             },
6019             0x6e => {
6020             Name => 'DeletedImageCount',
6021             Condition => '$$self{ShotInfoVersion} eq "0204"',
6022             Format => 'int32u',
6023             Priority => 0,
6024             Notes => 'D2X, D2Xs',
6025             },
6026             0x75 => { #JD
6027             Name => 'VibrationReduction',
6028             Condition => '$$self{ShotInfoVersion} eq "0207"',
6029             Format => 'int8u',
6030             Notes => 'D200',
6031             PrintConv => {
6032             0 => 'Off',
6033             # (not sure what the different values represent, but values
6034             # of 1 and 2 have even been observed for non-VR lenses!)
6035             1 => 'On (1)', #PH
6036             2 => 'On (2)', #PH
6037             3 => 'On (3)', #PH (rare -- only seen once)
6038             },
6039             },
6040             0x82 => { # educated guess, needs verification
6041             Name => 'VibrationReduction',
6042             Condition => '$$self{ShotInfoVersion} eq "0204"',
6043             Format => 'int8u',
6044             Notes => 'D2X, D2Xs',
6045             PrintConv => {
6046             0 => 'Off',
6047             1 => 'On',
6048             },
6049             },
6050             # 0xac - int16u[600] TiffMeteringImage1: 30x20 image (ShotInfoVersion 0800, ref JR)
6051             0x157 => { #JD
6052             Name => 'ShutterCount',
6053             Condition => '$$self{ShotInfoVersion} eq "0205"',
6054             Format => 'undef[2]',
6055             Priority => 0,
6056             Notes => 'D50',
6057             # treat as a 2-byte big-endian integer
6058             ValueConv => 'unpack("n", $val)',
6059             ValueConvInv => 'pack("n",$val)',
6060             },
6061             0x1ae => { #JD
6062             Name => 'VibrationReduction',
6063             Condition => '$$self{ShotInfoVersion} eq "0205"',
6064             Format => 'int8u',
6065             Notes => 'D50',
6066             PrintHex => 1,
6067             PrintConv => {
6068             0x00 => 'n/a',
6069             0x0c => 'Off',
6070             0x0f => 'On',
6071             },
6072             },
6073             0x24d => { #PH
6074             Name => 'ShutterCount',
6075             Condition => '$$self{ShotInfoVersion} eq "0211"',
6076             Notes => 'D60',
6077             Format => 'int32u',
6078             Priority => 0,
6079             },
6080             # 0x55c - int16u[2400] TiffMeteringImage2: 60x40 image (ShotInfoVersion 0800, ref JR)
6081             # 0x181c - int16u[1200] TiffMeteringImage?: 60x20 image for some NEF's (ShotInfoVersion 0800, ref JR)
6082             # 0x217c - int16u[2400] TiffMeteringImage3: 60x40 image (ShotInfoVersion 0800, ref JR)
6083             # 0x3d9c - int16u[2400] TiffMeteringImage4: 60x40 image (ShotInfoVersion 0800, ref JR)
6084             # 0x59c0 - TiffMeteringImageWidth (ShotInfoVersion 0800, ref JR)
6085             # 0x59c2 - TiffMeteringImageHeight (ShotInfoVersion 0800, ref JR)
6086             # 0x59c4 - int16u[1800] TiffMeteringImage5: 30x20 RGB image (ShotInfoVersion 0800, ref JR)
6087             );
6088              
6089             # shot information for D40 and D40X (encrypted) - ref PH
6090             %Image::ExifTool::Nikon::ShotInfoD40 = (
6091             PROCESS_PROC => \&ProcessNikonEncrypted,
6092             WRITE_PROC => \&ProcessNikonEncrypted,
6093             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6094             VARS => { ID_LABEL => 'Index' },
6095             IS_SUBDIR => [ 729 ],
6096             WRITABLE => 1,
6097             FIRST_ENTRY => 0,
6098             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6099             NOTES => 'These tags are extracted from encrypted data in D40 and D40X images.',
6100             0x00 => {
6101             Name => 'ShotInfoVersion',
6102             Format => 'string[4]',
6103             Writable => 0,
6104             },
6105             582 => {
6106             Name => 'ShutterCount',
6107             Format => 'int32u',
6108             Priority => 0,
6109             },
6110             586.1 => { #JD
6111             Name => 'VibrationReduction',
6112             Mask => 0x08,
6113             PrintConv => { 0 => 'Off', 1 => 'On' },
6114             },
6115             729 => { #JD
6116             Name => 'CustomSettingsD40',
6117             Format => 'undef[12]',
6118             SubDirectory => {
6119             TagTable => 'Image::ExifTool::NikonCustom::SettingsD40',
6120             },
6121             },
6122             );
6123              
6124             # shot information for D80 (encrypted) - ref JD
6125             %Image::ExifTool::Nikon::ShotInfoD80 = (
6126             PROCESS_PROC => \&ProcessNikonEncrypted,
6127             WRITE_PROC => \&ProcessNikonEncrypted,
6128             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6129             VARS => { ID_LABEL => 'Index' },
6130             IS_SUBDIR => [ 748 ],
6131             WRITABLE => 1,
6132             FIRST_ENTRY => 0,
6133             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6134             NOTES => 'These tags are extracted from encrypted data in D80 images.',
6135             0x00 => {
6136             Name => 'ShotInfoVersion',
6137             Format => 'string[4]',
6138             Writable => 0,
6139             },
6140             586 => {
6141             Name => 'ShutterCount',
6142             Format => 'int32u',
6143             Priority => 0,
6144             },
6145             # split 590 into a few different tags
6146             590.1 => {
6147             Name => 'Rotation',
6148             Mask => 0x07,
6149             PrintConv => {
6150             0 => 'Horizontal',
6151             1 => 'Rotate 270 CW',
6152             2 => 'Rotate 90 CW',
6153             3 => 'Rotate 180',
6154             },
6155             },
6156             590.2 => {
6157             Name => 'VibrationReduction',
6158             Mask => 0x18,
6159             PrintConv => {
6160             0 => 'Off',
6161             3 => 'On',
6162             },
6163             },
6164             590.3 => {
6165             Name => 'FlashFired',
6166             Mask => 0xe0,
6167             PrintConv => { BITMASK => {
6168             1 => 'Internal',
6169             2 => 'External',
6170             }},
6171             },
6172             708 => {
6173             Name => 'NikonImageSize',
6174             Mask => 0xf0,
6175             PrintConv => {
6176             0 => 'Large (10.0 M)',
6177             1 => 'Medium (5.6 M)',
6178             2 => 'Small (2.5 M)',
6179             },
6180             },
6181             708.1 => {
6182             Name => 'ImageQuality',
6183             Mask => 0x0f,
6184             PrintConv => {
6185             0 => 'NEF (RAW)',
6186             1 => 'JPEG Fine',
6187             2 => 'JPEG Normal',
6188             3 => 'JPEG Basic',
6189             4 => 'NEF (RAW) + JPEG Fine',
6190             5 => 'NEF (RAW) + JPEG Normal',
6191             6 => 'NEF (RAW) + JPEG Basic',
6192             },
6193             },
6194             748 => { #JD
6195             Name => 'CustomSettingsD80',
6196             Format => 'undef[17]',
6197             SubDirectory => {
6198             TagTable => 'Image::ExifTool::NikonCustom::SettingsD80',
6199             },
6200             },
6201             );
6202              
6203             # shot information for D90 (encrypted) - ref PH
6204             %Image::ExifTool::Nikon::ShotInfoD90 = (
6205             PROCESS_PROC => \&ProcessNikonEncrypted,
6206             WRITE_PROC => \&ProcessNikonEncrypted,
6207             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6208             VARS => { ID_LABEL => 'Index' },
6209             IS_SUBDIR => [ 0x374 ],
6210             WRITABLE => 1,
6211             FIRST_ENTRY => 0,
6212             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6213             NOTES => q{
6214             These tags are extracted from encrypted data in images from the D90 with
6215             firmware 1.00.
6216             },
6217             0x00 => {
6218             Name => 'ShotInfoVersion',
6219             Format => 'string[4]',
6220             Writable => 0,
6221             },
6222             0x04 => {
6223             Name => 'FirmwareVersion',
6224             Format => 'string[5]',
6225             Writable => 0,
6226             },
6227             0x2b5 => { #JD (same value found at offset 0x39, 0x2bf, 0x346)
6228             Name => 'ISO2',
6229             ValueConv => '100*exp(($val/12-5)*log(2))',
6230             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6231             PrintConv => 'int($val + 0.5)',
6232             PrintConvInv => '$val',
6233             },
6234             0x2d5 => {
6235             Name => 'ShutterCount',
6236             Format => 'int32u',
6237             Priority => 0,
6238             },
6239             0x374 => {
6240             Name => 'CustomSettingsD90',
6241             Format => 'undef[36]',
6242             SubDirectory => {
6243             TagTable => 'Image::ExifTool::NikonCustom::SettingsD90',
6244             },
6245             },
6246             );
6247              
6248             # shot information for the D3 firmware 0.37 and 1.00 (encrypted) - ref PH
6249             %Image::ExifTool::Nikon::ShotInfoD3a = (
6250             PROCESS_PROC => \&ProcessNikonEncrypted,
6251             WRITE_PROC => \&ProcessNikonEncrypted,
6252             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6253             VARS => { ID_LABEL => 'Index' },
6254             IS_SUBDIR => [ 0x301 ],
6255             WRITABLE => 1,
6256             FIRST_ENTRY => 0,
6257             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6258             NOTES => q{
6259             These tags are extracted from encrypted data in images from the D3 with
6260             firmware 1.00 and earlier.
6261             },
6262             0x00 => {
6263             Name => 'ShotInfoVersion',
6264             Format => 'string[4]',
6265             Writable => 0,
6266             },
6267             0x256 => { #JD (same value found at offset 0x26b)
6268             Name => 'ISO2',
6269             ValueConv => '100*exp(($val/12-5)*log(2))',
6270             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6271             PrintConv => 'int($val + 0.5)',
6272             PrintConvInv => '$val',
6273             },
6274             0x276 => { #JD
6275             Name => 'ShutterCount',
6276             Format => 'int32u',
6277             Priority => 0,
6278             },
6279             723.1 => {
6280             Name => 'NikonImageSize',
6281             Mask => 0x18,
6282             PrintConv => {
6283             0 => 'Large',
6284             1 => 'Medium',
6285             2 => 'Small',
6286             },
6287             },
6288             723.2 => {
6289             Name => 'ImageQuality',
6290             Mask => 0x07,
6291             PrintConv => {
6292             0 => 'NEF (RAW) + JPEG Fine',
6293             1 => 'NEF (RAW) + JPEG Norm',
6294             2 => 'NEF (RAW) + JPEG Basic',
6295             3 => 'NEF (RAW)',
6296             4 => 'TIF (RGB)',
6297             5 => 'JPEG Fine',
6298             6 => 'JPEG Normal',
6299             7 => 'JPEG Basic',
6300             },
6301             },
6302             0x301 => { #(NC)
6303             Name => 'CustomSettingsD3',
6304             Format => 'undef[24]',
6305             SubDirectory => {
6306             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
6307             },
6308             },
6309             );
6310              
6311             # shot information for the D3 firmware 1.10, 2.00 and 2.01 (encrypted) - ref PH
6312             %Image::ExifTool::Nikon::ShotInfoD3b = (
6313             PROCESS_PROC => \&ProcessNikonEncrypted,
6314             WRITE_PROC => \&ProcessNikonEncrypted,
6315             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6316             VARS => { ID_LABEL => 'Index' },
6317             IS_SUBDIR => [ 0x30a ],
6318             WRITABLE => 1,
6319             FIRST_ENTRY => 0,
6320             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6321             DATAMEMBER => [ 4 ],
6322             NOTES => q{
6323             These tags are extracted from encrypted data in images from the D3 with
6324             firmware 1.10, 2.00, 2.01 and 2.02.
6325             },
6326             0x00 => {
6327             Name => 'ShotInfoVersion',
6328             Format => 'string[4]',
6329             Writable => 0,
6330             },
6331             0x04 => {
6332             Name => 'FirmwareVersion',
6333             Format => 'string[5]',
6334             Writable => 0,
6335             RawConv => '$$self{FirmwareVersion} = $val',
6336             },
6337             0x10 => { #28
6338             Name => 'ImageArea',
6339             PrintConv => {
6340             0 => 'FX (36x24)',
6341             1 => 'DX (24x16)',
6342             2 => '5:4 (30x24)',
6343             },
6344             },
6345             0x25d => {
6346             Name => 'ISO2',
6347             ValueConv => '100*exp(($val/12-5)*log(2))',
6348             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6349             PrintConv => 'int($val + 0.5)',
6350             PrintConvInv => '$val',
6351             },
6352             0x27d => {
6353             Name => 'ShutterCount',
6354             Condition => '$$self{FirmwareVersion} =~ /^1\.01/',
6355             Notes => 'firmware 1.10',
6356             Format => 'int32u',
6357             Priority => 0,
6358             },
6359             0x27f => {
6360             Name => 'ShutterCount',
6361             Condition => '$$self{FirmwareVersion} =~ /^2\.0/',
6362             Notes => 'firmware 2.00, 2.01 and 2.02',
6363             Format => 'int32u',
6364             Priority => 0,
6365             },
6366             732.1 => { #28
6367             Name => 'NikonImageSize',
6368             Mask => 0x18,
6369             PrintConv => {
6370             0 => 'Large',
6371             1 => 'Medium',
6372             2 => 'Small',
6373             },
6374             },
6375             732.2 => { #28
6376             Name => 'ImageQuality',
6377             Mask => 0x07,
6378             PrintConv => {
6379             0 => 'NEF (RAW) + JPEG Fine',
6380             1 => 'NEF (RAW) + JPEG Norm',
6381             2 => 'NEF (RAW) + JPEG Basic',
6382             3 => 'NEF (RAW)',
6383             4 => 'TIF (RGB)',
6384             5 => 'JPEG Fine',
6385             6 => 'JPEG Normal',
6386             7 => 'JPEG Basic',
6387             },
6388             },
6389             0x28a => { #28
6390             Name => 'PreFlashReturnStrength',
6391             Notes => 'valid in TTL and TTL-BL flash control modes',
6392             # this is used to set the flash power using this relationship
6393             # for the SB-800 and SB-900:
6394             # $val < 140 ? 2**(0.08372*$val-12.352) : $val
6395             },
6396             0x30a => { # tested with firmware 2.00
6397             Name => 'CustomSettingsD3',
6398             Format => 'undef[24]',
6399             SubDirectory => {
6400             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
6401             },
6402             },
6403             );
6404              
6405             # shot information for the D3X firmware 1.00 (encrypted) - ref PH
6406             %Image::ExifTool::Nikon::ShotInfoD3X = (
6407             PROCESS_PROC => \&ProcessNikonEncrypted,
6408             WRITE_PROC => \&ProcessNikonEncrypted,
6409             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6410             VARS => { ID_LABEL => 'Index' },
6411             IS_SUBDIR => [ 0x30b ],
6412             WRITABLE => 1,
6413             FIRST_ENTRY => 0,
6414             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6415             NOTES => q{
6416             These tags are extracted from encrypted data in images from the D3X with
6417             firmware 1.00.
6418             },
6419             0x00 => {
6420             Name => 'ShotInfoVersion',
6421             Format => 'string[4]',
6422             Writable => 0,
6423             },
6424             0x04 => {
6425             Name => 'FirmwareVersion',
6426             Format => 'string[5]',
6427             Writable => 0,
6428             },
6429             0x25d => {
6430             Name => 'ISO2',
6431             ValueConv => '100*exp(($val/12-5)*log(2))',
6432             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6433             PrintConv => 'int($val + 0.5)',
6434             PrintConvInv => '$val',
6435             },
6436             0x280 => {
6437             Name => 'ShutterCount',
6438             Format => 'int32u',
6439             Priority => 0,
6440             },
6441             0x30b => { #(NC)
6442             Name => 'CustomSettingsD3X',
6443             Format => 'undef[24]',
6444             SubDirectory => {
6445             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
6446             },
6447             },
6448             );
6449              
6450             # shot information for the D3S firmware 0.16 and 1.00 (encrypted) - ref PH
6451             %Image::ExifTool::Nikon::ShotInfoD3S = (
6452             PROCESS_PROC => \&ProcessNikonEncrypted,
6453             WRITE_PROC => \&ProcessNikonEncrypted,
6454             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6455             VARS => { ID_LABEL => 'Index' },
6456             IS_SUBDIR => [ 0x2ce ],
6457             WRITABLE => 1,
6458             FIRST_ENTRY => 0,
6459             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6460             NOTES => q{
6461             These tags are extracted from encrypted data in images from the D3S with
6462             firmware 1.00 and earlier.
6463             },
6464             0x00 => {
6465             Name => 'ShotInfoVersion',
6466             Format => 'string[4]',
6467             Writable => 0,
6468             },
6469             0x04 => {
6470             Name => 'FirmwareVersion',
6471             Format => 'string[5]',
6472             Writable => 0,
6473             },
6474             0x10 => { #28
6475             Name => 'ImageArea',
6476             PrintConv => {
6477             0 => 'FX (36x24)',
6478             1 => 'DX (24x16)',
6479             2 => '5:4 (30x24)',
6480             3 => '1.2x (30x20)',
6481             },
6482             },
6483             0x221 => {
6484             Name => 'ISO2',
6485             ValueConv => '100*exp(($val/12-5)*log(2))',
6486             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6487             PrintConv => 'int($val + 0.5)',
6488             PrintConvInv => '$val',
6489             },
6490             0x242 => {
6491             Name => 'ShutterCount',
6492             Format => 'int32u',
6493             Priority => 0,
6494             },
6495             671.1 => { # 0x29f
6496             Name => 'JPGCompression',
6497             Mask => 0x40,
6498             PrintConv => {
6499             0 => 'Size Priority',
6500             1 => 'Optimal Quality',
6501             },
6502             },
6503             # this works for one set of D3S samples, but is 0 in some others
6504             #671.2 => { # 0x29f
6505             # Name => 'Quality',
6506             # Mask => 0x03,
6507             # PrintConv => {
6508             # 1 => 'Fine',
6509             # 2 => 'Normal',
6510             # 3 => 'Basic',
6511             # },
6512             #},
6513             0x2ce => { #(NC)
6514             Name => 'CustomSettingsD3S',
6515             Format => 'undef[27]',
6516             SubDirectory => {
6517             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
6518             },
6519             },
6520             );
6521              
6522             # shot information for the D300 firmware 1.00 (encrypted) - ref JD
6523             %Image::ExifTool::Nikon::ShotInfoD300a = (
6524             PROCESS_PROC => \&ProcessNikonEncrypted,
6525             WRITE_PROC => \&ProcessNikonEncrypted,
6526             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6527             VARS => { ID_LABEL => 'Index' },
6528             IS_SUBDIR => [ 790 ],
6529             WRITABLE => 1,
6530             FIRST_ENTRY => 0,
6531             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6532             NOTES => q{
6533             These tags are extracted from encrypted data in images from the D300 with
6534             firmware 1.00 and earlier.
6535             },
6536             0x00 => {
6537             Name => 'ShotInfoVersion',
6538             Format => 'string[4]',
6539             Writable => 0,
6540             },
6541             604 => {
6542             Name => 'ISO2',
6543             ValueConv => '100*exp(($val/12-5)*log(2))',
6544             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6545             PrintConv => 'int($val + 0.5)',
6546             PrintConvInv => '$val',
6547             },
6548             633 => {
6549             Name => 'ShutterCount',
6550             Format => 'int32u',
6551             Priority => 0,
6552             },
6553             721 => { #PH
6554             Name => 'AFFineTuneAdj',
6555             Format => 'int16u',
6556             PrintHex => 1,
6557             PrintConvColumns => 3,
6558             # thanks to Neil Nappe for the samples to decode this!...
6559             # (have seen various unknown values here when flash is enabled, but
6560             # these are yet to be decoded: 0x2e,0x619,0xd0d,0x103a,0x2029 - PH)
6561             PrintConv => {
6562             0x403e => '+20',
6563             0x303e => '+19',
6564             0x203e => '+18',
6565             0x103e => '+17',
6566             0x003e => '+16',
6567             0xe03d => '+15',
6568             0xc03d => '+14',
6569             0xa03d => '+13',
6570             0x803d => '+12',
6571             0x603d => '+11',
6572             0x403d => '+10',
6573             0x203d => '+9',
6574             0x003d => '+8',
6575             0xc03c => '+7',
6576             0x803c => '+6',
6577             0x403c => '+5',
6578             0x003c => '+4',
6579             0x803b => '+3',
6580             0x003b => '+2',
6581             0x003a => '+1',
6582             0x0000 => '0',
6583             0x00c6 => '-1',
6584             0x00c5 => '-2',
6585             0x80c5 => '-3',
6586             0x00c4 => '-4',
6587             0x40c4 => '-5',
6588             0x80c4 => '-6',
6589             0xc0c4 => '-7',
6590             0x00c3 => '-8',
6591             0x20c3 => '-9',
6592             0x40c3 => '-10',
6593             0x60c3 => '-11',
6594             0x80c3 => '-12',
6595             0xa0c3 => '-13',
6596             0xc0c3 => '-14',
6597             0xe0c3 => '-15',
6598             0x00c2 => '-16',
6599             0x10c2 => '-17',
6600             0x20c2 => '-18',
6601             0x30c2 => '-19',
6602             0x40c2 => '-20',
6603             },
6604             },
6605             790 => {
6606             Name => 'CustomSettingsD300',
6607             Format => 'undef[24]',
6608             SubDirectory => {
6609             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
6610             },
6611             },
6612             );
6613              
6614             # shot information for the D300 firmware 1.10 (encrypted) - ref PH
6615             %Image::ExifTool::Nikon::ShotInfoD300b = (
6616             PROCESS_PROC => \&ProcessNikonEncrypted,
6617             WRITE_PROC => \&ProcessNikonEncrypted,
6618             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6619             VARS => { ID_LABEL => 'Index' },
6620             DATAMEMBER => [ 4 ],
6621             IS_SUBDIR => [ 802 ],
6622             WRITABLE => 1,
6623             FIRST_ENTRY => 0,
6624             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6625             NOTES => q{
6626             These tags are extracted from encrypted data in images from the D300 with
6627             firmware 1.10.
6628             },
6629             0x00 => {
6630             Name => 'ShotInfoVersion',
6631             Format => 'string[4]',
6632             Writable => 0,
6633             },
6634             0x04 => { #PH
6635             Name => 'FirmwareVersion',
6636             DataMember => 'FirmwareVersion',
6637             Format => 'string[5]',
6638             Writable => 0,
6639             RawConv => '$$self{FirmwareVersion} = $val',
6640             },
6641             613 => {
6642             Name => 'ISO2',
6643             ValueConv => '100*exp(($val/12-5)*log(2))',
6644             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6645             PrintConv => 'int($val + 0.5)',
6646             PrintConvInv => '$val',
6647             },
6648             644 => {
6649             Name => 'ShutterCount',
6650             Format => 'int32u',
6651             Priority => 0,
6652             },
6653             732 => [{
6654             Name => 'AFFineTuneAdj',
6655             Condition => '$$self{FirmwareVersion} eq "1.10B"',
6656             Notes => 'firmware version 1.10B',
6657             Format => 'int16u',
6658             PrintHex => 1,
6659             PrintConvColumns => 3,
6660             # thanks to Michael Tapes for the samples to decode this!...
6661             PrintConv => {
6662             0xe03e => '+20',
6663             0xc83e => '+19',
6664             0xb03e => '+18',
6665             0x983e => '+17',
6666             0x803e => '+16',
6667             0x683e => '+15',
6668             0x503e => '+14',
6669             0x383e => '+13',
6670             0x203e => '+12',
6671             0x083e => '+11',
6672             0xe03d => '+10',
6673             0xb03d => '+9',
6674             0x803d => '+8',
6675             0x503d => '+7',
6676             0x203d => '+6',
6677             0xe03c => '+5',
6678             0x803c => '+4',
6679             0x203c => '+3',
6680             0x803b => '+2',
6681             0x803a => '+1',
6682             0x0000 => '0',
6683             0x80c6 => '-1',
6684             0x80c5 => '-2',
6685             0x20c4 => '-3',
6686             0x80c4 => '-4',
6687             0xe0c4 => '-5',
6688             0x20c3 => '-6',
6689             0x50c3 => '-7',
6690             0x80c3 => '-8',
6691             0xb0c3 => '-9',
6692             0xe0c3 => '-10',
6693             0x08c2 => '-11',
6694             0x20c2 => '-12',
6695             0x38c2 => '-13',
6696             0x50c2 => '-14',
6697             0x68c2 => '-15',
6698             0x80c2 => '-16',
6699             0x98c2 => '-17',
6700             0xb0c2 => '-18',
6701             0xc8c2 => '-19',
6702             0xe0c2 => '-20',
6703             },
6704             },{
6705             Name => 'AFFineTuneAdj',
6706             Notes => 'other versions',
6707             Format => 'int16u',
6708             PrintHex => 1,
6709             PrintConvColumns => 3,
6710             # thanks to Stuart Solomon for the samples to decode this!...
6711             PrintConv => {
6712             0x903e => '+20',
6713             0x7c3e => '+19',
6714             0x683e => '+18',
6715             0x543e => '+17',
6716             0x403e => '+16',
6717             0x2c3e => '+15',
6718             0x183e => '+14',
6719             0x043e => '+13',
6720             0xe03d => '+12',
6721             0xb83d => '+11',
6722             0x903d => '+10',
6723             0x683d => '+9',
6724             0x403d => '+8',
6725             0x183d => '+7',
6726             0xe03c => '+6',
6727             0x903c => '+5',
6728             0x403c => '+4',
6729             0xe03b => '+3',
6730             0x403b => '+2',
6731             0x403a => '+1',
6732             0x0000 => '0',
6733             0x40c6 => '-1',
6734             0x40c5 => '-2',
6735             0xe0c5 => '-3',
6736             0x40c4 => '-4',
6737             0x90c4 => '-5',
6738             0xe0c4 => '-6',
6739             0x18c3 => '-7',
6740             0x40c3 => '-8',
6741             0x68c3 => '-9',
6742             0x90c3 => '-10',
6743             0xb8c3 => '-11',
6744             0xe0c3 => '-12',
6745             0x04c2 => '-13',
6746             0x18c2 => '-14',
6747             0x2cc2 => '-15',
6748             0x40c2 => '-16',
6749             0x54c2 => '-17',
6750             0x68c2 => '-18',
6751             0x7cc2 => '-19',
6752             0x90c2 => '-20',
6753             },
6754             }],
6755             802 => {
6756             Name => 'CustomSettingsD300',
6757             Format => 'undef[24]',
6758             SubDirectory => {
6759             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
6760             },
6761             },
6762             );
6763              
6764             # shot information for the D300S firmware 1.00 (encrypted) - ref PH
6765             %Image::ExifTool::Nikon::ShotInfoD300S = (
6766             PROCESS_PROC => \&ProcessNikonEncrypted,
6767             WRITE_PROC => \&ProcessNikonEncrypted,
6768             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6769             VARS => { ID_LABEL => 'Index' },
6770             IS_SUBDIR => [ 804 ],
6771             WRITABLE => 1,
6772             FIRST_ENTRY => 0,
6773             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6774             NOTES => q{
6775             These tags are extracted from encrypted data in images from the D300S with
6776             firmware 1.00.
6777             },
6778             0x00 => {
6779             Name => 'ShotInfoVersion',
6780             Format => 'string[4]',
6781             Writable => 0,
6782             },
6783             0x04 => {
6784             Name => 'FirmwareVersion',
6785             Format => 'string[5]',
6786             Writable => 0,
6787             },
6788             613 => {
6789             Name => 'ISO2',
6790             ValueConv => '100*exp(($val/12-5)*log(2))',
6791             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6792             PrintConv => 'int($val + 0.5)',
6793             PrintConvInv => '$val',
6794             },
6795             646 => {
6796             Name => 'ShutterCount',
6797             Format => 'int32u',
6798             Priority => 0,
6799             },
6800             804 => { #(NC)
6801             Name => 'CustomSettingsD300S',
6802             Format => 'undef[24]',
6803             SubDirectory => {
6804             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
6805             },
6806             },
6807             );
6808              
6809             # shot information for the D700 firmware 1.02f (encrypted) - ref 29
6810             %Image::ExifTool::Nikon::ShotInfoD700 = (
6811             PROCESS_PROC => \&ProcessNikonEncrypted,
6812             WRITE_PROC => \&ProcessNikonEncrypted,
6813             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6814             VARS => { ID_LABEL => 'Index' },
6815             IS_SUBDIR => [ 804 ],
6816             WRITABLE => 1,
6817             FIRST_ENTRY => 0,
6818             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6819             NOTES => q{
6820             These tags are extracted from encrypted data in images from the D700 with
6821             firmware 1.02f.
6822             },
6823             0x00 => {
6824             Name => 'ShotInfoVersion',
6825             Format => 'string[4]',
6826             Writable => 0,
6827             },
6828             0x04 => {
6829             Name => 'FirmwareVersion',
6830             Format => 'string[5]',
6831             Writable => 0,
6832             },
6833             613 => { # 0x265
6834             Name => 'ISO2',
6835             ValueConv => '100*exp(($val/12-5)*log(2))',
6836             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6837             PrintConv => 'int($val + 0.5)',
6838             PrintConvInv => '$val',
6839             },
6840             0x287 => {
6841             Name => 'ShutterCount',
6842             Format => 'int32u',
6843             Priority => 0,
6844             },
6845             804 => { # 0x324 (NC)
6846             Name => 'CustomSettingsD700',
6847             Format => 'undef[48]',
6848             SubDirectory => {
6849             TagTable => 'Image::ExifTool::NikonCustom::SettingsD700',
6850             },
6851             },
6852             );
6853              
6854             # shot information for the D780 - ref #28
6855             %Image::ExifTool::Nikon::ShotInfoD780 = (
6856             PROCESS_PROC => \&ProcessNikonEncrypted,
6857             WRITE_PROC => \&ProcessNikonEncrypted,
6858             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6859             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x24 },
6860             DATAMEMBER => [ 0x04 ],
6861             IS_SUBDIR => [ 0x9c ],
6862             WRITABLE => 1,
6863             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6864             NOTES => 'These tags are extracted from encrypted data in images from the D780.',
6865             0x00 => {
6866             Name => 'ShotInfoVersion',
6867             Format => 'string[4]',
6868             Writable => 0,
6869             },
6870             0x04 => {
6871             Name => 'FirmwareVersion',
6872             DataMember => 'FirmwareVersion',
6873             Format => 'string[5]',
6874             Writable => 0,
6875             RawConv => '$$self{FirmwareVersion} = $val',
6876             },
6877             0x9c => {
6878             Name => 'OrientOffset',
6879             Format => 'int32u',
6880             SubDirectory => {
6881             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
6882             Start => '$val',
6883             },
6884             },
6885             );
6886              
6887             # shot information for the D5000 firmware 1.00 (encrypted) - ref PH
6888             %Image::ExifTool::Nikon::ShotInfoD5000 = (
6889             PROCESS_PROC => \&ProcessNikonEncrypted,
6890             WRITE_PROC => \&ProcessNikonEncrypted,
6891             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6892             VARS => { ID_LABEL => 'Index' },
6893             IS_SUBDIR => [ 0x378 ],
6894             WRITABLE => 1,
6895             FIRST_ENTRY => 0,
6896             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6897             NOTES => q{
6898             These tags are extracted from encrypted data in images from the D5000 with
6899             firmware 1.00.
6900             },
6901             0x00 => {
6902             Name => 'ShotInfoVersion',
6903             Format => 'string[4]',
6904             Writable => 0,
6905             },
6906             0x04 => {
6907             Name => 'FirmwareVersion',
6908             Format => 'string[5]',
6909             Writable => 0,
6910             },
6911             0x2b5 => { # (also found at 0x2c0)
6912             Name => 'ISO2',
6913             ValueConv => '100*exp(($val/12-5)*log(2))',
6914             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6915             PrintConv => 'int($val + 0.5)',
6916             PrintConvInv => '$val',
6917             },
6918             0x2d6 => {
6919             Name => 'ShutterCount',
6920             Format => 'int32u',
6921             Priority => 0,
6922             },
6923             0x378 => {
6924             Name => 'CustomSettingsD5000',
6925             Format => 'undef[34]',
6926             SubDirectory => {
6927             TagTable => 'Image::ExifTool::NikonCustom::SettingsD5000',
6928             },
6929             },
6930             );
6931              
6932             # shot information for the D5100 firmware 1.00f (encrypted) - ref PH
6933             %Image::ExifTool::Nikon::ShotInfoD5100 = (
6934             PROCESS_PROC => \&ProcessNikonEncrypted,
6935             WRITE_PROC => \&ProcessNikonEncrypted,
6936             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6937             VARS => { ID_LABEL => 'Index' },
6938             IS_SUBDIR => [ 0x407 ],
6939             WRITABLE => 1,
6940             FIRST_ENTRY => 0,
6941             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6942             0x00 => {
6943             Name => 'ShotInfoVersion',
6944             Format => 'string[4]',
6945             Writable => 0,
6946             },
6947             0x04 => {
6948             Name => 'FirmwareVersion',
6949             Format => 'string[5]',
6950             Writable => 0,
6951             },
6952             0x321 => {
6953             Name => 'ShutterCount',
6954             Format => 'int32u',
6955             Priority => 0,
6956             },
6957             0x407 => {
6958             Name => 'CustomSettingsD5100',
6959             Format => 'undef[34]',
6960             SubDirectory => {
6961             TagTable => 'Image::ExifTool::NikonCustom::SettingsD5100',
6962             },
6963             },
6964             );
6965              
6966             # shot information for the D5200 firmware 1.00 (encrypted) - ref PH
6967             %Image::ExifTool::Nikon::ShotInfoD5200 = (
6968             PROCESS_PROC => \&ProcessNikonEncrypted,
6969             WRITE_PROC => \&ProcessNikonEncrypted,
6970             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6971             VARS => { ID_LABEL => 'Index' },
6972             IS_SUBDIR => [ 0xcd5 ],
6973             WRITABLE => 1,
6974             FIRST_ENTRY => 0,
6975             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6976             0x00 => {
6977             Name => 'ShotInfoVersion',
6978             Format => 'string[4]',
6979             Writable => 0,
6980             },
6981             0x04 => {
6982             Name => 'FirmwareVersion',
6983             Format => 'string[5]',
6984             Writable => 0,
6985             },
6986             # 0x101 - 2=VR Off, 3=VR On
6987             # 0x13d - 0=VR On, 1=VR Off
6988             0xbd8 => {
6989             Name => 'ShutterCount',
6990             Format => 'int32u',
6991             Priority => 0,
6992             },
6993             # 0xcd2 - 12=VR Off, 15=VR On
6994             0xcd5 => {
6995             Name => 'CustomSettingsD5200',
6996             Format => 'undef[34]',
6997             SubDirectory => {
6998             TagTable => 'Image::ExifTool::NikonCustom::SettingsD5200',
6999             },
7000             },
7001             );
7002              
7003             # shot information for the D7000 firmware 1.01d (encrypted) - ref 29
7004             %Image::ExifTool::Nikon::ShotInfoD7000 = (
7005             PROCESS_PROC => \&ProcessNikonEncrypted,
7006             WRITE_PROC => \&ProcessNikonEncrypted,
7007             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7008             VARS => { ID_LABEL => 'Index' },
7009             IS_SUBDIR => [ 1028 ],
7010             WRITABLE => 1,
7011             FIRST_ENTRY => 0,
7012             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7013             NOTES => q{
7014             These tags are extracted from encrypted data in images from the D7000 with
7015             firmware 1.01b.
7016             },
7017             0x00 => {
7018             Name => 'ShotInfoVersion',
7019             Format => 'string[4]',
7020             Writable => 0,
7021             },
7022             0x04 => {
7023             Name => 'FirmwareVersion',
7024             Format => 'string[5]',
7025             Writable => 0,
7026             },
7027             #613 => {
7028             # Name => 'ISO2',
7029             # ValueConv => '100*exp(($val/12-5)*log(2))',
7030             # ValueConvInv => '(log($val/100)/log(2)+5)*12',
7031             # PrintConv => 'int($val + 0.5)',
7032             # PrintConvInv => '$val',
7033             #},
7034             0x320 => { # 800
7035             Name => 'ShutterCount',
7036             Format => 'int32u',
7037             Priority => 0,
7038             },
7039             0x404 => { # 1028 (NC)
7040             Name => 'CustomSettingsD7000',
7041             Format => 'undef[48]',
7042             SubDirectory => {
7043             TagTable => 'Image::ExifTool::NikonCustom::SettingsD7000',
7044             },
7045             },
7046             );
7047              
7048             # shot information for the D7500 - ref #28
7049             %Image::ExifTool::Nikon::ShotInfoD7500 = (
7050             PROCESS_PROC => \&ProcessNikonEncrypted,
7051             WRITE_PROC => \&ProcessNikonEncrypted,
7052             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7053             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x0c },
7054             DATAMEMBER => [ 0x04 ],
7055             IS_SUBDIR => [ 0xa0 ],
7056             WRITABLE => 1,
7057             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7058             NOTES => 'These tags are extracted from encrypted data in images from the D7500.',
7059             0x00 => {
7060             Name => 'ShotInfoVersion',
7061             Format => 'string[4]',
7062             Writable => 0,
7063             },
7064             0x04 => {
7065             Name => 'FirmwareVersion',
7066             DataMember => 'FirmwareVersion',
7067             Format => 'string[5]',
7068             Writable => 0,
7069             RawConv => '$$self{FirmwareVersion} = $val',
7070             },
7071             0xa0 => {
7072             Name => 'OrientOffset',
7073             Format => 'int32u',
7074             SubDirectory => {
7075             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
7076             Start => '$val',
7077             },
7078             },
7079             );
7080              
7081             # shot information for the D800 firmware 1.01a (encrypted) - ref PH
7082             %Image::ExifTool::Nikon::ShotInfoD800 = (
7083             PROCESS_PROC => \&ProcessNikonEncrypted,
7084             WRITE_PROC => \&ProcessNikonEncrypted,
7085             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7086             VARS => { ID_LABEL => 'Index' },
7087             IS_SUBDIR => [ 0x6ec ],
7088             WRITABLE => 1,
7089             FIRST_ENTRY => 0,
7090             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7091             NOTES => 'These tags are extracted from encrypted data in images from the D800.',
7092             0x00 => {
7093             Name => 'ShotInfoVersion',
7094             Format => 'string[4]',
7095             Writable => 0,
7096             },
7097             0x04 => {
7098             Name => 'FirmwareVersion',
7099             Format => 'string[5]',
7100             Writable => 0,
7101             },
7102             0x4c0 => {
7103             Name => 'RepeatingFlashOutputExternal',
7104             ValueConv => '2 ** (-$val/6)',
7105             ValueConvInv => '$val > 0 ? -6*log($val)/log(2) : 0',
7106             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
7107             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
7108             },
7109             0x4c2 => {
7110             Name => 'RepeatingFlashRateExternal',
7111             DelValue => 0,
7112             RawConv => '$val || undef',
7113             PrintConv => '"$val Hz"',
7114             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
7115             },
7116             0x4c3 => {
7117             Name => 'RepeatingFlashCountExternal',
7118             DelValue => 0,
7119             RawConv => '$val || undef',
7120             },
7121             0x4d2 => {
7122             Name => 'FlashExposureComp2',
7123             Notes => 'includes the effect of flash bracketing',
7124             Format => 'int8s',
7125             ValueConv => '-$val/6',
7126             ValueConvInv => '-6 * $val',
7127             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
7128             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
7129             },
7130             # 0x4d4 - FEC again, doesn't include bracketing this time (internal?)
7131             # (not fully decoded, and duplicated in custom settings)
7132             # 0x4d9 => {
7133             # Name => 'FlashControlBuilt-in',
7134             # PrintConv => {
7135             # 1 => 'TTL',
7136             # 6 => 'Manual',
7137             # 7 => 'Repeating Flash',
7138             # },
7139             # },
7140             0x4da => {
7141             Name => 'RepeatingFlashRateBuilt-in',
7142             DelValue => 0,
7143             RawConv => '$val || undef',
7144             PrintConv => '"$val Hz"',
7145             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
7146             },
7147             0x4db => {
7148             Name => 'RepeatingFlashCountBuilt-in',
7149             DelValue => 0,
7150             RawConv => '$val || undef',
7151             },
7152             # 1294.1 => { # (0x4dc)
7153             # Name => 'FlashModeBuilt-in',
7154             # Mask => 0x0f,
7155             # PrintConv => {
7156             # 0 => 'Front-curtain Sync',
7157             # 1 => 'Red-eye Reduction',
7158             # 2 => 'Redy-eye Reduction with Slow Sync',
7159             # 3 => 'Slow Sync',
7160             # 4 => 'Rear-curtain Sync',
7161             # 5 => 'Rear-curtain Sync 2', # got this in P exposure mode
7162             # },
7163             # },
7164             # 1294.2 => { # (0x4dc)
7165             # Name => 'ExposureMode2',
7166             # Mask => 0xf0,
7167             # PrintConv => {
7168             # 0 => 'Program',
7169             # 1 => 'Aperture Priority',
7170             # 3 => 'Manual',
7171             # },
7172             # },
7173             # 0x511 - related to FlashSyncSpeed
7174             0x51c => 'SequenceNumber',
7175             # 0x4ba+0x63 - interesting
7176             # 0x4ba+0x68 - general downward trend
7177             # 0x4ba+0x7b - FlashControlBuilt-in: 8=TTL, 72=Manual
7178             # (not reliable)
7179             # 1346.1 => { # (0x542)
7180             # Name => 'RepeatingFlashOutputBuilt-in',
7181             # DelValue => 112,
7182             # Mask => 0xfc,
7183             # RawConv => '$val == 0x1c ? undef : 2 ** ($val/3-7)',
7184             # ValueConvInv => '$val > 0 ? (log($val)/log(2)+7)*3 : 0',
7185             # PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
7186             # PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
7187             # },
7188             0x5fb => {
7189             Name => 'ShutterCount',
7190             Format => 'int32u',
7191             },
7192             0x6ec => {
7193             Name => 'CustomSettingsD800',
7194             Format => 'undef[48]',
7195             SubDirectory => {
7196             TagTable => 'Image::ExifTool::NikonCustom::SettingsD800',
7197             },
7198             },
7199             );
7200              
7201             # shot information for the D5 firmware 1.10a and D500 firmware 1.01 (encrypted) - ref 28
7202             %Image::ExifTool::Nikon::ShotInfoD500 = (
7203             PROCESS_PROC => \&ProcessNikonEncrypted,
7204             WRITE_PROC => \&ProcessNikonEncrypted,
7205             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7206             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x0c },
7207             DATAMEMBER => [ 0x04 ],
7208             IS_SUBDIR => [ 0x10, 0x14, 0x2c, 0x50, 0x58, 0xa0, 0xa8 ],
7209             WRITABLE => 1,
7210             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7211             NOTES => 'These tags are extracted from encrypted data in images from the D5 and D500.',
7212             0x00 => {
7213             Name => 'ShotInfoVersion',
7214             Format => 'string[4]',
7215             Writable => 0,
7216             },
7217             0x04 => {
7218             Name => 'FirmwareVersion',
7219             DataMember => 'FirmwareVersion',
7220             Format => 'string[5]',
7221             Writable => 0,
7222             RawConv => '$$self{FirmwareVersion} = $val',
7223             },
7224             0x10 => {
7225             Name => 'RotationInfoOffset',
7226             Format => 'int32u',
7227             SubDirectory => {
7228             TagTable => 'Image::ExifTool::Nikon::RotationInfoD500',
7229             Start => '$val',
7230             }
7231             },
7232             0x14 => {
7233             Name => 'JPGInfoOffset',
7234             Format => 'int32u',
7235             SubDirectory => {
7236             TagTable => 'Image::ExifTool::Nikon::JPGInfoD500',
7237             Start => '$val',
7238             }
7239             },
7240             0x2c => {
7241             Name => 'BracketingOffset',
7242             Format => 'int32u',
7243             SubDirectory => {
7244             TagTable => 'Image::ExifTool::Nikon::BracketingInfoD500',
7245             Start => '$val',
7246             }
7247             },
7248             0x50 => {
7249             Name => 'ShootingMenuOffset',
7250             Format => 'int32u',
7251             SubDirectory => {
7252             TagTable => 'Image::ExifTool::Nikon::ShootingMenuD500',
7253             Start => '$val',
7254             }
7255             },
7256             0x58 => {
7257             Name => 'CustomSettingsOffset',
7258             Format => 'int32u',
7259             SubDirectory => {
7260             TagTable => 'Image::ExifTool::Nikon::CustomSettingsD500',
7261             Start => '$val',
7262             }
7263             },
7264             0xa0 => {
7265             Name => 'OrientationOffset',
7266             Format => 'int32u',
7267             SubDirectory => {
7268             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
7269             Start => '$val',
7270             }
7271             },
7272             0xa8 => {
7273             Name => 'OtherOffset',
7274             Format => 'int32u',
7275             SubDirectory => {
7276             TagTable => 'Image::ExifTool::Nikon::OtherInfoD500',
7277             Start => '$val',
7278             }
7279             },
7280             );
7281              
7282             %Image::ExifTool::Nikon::RotationInfoD500 = (
7283             %binaryDataAttrs,
7284             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7285             0x1a => {
7286             Name => 'Rotation',
7287             Mask => 0x03,
7288             PrintConv => {
7289             0 => 'Horizontal',
7290             1 => 'Rotate 270 CW',
7291             2 => 'Rotate 90 CW',
7292             3 => 'Rotate 180',
7293             },
7294             },
7295             0x20 => {
7296             Name => 'Interval',
7297             # prior version of the d% firmware do not support this tag, nor does the D500 (at least thru firmware 1.3)
7298             Condition => '$$self{Model} eq "NIKON D5" and $$self{FirmwareVersion} ge "1.40"',
7299             PrintConv => '$val > 0 ? sprintf("%.0f", $val) : ""',
7300             },
7301             0x24 => {
7302             Name => 'IntervalFrame',
7303             # prior version of the d% firmware do not support this tag, nor does the D500 (at least thru firmware 1.3)
7304             Condition => '$$self{Model} eq "NIKON D5" and $$self{FirmwareVersion} ge "1.40"',
7305             PrintConv => '$val > 0 ? sprintf("%.0f", $val) : ""',
7306             },
7307             0x0532 => {
7308             Name => 'FlickerReductionIndicator',
7309             Mask => 0x01,
7310             PrintConv => { 0 => 'On', 1 => 'Off' },
7311             },
7312             );
7313              
7314             %Image::ExifTool::Nikon::JPGInfoD500 = (
7315             %binaryDataAttrs,
7316             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7317             0x24 => {
7318             Name => 'JPGCompression',
7319             Mask => 0x01,
7320             PrintConv => {
7321             0 => 'Size Priority',
7322             1 => 'Optimal Quality',
7323             },
7324             },
7325             );
7326              
7327             %Image::ExifTool::Nikon::BracketingInfoD500 = (
7328             %binaryDataAttrs,
7329             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7330             0x0f => {
7331             Name => 'AEBracketingSteps',
7332             Condition => '$$self{FILE_TYPE} ne "TIFF"', # (covers NEF and TIFF)
7333             Mask => 0xff,
7334             PrintHex => 1,
7335             PrintConvColumns => 2,
7336             PrintConv => {
7337             0x00 => 'AE Bracketing Disabled',
7338             0x20 => 'AE Bracketing Disabled',
7339             0x30 => 'AE Bracketing Disabled',
7340             0x40 => 'AE Bracketing Disabled',
7341             0x50 => 'AE Bracketing Disabled',
7342             0x81 => '+3F0.3',
7343             0x82 => '-3F0.3',
7344             0x83 => '+2F0.3',
7345             0x84 => '-2F0.3',
7346             0x85 => '3F0.3',
7347             0x86 => '5F0.3',
7348             0x87 => '7F0.3',
7349             0x88 => '9F0.3',
7350             0x91 => '+3F0.5',
7351             0x92 => '-3F0.5',
7352             0x93 => '+2F0.5',
7353             0x94 => '-2F0.5',
7354             0x95 => '3F0.5',
7355             0x96 => '5F0.5',
7356             0x97 => '7F0.5',
7357             0x98 => '9F0.5',
7358             0xa1 => '+3F0.7',
7359             0xa2 => '-3F0.7',
7360             0xa3 => '+2F0.7',
7361             0xa4 => '-2F0.7',
7362             0xa5 => '3F0.7',
7363             0xa6 => '5F0.7',
7364             0xa7 => '7F0.7',
7365             0xa8 => '9F0.7',
7366             0xb1 => '+3F1',
7367             0xb2 => '-3F1',
7368             0xb3 => '+2F1',
7369             0xb4 => '-2F1',
7370             0xb5 => '3F1',
7371             0xb6 => '5F1',
7372             0xb7 => '7F1',
7373             0xb8 => '9F1',
7374             0xc1 => '+3F2',
7375             0xc2 => '-3F2',
7376             0xc3 => '+2F2',
7377             0xc4 => '-2F2',
7378             0xc5 => '3F2',
7379             0xc6 => '5F2',
7380             0xd1 => '+3F3',
7381             0xd2 => '-3F3',
7382             0xd3 => '+2F3',
7383             0xd4 => '-2F3',
7384             0xd5 => '3F3',
7385             0xd6 => '5F3',
7386             },
7387             },
7388             0x10 => {
7389             Name => 'WBBracketingSteps',
7390             Condition => '$$self{FILE_TYPE} ne "TIFF"', # (covers NEF and TIFF)
7391             Mask => 0xff,
7392             PrintHex => 1,
7393             PrintConvColumns => 2,
7394             PrintConv => {
7395             0x00 => 'WB Bracketing Disabled',
7396             0x01 => 'b3F 1',
7397             0x02 => 'A3F 1',
7398             0x03 => 'b2F 1',
7399             0x04 => 'A2F 1',
7400             0x05 => '3F 1',
7401             0x06 => '5F 1',
7402             0x07 => '7F 1',
7403             0x08 => '9F 1',
7404             0x10 => '0F 2',
7405             0x11 => 'b3F 2',
7406             0x12 => 'A3F 2',
7407             0x13 => 'b2F 2',
7408             0x14 => 'A2F 2',
7409             0x15 => '3F 2',
7410             0x16 => '5F 2',
7411             0x17 => '7F 2',
7412             0x18 => '9F 2',
7413             0x20 => '0F 3',
7414             0x21 => 'b3F 3',
7415             0x22 => 'A3F 3',
7416             0x23 => 'b2F 3',
7417             0x24 => 'A2F 3',
7418             0x25 => '3F 3',
7419             0x26 => '5F 3',
7420             0x27 => '7F 3',
7421             0x28 => '9F 3',
7422             0x22 => 'A3F 3',
7423             0x23 => 'b2F 3',
7424             0x24 => 'A2F 3',
7425             0x25 => '3F 3',
7426             0x26 => '5F 3',
7427             0x27 => '7F 3',
7428             0x28 => '9F 3',
7429             },
7430             },
7431             0x17 => {
7432             Name => 'ADLBracketingStep',
7433             Mask => 0xf0,
7434             PrintConv => {
7435             0 => 'Off',
7436             1 => 'Low',
7437             2 => 'Normal',
7438             3 => 'High',
7439             4 => 'Extra High',
7440             8 => 'Auto',
7441             },
7442             },
7443             0x18 => {
7444             Name => 'ADLBracketingType',
7445             Mask => 0x0f,
7446             PrintConv => {
7447             0 => 'Off',
7448             1 => '2 Shots',
7449             2 => '3 Shots',
7450             3 => '4 Shots',
7451             4 => '5 Shots',
7452             },
7453             },
7454             );
7455              
7456             %Image::ExifTool::Nikon::ShootingMenuD500 = (
7457             %binaryDataAttrs,
7458             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7459             0x00 => {
7460             Name => 'PhotoShootingMenuBank',
7461             Mask => 0x03,
7462             PrintConv => {
7463             0 => 'A',
7464             1 => 'B',
7465             2 => 'C',
7466             3 => 'D',
7467             },
7468             },
7469             0x02 => {
7470             Name => 'PrimarySlot',
7471             Condition => '$$self{Model} =~ /\bD500\b/',
7472             Notes => 'D500 only',
7473             Mask => 0x80,
7474             PrintConv => {
7475             0 => 'XQD Card',
7476             1 => 'SD Card',
7477             },
7478             },
7479             0x04 => {
7480             Name => 'ISOAutoShutterTime',
7481             Mask => 0x3f,
7482             PrintConv => {
7483             0 => '1/4000 s',
7484             1 => '1/3200 s',
7485             2 => '1/2500 s',
7486             3 => '1/2000 s',
7487             4 => '1/1600 s',
7488             5 => '1/1250 s',
7489             6 => '1/1000 s',
7490             7 => '1/800 s',
7491             8 => '1/640 s',
7492             9 => '1/500 s',
7493             10 => '1/400 s',
7494             11 => '1/320 s',
7495             12 => '1/250 s',
7496             13 => '1/200 s',
7497             14 => '1/160 s',
7498             15 => '1/125 s',
7499             16 => '1/100 s',
7500             17 => '1/80 s',
7501             18 => '1/60 s',
7502             19 => '1/50 s',
7503             20 => '1/40 s',
7504             21 => '1/30 s',
7505             22 => '1/15 s',
7506             23 => '1/8 s',
7507             24 => '1/4 s',
7508             25 => '1/2 s',
7509             26 => '1 s',
7510             27 => '2 s',
7511             28 => '4 s',
7512             29 => '8 s',
7513             30 => '15 s',
7514             31 => '30 s',
7515             32 => 'Auto (Slowest)',
7516             33 => 'Auto (Slower)',
7517             34 => 'Auto',
7518             35 => 'Auto (Faster)',
7519             36 => 'Auto (Fastest)',
7520             },
7521             },
7522             0x05 => {
7523             Name => 'ISOAutoHiLimit',
7524             Mask => 0xff,
7525             PrintHex => 1,
7526             PrintConv => {
7527             0x24 => 'ISO 200',
7528             0x26 => 'ISO 250',
7529             0x27 => 'ISO 280',
7530             0x28 => 'ISO 320',
7531             0x2a => 'ISO 400',
7532             0x2c => 'ISO 500',
7533             0x2d => 'ISO 560',
7534             0x2e => 'ISO 640',
7535             0x30 => 'ISO 800',
7536             0x32 => 'ISO 1000',
7537             0x33 => 'ISO 1100',
7538             0x34 => 'ISO 1250',
7539             0x36 => 'ISO 1600',
7540             0x38 => 'ISO 2000',
7541             0x39 => 'ISO 2200',
7542             0x3a => 'ISO 2500',
7543             0x3c => 'ISO 3200',
7544             0x3e => 'ISO 4000',
7545             0x3f => 'ISO 4500',
7546             0x40 => 'ISO 5000',
7547             0x42 => 'ISO 6400',
7548             0x44 => 'ISO 8000',
7549             0x45 => 'ISO 9000',
7550             0x46 => 'ISO 10000',
7551             0x48 => 'ISO 12800',
7552             0x4a => 'ISO 16000',
7553             0x4b => 'ISO 18000',
7554             0x4c => 'ISO 20000',
7555             0x4e => 'ISO 25600',
7556             0x50 => 'ISO 32000',
7557             0x51 => 'ISO 36000',
7558             0x52 => 'ISO 40000',
7559             0x54 => 'ISO 51200',
7560             0x56 => 'ISO Hi 0.3',
7561             0x57 => 'ISO Hi 0.5',
7562             0x58 => 'ISO Hi 0.7',
7563             0x5a => 'ISO Hi 1.0',
7564             0x60 => 'ISO Hi 2.0',
7565             0x66 => 'ISO Hi 3.0',
7566             0x6c => 'ISO Hi 4.0',
7567             0x72 => 'ISO Hi 5.0',
7568             },
7569             },
7570             0x07 => {
7571             Name => 'FlickerReduction',
7572             Mask => 0x20,
7573             PrintConv => {
7574             0 => 'Enable',
7575             1 => 'Disable',
7576             },
7577             },
7578             7.1 => {
7579             Name => 'PhotoShootingMenuBankImageArea',
7580             Mask => 0x07,
7581             PrintConv => {
7582             0 => 'FX (36x24)',
7583             1 => 'DX (24x16)',
7584             2 => '5:4 (30x24)',
7585             3 => '1.2x (30x20)',
7586             4 => '1.3x (18x12)',
7587             },
7588             },
7589             );
7590              
7591             %Image::ExifTool::Nikon::CustomSettingsD500 = (
7592             %binaryDataAttrs,
7593             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7594             IS_SUBDIR => [ 0x00 ],
7595             VARS => { ALLOW_REPROCESS => 1 }, # (necessary because subdirectory is at offset 0)
7596             0x00 => [{
7597             Name => 'CustomSettingsD5',
7598             Condition => '$$self{Model} =~ /\bD5\b/',
7599             Format => 'undef[90]',
7600             SubDirectory => {
7601             TagTable => 'Image::ExifTool::NikonCustom::SettingsD5',
7602             },
7603             },{
7604             Name => 'CustomSettingsD500',
7605             Format => 'undef[90]',
7606             SubDirectory => {
7607             TagTable => 'Image::ExifTool::NikonCustom::SettingsD500',
7608             },
7609             }],
7610             # 0x7d => { #this decode works, but involves more bits than should be necessary
7611             # Name => 'ShutterTrigger',
7612             # Mask => 0xff,
7613             # PrintConv => {
7614             # 0 => 'Timer',
7615             # 15 => 'Cable Release/Remote',
7616             # 195 => 'Shutter Button',
7617             # },
7618             # },
7619             );
7620              
7621             %Image::ExifTool::Nikon::OtherInfoD500 = (
7622             %binaryDataAttrs,
7623             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7624             # (needs testing)
7625             #0x22 => {
7626             # Name => 'ExtendedPhotoShootingBanks',
7627             # Mask => 0x01,
7628             # PrintConv => {
7629             # 0 => 'On',
7630             # 1 => 'Off',
7631             # },
7632             #},
7633             # (may not be reliable and is found elsewhere)
7634             #0x212 => {
7635             # Name => 'Rotation',
7636             # Condition => '$$self{Model} =~ /\bD500\b/',
7637             # Notes => 'D500 firmware 1.1x',
7638             # Mask => 0x30,
7639             # PrintConv => {
7640             # 0 => 'Horizontal',
7641             # 1 => 'Rotate 270 CW',
7642             # 2 => 'Rotate 90 CW',
7643             # 3 => 'Rotate 180',
7644             # },
7645             #},
7646             0x214 => { #PH
7647             Name => 'NikonMeteringMode',
7648             Condition => '$$self{Model} =~ /\bD500\b/', # (didn't seem to work for D5, but I need more samples)
7649             Notes => 'D500 only',
7650             Mask => 0x03,
7651             PrintConv => {
7652             0 => 'Matrix',
7653             1 => 'Center',
7654             2 => 'Spot',
7655             3 => 'Highlight'
7656             },
7657             },
7658             );
7659              
7660             # shot information for the D6 firmware 1.00 (encrypted) - ref 28
7661             %Image::ExifTool::Nikon::ShotInfoD6 = (
7662             PROCESS_PROC => \&ProcessNikonEncrypted,
7663             WRITE_PROC => \&ProcessNikonEncrypted,
7664             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7665             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x24 },
7666             IS_SUBDIR => [ 0x30, 0x9c, 0xa4 ],
7667             WRITABLE => 1,
7668             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7669             NOTES => 'These tags are extracted from encrypted data in images from the D6.',
7670             0x00 => {
7671             Name => 'ShotInfoVersion',
7672             Format => 'string[4]',
7673             Writable => 0,
7674             },
7675             0x04 => {
7676             Name => 'FirmwareVersion',
7677             Format => 'string[8]',
7678             Writable => 0,
7679             },
7680             0x24 => {
7681             Name => 'NumberOffsets', # (number of entries in offset table. offsets are from start of ShotInfo data)
7682             Format => 'int32u',
7683             Writable => 0,
7684             #Hidden => 1,
7685             },
7686             0x30 => {
7687             Name => 'SequenceOffset',
7688             Format => 'int32u',
7689             SubDirectory => {
7690             TagTable => 'Image::ExifTool::Nikon::SeqInfoD6',
7691             Start => '$val',
7692             },
7693             },
7694             0x9c => {
7695             Name => 'OrientationOffset',
7696             Format => 'int32u',
7697             SubDirectory => {
7698             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
7699             Start => '$val',
7700             },
7701             },
7702             0xa4 => {
7703             Name => 'IntervalOffset',
7704             Format => 'int32u',
7705             SubDirectory => {
7706             TagTable => 'Image::ExifTool::Nikon::IntervalInfoD6',
7707             Start => '$val',
7708             }
7709             },
7710             );
7711              
7712             %Image::ExifTool::Nikon::SeqInfoD6 = (
7713             %binaryDataAttrs,
7714             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7715             DATAMEMBER => [ 0x24, 0x28 ],
7716             0x24 => {
7717             Name => 'IntervalShooting',
7718             RawConv => '$$self{IntervalShooting} = $val',
7719             Format => 'int16u',
7720             PrintConv => q{
7721             return 'Off' if $val == 0 ;
7722             my $i = sprintf("Interval %.0f of %.0f",$val, $$self{IntervalShootingIntervals}||0); #something like "Interval 1 of 3"
7723             my $f = ($$self{IntervalShootingShotsPerInterval}||0) > 1 ? sprintf(" Frame %.0f of %.0f",$$self{IntervalFrame}||0, $$self{IntervalShootingShotsPerInterval}||0): '' ; #something like "Frame 1 of 3" or blank
7724             return "On: $i$f"
7725             #$val == 0 ? 'Off' : sprintf("On: Interval %.0f of %.0f Frame %.0f of %.0f",$val, $$self{IntervalShootingIntervals}||0, $$self{IntervalFrame}||0, $$self{IntervalShootingShotsPerInterval}||0),
7726             },
7727             },
7728             0x28 => {
7729             Name => 'IntervalFrame',
7730             RawConv => '$$self{IntervalFrame} = $val',
7731             Condition => '$$self{IntervalShooting} > 0',
7732             Format => 'int16u',
7733             #Hidden => 1,
7734             },
7735             0x2b => {
7736             Name => 'ImageArea',
7737             PrintConv => \%imageAreaD6,
7738             },
7739             );
7740              
7741             %Image::ExifTool::Nikon::IntervalInfoD6 = (
7742             %binaryDataAttrs,
7743             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7744             DATAMEMBER => [ 0x17c, 0x180, 0x214, 0x22c ],
7745             0x17c => {
7746             Name => 'Intervals',
7747             Format => 'int32u',
7748             RawConv => '$$self{IntervalShootingIntervals} = $val',
7749             Condition => '$$self{IntervalShooting} > 0',
7750             },
7751             0x180 => {
7752             Name => 'ShotsPerInterval',
7753             Format => 'int32u',
7754             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
7755             Condition => '$$self{IntervalShooting} > 0',
7756             },
7757             0x184 => {
7758             Name => 'IntervalExposureSmoothing',
7759             Condition => '$$self{IntervalShooting} > 0',
7760             Format => 'int8u',
7761             PrintConv => \%offOn,
7762             },
7763             0x186 => {
7764             Name => 'IntervalPriority',
7765             Condition => '$$self{IntervalShooting} > 0',
7766             Format => 'int8u',
7767             PrintConv => \%offOn,
7768             },
7769             0x1a8 => {
7770             Name => 'FocusShiftNumberShots',
7771             },
7772             0x1ac => {
7773             Name => 'FocusShiftStepWidth',
7774             },
7775             0x1b0 => {
7776             Name => 'FocusShiftInterval',
7777             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
7778             },
7779             0x1b4 => {
7780             Name => 'FocusShiftExposureLock',
7781             PrintConv => \%offOn,
7782             },
7783             #0x20a => HighISONoiseReduction
7784             0x20e => {
7785             Name => 'DiffractionCompensation',
7786             Format => 'int8u',
7787             PrintConv => \%offOn,
7788             },
7789             #0x20f => {Name => 'FlickerReductionShooting',}, #redundant with tag in NikonSettings
7790             0x214 => {
7791             Name => 'FlashControlMode', #this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
7792             RawConv => '$$self{FlashControlMode} = $val',
7793             PrintConv => {
7794             0 => 'TTL',
7795             1 => 'Auto External Flash',
7796             2 => 'GN (distance priority)',
7797             3 => 'Manual',
7798             4 => 'Repeating Flash',
7799             },
7800             },
7801             0x21a => {
7802             Name => 'FlashGNDistance',
7803             Condition => '$$self{FlashControlMode} == 2',
7804             Unknown => 1,
7805             ValueConv => '$val + 3',
7806             PrintConv => \%flashGNDistance,
7807             },
7808             0x21e => {
7809             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)
7810             Condition => '$$self{FlashControlMode} >= 3',
7811             Unknown => 1,
7812             ValueConv => '2 ** (-$val/3)',
7813             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
7814             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
7815             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
7816             },
7817             0x228 => {
7818             Name => 'FlashRemoteControl',
7819             Unknown => 1,
7820             PrintConv => {
7821             0 => 'Group',
7822             1 => 'Quick Wireless',
7823             2 => 'Remote Repeating',
7824             },
7825             },
7826             0x22c => {
7827             Name => 'FlashMasterControlMode', #tag name chosen for compatibility with those found in FlashInfo0102 & FlashInfo0103
7828             RawConv => '$$self{FlashGroupOptionsMasterMode} = $val',
7829             PrintConv => \%flashGroupOptionsMode,
7830             },
7831             0x22e => {
7832             Name => 'FlashMasterCompensation',
7833             Unknown => 1,
7834             Format => 'int8s',
7835             Condition => '$$self{FlashGroupOptionsMasterMode} != 3', #other than 'Off'
7836             ValueConv => '$val/6',
7837             ValueConvInv => '6 * $val',
7838             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
7839             PrintConvInv => '$val',
7840             },
7841             0x232 => {
7842             Name => 'FlashMasterOutput',
7843             Unknown => 1,
7844             Condition => '$$self{FlashGroupOptionsMasterMode} == 1', #only for Mode=M
7845             ValueConv => '2 ** (-$val/3)',
7846             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
7847             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
7848             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
7849             },
7850             0x234 => {
7851             Name => 'FlashWirelessOption',
7852             Unknown => 1,
7853             PrintConv => {
7854             0 => 'Optical AWL',
7855             1 => 'Off',
7856             },
7857             },
7858             0x2ca => {
7859             Name => 'MovieType',
7860             Unknown => 1,
7861             PrintConv => {
7862             0 => 'MOV',
7863             1 => 'MP4',
7864             },
7865             },
7866             );
7867              
7868             # shot information for the D610 firmware 1.00 (encrypted) - ref PH
7869             %Image::ExifTool::Nikon::ShotInfoD610 = (
7870             PROCESS_PROC => \&ProcessNikonEncrypted,
7871             WRITE_PROC => \&ProcessNikonEncrypted,
7872             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7873             VARS => { ID_LABEL => 'Index' },
7874             IS_SUBDIR => [ 0x07cf ],
7875             WRITABLE => 1,
7876             FIRST_ENTRY => 0,
7877             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7878             NOTES => 'These tags are extracted from encrypted data in images from the D610.',
7879             0x00 => {
7880             Name => 'ShotInfoVersion',
7881             Format => 'string[4]',
7882             Writable => 0,
7883             },
7884             0x04 => {
7885             Name => 'FirmwareVersion',
7886             Format => 'string[5]',
7887             Writable => 0,
7888             },
7889             0x07cf => {
7890             Name => 'CustomSettingsD610',
7891             Format => 'undef[48]',
7892             SubDirectory => {
7893             TagTable => 'Image::ExifTool::NikonCustom::SettingsD610',
7894             },
7895             },
7896             );
7897              
7898             # shot information for the D810 firmware 1.00(PH)/1.01 (encrypted) - ref 28
7899             %Image::ExifTool::Nikon::ShotInfoD810 = (
7900             PROCESS_PROC => \&ProcessNikonEncrypted,
7901             WRITE_PROC => \&ProcessNikonEncrypted,
7902             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7903             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x0c },
7904             DATAMEMBER => [ 0x04 ],
7905             IS_SUBDIR => [ 0x10, 0x24, 0x38, 0x40, 0x84 ],
7906             WRITABLE => 1,
7907             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7908             NOTES => 'These tags are extracted from encrypted data in images from the D810.',
7909             0x00 => {
7910             Name => 'ShotInfoVersion',
7911             Format => 'string[4]',
7912             Writable => 0,
7913             },
7914             0x04 => {
7915             Name => 'FirmwareVersion',
7916             DataMember => 'FirmwareVersion',
7917             Format => 'string[5]',
7918             Writable => 0,
7919             RawConv => '$$self{FirmwareVersion} = $val',
7920             },
7921             # 0x0c - number of entries in offset table (= 0x21)
7922             # 0x10 - int32u[val 0x0c]: offset table
7923             0x10 => {
7924             Name => 'SettingsOffset',
7925             Format => 'int32u',
7926             SubDirectory => {
7927             TagTable => 'Image::ExifTool::Nikon::SettingsInfoD810',
7928             Start => '$val',
7929             },
7930             },
7931             0x24 => {
7932             Name => 'BracketingOffset',
7933             Format => 'int32u',
7934             SubDirectory => {
7935             TagTable => 'Image::ExifTool::Nikon::BracketingInfoD810',
7936             Start => '$val',
7937             },
7938             },
7939             0x38 => {
7940             Name => 'ISOAutoOffset',
7941             Format => 'int32u',
7942             SubDirectory => {
7943             TagTable => 'Image::ExifTool::Nikon::ISOAutoInfoD810',
7944             Start => '$val',
7945             },
7946             },
7947             0x40 => {
7948             Name => 'CustomSettingsOffset', # (relative offset from start of ShotInfo data)
7949             Format => 'int32u',
7950             SubDirectory => {
7951             TagTable => 'Image::ExifTool::NikonCustom::SettingsD810',
7952             Start => '$val',
7953             },
7954             },
7955             0x84 => {
7956             Name => 'OrientationOffset',
7957             Format => 'int32u',
7958             SubDirectory => {
7959             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
7960             Start => '$val',
7961             }
7962             },
7963             # (moves around too much and doesn't fit cleanly in the offset table)
7964             #0x38be => {
7965             # Name => 'Rotation',
7966             # Condition => '$$self{FirmwareVersion} =~ /^1\.0/',
7967             # Mask => 0x30,
7968             # PrintConv => {
7969             # 0 => 'Horizontal',
7970             # 1 => 'Rotate 270 CW',
7971             # 2 => 'Rotate 90 CW',
7972             # 3 => 'Rotate 180',
7973             # },
7974             #},
7975             );
7976              
7977             %Image::ExifTool::Nikon::SettingsInfoD810 = (
7978             %binaryDataAttrs,
7979             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7980             0x13c => {
7981             Name => 'SecondarySlotFunction',
7982             Mask => 0x03,
7983             PrintConv => {
7984             0 => 'Overflow',
7985             2 => 'Backup',
7986             3 => 'NEF Primary + JPG Secondary',
7987             },
7988             },
7989             );
7990              
7991             %Image::ExifTool::Nikon::BracketingInfoD810 = (
7992             %binaryDataAttrs,
7993             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7994             0x0f => {
7995             Name => 'AEBracketingSteps',
7996             Mask => 0xff,
7997             PrintHex => 1,
7998             PrintConvColumns => 2,
7999             PrintConv => {
8000             0x00 => 'AE Bracketing Disabled',
8001             0x20 => 'AE Bracketing Disabled',
8002             0x30 => 'AE Bracketing Disabled',
8003             0x40 => 'AE Bracketing Disabled',
8004             0x50 => 'AE Bracketing Disabled',
8005             0x81 => '+3F0.3',
8006             0x82 => '-3F0.3',
8007             0x83 => '+2F0.3',
8008             0x84 => '-2F0.3',
8009             0x85 => '3F0.3',
8010             0x86 => '5F0.3',
8011             0x87 => '7F0.3',
8012             0x88 => '9F0.3',
8013             0x91 => '+3F0.5',
8014             0x92 => '-3F0.5',
8015             0x93 => '+2F0.5',
8016             0x94 => '-2F0.5',
8017             0x95 => '3F0.5',
8018             0x96 => '5F0.5',
8019             0x97 => '7F0.5',
8020             0x98 => '9F0.5',
8021             0xa1 => '+3F0.7',
8022             0xa2 => '-3F0.7',
8023             0xa3 => '+2F0.7',
8024             0xa4 => '-2F0.7',
8025             0xa5 => '3F0.7',
8026             0xa6 => '5F0.7',
8027             0xa7 => '7F0.7',
8028             0xa8 => '9F0.7',
8029             0xb1 => '+3F1',
8030             0xb2 => '-3F1',
8031             0xb3 => '+2F1',
8032             0xb4 => '-2F1',
8033             0xb5 => '3F1',
8034             0xb6 => '5F1',
8035             0xb7 => '7F1',
8036             0xb8 => '9F1',
8037             0xc1 => '+3F2',
8038             0xc2 => '-3F2',
8039             0xc3 => '+2F2',
8040             0xc4 => '-2F2',
8041             0xc5 => '3F2',
8042             0xc6 => '5F2',
8043             0xd1 => '+3F3',
8044             0xd2 => '-3F3',
8045             0xd3 => '+2F3',
8046             0xd4 => '-2F3',
8047             0xd5 => '3F3',
8048             0xd6 => '5F3',
8049             },
8050             },
8051             0x10 => {
8052             Name => 'WBBracketingSteps',
8053             Condition => '$$self{FILE_TYPE} ne "TIFF"', # (covers NEF and TIFF)
8054             Mask => 0xff,
8055             PrintHex => 1,
8056             PrintConvColumns => 2,
8057             PrintConv => {
8058             0x00 => 'WB Bracketing Disabled',
8059             0x01 => 'b3F 1',
8060             0x02 => 'A3F 1',
8061             0x03 => 'b2F 1',
8062             0x04 => 'A2F 1',
8063             0x05 => '3F 1',
8064             0x06 => '5F 1',
8065             0x07 => '7F 1',
8066             0x08 => '9F 1',
8067             0x10 => '0F 2',
8068             0x11 => 'b3F 2',
8069             0x12 => 'A3F 2',
8070             0x13 => 'b2F 2',
8071             0x14 => 'A2F 2',
8072             0x15 => '3F 2',
8073             0x16 => '5F 2',
8074             0x17 => '7F 2',
8075             0x18 => '9F 2',
8076             0x20 => '0F 3',
8077             0x21 => 'b3F 3',
8078             0x22 => 'A3F 3',
8079             0x23 => 'b2F 3',
8080             0x24 => 'A2F 3',
8081             0x25 => '3F 3',
8082             0x26 => '5F 3',
8083             0x27 => '7F 3',
8084             0x28 => '9F 3',
8085             0x22 => 'A3F 3',
8086             0x23 => 'b2F 3',
8087             0x24 => 'A2F 3',
8088             0x25 => '3F 3',
8089             0x26 => '5F 3',
8090             0x27 => '7F 3',
8091             0x28 => '9F 3',
8092             },
8093             },
8094             0x17 => {
8095             Name => 'NikonMeteringMode',
8096             Mask => 0x03,
8097             PrintConv => {
8098             0 => 'Matrix',
8099             1 => 'Center',
8100             2 => 'Spot',
8101             3 => 'Highlight'
8102             },
8103             },
8104             );
8105              
8106             %Image::ExifTool::Nikon::ISOAutoInfoD810 = (
8107             %binaryDataAttrs,
8108             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8109             0x04 => {
8110             Name => 'ISOAutoShutterTime',
8111             Mask => 0x3f,
8112             PrintConv => {
8113             0 => '1/4000 s',
8114             1 => '1/3200 s',
8115             2 => '1/2500 s',
8116             3 => '1/2000 s',
8117             4 => '1/1600 s',
8118             5 => '1/1250 s',
8119             6 => '1/1000 s',
8120             7 => '1/800 s',
8121             8 => '1/640 s',
8122             9 => '1/500 s',
8123             10 => '1/400 s',
8124             11 => '1/320 s',
8125             12 => '1/250 s',
8126             13 => '1/200 s',
8127             14 => '1/160 s',
8128             15 => '1/125 s',
8129             16 => '1/100 s',
8130             17 => '1/80 s',
8131             18 => '1/60 s',
8132             19 => '1/50 s',
8133             20 => '1/40 s',
8134             21 => '1/30 s',
8135             22 => '1/15 s',
8136             23 => '1/8 s',
8137             24 => '1/4 s',
8138             25 => '1/2 s',
8139             26 => '1 s',
8140             27 => '2 s',
8141             28 => '4 s',
8142             29 => '8 s',
8143             30 => '15 s',
8144             31 => '30 s',
8145             32 => 'Auto (Slowest)',
8146             33 => 'Auto (Slower)',
8147             34 => 'Auto',
8148             35 => 'Auto (Faster)',
8149             36 => 'Auto (Fastest)',
8150             },
8151             },
8152             0x05 => {
8153             Name => 'ISOAutoHiLimit',
8154             Mask => 0xff,
8155             PrintHex => 1,
8156             PrintConv => {
8157             0x24 => 'ISO 200',
8158             0x26 => 'ISO 250',
8159             0x27 => 'ISO 280',
8160             0x28 => 'ISO 320',
8161             0x2a => 'ISO 400',
8162             0x2c => 'ISO 500',
8163             0x2d => 'ISO 560',
8164             0x2e => 'ISO 640',
8165             0x30 => 'ISO 800',
8166             0x32 => 'ISO 1000',
8167             0x33 => 'ISO 1100',
8168             0x34 => 'ISO 1250',
8169             0x36 => 'ISO 1600',
8170             0x38 => 'ISO 2000',
8171             0x39 => 'ISO 2200',
8172             0x3a => 'ISO 2500',
8173             0x3c => 'ISO 3200',
8174             0x3e => 'ISO 4000',
8175             0x3f => 'ISO 4500',
8176             0x40 => 'ISO 5000',
8177             0x42 => 'ISO 6400',
8178             0x44 => 'ISO 8000',
8179             0x45 => 'ISO 9000',
8180             0x46 => 'ISO 10000',
8181             0x48 => 'ISO 12800',
8182             0x4a => 'ISO 16000',
8183             0x4b => 'ISO 18000',
8184             0x4c => 'ISO 20000',
8185             0x4e => 'ISO 25600',
8186             0x50 => 'ISO 32000',
8187             0x51 => 'ISO 36000',
8188             0x52 => 'ISO 40000',
8189             0x54 => 'ISO 51200',
8190             0x56 => 'ISO Hi 0.3',
8191             0x57 => 'ISO Hi 0.5',
8192             0x58 => 'ISO Hi 0.7',
8193             0x5a => 'ISO Hi 1.0',
8194             0x60 => 'ISO Hi 2.0',
8195             0x66 => 'ISO Hi 3.0',
8196             0x6c => 'ISO Hi 4.0',
8197             0x72 => 'ISO Hi 5.0',
8198             },
8199             },
8200             );
8201              
8202             # shot information for the D850 firmware 1.00b (encrypted) - ref 28
8203             %Image::ExifTool::Nikon::ShotInfoD850 = (
8204             PROCESS_PROC => \&ProcessNikonEncrypted,
8205             WRITE_PROC => \&ProcessNikonEncrypted,
8206             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8207             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x0c },
8208             DATAMEMBER => [ 0x04 ],
8209             IS_SUBDIR => [ 0x10, 0x4c, 0x58, 0xa0 ],
8210             WRITABLE => 1,
8211             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8212             NOTES => 'These tags are extracted from encrypted data in images from the D850.',
8213             0x00 => {
8214             Name => 'ShotInfoVersion',
8215             Format => 'string[4]',
8216             Writable => 0,
8217             },
8218             0x04 => {
8219             Name => 'FirmwareVersion',
8220             DataMember => 'FirmwareVersion',
8221             Format => 'string[5]',
8222             Writable => 0,
8223             RawConv => '$$self{FirmwareVersion} = $val',
8224             },
8225             0x10 => {
8226             Name => 'MenuSettingsOffset',
8227             Format => 'int32u',
8228             SubDirectory => {
8229             TagTable => 'Image::ExifTool::Nikon::MenuSettingsD850',
8230             Start => '$val',
8231             },
8232             },
8233             0x4c => {
8234             Name => 'MoreSettingsOffset',
8235             Format => 'int32u',
8236             SubDirectory => {
8237             TagTable => 'Image::ExifTool::Nikon::MoreSettingsD850',
8238             Start => '$val',
8239             },
8240             },
8241             0x58 => {
8242             Name => 'CustomSettingsOffset',
8243             Format => 'int32u',
8244             SubDirectory => {
8245             TagTable => 'Image::ExifTool::NikonCustom::SettingsD850',
8246             Start => '$val',
8247             },
8248             },
8249             0xa0 => {
8250             Name => 'OrientationOffset',
8251             Format => 'int32u',
8252             SubDirectory => {
8253             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
8254             Start => '$val',
8255             },
8256             },
8257             );
8258              
8259             %Image::ExifTool::Nikon::MenuSettingsD850 = (
8260             %binaryDataAttrs,
8261             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8262             0x06dd => {
8263             Name => 'PhotoShootingMenuBankImageArea',
8264             Mask => 0x07,
8265             PrintConv => {
8266             0 => 'FX (36x24)',
8267             1 => 'DX (24x16)',
8268             2 => '5:4 (30x24)',
8269             3 => '1.2x (30x20)',
8270             4 => '1:1 (24x24)',
8271             },
8272             },
8273             );
8274              
8275             %Image::ExifTool::Nikon::MoreSettingsD850 = (
8276             %binaryDataAttrs,
8277             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8278             0x24 => {
8279             Name => 'PhotoShootingMenuBank',
8280             Condition => '$$self{FILE_TYPE} eq "JPEG"',
8281             Notes => 'valid for JPEG images only',
8282             Mask => 0x03,
8283             PrintConv => {
8284             0 => 'A',
8285             1 => 'B',
8286             2 => 'C',
8287             3 => 'D',
8288             },
8289             },
8290             0x25 => {
8291             Name => 'PrimarySlot',
8292             Mask => 0x80,
8293             PrintConv => {
8294             0 => 'XQD Card',
8295             1 => 'SD Card',
8296             },
8297             },
8298             );
8299              
8300             # shot information for the D4 firmware 1.00g (ref PH)
8301             %Image::ExifTool::Nikon::ShotInfoD4 = (
8302             PROCESS_PROC => \&ProcessNikonEncrypted,
8303             WRITE_PROC => \&ProcessNikonEncrypted,
8304             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8305             VARS => { ID_LABEL => 'Index' },
8306             IS_SUBDIR => [ 0x0751 ],
8307             WRITABLE => 1,
8308             FIRST_ENTRY => 0,
8309             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8310             NOTES => q{
8311             These tags are extracted from encrypted data in images from the D4.
8312             },
8313             0x00 => {
8314             Name => 'ShotInfoVersion',
8315             Format => 'string[4]',
8316             Writable => 0,
8317             },
8318             0x04 => {
8319             Name => 'FirmwareVersion',
8320             Format => 'string[5]',
8321             Writable => 0,
8322             },
8323             0x0751 => { #PH (NC)
8324             Name => 'CustomSettingsD4',
8325             # (seems to work for 1.00g and 1.02b)
8326             Format => 'undef[56]',
8327             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsD4' },
8328             },
8329             );
8330              
8331             # shot information for the D4S firmware 1.01a (ref 28, encrypted)
8332             %Image::ExifTool::Nikon::ShotInfoD4S = (
8333             PROCESS_PROC => \&ProcessNikonEncrypted,
8334             WRITE_PROC => \&ProcessNikonEncrypted,
8335             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8336             VARS => { ID_LABEL => 'Index' },
8337             DATAMEMBER => [ 4 ],
8338             IS_SUBDIR => [ 0x189d, 0x193d, 0x350b ],
8339             WRITABLE => 1,
8340             FIRST_ENTRY => 0,
8341             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8342             NOTES => 'These tags are extracted from encrypted data in images from the D4S.',
8343             0x00 => {
8344             Name => 'ShotInfoVersion',
8345             Format => 'string[4]',
8346             Writable => 0,
8347             },
8348             0x04 => {
8349             Name => 'FirmwareVersion',
8350             DataMember => 'FirmwareVersion',
8351             Format => 'string[5]',
8352             Writable => 0,
8353             RawConv => '$$self{FirmwareVersion} = $val',
8354             },
8355             0x01d0 => {
8356             Name => 'SecondarySlotFunction',
8357             Mask => 0x03,
8358             PrintConv => {
8359             0 => 'Overflow',
8360             2 => 'Backup',
8361             3 => 'NEF Primary + JPG Secondary',
8362             },
8363             },
8364             0x174c => {
8365             Name => 'AEBracketingSteps',
8366             Mask => 0xff,
8367             PrintHex => 1,
8368             PrintConvColumns => 2,
8369             PrintConv => {
8370             0x00 => 'AE Bracketing Disabled',
8371             0x20 => 'AE Bracketing Disabled',
8372             0x30 => 'AE Bracketing Disabled',
8373             0x40 => 'AE Bracketing Disabled',
8374             0x50 => 'AE Bracketing Disabled',
8375             0x81 => '+3F0.3',
8376             0x82 => '-3F0.3',
8377             0x83 => '+2F0.3',
8378             0x84 => '-2F0.3',
8379             0x85 => '3F0.3',
8380             0x86 => '5F0.3',
8381             0x87 => '7F0.3',
8382             0x88 => '9F0.3',
8383             0x91 => '+3F0.5',
8384             0x92 => '-3F0.5',
8385             0x93 => '+2F0.5',
8386             0x94 => '-2F0.5',
8387             0x95 => '3F0.5',
8388             0x96 => '5F0.5',
8389             0x97 => '7F0.5',
8390             0x98 => '9F0.5',
8391             0xa1 => '+3F0.7',
8392             0xa2 => '-3F0.7',
8393             0xa3 => '+2F0.7',
8394             0xa4 => '-2F0.7',
8395             0xa5 => '3F0.7',
8396             0xa6 => '5F0.7',
8397             0xa7 => '7F0.7',
8398             0xa8 => '9F0.7',
8399             0xb1 => '+3F1',
8400             0xb2 => '-3F1',
8401             0xb3 => '+2F1',
8402             0xb4 => '-2F1',
8403             0xb5 => '3F1',
8404             0xb6 => '5F1',
8405             0xb7 => '7F1',
8406             0xb8 => '9F1',
8407             0xc1 => '+3F2',
8408             0xc2 => '-3F2',
8409             0xc3 => '+2F2',
8410             0xc4 => '-2F2',
8411             0xc5 => '3F2',
8412             0xc6 => '5F2',
8413             0xd1 => '+3F3',
8414             0xd2 => '-3F3',
8415             0xd3 => '+2F3',
8416             0xd4 => '-2F3',
8417             0xd5 => '3F3',
8418             0xd6 => '5F3',
8419             },
8420             },
8421             0x174d => {
8422             Name => 'WBBracketingSteps',
8423             Condition => '$$self{FILE_TYPE} ne "TIFF"', # (covers NEF and TIFF)
8424             Mask => 0xff,
8425             PrintHex => 1,
8426             PrintConvColumns => 2,
8427             PrintConv => {
8428             0x00 => 'WB Bracketing Disabled',
8429             0x01 => 'b3F 1',
8430             0x02 => 'A3F 1',
8431             0x03 => 'b2F 1',
8432             0x04 => 'A2F 1',
8433             0x05 => '3F 1',
8434             0x06 => '5F 1',
8435             0x07 => '7F 1',
8436             0x08 => '9F 1',
8437             0x10 => '0F 2',
8438             0x11 => 'b3F 2',
8439             0x12 => 'A3F 2',
8440             0x13 => 'b2F 2',
8441             0x14 => 'A2F 2',
8442             0x15 => '3F 2',
8443             0x16 => '5F 2',
8444             0x17 => '7F 2',
8445             0x18 => '9F 2',
8446             0x20 => '0F 3',
8447             0x21 => 'b3F 3',
8448             0x22 => 'A3F 3',
8449             0x23 => 'b2F 3',
8450             0x24 => 'A2F 3',
8451             0x25 => '3F 3',
8452             0x26 => '5F 3',
8453             0x27 => '7F 3',
8454             0x28 => '9F 3',
8455             0x22 => 'A3F 3',
8456             0x23 => 'b2F 3',
8457             0x24 => 'A2F 3',
8458             0x25 => '3F 3',
8459             0x26 => '5F 3',
8460             0x27 => '7F 3',
8461             0x28 => '9F 3',
8462             },
8463             },
8464             0x184d => {
8465             Name => 'ReleaseMode',
8466             Mask => 0xff,
8467             PrintConv => {
8468             0 => 'Single Frame',
8469             1 => 'Continuous High Speed',
8470             3 => 'Continuous Low Speed',
8471             4 => 'Timer',
8472             32 => 'Mirror-Up',
8473             64 => 'Quiet',
8474             },
8475             },
8476             0x189d => { #PH (NC)
8477             Name => 'CustomSettingsD4S',
8478             Condition => '$$self{FirmwareVersion} =~ /^1\.00/',
8479             Notes => 'firmware version 1.00',
8480             Format => 'undef[56]',
8481             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsD4' },
8482             },
8483             0x18c2 => { # CSf1-c (no idea why it is so far away from the rest of the settings)
8484             Name => 'MultiSelectorLiveViewMode',
8485             Groups => { 1 => 'NikonCustom' },
8486             Condition => '$$self{FirmwareVersion} !~ /^1\.00/',
8487             Mask => 0xc0,
8488             PrintConv => {
8489             0 => 'Reset',
8490             1 => 'Zoom',
8491             3 => 'None',
8492             },
8493             },
8494             0x18ea => {
8495             Name => 'ISOAutoShutterTime',
8496             Mask => 0x3f,
8497             PrintConv => {
8498             0 => '1/4000 s',
8499             1 => '1/3200 s',
8500             2 => '1/2500 s',
8501             3 => '1/2000 s',
8502             4 => '1/1600 s',
8503             5 => '1/1250 s',
8504             6 => '1/1000 s',
8505             7 => '1/800 s',
8506             8 => '1/640 s',
8507             9 => '1/500 s',
8508             10 => '1/400 s',
8509             11 => '1/320 s',
8510             12 => '1/250 s',
8511             13 => '1/200 s',
8512             14 => '1/160 s',
8513             15 => '1/125 s',
8514             16 => '1/100 s',
8515             17 => '1/80 s',
8516             18 => '1/60 s',
8517             19 => '1/50 s',
8518             20 => '1/40 s',
8519             21 => '1/30 s',
8520             22 => '1/15 s',
8521             23 => '1/8 s',
8522             24 => '1/4 s',
8523             25 => '1/2 s',
8524             26 => '1 s',
8525             27 => '2 s',
8526             28 => '4 s',
8527             29 => '8 s',
8528             30 => '15 s',
8529             31 => '30 s',
8530             32 => 'Auto (Slowest)',
8531             33 => 'Auto (Slower)',
8532             34 => 'Auto',
8533             35 => 'Auto (Faster)',
8534             36 => 'Auto (Fastest)',
8535             },
8536             },
8537             0x18eb => {
8538             Name => 'ISOAutoHiLimit',
8539             Mask => 0xff,
8540             PrintHex => 1,
8541             PrintConv => {
8542             0x24 => 'ISO 200',
8543             0x26 => 'ISO 250',
8544             0x27 => 'ISO 280',
8545             0x28 => 'ISO 320',
8546             0x2a => 'ISO 400',
8547             0x2c => 'ISO 500',
8548             0x2d => 'ISO 560',
8549             0x2e => 'ISO 640',
8550             0x30 => 'ISO 800',
8551             0x32 => 'ISO 1000',
8552             0x33 => 'ISO 1100',
8553             0x34 => 'ISO 1250',
8554             0x36 => 'ISO 1600',
8555             0x38 => 'ISO 2000',
8556             0x39 => 'ISO 2200',
8557             0x3a => 'ISO 2500',
8558             0x3c => 'ISO 3200',
8559             0x3e => 'ISO 4000',
8560             0x3f => 'ISO 4500',
8561             0x40 => 'ISO 5000',
8562             0x42 => 'ISO 6400',
8563             0x44 => 'ISO 8000',
8564             0x45 => 'ISO 9000',
8565             0x46 => 'ISO 10000',
8566             0x48 => 'ISO 12800',
8567             0x4a => 'ISO 16000',
8568             0x4b => 'ISO 18000',
8569             0x4c => 'ISO 20000',
8570             0x4e => 'ISO 25600',
8571             0x50 => 'ISO 32000',
8572             0x51 => 'ISO 36000',
8573             0x52 => 'ISO 40000',
8574             0x54 => 'ISO 51200',
8575             0x56 => 'ISO Hi 0.3',
8576             0x57 => 'ISO Hi 0.5',
8577             0x58 => 'ISO Hi 0.7',
8578             0x5a => 'ISO Hi 1.0',
8579             0x60 => 'ISO Hi 2.0',
8580             0x66 => 'ISO Hi 3.0',
8581             0x6c => 'ISO Hi 4.0',
8582             0x72 => 'ISO Hi 5.0',
8583             },
8584             },
8585             0x193d => {
8586             Name => 'CustomSettingsD4S',
8587             Condition => '$$self{FirmwareVersion} !~ /^1\.00/',
8588             Notes => 'firmware version 1.01',
8589             Format => 'undef[56]',
8590             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsD4' },
8591             },
8592             # 0x1978 => { # this decode works, but involves more bits than should be necessary
8593             # Name => 'ShutterTrigger',
8594             # Mask => 0xff,
8595             # PrintConv => {
8596             # 0 => 'Timer',
8597             # 15 => 'Cable Release/Remote',
8598             # 195 => 'Shutter Button',
8599             # },
8600             # },
8601             0x350b => {
8602             Name => 'OrientationInfo',
8603             Format => 'undef[12]',
8604             SubDirectory => {
8605             # Note: pitch angle may be wrong sign for this model?
8606             # (pitch sign was changed without verification to use same decoding as other models)
8607             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
8608             },
8609             },
8610             0x3693 => {
8611             Name => 'Rotation',
8612             Mask => 0x30,
8613             PrintConv => {
8614             0 => 'Horizontal',
8615             1 => 'Rotate 270 CW',
8616             2 => 'Rotate 90 CW',
8617             3 => 'Rotate 180',
8618             },
8619             },
8620             );
8621              
8622             # shot information for the Z6III firmware 1.00 (encrypted) - ref 28
8623             %Image::ExifTool::Nikon::ShotInfoZ6III = (
8624             PROCESS_PROC => \&ProcessNikonEncrypted,
8625             WRITE_PROC => \&ProcessNikonEncrypted,
8626             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8627             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x24 },
8628             DATAMEMBER => [ 0x04 ],
8629             IS_SUBDIR => [ 0x88, 0x90 ],
8630             WRITABLE => 1,
8631             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8632             NOTES => 'These tags are extracted from encrypted data in images from the Z6III.',
8633             0x00 => {
8634             Name => 'ShotInfoVersion',
8635             Format => 'string[4]',
8636             Writable => 0,
8637             },
8638             0x04 => {
8639             Name => 'FirmwareVersion',
8640             DataMember => 'FirmwareVersion',
8641             Format => 'string[8]',
8642             Writable => 0,
8643             RawConv => '$$self{FirmwareVersion} = $val',
8644             },
8645             0x0e => {
8646             Name => 'FirmwareVersion2',
8647             Format => 'string[8]',
8648             Writable => 0,
8649             #Hidden => 1,
8650             },
8651             0x18 => {
8652             Name => 'FirmwareVersion3',
8653             Format => 'string[8]',
8654             Writable => 0,
8655             #Hidden => 1,
8656             },
8657             0x24 => {
8658             Name => 'NumberOffsets', # number of entries in offset table. offsets are from start of ShotInfo data.
8659             Format => 'int32u',
8660             Writable => 0,
8661             #Hidden => 1,
8662             },
8663             #0x28 Offset1 - non-zero for NEF only
8664             #0x2c Offset2 - non-zero for NEF only
8665             #0x38 Offset5 - contains SkinSoftening at 0x2d1 - mapping is %offLowNormalHighZ7
8666             0x88 => {
8667             Name => 'OrientationOffset',
8668             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96', #not valid for C30/C60/C120
8669             Format => 'int32u',
8670             SubDirectory => {
8671             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
8672             Start => '$val',
8673             }
8674             },
8675             0x90 => {
8676             Name => 'MenuOffset',
8677             Condition => '$$self{Model} =~ /^NIKON Z6_3\b/i and $$self{FirmwareVersion} and $$self{FirmwareVersion} lt "02.00"',
8678             Format => 'int32u',
8679             AlwaysDecrypt => 1, # (necessary because FirmwareVersion is extracted after decryption time)
8680             SubDirectory => {
8681             TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ6III',
8682             Start => '$val',
8683             },
8684             },
8685             );
8686              
8687             # shot information for the Z7II firmware 1.00 (encrypted) - ref 28
8688             %Image::ExifTool::Nikon::ShotInfoZ7II = (
8689             PROCESS_PROC => \&ProcessNikonEncrypted,
8690             WRITE_PROC => \&ProcessNikonEncrypted,
8691             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8692             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x24 },
8693             DATAMEMBER => [ 0x04 ],
8694             IS_SUBDIR => [ 0x30, 0x38, 0x88, 0x98, 0xa0 ],
8695             WRITABLE => 1,
8696             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8697             NOTES => 'These tags are extracted from encrypted data in images from the Z7II.',
8698             0x00 => {
8699             Name => 'ShotInfoVersion',
8700             Format => 'string[4]',
8701             Writable => 0,
8702             },
8703             0x04 => {
8704             Name => 'FirmwareVersion',
8705             DataMember => 'FirmwareVersion',
8706             Format => 'string[8]',
8707             Writable => 0,
8708             RawConv => '$$self{FirmwareVersion} = $val',
8709             },
8710             0x0e => {
8711             Name => 'FirmwareVersion2',
8712             Format => 'string[8]',
8713             Writable => 0,
8714             #Hidden => 1,
8715             },
8716             0x18 => {
8717             Name => 'FirmwareVersion3',
8718             Format => 'string[8]',
8719             Writable => 0,
8720             #Hidden => 1,
8721             },
8722             0x24 => {
8723             Name => 'NumberOffsets', # number of entries in offset table. offsets are from start of ShotInfo data.
8724             Format => 'int32u',
8725             Writable => 0,
8726             #Hidden => 1,
8727             },
8728             0x30 => {
8729             Name => 'IntervalOffset',
8730             Format => 'int32u',
8731             SubDirectory => {
8732             TagTable => 'Image::ExifTool::Nikon::IntervalInfoZ7II',
8733             Start => '$val',
8734             }
8735             },
8736             0x38 => {
8737             Name => 'PortraitOffset',
8738             Format => 'int32u',
8739             SubDirectory => {
8740             TagTable => 'Image::ExifTool::Nikon::PortraitInfoZ7II',
8741             Start => '$val',
8742             }
8743             },
8744             0x88 => {
8745             Name => 'OrientationOffset',
8746             Format => 'int32u',
8747             Condition => '$$self{Model} =~ /^NIKON Z f\b/i',
8748             SubDirectory => {
8749             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
8750             Start => '$val',
8751             }
8752             },
8753             0x98 => {
8754             Name => 'OrientationOffset',
8755             Format => 'int32u',
8756             Condition => '$$self{Model} =~ /^NIKON Z (30|5|50|6|6_2|7|7_2|8|fc)\b/i', #models other then the Z f
8757             SubDirectory => {
8758             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
8759             Start => '$val',
8760             }
8761             },
8762             0xa0 => {
8763             Name => 'MenuOffset',
8764             Format => 'int32u',
8765             SubDirectory => {
8766             TagTable => 'Image::ExifTool::Nikon::MenuInfoZ7II',
8767             Start => '$val',
8768             },
8769             },
8770             );
8771              
8772             %Image::ExifTool::Nikon::IntervalInfoZ7II = (
8773             %binaryDataAttrs,
8774             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8775             DATAMEMBER => [ 0x24, 0x28 ],
8776             0x24 => {
8777             Name => 'IntervalShooting',
8778             RawConv => '$$self{IntervalShooting} = $val',
8779             Format => 'int16u',
8780             PrintConv => q{
8781             return 'Off' if $val == 0 ;
8782             my $i = sprintf("Interval %.0f of %.0f",$val, $$self{IntervalShootingIntervals}||0); # something like "Interval 1 of 3"
8783             my $f = ($$self{IntervalShootingShotsPerInterval}||0) > 1 ? sprintf(" Frame %.0f of %.0f",$$self{IntervalFrame}||0, $$self{IntervalShootingShotsPerInterval}||0): '' ; # something like "Frame 1 of 3" or blank
8784             return "On: $i$f"
8785             #$val == 0 ? 'Off' : sprintf("On: Interval %.0f of %.0f Frame %.0f of %.0f",$val, $$self{IntervalShootingIntervals}||0, $$self{IntervalFrame}||0, $$self{IntervalShootingShotsPerInterval}||0),
8786             },
8787             },
8788             0x28 => {
8789             Name => 'IntervalFrame',
8790             RawConv => '$$self{IntervalFrame} = $val',
8791             Condition => '$$self{IntervalShooting} > 0',
8792             Format => 'int16u',
8793             #Hidden => 1,
8794             },
8795             0x2b => {
8796             Name => 'ImageArea',
8797             PrintConv => \%imageAreaD6,
8798             },
8799             );
8800              
8801             %Image::ExifTool::Nikon::PortraitInfoZ7II = (
8802             %binaryDataAttrs,
8803             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8804             0xa0 => { #28
8805             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
8806             # offset5+160; 128 is neutral; >128 increases Yellow; <128 increases Magenta; increments of 4 result from 1 full unit adjustment on the camera
8807             # offset5+161 128 is neutral; >128 increases Brightness; <128 decreases Brightness
8808             # 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]
8809             Format => 'int8u[2]',
8810             Condition => '$$self{FirmwareVersion} ge "01.30"',
8811             PrintConv => q{
8812             return 'Off' if $val eq '0 0' or $val eq '255 255';
8813             my @v = split ' ', $val;
8814             my $brightness = $v[1]==128 ? 'Brightness: Neutral' : sprintf('Brightness: %+.1f',($v[1]-128)/4);
8815             my $color = $v[0]==128 ? 'Color: Neutral' : sprintf('%s: %.1f', $v[0]>128 ? 'Yellow' : 'Magenta', abs($v[0]-128)/4);
8816             # will return something like: 'Magenta: 1.0 Brightness: Neutral'
8817             return "$color $brightness"
8818             },
8819             },
8820             );
8821              
8822             %Image::ExifTool::Nikon::MenuInfoZ7II = (
8823             %binaryDataAttrs,
8824             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8825             IS_SUBDIR => [ 0x10 ],
8826             0x10 => {
8827             Name => 'MenuSettingsOffsetZ7II',
8828             Format => 'int32u',
8829             SubDirectory => {
8830             TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ7II',
8831             Start => '$dirStart + $val',
8832             },
8833             },
8834             );
8835              
8836             # shot information for the Z8 firmware 1.00 (encrypted) - ref 28
8837             %Image::ExifTool::Nikon::ShotInfoZ8 = (
8838             PROCESS_PROC => \&ProcessNikonEncrypted,
8839             WRITE_PROC => \&ProcessNikonEncrypted,
8840             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8841             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x24 },
8842             DATAMEMBER => [ 0x04 ],
8843             IS_SUBDIR => [ 0x30, 0x80, 0x84, 0x8c ],
8844             WRITABLE => 1,
8845             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8846             NOTES => 'These tags are extracted from encrypted data in images from the Z8.',
8847             0x00 => {
8848             Name => 'ShotInfoVersion',
8849             Format => 'string[4]',
8850             Writable => 0,
8851             },
8852             0x04 => {
8853             Name => 'FirmwareVersion',
8854             DataMember => 'FirmwareVersion',
8855             Format => 'string[8]',
8856             Writable => 0,
8857             RawConv => '$$self{FirmwareVersion} = $val',
8858             },
8859             0x0e => {
8860             Name => 'FirmwareVersion2',
8861             Format => 'string[8]',
8862             Writable => 0,
8863             #Hidden => 1,
8864             },
8865             0x18 => {
8866             Name => 'FirmwareVersion3',
8867             Format => 'string[8]',
8868             Writable => 0,
8869             #Hidden => 1,
8870             },
8871             0x24 => {
8872             Name => 'NumberOffsets', # number of entries in offset table. offsets are from start of ShotInfo data.
8873             Format => 'int32u',
8874             Writable => 0,
8875             #Hidden => 1,
8876             },
8877             # subdirectories, referenced by offsets (not processed if offset is zero)
8878             0x30 => {
8879             Name => 'SequenceOffset',
8880             Format => 'int32u',
8881             SubDirectory => {
8882             TagTable => 'Image::ExifTool::Nikon::SeqInfoZ9',
8883             Start => '$val',
8884             },
8885             },
8886             0x80 => {
8887             Name => 'AutoCaptureOffset',
8888             Condition => '$$self{FirmwareVersion} and $$self{FirmwareVersion} ge "02.00"',
8889             Format => 'int32u',
8890             AlwaysDecrypt => 1, # (necessary because FirmwareVersion is extracted after decryption time)
8891             SubDirectory => {
8892             TagTable => 'Image::ExifTool::Nikon::AutoCaptureInfo',
8893             Start => '$val',
8894             },
8895             },
8896             0x84 => {
8897             Name => 'OrientOffset',
8898             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96', #not valid for C30/C60/C120
8899             Format => 'int32u',
8900             SubDirectory => {
8901             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
8902             Start => '$val',
8903             },
8904             },
8905             0x8c => {
8906             Name => 'MenuOffset',
8907             Format => 'int32u',
8908             SubDirectory => {
8909             TagTable => 'Image::ExifTool::Nikon::MenuInfoZ8',
8910             Start => '$val',
8911             },
8912             },
8913             );
8914              
8915             # shot information for the Z9 firmware 1.00 (encrypted) - ref 28
8916             %Image::ExifTool::Nikon::ShotInfoZ9 = (
8917             PROCESS_PROC => \&ProcessNikonEncrypted,
8918             WRITE_PROC => \&ProcessNikonEncrypted,
8919             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8920             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x24 },
8921             DATAMEMBER => [ 0x04 ],
8922             IS_SUBDIR => [ 0x30, 0x58, 0x80, 0x84, 0x8c ],
8923             WRITABLE => 1,
8924             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8925             NOTES => 'These tags are extracted from encrypted data in images from the Z9.',
8926             0x00 => {
8927             Name => 'ShotInfoVersion',
8928             Format => 'string[4]',
8929             Writable => 0,
8930             },
8931             0x04 => {
8932             Name => 'FirmwareVersion',
8933             DataMember => 'FirmwareVersion',
8934             Format => 'string[8]',
8935             Writable => 0,
8936             RawConv => '$$self{FirmwareVersion} = $val',
8937             },
8938             0x0e => {
8939             Name => 'FirmwareVersion2',
8940             Format => 'string[8]',
8941             Writable => 0,
8942             #Hidden => 1,
8943             },
8944             0x18 => {
8945             Name => 'FirmwareVersion3',
8946             Format => 'string[8]',
8947             Writable => 0,
8948             #Hidden => 1,
8949             },
8950             0x24 => {
8951             Name => 'NumberOffsets', # number of entries in offset table. offsets are from start of ShotInfo data.
8952             Format => 'int32u',
8953             Writable => 0,
8954             #Hidden => 1,
8955             },
8956             # subdirectories, referenced by offsets (not processed if offset is zero)
8957             0x30 => {
8958             Name => 'SequenceOffset',
8959             Format => 'int32u',
8960             SubDirectory => {
8961             TagTable => 'Image::ExifTool::Nikon::SeqInfoZ9',
8962             Start => '$val',
8963             },
8964             },
8965             0x58 => {
8966             Name => 'Offset13', #offset13 - length x'8f80 (Z9 firmware 3.01 NEF), using currently for a few focus related tags. Might be premature to give the offset a more meaningful name at this point.
8967             Condition => '$$self{FirmwareVersion} and $$self{FirmwareVersion} ge "03.01"',
8968             Format => 'int32u',
8969             AlwaysDecrypt => 1, # (necessary because FirmwareVersion is extracted after decryption time)
8970             SubDirectory => {
8971             TagTable => 'Image::ExifTool::Nikon::Offset13InfoZ9',
8972             Start => '$val',
8973             },
8974             },
8975             0x80 => {
8976             Name => 'AutoCaptureOffset',
8977             Condition => '$$self{FirmwareVersion} and $$self{FirmwareVersion} ge "04.00"',
8978             Format => 'int32u',
8979             AlwaysDecrypt => 1, # (necessary because FirmwareVersion is extracted after decryption time)
8980             SubDirectory => {
8981             TagTable => 'Image::ExifTool::Nikon::AutoCaptureInfo',
8982             Start => '$val',
8983             },
8984             },
8985             0x84 => {
8986             Name => 'OrientOffset',
8987             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96', #not valid for C30/C60/C120
8988             Format => 'int32u',
8989             SubDirectory => {
8990             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
8991             Start => '$val',
8992             },
8993             },
8994             0x8c => {
8995             Name => 'MenuOffset',
8996             Format => 'int32u',
8997             SubDirectory => {
8998             TagTable => 'Image::ExifTool::Nikon::MenuInfoZ9',
8999             Start => '$val',
9000             },
9001             },
9002             );
9003              
9004             # ref 28
9005             %Image::ExifTool::Nikon::SeqInfoZ9 = (
9006             %binaryDataAttrs,
9007             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9008             DATAMEMBER => [ 0x20, 0x28, 0x2a ],
9009             #0x0019 => HDRFrame # For JPG 0=> Not HDR; 1=> file is the blended exposure. For raw files: 0=> Not from an HDR capture sequence; otherwise frame number in the HDR capture sequence -- 'Save Individual Pictures (RAW)' must be enabled.
9010             #0x001A => MultipleExposureFrame # For JPG 0=> Not a multiple exposure; 1=> file is the blended exposure. For raw files: 0=> Not a multiple exposure capture; otherwise frame number in the capture sequence -- 'Save Individual Pictures (RAW)' must be enabled.
9011             0x0020 => {
9012             Name => 'FocusShiftShooting',
9013             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96', #not valid for C30/C60/C120
9014             RawConv => '$$self{FocusShiftShooting} = $val',
9015             PrintConv => q{
9016             return 'Off' if $val == 0 ;
9017             my $i = sprintf("Frame %.0f of %.0f",$val, $$self{FocusShiftNumberShots}); # something like Frame 1 of 100"
9018             if ($$self{PixelShiftActive} and $$self{PixelShiftActive} eq 1) {$i = sprintf("Frame %.0f",$val);} #for the Z8 fw3 with PixelShift Enabled, the frame count is correct, but the frame total needs to be multiplied by the number of PixelShift frames (which I cannot find)
9019             return "On: $i"
9020             },
9021             Hook => '$varSize += 2 if $$self{Model} =~ /^NIKON Z 8/ and $$self{FirmwareVersion} and $$self{FirmwareVersion} ge "03.00"', # 2 bytes were added with Z8 firmware 3.0 support for pixel shift when focus stacking
9022             },
9023             #
9024             # Note: Offsets after this are shifted by +2 for Z8 firmware 3.0 (see Hook above)
9025             #
9026             0x0028 => {
9027             Name => 'IntervalShooting', #will be 'On' when Interval Shooting is selected via the Photo Shooting Menu and also when a non-zero interval is specified when using Focus Shift and/or Pixel Shift Shooting
9028             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96', #not valid for C30/C60/C120
9029             RawConv => '$$self{IntervalShooting} = $val',
9030             Format => 'int16u',
9031             PrintConv => q{
9032             return 'Off' if $val == 0 ;
9033             my $i = sprintf("Interval %.0f of %.0f",$val, $$self{IntervalShootingIntervals}||0); # something like "Interval 1 of 3"
9034             my $f = ($$self{IntervalShootingShotsPerInterval}||0) > 1 ? sprintf(" Frame %.0f of %.0f",$$self{IntervalFrame}||0, $$self{IntervalShootingShotsPerInterval}||0): '' ; # something like "Frame 1 of 3" or blank
9035             return "On: $i$f"
9036             #$val == 0 ? 'Off' : sprintf("On: Interval %.0f of %.0f Frame %.0f of %.0f",$val, $$self{IntervalShootingIntervals}||0, $$self{IntervalFrame}||0, $$self{IntervalShootingShotsPerInterval}||0),
9037             },
9038             },
9039             0x002a => {
9040             Name => 'IntervalFrame',
9041             RawConv => '$$self{IntervalFrame} = $val',
9042             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0', #not valid for C30/C60/C120
9043             Format => 'int16u',
9044             #Hidden => 1,
9045             },
9046             );
9047              
9048             # ref 28
9049             %Image::ExifTool::Nikon::Offset13InfoZ9 = (
9050             %binaryDataAttrs,
9051             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9052             DATAMEMBER => [ 0x0bea, 0x0beb ],
9053             0x0be8 => {
9054             Name => 'AFAreaInitialXPosition', #the horizontal position of the center the focus box prior to any subject detection or tracking. Origin is Top Left.
9055             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96', #not valid for C30/C60/C120
9056             Format => 'int8s',
9057             PrintConv => q{
9058             my $imageArea = $$self{ImageArea};
9059             my $afAreaMode = $$self{VALUE}{AFAreaMode};
9060             my $dynamicAFAreaSize = ( defined $$self{DynamicAFAreaSize} ? $$self{DynamicAFAreaSize} : 0 );
9061              
9062             my $FX = 0; #image size 8256 x 5504
9063             my $DX = 1; #image size 5392 x 3592
9064             my $WideScreen = 4; #16:9 image area, image size 8256x4640
9065             my $OneToOne = 8; #1:1 image area, image size 5504x5504
9066              
9067             my $Single = 1;
9068             my $Dynamic = 2;
9069             my $WideS = 3;
9070             my $WideL = 4;
9071             my $ThreeD = 5;
9072             my $Auto = 6;
9073             my $WideC1 = 12;
9074              
9075             my $DynamicS = 0;
9076             my $DynamicM = 1;
9077             my $DynamicL = 2;
9078              
9079             my $start = 502; #FX, 16:9 & 1:1 formats
9080             my $increment = 259; #FX & 16:9 formats
9081              
9082             $start = $start + 5 * $increment if $imageArea == $OneToOne; # need to provide additional offset for the cropped horizontal pixels in 1:1 (19 vs 29 horizontal focus positions)
9083             $start = $start - $increment if $val < 49 and ($imageArea == $FX or $imageArea == $WideScreen); #calculations for the left side of the frames are offset by 1 position from the right side
9084             $start = $start - $increment if $imageArea == $OneToOne and $afAreaMode == $Auto;
9085              
9086             if ($imageArea == $DX) { # DX results are in FX coordinate system to match reporting of ($AFAreaXPosition , $AFAreaYPosition)
9087             $start = 636;
9088             $increment = 388;
9089             if ( $afAreaMode == $WideS ) { #Wide S focus box width is an unusual size
9090             $start = 591;
9091             $increment = 393;
9092             }
9093             $start = $start - $increment if $afAreaMode == $Auto ;
9094             }
9095              
9096             my $divisor = 3.99; #subtract .01 to ensure $val of 2n+2 rounds up
9097             $divisor = 4.01 if $val >= 50; #...but round up on the right side of the frame
9098             $divisor = 6 if $imageArea == $DX or $imageArea == $OneToOne;
9099              
9100             my $roundedValOverDivisor = sprintf("%.0f", $val / $divisor); #round to nearest int
9101              
9102             my $focusBoxWidth = $$self{AFAreaInitialWidth} ; #wider focus boxes (e.g., DynM, DynL and some Wide C1/C2) will start and end closer to the center of the frame
9103             $focusBoxWidth = int($focusBoxWidth * 2 / 3) if $imageArea == $DX or $imageArea == $OneToOne ;
9104              
9105             my $skipPositions = int($focusBoxWidth / 2); #jump over half the width of the focus box
9106              
9107             my $result = $start + $increment * ($roundedValOverDivisor + $skipPositions - 1 ) ;
9108              
9109             return $result;
9110             },
9111             },
9112             0x0be9 => {
9113             Name =>'AFAreaInitialYPosition', #the vertical position of the center the focus box prior to any subject detection or tracking. Origin is Top Left.
9114             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96', #not valid for C30/C60/C120 or for Area Modes 1:1 and 16:9
9115             Format => 'int8s',
9116             PrintConv => q{
9117             my $imageArea = $$self{ImageArea};
9118             my $afAreaMode = $$self{VALUE}{AFAreaMode};
9119              
9120             my $FX = 0; #image size 8256 x 5504
9121             my $DX = 1; #image size 5392 x 3592
9122             my $WideScreen = 4; #16:9 image area, image size 8256x4640
9123             my $OneToOne = 8; #1:1 image area, image size 5504x5504
9124              
9125             my $Single = 1;
9126             my $Dynamic = 2;
9127             my $WideS = 3;
9128             my $WideL = 4;
9129             my $ThreeD = 5;
9130             my $Auto = 6;
9131             my $WideC1 = 12;
9132              
9133             my $DynamicS = 0;
9134             my $DynamicM = 1;
9135             my $DynamicL = 2;
9136              
9137             my $start = 424; #FX, 16:9 & 1:1 formats
9138             my $increment = 291; #FX, & 16:9 formats
9139             $start = $start + $increment if $imageArea == $WideScreen and $val > 0;
9140              
9141             if ($imageArea == $DX) { # DX results are in FX coordinate system to match reporting of ($AFAreaXPosition , $AFAreaYPosition)
9142             $start = 572;
9143             $increment = 436;
9144             if ( $afAreaMode == $WideS ) { #Wide S focus box is a strange size
9145             $start = 542;
9146             $increment = 442;
9147             }
9148             }
9149              
9150             my $divisor = 6.67;
9151             $divisor = 10.01 if $imageArea == $DX ; #extra .01 to ensure $val of 10*n+5 rounds down
9152             $divisor = 8.01 if $imageArea == $WideScreen ;
9153              
9154             my $roundedValOverDivisor = sprintf("%.0f", $val / $divisor); #round to nearest int
9155              
9156             my $focusBoxHeight = $$self{AFAreaInitialHeight} ; #wider focus boxes (e.g., DynM, DynL and some Wide C1/C2) will start and end closer to the center of the frame
9157             $focusBoxHeight = int($focusBoxHeight * 2 / 3) if $imageArea == $DX ;
9158              
9159             my $skipPositions = int($focusBoxHeight / 2); #jump over half the height of the focus box
9160              
9161             my $result = $start + $increment * ($roundedValOverDivisor + $skipPositions - 1 ) ;
9162             return $result;
9163             },
9164             },
9165             0x0bea => {
9166             Name => 'AFAreaInitialWidth',
9167             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96', #not valid for C30/C60/C120
9168             RawConv => '$$self{AFAreaInitialWidth} = 1 + int ($val / 4)', #convert from [3, 11, 19, 35, 51, 75] to [1, 3, 5, 9 13, 19] to match camera options for C1/C2 focus modes .. input/output of 11/3 is for Wide(S)
9169             },
9170             0x0beb => {
9171             Name => 'AFAreaInitialHeight',
9172             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96', #not valid for C30/C60/C120
9173             RawConv => '$$self{AFAreaInitialHeight} = 1 + int ($val / 7) ', #convert from [6, 20, 33, 46, 73] to [1, 3, 5, 7, 11] to match camera options for C1/C2 focus modes .. input/output of 33/5 is for Wide(L)
9174             },
9175             );
9176              
9177             %Image::ExifTool::Nikon::MenuInfoZ8 = (
9178             %binaryDataAttrs,
9179             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9180             IS_SUBDIR => [ 0x10 ],
9181             # 0x00 - int32u size of this directory
9182             0x10 => [
9183             {
9184             Name => 'MenuSettingsOffsetZ8v1',
9185             Condition => '$$self{FirmwareVersion} and $$self{FirmwareVersion} lt "02.00"',
9186             Format => 'int32u',
9187             Notes => 'Firmware versions 1.00 and 1.10',
9188             SubDirectory => {
9189             TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ8v1',
9190             Start => '$dirStart + $val',
9191             },
9192             },
9193             {
9194             Name => 'MenuSettingsOffsetZ8v2',
9195             Condition => '$$self{FirmwareVersion} and $$self{FirmwareVersion} ge "02.00"',
9196             Notes => 'Firmware version 2.00 and 2.10',
9197             Format => 'int32u',
9198             SubDirectory => {
9199             TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ8v2',
9200             Start => '$dirStart + $val',
9201             },
9202             },
9203             ],
9204             );
9205              
9206             %Image::ExifTool::Nikon::MenuInfoZ9 = (
9207             %binaryDataAttrs,
9208             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9209             IS_SUBDIR => [ 0x10 ],
9210             # 0x00 - int32u size of this directory
9211             0x10 => [
9212             {
9213             Name => 'MenuSettingsOffsetZ9',
9214             Condition => '$$self{FirmwareVersion} and $$self{FirmwareVersion} lt "03.00"',
9215             Format => 'int32u',
9216             Notes => 'Firmware versions 2.11 and earlier',
9217             SubDirectory => {
9218             TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ9',
9219             Start => '$dirStart + $val',
9220             },
9221             },
9222             {
9223             Name => 'MenuSettingsOffsetZ9v3',
9224             Condition => '$$self{FirmwareVersion} and $$self{FirmwareVersion} lt "04.00"',
9225             Notes => 'Firmware versions 3.00 and v3.10',
9226             Format => 'int32u',
9227             SubDirectory => {
9228             TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ9v3',
9229             Start => '$dirStart + $val',
9230             },
9231             },
9232             {
9233             Name => 'MenuSettingsOffsetZ9v4',
9234             Notes => 'Firmware versions 4.00 and higher',
9235             Format => 'int32u',
9236             SubDirectory => {
9237             TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ9v4',
9238             Start => '$dirStart + $val',
9239             },
9240             },
9241             ],
9242             );
9243              
9244             %Image::ExifTool::Nikon::AutoCaptureInfo = (
9245             %binaryDataAttrs,
9246             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9247             DATAMEMBER => [ 0 ],
9248             0 => {
9249             Name => 'AutoCapturedFrame',
9250             RawConv => '$$self{AutoCapturedFrame} = $val',
9251             PrintConv => {
9252             0 => 'No',
9253             5 => 'Yes',
9254             },
9255             },
9256             1 => {
9257             Name => 'AutoCaptureCriteria',
9258             Condition => '$$self{AutoCapturedFrame} and $$self{AutoCapturedFrame} ne 0',
9259             PrintConv => q[
9260             $_ = '';
9261             return $_ . Image::ExifTool::DecodeBits($val,
9262             {
9263             0 => 'Distance',
9264             1 => 'Motion',
9265             2 => 'Subject Detection',
9266             });
9267             ],
9268             },
9269             # offsets 3-52 contain a bitmap of the focus points enabled when AutoArea is the AF-Area Mode. 0=> disabled, 1=> enabled. Focus points are in a grid with dimensions 25x15.
9270             55 => {
9271             Name => 'AutoCaptureRecordingTime',
9272             Condition => '$$self{AutoCapturedFrame} and $$self{AutoCapturedFrame} ne 0',
9273             PrintConv => {
9274             0 => '1 Sec',
9275             1 => '3 Sec',
9276             2 => '5 Sec',
9277             #3 => '',
9278             4 => '30 Sec',
9279             5 => 'No Limit',
9280             6 => '2 Sec',
9281             7 => '10 Sec',
9282             8 => '20 Sec',
9283             9 => '1 Min',
9284             10 => '3 Min',
9285             11 => '5 Min',
9286             12 => '10 Min',
9287             13 => '30 Min',
9288             },
9289             },
9290             56 => {
9291             Name => 'AutoCaptureWaitTime',
9292             Condition => '$$self{AutoCapturedFrame} and $$self{AutoCapturedFrame} ne 0',
9293             PrintConv => {
9294             0 => 'No Wait',
9295             1 => '10 Sec',
9296             2 => '30 Sec',
9297             3 => '1 Min',
9298             4 => '5 Min',
9299             5 => '10 Min',
9300             6 => '30 Min',
9301             7 => '1 Sec',
9302             8 => '2 Sec',
9303             9 => '3 Sec',
9304             10 => '5 Sec',
9305             11 => '20 Sec',
9306             12 => '3 Min',
9307             },
9308             },
9309             74 => {
9310             Name => 'AutoCaptureDistanceFar',
9311             Condition => '$$self{AutoCapturedFrame} and $$self{AutoCapturedFrame} ne 0',
9312             PrintConv => 'sprintf("%.1f m", $val/10)',
9313             },
9314             78 => {
9315             Name => 'AutoCaptureDistanceNear',
9316             Condition => '$$self{AutoCapturedFrame} and $$self{AutoCapturedFrame} ne 0',
9317             PrintConv => 'sprintf("%.1f m", $val/10)',
9318             },
9319             95 => {
9320             Name => 'AutoCaptureCriteriaMotionDirection',
9321             Condition => '$$self{AutoCapturedFrame} and $$self{AutoCapturedFrame} ne 0',
9322             PrintConv => q[
9323             return 'All' if $val eq 255;
9324             $_ = '';
9325             return $_ . Image::ExifTool::DecodeBits($val,
9326             {
9327             0 => 'Top Left',
9328             1 => 'Top Right',
9329             2 => 'Bottom Left',
9330             3 => 'Bottom Right',
9331             4 => 'Left',
9332             5 => 'Right',
9333             6 => 'Top Center',
9334             7 => 'Bottom Center',
9335             });
9336             ],
9337             },
9338             99 => {
9339             Name => 'AutoCaptureCriteriaMotionSpeed', #1-5
9340             Condition => '$$self{AutoCapturedFrame} and $$self{AutoCapturedFrame} ne 0',
9341             },
9342             100 => {
9343             Name => 'AutoCaptureCriteriaMotionSize', #1-5
9344             Condition => '$$self{AutoCapturedFrame} and $$self{AutoCapturedFrame} ne 0',
9345             },
9346             105 => {
9347             Name => 'AutoCaptureCriteriaSubjectSize', #1-5
9348             Condition => '$$self{AutoCapturedFrame} and $$self{AutoCapturedFrame} ne 0',
9349             },
9350             106 => {
9351             Name => 'AutoCaptureCriteriaSubjectType',
9352             Condition => '$$self{AutoCapturedFrame} and $$self{AutoCapturedFrame} ne 0',
9353             ValueConv => '$val + 1', # change value range to align with %subjectDetectionZ9
9354             ValueConvInv => '$val - 1',
9355             PrintConv => \%subjectDetectionZ9,
9356             },
9357             );
9358              
9359             %Image::ExifTool::Nikon::OrientationInfo = (
9360             %binaryDataAttrs,
9361             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9362             0 => {
9363             Name => 'RollAngle',
9364             Format => 'fixed32u',
9365             Notes => 'converted to degrees of clockwise camera roll',
9366             ValueConv => '$val <= 180 ? $val : $val - 360',
9367             ValueConvInv => '$val >= 0 ? $val : $val + 360',
9368             PrintConv => 'sprintf("%.1f", $val)',
9369             PrintConvInv => '$val',
9370             },
9371             4 => {
9372             Name => 'PitchAngle',
9373             Format => 'fixed32u',
9374             Notes => 'converted to degrees of upward camera tilt',
9375             ValueConv => '$val <= 180 ? $val : $val - 360',
9376             ValueConvInv => '$val >= 0 ? $val : $val + 360',
9377             PrintConv => 'sprintf("%.1f", $val)',
9378             PrintConvInv => '$val',
9379             },
9380             8 => {
9381             Name => 'YawAngle',
9382             Format => 'fixed32u',
9383             Notes => 'the camera yaw angle when shooting in portrait orientation',
9384             ValueConv => '$val <= 180 ? $val : $val - 360',
9385             ValueConvInv => '$val >= 0 ? $val : $val + 360',
9386             PrintConv => 'sprintf("%.1f", $val)',
9387             PrintConvInv => '$val',
9388             },
9389             );
9390              
9391             %Image::ExifTool::Nikon::MenuSettingsZ6III = (
9392             %binaryDataAttrs,
9393             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9394             NOTES => 'These tags are used by the Z6III.',
9395             DATAMEMBER => [ 360, 444, 492, 496, 724, 748, 832, 838, 852, 880, 904, 1050 ],
9396             IS_SUBDIR => [ 1255 ],
9397             360 => {
9398             Name => 'SingleFrame', #0=> Single Frame 1=> one of the continuous modes
9399             #Hidden => 1,
9400             RawConv => '$$self{SingleFrame} = $val',
9401             },
9402             364 => {
9403             Name => 'HighFrameRate', #CH and C30/C60/C120 but not CL
9404             PrintConv => \%highFrameRateZ9,
9405             },
9406             444 => {
9407             Name => 'MultipleExposureMode',
9408             RawConv => '$$self{MultipleExposureMode} = $val',
9409             PrintConv => \%multipleExposureModeZ9,
9410             },
9411             446 => {Name => 'MultiExposureShots', Condition => '$$self{MultipleExposureMode} != 0'}, #range 2-9
9412             476 => {
9413             Name => 'IntervalDurationHours',
9414             Format => 'int32u',
9415             },
9416             480 => {
9417             Name => 'IntervalDurationMinutes',
9418             Format => 'int32u',
9419             },
9420             484 => {
9421             Name => 'IntervalDurationSeconds',
9422             Format => 'int32u',
9423             },
9424             492 => {
9425             Name => 'Intervals',
9426             Format => 'int32u',
9427             RawConv => '$$self{IntervalShootingIntervals} = $val',
9428             },
9429             496 => {
9430             Name => 'ShotsPerInterval',
9431             Format => 'int32u',
9432             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
9433             },
9434             500 => {
9435             Name => 'IntervalExposureSmoothing',
9436             Format => 'int8u',
9437             PrintConv => \%offOn,
9438             },
9439             502 => {
9440             Name => 'IntervalPriority',
9441             Format => 'int8u',
9442             PrintConv => \%offOn,
9443             },
9444             536 => {
9445             Name => 'FocusShiftNumberShots',
9446             },
9447             540 => {
9448             Name => 'FocusShiftStepWidth',
9449             },
9450             544 => {
9451             Name => 'FocusShiftInterval',
9452             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
9453             },
9454             548 => {
9455             Name => 'FocusShiftExposureLock',
9456             PrintConv => \%offOn,
9457             },
9458             648 => { Name => 'AutoISO', PrintConv => \%offOn },
9459             650 => {
9460             Name => 'ISOAutoHiLimit',
9461             Format => 'int16u',
9462             Unknown => 1,
9463             ValueConv => '($val-104)/8',
9464             ValueConvInv => '8 * ($val + 104)',
9465             PrintConv => \%iSOAutoHiLimitZ6III,
9466             },
9467             #652 => ISOAutoFlashLimit # only when ISOAutoFlashLimitSameAsHiLimit == 0
9468             #654 => ISOAutoFlashLimitSameAsHiLimit 1=> Same as ISOAutoHiLimit 0=> Separate (use ISOAutoFlashLimit)
9469             718 => {
9470             Name => 'DiffractionCompensation',
9471             Format => 'int8u',
9472             PrintConv => \%offOn,
9473             },
9474             719 => {
9475             Name => 'AutoDistortionControl',
9476             Format => 'int8u',
9477             PrintConv => \%offOn,
9478             },
9479             720 => { Name => 'FlickerReductionShooting',PrintConv => \%offOn },
9480             722 => { Name => 'NikonMeteringMode', PrintConv => \%meteringModeZ7},
9481             724 => {
9482             Name => 'FlashControlMode',
9483             RawConv => '$$self{FlashControlMode} = $val',
9484             PrintConv => \%flashControlModeZ7,
9485             },
9486             730 => {
9487             Name => 'FlashGNDistance',
9488             Condition => '$$self{FlashControlMode} == 2',
9489             Unknown => 1,
9490             ValueConv => '$val + 3',
9491             PrintConv => \%flashGNDistance,
9492             },
9493             734 => {
9494             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)
9495             Condition => '$$self{FlashControlMode} >= 3',
9496             Unknown => 1,
9497             ValueConv => '2 ** (-$val/3)',
9498             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
9499             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
9500             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9501             },
9502             742 => { Name => 'FlashWirelessOption', PrintConv => \%flashWirelessOptionZ7, Unknown => 1 },
9503             744 => { Name => 'FlashRemoteControl', PrintConv => \%flashRemoteControlZ7, Unknown => 1 },
9504             748 => {
9505             Name => 'FlashMasterControlMode', # tag name chosen for compatibility with those found in FlashInfo0102 & FlashInfo0103
9506             RawConv => '$$self{FlashGroupOptionsMasterMode} = $val',
9507             PrintConv => \%flashGroupOptionsMode,
9508             },
9509             750 => {
9510             Name => 'FlashMasterCompensation',
9511             Format => 'int8s',
9512             Condition => '$$self{FlashGroupOptionsMasterMode} != 3', # other than 'Off'
9513             Unknown => 1,
9514             ValueConv => '$val/6',
9515             ValueConvInv => '6 * $val',
9516             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9517             PrintConvInv => '$val',
9518             },
9519             754 => {
9520             Name => 'FlashMasterOutput',
9521             Unknown => 1,
9522             Condition => '$$self{FlashGroupOptionsMasterMode} == 1', # only for Mode=M
9523             ValueConv => '2 ** (-$val/3)',
9524             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
9525             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
9526             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9527             },
9528             832 => { Name => 'AFAreaMode', RawConv => '$$self{AFAreaMode} = $val', PrintConv => \%aFAreaModeZ9},
9529             834 => { Name => 'VRMode', PrintConv => \%vRModeZ9},
9530             838 => {
9531             Name => 'BracketSet',
9532             RawConv => '$$self{BracketSet} = $val',
9533             PrintConv => \%bracketSetZ9,
9534             },
9535             840 => {
9536             Name => 'BracketProgram',
9537             Condition => '$$self{BracketSet} < 3',
9538             Notes => 'AE and/or Flash Bracketing',
9539             PrintConv => \%bracketProgramZ9,
9540             },
9541             842 => {
9542             Name => 'BracketIncrement',
9543             Condition => '$$self{BracketSet} < 3',
9544             Notes => 'AE and/or Flash Bracketing',
9545             PrintConv => \%bracketIncrementZ9,
9546             },
9547             852 => { Name => 'HDR', RawConv => '$$self{HDR} = $val', PrintConv => \%multipleExposureModeZ9 },
9548             858 => { Name => 'SecondarySlotFunction', PrintConv => \%secondarySlotFunctionZ9 },
9549             864 => { Name => 'HDRLevel', Condition => '$$self{HDR} ne 0', PrintConv => \%hdrLevelZ8 },
9550             868 => { Name => 'Slot2JpgSize', PrintConv => { 0 => 'Large (6048x4032)', 1 => 'Medium (4528x3024)', 2 => 'Small (3024x2016)' }, Unknown => 1},
9551             878 => { Name => 'SubjectDetection', PrintConv => \%subjectDetectionZ9 },
9552             880 => {
9553             Name => 'DynamicAFAreaSize',
9554             Condition => '$$self{AFAreaMode} == 2',
9555             RawConv => '$$self{DynamicAFAreaSize} = $val',
9556             PrintConv => \%dynamicAfAreaModesZ9,
9557             },
9558             884 => { Name => 'ToneMap', PrintConv => { 0 => 'SDR', 1 => 'HLG' }, Unknown => 1 },
9559             888 => { Name => 'PortraitImpressionBalance', PrintConv => \%portraitImpressionBalanceZ8 },
9560             902 => { Name => 'HighFrequencyFlickerReduction', PrintConv => \%offOn, Unknown => 1 },
9561             904 => { Name => 'PixelShiftShooting', RawConv => '$$self{PixelShiftShooting} = $val', PrintConv => \%multipleExposureModeZ9 }, #off/on/on (series)
9562             906 => { Name => 'PixelShiftNumberShots', Condition => '$$self{PixelShiftShooting} > 0', PrintConv => \%pixelShiftNumberShots },
9563             908 => { Name => 'PixelShiftDelay', Condition => '$$self{PixelShiftShooting} > 0', PrintConv => '$val == 0? "No Delay" : sprintf("%.0f sec",$val)' }, #seconds in set {0,1,2,3,5,10}
9564             910 => { Name => 'PixelShiftInterval', Condition => '$$self{PixelShiftShooting} > 0', PrintConv => '$val == 0? "No Delay" : sprintf("%.0f sec",$val)' }, #seconds in integer range [0,30]
9565             1002 => { Name => 'SubjectDetectionAreaMF', PrintConv => \%subjectDetectionAreaMZ6III }, #new tag with Z6III
9566             1004 => { Name => 'LinkVRToFocusPoint', PrintConv => \%offOn, Unknown => 1 }, #new tag with Z6III
9567             #1044 => { Name => 'MovieFrameRateH264',PrintConv => \%movieFrameRateZ6III, Unknown => 1 }, #new tag with Z6III - only valid for H.264, frame rates for other movie types are at 1164
9568             1046 => { Name => 'MovieSlowMotion', PrintConv => \%movieSlowMotion, Unknown => 1 },
9569             1050 => { Name => 'MovieType', RawConv => '$$self{MovieType} = $val' , PrintConv => \%movieTypeZ9},
9570             1162 => { Name => 'MovieFrameSize', PrintConv => \%movieFrameSizeZ9, Unknown => 1 },
9571             1164 => { Name => 'MovieFrameRate', Condition => '$$self{MovieType} != 1', PrintConv => \%movieFrameRateZ6III, Unknown => 1 },
9572             1255 => {
9573             Name => 'CustomSettingsZ6III',
9574             Format => 'undef[700]',
9575             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsZ6III' },
9576             },
9577             2300 => { Name => 'Language', PrintConv => \%languageZ9, Unknown => 1 },
9578             2302 => { Name => 'TimeZone', PrintConv => \%timeZoneZ9, SeparateTable => 'TimeZone' },
9579             2308 => { Name => 'MonitorBrightness', PrintConv => \%monitorBrightnessZ9, Unknown => 1 }, # settings: -5 to +5 and Lo1, Lo2, Hi1, Hi2
9580             2444 => { Name => 'EmptySlotRelease', PrintConv => { 0 => 'Disable Release', 1 => 'Enable Release' }, Unknown => 1 },
9581             2450 => { Name => 'EnergySavingMode', PrintConv => \%offOn, Unknown => 1 },
9582             2476 => { Name => 'USBPowerDelivery', PrintConv => \%offOn, Unknown => 1 },
9583             2480 => { Name => 'SaveFocusPosition', PrintConv => \%offOn, Unknown => 1 },
9584             2487 => { Name => 'SilentPhotography', PrintConv => \%offOn, Unknown => 1 },
9585             2496 => { Name => 'AirplaneMode', PrintConv => \%offOn, Unknown => 1 },
9586             ),
9587              
9588             %Image::ExifTool::Nikon::MenuSettingsZ7II = (
9589             %binaryDataAttrs,
9590             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9591             DATAMEMBER => [ 90, 176, 180, 328, 352, 858 ],
9592             NOTES => 'These tags are used by the Z5, Z6, Z7, Z6II, Z7II, Z50, Zfc and Zf.',
9593             #48 SelfTimer' #0=> no 1=> yes works for Z7II firmware 1.40, but not 1.30. Follow-up required.
9594             90 => {
9595             Name => 'SingleFrame', #0=> Single Frame 1=> one of the continuous modes
9596             #Hidden => 1,
9597             RawConv => '$$self{SingleFrame} = $val',
9598             },
9599             92 => {
9600             Name => 'ReleaseMode',
9601             #ValueConv => '$$self{SelfTimer} == 1 ? 4 : $$self{SingleFrame} == 0 ? 5 : $val', #map single frame and timer to a unique values for PrintConv. Activate when SelfTimer tag is clarified for cameras other than Z7II fw 1.40
9602             ValueConv => '$$self{SingleFrame} == 0 ? 5 : $val', #map single frame to a unique value for PrintConv
9603             PrintConv => \%releaseModeZ7,
9604             },
9605             160 => {
9606             Name => 'IntervalDurationHours',
9607             Format => 'int32u',
9608             #Condition => '$$self{IntervalShooting} > 0',
9609             },
9610             164 => {
9611             Name => 'IntervalDurationMinutes',
9612             Format => 'int32u',
9613             #Condition => '$$self{IntervalShooting} > 0',
9614             },
9615             168 => {
9616             Name => 'IntervalDurationSeconds',
9617             Format => 'int32u',
9618             #Condition => '$$self{IntervalShooting} > 0',
9619             },
9620             176 => {
9621             Name => 'Intervals',
9622             Format => 'int32u',
9623             RawConv => '$$self{IntervalShootingIntervals} = $val',
9624             #Condition => '$$self{IntervalShooting} > 0',
9625             },
9626             180 => {
9627             Name => 'ShotsPerInterval',
9628             Format => 'int32u',
9629             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
9630             #Condition => '$$self{IntervalShooting} > 0',
9631             },
9632             184 => {
9633             Name => 'IntervalExposureSmoothing',
9634             #Condition => '$$self{IntervalShooting} > 0',
9635             Format => 'int8u',
9636             PrintConv => \%offOn,
9637             },
9638             186 => {
9639             Name => 'IntervalPriority',
9640             #Condition => '$$self{IntervalShooting} > 0',
9641             Format => 'int8u',
9642             PrintConv => \%offOn,
9643             },
9644             220 => {
9645             Name => 'FocusShiftNumberShots',
9646             },
9647             224 => {
9648             Name => 'FocusShiftStepWidth',
9649             },
9650             228 => {
9651             Name => 'FocusShiftInterval',
9652             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
9653             },
9654             232 => {
9655             Name => 'FocusShiftExposureLock',
9656             PrintConv => \%offOn,
9657             },
9658             #304 => White Balance - Kelvin Temp
9659             #312 => ColorSpace
9660             #314 => ActiveD-Lighting
9661             #318 => HighISONoiseReduction
9662             322 => {
9663             Name => 'DiffractionCompensation',
9664             Format => 'int8u',
9665             PrintConv => \%offOn,
9666             },
9667             323 => {
9668             Name => 'AutoDistortionControl',
9669             Format => 'int8u',
9670             PrintConv => \%offOn,
9671             },
9672             #324 => {Name => 'FlickerReductionShooting',}, # redundant with tag in NikonSettings
9673             326 => { Name => 'NikonMeteringMode', PrintConv => \%meteringModeZ7 },
9674             328 => {
9675             Name => 'FlashControlMode', # this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
9676             RawConv => '$$self{FlashControlMode} = $val',
9677             PrintConv => \%flashControlModeZ7,
9678             },
9679             334 => {
9680             Name => 'FlashGNDistance',
9681             Condition => '$$self{FlashControlMode} == 2',
9682             Unknown => 1,
9683             ValueConv => '$val + 3',
9684             PrintConv => \%flashGNDistance,
9685             },
9686             338 => {
9687             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)
9688             Condition => '$$self{FlashControlMode} >= 3',
9689             Unknown => 1,
9690             ValueConv => '2 ** (-$val/3)',
9691             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
9692             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
9693             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9694             },
9695             346 => { Name => 'FlashWirelessOption', PrintConv => \%flashWirelessOptionZ7, Unknown => 1 },
9696             348 => { Name => 'FlashRemoteControl', PrintConv => \%flashRemoteControlZ7, Unknown => 1 },
9697             352 => {
9698             Name => 'FlashMasterControlMode', # tag name chosen for compatibility with those found in FlashInfo0102 & FlashInfo0103
9699             RawConv => '$$self{FlashGroupOptionsMasterMode} = $val',
9700             PrintConv => \%flashGroupOptionsMode,
9701             },
9702             354 => {
9703             Name => 'FlashMasterCompensation',
9704             Format => 'int8s',
9705             Condition => '$$self{FlashGroupOptionsMasterMode} != 3', # other than 'Off'
9706             Unknown => 1,
9707             ValueConv => '$val/6',
9708             ValueConvInv => '6 * $val',
9709             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9710             PrintConvInv => '$val',
9711             },
9712             358 => {
9713             Name => 'FlashMasterOutput',
9714             Unknown => 1,
9715             Condition => '$$self{FlashGroupOptionsMasterMode} == 1', # only for Mode=M
9716             ValueConv => '2 ** (-$val/3)',
9717             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
9718             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
9719             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9720             },
9721             #360 => { Name => 'FlashGroupAControlMode' }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupACompensation at 362 and FlashGroupAOutput at 368
9722             #368 => { Name => 'FlashGroupBControlMode' }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupBCompensation at 370 and FlashGroupBOutput at 374
9723             #376 => { Name => 'FlashGroupCControlMode' }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupCCompensation at 378 and FlashGroupCOutput at 382
9724             #384 => { Name => 'FlashGroupDControlMode' }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupDCompensation at 386 and FlashGroupDOutput at 390
9725             #392 => { Name => 'FlashGroupEControlMode' }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupECompensation at 394 and FlashGroupEOutput at 398
9726             #400 => { Name => 'FlashGroupFControlMode' }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupFCompensation at 402 and FlashGroupFOutput at 406
9727             #434 => FocusMode
9728             #436 => AFAreaMode
9729             #438 => VibrationReduction
9730             #442 => BracketSet
9731             #444 => BracketProgram
9732             #446 => BracketIncrement
9733             #463 => SilentPhotography
9734             502 => { Name => 'MovieFrameSize', PrintConv => \%movieFrameSizeZ9, Unknown => 1 },
9735             504 => { Name => 'MovieFrameRate', PrintConv => \%movieFrameRateZ7, Unknown => 1 },
9736             506 => { Name => 'MovieSlowMotion', PrintConv => \%movieSlowMotion, Unknown => 1 },
9737             510 => {
9738             Name => 'MovieType',
9739             Unknown => 1,
9740             PrintConv => {
9741             0 => 'MOV',
9742             1 => 'MP4',
9743             },
9744             },
9745             #512 => MovieISOAutoHiLimit
9746             516 => {
9747             Name => 'MovieISOAutoManualMode',
9748             Condition => '$$self{Model} =~ /^NIKON 7/', #ISO ranges vary by model. These mappings are for the Z7 and Z7II
9749             %isoAutoHiLimitZ7,
9750             },
9751             #520 => MovieWhiteBalanceSameAsPhoto
9752             568 => { Name => 'MovieActiveD-Lighting', PrintConv => \%activeDLightingZ7, Unknown => 1 },
9753             572 => { Name => 'MovieHighISONoiseReduction', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
9754             574 => { Name => 'MovieVignetteControl', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
9755             576 => {
9756             Name => 'MovieVignetteControlSameAsPhoto',
9757             Unknown => 1,
9758             PrintConv => \%noYes
9759             },
9760             577 => {
9761             Name => 'MovieDiffractionCompensation',
9762             Unknown => 1,
9763             PrintConv => \%offOn
9764             },
9765             578 => {
9766             Name => 'MovieAutoDistortionControl',
9767             Unknown => 1,
9768             PrintConv => \%offOn
9769             },
9770             584 => { Name => 'MovieFocusMode', PrintConv => \%focusModeZ7, Unknown => 1 },
9771             #586 => MovieAFAreaMode
9772             590 => {
9773             Name => 'MovieVibrationReduction',
9774             Unknown => 1,
9775             PrintConv => {
9776             0 => 'Off',
9777             1 => 'On (Normal)',
9778             2 => 'On (Sport)',
9779             },
9780             },
9781             591 => {
9782             Name => 'MovieVibrationReductionSameAsPhoto',
9783             Unknown => 1,
9784             PrintConv => \%noYes
9785             },
9786             #848 => HDMIOutputResolution
9787             #850 => HDMIOutputRange
9788             #854 => HDMIExternalRecorder
9789             #856 => HDMIBitDepth
9790             858 => {
9791             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
9792             Condition => '$$self{HDMIBitDepth} and $$self{HDMIBitDepth} == 2', # only for 10 bit
9793             RawConv => '$$self{HDMIOutputNLog} = $val',
9794             Unknown => 1,
9795             PrintConv => \%offOn,
9796             },
9797             #859 => HDMIViewAssist
9798             );
9799              
9800             %Image::ExifTool::Nikon::MenuSettingsZ8 = (
9801             %binaryDataAttrs,
9802             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9803             DATAMEMBER => [ 72, 152, 200, 204, 244, 440, 548, 554, 570, 596, 636 ],
9804             NOTES => 'These tags are common to all Z8 firmware versions.',
9805             72 => {
9806             Name => 'HighFrameRate', #CH and C30/C60/C120 but not CL
9807             PrintConv => \%highFrameRateZ9,
9808             Hook => '$varSize += 4 if $$self{FirmwareVersion} and $$self{FirmwareVersion} ge "02.10"',
9809             },
9810             #
9811             # firmware 2.10 adds 4 bytes somewhere in the range 105-107 (hence the Hook above)
9812             #
9813             152 => {
9814             Name => 'MultipleExposureMode',
9815             RawConv => '$$self{MultipleExposureMode} = $val',
9816             PrintConv => \%multipleExposureModeZ9,
9817             },
9818             154 => {Name => 'MultiExposureShots', Condition => '$$self{MultipleExposureMode} != 0'}, #range 2-9 - not present in a NEF, only in the assembled JPG
9819             184 => {
9820             Name => 'IntervalDurationHours',
9821             Format => 'int32u',
9822             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0',
9823             },
9824             188 => {
9825             Name => 'IntervalDurationMinutes',
9826             Format => 'int32u',
9827             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0',
9828             },
9829             192 => {
9830             Name => 'IntervalDurationSeconds',
9831             Format => 'int32u',
9832             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0',
9833             },
9834             200 => {
9835             Name => 'Intervals',
9836             Format => 'int32u',
9837             RawConv => '$$self{IntervalShootingIntervals} = $val',
9838             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0',
9839             },
9840             204 => {
9841             Name => 'ShotsPerInterval',
9842             Format => 'int32u',
9843             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
9844             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0',
9845             },
9846             208 => {
9847             Name => 'IntervalExposureSmoothing',
9848             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0',
9849             Format => 'int8u',
9850             PrintConv => \%offOn,
9851             },
9852             210 => {
9853             Name => 'IntervalPriority',
9854             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0',
9855             Format => 'int8u',
9856             PrintConv => \%offOn,
9857             },
9858             244 => {
9859             Name => 'FocusShiftNumberShots', #1-300
9860             RawConv => '$$self{FocusShiftNumberShots} = $val',
9861             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
9862             },
9863             248 => {
9864             Name => 'FocusShiftStepWidth', #1(Narrow) to 10 (Wide)
9865             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
9866             },
9867             252 => {
9868             Name => 'FocusShiftInterval',
9869             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
9870             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
9871             },
9872             256 => {
9873             Name => 'FocusShiftExposureLock',
9874             Unknown => 1,
9875             PrintConv => \%offOn,
9876             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
9877             },
9878             286 => { Name => 'PhotoShootingMenuBank', PrintConv => \%banksZ9 },
9879             288 => { Name => 'ExtendedMenuBanks', PrintConv => \%offOn }, # single tag from both Photo & Video menus
9880             324 => { Name => 'PhotoShootingMenuBankImageArea', PrintConv => \%imageAreaZ9 },
9881             338 => { Name => 'AutoISO', PrintConv => \%offOn },
9882             340 => { Name => 'ISOAutoHiLimit', %isoAutoHiLimitZ7 },
9883             342 => { Name => 'ISOAutoFlashLimit', %isoAutoHiLimitZ7 },
9884             350 => {
9885             Name => 'ISOAutoShutterTime', # shutter speed is 2 ** (-$val/24)
9886             ValueConv => '$val / 8',
9887             Format => 'int16s',
9888             PrintConv => \%iSOAutoShutterTimeZ9,
9889             },
9890             432 => { Name => 'MovieVignetteControl', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
9891             434 => { Name => 'DiffractionCompensation', PrintConv => \%offOn }, # value can be set from both the Photo Shoot Menu and the Video Shooting Menu
9892             436 => { Name => 'FlickerReductionShooting',PrintConv => \%offOn },
9893             440 => {
9894             Name => 'FlashControlMode', # this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
9895             RawConv => '$$self{FlashControlMode} = $val',
9896             PrintConv => \%flashControlModeZ7,
9897             },
9898             548 => { Name => 'AFAreaMode', RawConv => '$$self{AFAreaMode} = $val', PrintConv => \%aFAreaModeZ9},
9899             550 => { Name => 'VRMode', PrintConv => \%vRModeZ9},
9900             554 => {
9901             Name => 'BracketSet',
9902             RawConv => '$$self{BracketSet} = $val',
9903             PrintConv => \%bracketSetZ9,
9904             },
9905             556 => {
9906             Name => 'BracketProgram',
9907             Condition => '$$self{BracketSet} < 3',
9908             Notes => 'AE and/or Flash Bracketing',
9909             PrintConv => \%bracketProgramZ9,
9910             },
9911             558 => {
9912             Name => 'BracketIncrement',
9913             Condition => '$$self{BracketSet} < 3',
9914             Notes => 'AE and/or Flash Bracketing',
9915             PrintConv => \%bracketIncrementZ9,
9916             },
9917             570 => { Name => 'HDR', RawConv => '$$self{HDR} = $val', PrintConv => \%multipleExposureModeZ9 }, #will be 'on' for the tone mapped JPGs, off for the source NEF files
9918             #572 HDRSaveRaw 0=> No; 1=> Yes
9919             576 => { Name => 'SecondarySlotFunction', PrintConv => \%secondarySlotFunctionZ9 },
9920             582 => { Name => 'HDRLevel', Condition => '$$self{HDR} ne 0', PrintConv => \%hdrLevelZ8 },
9921             586 => { Name => 'Slot2JpgSize', PrintConv => { 0 => 'Large (8256x5504)', 1 => 'Medium (6192x4128)', 2 => 'Small (4128x2752)' }, Unknown => 1},
9922             592 => { Name => 'DXCropAlert', PrintConv => \%offOn },
9923             594 => { Name => 'SubjectDetection', PrintConv => \%subjectDetectionZ9 },
9924             596 => {
9925             Name => 'DynamicAFAreaSize',
9926             Condition => '$$self{AFAreaMode} == 2',
9927             RawConv => '$$self{DynamicAFAreaSize} = $val',
9928             PrintConv => \%dynamicAfAreaModesZ9,
9929             },
9930             618 => { Name => 'ToneMap', PrintConv => { 0 => 'SDR', 1 => 'HLG' }, Unknown => 1 },
9931             622 => { Name => 'PortraitImpressionBalance', PrintConv => \%portraitImpressionBalanceZ8 },
9932             636 => {
9933             Name => 'HighFrequencyFlickerReduction',
9934             PrintConv => \%offOn,
9935             # Unknown => 1, (can't have Unknown tag with a Hook)
9936             Hook => '$varSize += 4 if $$self{FirmwareVersion} and $$self{FirmwareVersion} ge "03.00"',
9937             },
9938             #
9939             # firmware 3.00 adds 4 bytes somewhere in the range 638-730 (hence the Hook above)
9940             #
9941             730 => {
9942             Name => 'MovieImageArea',
9943             Unknown => 1,
9944             Mask => 0x01, # without the mask 4 => 'FX' 5 => DX only the 2nd Z-series field encountered with a mask.
9945             PrintConv => \%imageAreaZ9b,
9946             },
9947             740 => { Name => 'MovieType', PrintConv => \%movieTypeZ9, Unknown => 1 },
9948             742 => { Name => 'MovieISOAutoHiLimit', %isoAutoHiLimitZ7 },
9949             744 => { Name => 'MovieISOAutoControlManualMode', PrintConv => \%offOn, Unknown => 1 },
9950             746 => { Name => 'MovieISOAutoManualMode', %isoAutoHiLimitZ7 },
9951             820 => { Name => 'MovieActiveD-Lighting', PrintConv => \%activeDLightingZ7, Unknown => 1 },
9952             822 => { Name => 'MovieHighISONoiseReduction', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
9953             828 => { Name => 'MovieFlickerReduction', PrintConv => \%movieFlickerReductionZ9 },
9954             830 => { Name => 'MovieMeteringMode', PrintConv => \%meteringModeZ7, Unknown => 1 },
9955             832 => { Name => 'MovieFocusMode', PrintConv => \%focusModeZ7, Unknown => 1 },
9956             834 => { Name => 'MovieAFAreaMode', PrintConv => \%aFAreaModeZ9 },
9957             836 => { Name => 'MovieVRMode', PrintConv => \%vRModeZ9, Unknown => 1 },
9958             840 => { Name => 'MovieElectronicVR', PrintConv => \%offOn, Unknown => 1 }, # distinct from MoveieVRMode
9959             842 => { Name => 'MovieSoundRecording', PrintConv => { 0 => 'Off', 1 => 'Auto', 2 => 'Manual' }, Unknown => 1 },
9960             844 => { Name => 'MicrophoneSensitivity', Unknown => 1 }, # 1-20
9961             846 => { Name => 'MicrophoneAttenuator', PrintConv => \%offOn, Unknown => 1 }, # distinct from MoveieVRMode
9962             848 => { Name => 'MicrophoneFrequencyResponse',PrintConv => { 0 => 'Wide Range', 1 => 'Vocal Range' }, Unknown => 1 },
9963             850 => { Name => 'WindNoiseReduction', PrintConv => \%offOn, Unknown => 1 },
9964             882 => { Name => 'MovieFrameSize', PrintConv => \%movieFrameSizeZ9, Unknown => 1 },
9965             884 => { Name => 'MovieFrameRate', PrintConv => \%movieFrameRateZ7, Unknown => 1 },
9966             886 => { Name => 'MicrophoneJackPower', PrintConv => \%offOn, Unknown => 1 },
9967             887 => { Name => 'MovieDXCropAlert', PrintConv => \%offOn, Unknown => 1 },
9968             888 => { Name => 'MovieSubjectDetection', PrintConv => \%subjectDetectionZ9, Unknown => 1 },
9969             896 => { Name => 'MovieHighResZoom', PrintConv => \%offOn, Unknown => 1 },
9970             );
9971              
9972             %Image::ExifTool::Nikon::MenuSettingsZ8v1 = (
9973             %binaryDataAttrs,
9974             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9975             NOTES => 'These tags are used by the Z8 firmware 1.00 and 1.10.',
9976             IS_SUBDIR => [ 0, 943 ],
9977             0 => {
9978             Name => 'MenuSettingsZ8',
9979             Format => 'undef[943]',
9980             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ8' },
9981             },
9982             943 => {
9983             Name => 'CustomSettingsZ8',
9984             Format => 'undef[730]',
9985             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsZ8' },
9986             },
9987             1684 => { Name => 'TimeZone', PrintConv => \%timeZoneZ9, SeparateTable => 'TimeZone' },
9988             1690 => { Name => 'MonitorBrightness', PrintConv => \%monitorBrightnessZ9, Unknown => 1 }, # settings: -5 to +5. Added with firmware 3.0: Lo1, Lo2, Hi1, Hi2
9989             1698 => { Name => 'Language', PrintConv => \%languageZ9, Unknown => 1 },
9990             1712 => { Name => 'AFFineTune', PrintConv => \%offOn, Unknown => 1 },
9991             1716 => { Name => 'NonCPULens1FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1}, #should probably hide altogther if $val is 0
9992             1718 => { Name => 'NonCPULens2FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
9993             1720 => { Name => 'NonCPULens3FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
9994             1722 => { Name => 'NonCPULens4FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
9995             1724 => { Name => 'NonCPULens5FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
9996             1726 => { Name => 'NonCPULens6FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
9997             1728 => { Name => 'NonCPULens7FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
9998             1730 => { Name => 'NonCPULens8FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
9999             1732 => { Name => 'NonCPULens9FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10000             1734 => { Name => 'NonCPULens10FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10001             1736 => { Name => 'NonCPULens11FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10002             1738 => { Name => 'NonCPULens12FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10003             1740 => { Name => 'NonCPULens13FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10004             1742 => { Name => 'NonCPULens14FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10005             1744 => { Name => 'NonCPULens15FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10006             1746 => { Name => 'NonCPULens16FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10007             1748 => { Name => 'NonCPULens17FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10008             1750 => { Name => 'NonCPULens18FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10009             1752 => { Name => 'NonCPULens19FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10010             1754 => { Name => 'NonCPULens20FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10011             1756 => { Name => 'NonCPULens1MaxAperture', %nonCPULensApertureZ8 },
10012             1758 => { Name => 'NonCPULens2MaxAperture', %nonCPULensApertureZ8},
10013             1760 => { Name => 'NonCPULens3MaxAperture', %nonCPULensApertureZ8},
10014             1762 => { Name => 'NonCPULens4MaxAperture', %nonCPULensApertureZ8},
10015             1764 => { Name => 'NonCPULens5MaxAperture', %nonCPULensApertureZ8},
10016             1766 => { Name => 'NonCPULens6MaxAperture', %nonCPULensApertureZ8},
10017             1768 => { Name => 'NonCPULens7MaxAperture', %nonCPULensApertureZ8},
10018             1770 => { Name => 'NonCPULens8MaxAperture', %nonCPULensApertureZ8},
10019             1772 => { Name => 'NonCPULens9MaxAperture', %nonCPULensApertureZ8},
10020             1774 => { Name => 'NonCPULens10MaxAperture', %nonCPULensApertureZ8},
10021             1776 => { Name => 'NonCPULens11MaxAperture', %nonCPULensApertureZ8},
10022             1778 => { Name => 'NonCPULens12MaxAperture', %nonCPULensApertureZ8},
10023             1780 => { Name => 'NonCPULens13MaxAperture', %nonCPULensApertureZ8},
10024             1782 => { Name => 'NonCPULens14MaxAperture', %nonCPULensApertureZ8},
10025             1784 => { Name => 'NonCPULens15MaxAperture', %nonCPULensApertureZ8},
10026             1786 => { Name => 'NonCPULens16MaxAperture', %nonCPULensApertureZ8},
10027             1788 => { Name => 'NonCPULens17MaxAperture', %nonCPULensApertureZ8},
10028             1790 => { Name => 'NonCPULens18MaxAperture', %nonCPULensApertureZ8},
10029             1792 => { Name => 'NonCPULens19MaxAperture', %nonCPULensApertureZ8},
10030             1794 => { Name => 'NonCPULens20MaxAperture', %nonCPULensApertureZ8},
10031             1808 => { Name => 'HDMIOutputResolution', PrintConv => \%hDMIOutputResolutionZ9 },
10032             1826 => { Name => 'AirplaneMode', PrintConv => \%offOn, Unknown => 1 },
10033             1827 => { Name => 'EmptySlotRelease', PrintConv => { 0 => 'Disable Release', 1 => 'Enable Release' }, Unknown => 1 },
10034             1862 => { Name => 'EnergySavingMode', PrintConv => \%offOn, Unknown => 1 },
10035             1890 => { Name => 'USBPowerDelivery', PrintConv => \%offOn, Unknown => 1 },
10036             1899 => { Name => 'SensorShield', PrintConv => { 0 => 'Stays Open', 1 => 'Closes' }, Unknown => 1 },
10037             );
10038              
10039             %Image::ExifTool::Nikon::MenuSettingsZ8v2 = (
10040             %binaryDataAttrs,
10041             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10042             DATAMEMBER => [ 0, 2046 ],
10043             IS_SUBDIR => [ 0, 943 ],
10044             NOTES => 'These tags are used by the Z8 firmware 2.00 and 2.10.',
10045             0 => {
10046             Name => 'MenuSettingsZ8',
10047             Format => 'undef[943]',
10048             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ8' },
10049             Hook => q{
10050             if ($$self{FirmwareVersion}) {
10051             if ($$self{FirmwareVersion} =~ /^02\.10/) {
10052             $varSize += 4;
10053             } elsif ($$self{FirmwareVersion} ge "03.0") {
10054             $varSize += 8
10055             }
10056             }
10057             },
10058             },
10059             943 => {
10060             Name => 'CustomSettingsZ8',
10061             Format => 'undef[755]',
10062             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsZ8' },
10063             },
10064             1698 => { Name => 'Language', PrintConv => \%languageZ9, Unknown => 1 },
10065             1700 => { Name => 'TimeZone', PrintConv => \%timeZoneZ9, SeparateTable => 'TimeZone' },
10066             1706 => { Name => 'MonitorBrightness', PrintConv => \%monitorBrightnessZ9, Unknown => 1 }, # settings: -5 to +5. Added with firmware 3.0: Lo1, Lo2, Hi1, Hi2
10067             1728 => { Name => 'AFFineTune', PrintConv => \%offOn, Unknown => 1 },
10068             1732 => { Name => 'NonCPULens1FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1}, #should probably hide altogther if $val is 0
10069             1734 => { Name => 'NonCPULens2FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10070             1736 => { Name => 'NonCPULens3FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10071             1738 => { Name => 'NonCPULens4FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10072             1740 => { Name => 'NonCPULens5FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10073             1742 => { Name => 'NonCPULens6FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10074             1744 => { Name => 'NonCPULens7FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10075             1746 => { Name => 'NonCPULens8FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10076             1748 => { Name => 'NonCPULens9FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10077             1750 => { Name => 'NonCPULens10FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10078             1752 => { Name => 'NonCPULens11FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10079             1754 => { Name => 'NonCPULens12FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10080             1756 => { Name => 'NonCPULens13FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10081             1758 => { Name => 'NonCPULens14FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10082             1760 => { Name => 'NonCPULens15FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10083             1762 => { Name => 'NonCPULens16FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10084             1764 => { Name => 'NonCPULens17FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10085             1766 => { Name => 'NonCPULens18FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10086             1768 => { Name => 'NonCPULens19FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10087             1770 => { Name => 'NonCPULens20FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10088             1812 => { Name => 'NonCPULens1MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10089             1816 => { Name => 'NonCPULens2MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10090             1820 => { Name => 'NonCPULens3MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10091             1824 => { Name => 'NonCPULens4MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10092             1828 => { Name => 'NonCPULens5MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10093             1832 => { Name => 'NonCPULens6MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10094             1836 => { Name => 'NonCPULens7MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10095             1840 => { Name => 'NonCPULens8MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10096             1844 => { Name => 'NonCPULens9MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10097             1848 => { Name => 'NonCPULens10MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10098             1852 => { Name => 'NonCPULens11MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10099             1856 => { Name => 'NonCPULens12MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10100             1860 => { Name => 'NonCPULens13MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10101             1864 => { Name => 'NonCPULens14MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10102             1868 => { Name => 'NonCPULens15MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10103             1872 => { Name => 'NonCPULens16MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10104             1876 => { Name => 'NonCPULens17MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10105             1880 => { Name => 'NonCPULens18MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10106             1884 => { Name => 'NonCPULens19MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10107             1888 => { Name => 'NonCPULens20MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10108             1904 => { Name => 'HDMIOutputResolution', PrintConv => \%hDMIOutputResolutionZ9 },
10109             1922 => { Name => 'AirplaneMode', PrintConv => \%offOn, Unknown => 1 },
10110             1923 => { Name => 'EmptySlotRelease', PrintConv => { 0 => 'Disable Release', 1 => 'Enable Release' }, Unknown => 1 },
10111             1958 => { Name => 'EnergySavingMode', PrintConv => \%offOn, Unknown => 1 },
10112             1986 => { Name => 'USBPowerDelivery', PrintConv => \%offOn, Unknown => 1 },
10113             1995 => { Name => 'SensorShield', PrintConv => { 0 => 'Stays Open', 1 => 'Closes' }, Unknown => 1 },
10114             2046 => { Name => 'PixelShiftShooting', RawConv => '$$self{PixelShiftShooting} = $val', PrintConv => \%multipleExposureModeZ9 }, #off/on/on (series)
10115             2048 => { Name => 'PixelShiftNumberShots', Condition => '$$self{PixelShiftShooting} > 0', PrintConv => \%pixelShiftNumberShots },
10116             2050 => { Name => 'PixelShiftDelay', Condition => '$$self{PixelShiftShooting} > 0', PrintConv => \%pixelShiftDelay },
10117             2052 => { Name => 'PlaybackButton', %buttonsZ8 }, #CSf2
10118             2054 => { Name => 'WBButton', %buttonsZ8}, #CSf2
10119             2056 => { Name => 'BracketButton', %buttonsZ8}, #CSf2
10120             2058 => { Name => 'LensFunc1ButtonPlaybackMode', %buttonsZ8}, #CSf3
10121             2060 => { Name => 'LensFunc2ButtonPlaybackMode', %buttonsZ8}, #CSf3
10122             2062 => { Name => 'PlaybackButtonPlaybackMode', %buttonsZ8}, #CSf3
10123             2064 => { Name => 'BracketButtonPlaybackMode', %buttonsZ8}, #CSf3
10124             #2088 FlickerFrequencyPreset #Z8 fw 3.0
10125             2206 => { Name => 'MaximumApertureLV', PrintConv => \%offOn, Unknown => 1 }, #CSa14
10126             2208 => { Name => 'ReleaseModeButton', %buttonsZ8}, #CSf2
10127             2216 => { Name => 'ReleaseModeButtonPlaybackMode', %buttonsZ8}, #CSf3
10128             );
10129              
10130             %Image::ExifTool::Nikon::MenuSettingsZ9 = (
10131             %binaryDataAttrs,
10132             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10133             DATAMEMBER => [ 140, 188, 192, 232, 308, 424, 528, 534, 576 ],
10134             IS_SUBDIR => [ 799 ],
10135             NOTES => 'These tags are used by the Z9.',
10136             #90 ISO
10137             140 => {
10138             Name => 'MultipleExposureMode',
10139             RawConv => '$$self{MultipleExposureMode} = $val',
10140             PrintConv => \%multipleExposureModeZ9,
10141             },
10142             142 => {Name => 'MultiExposureShots', Condition => '$$self{MultipleExposureMode} != 0' }, #range 2-9
10143             188 => {
10144             Name => 'Intervals',
10145             Format => 'int32u',
10146             RawConv => '$$self{IntervalShootingIntervals} = $val',
10147             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0', #not valid for C30/C60/C120
10148             },
10149             192 => {
10150             Name => 'ShotsPerInterval',
10151             Format => 'int32u',
10152             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
10153             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0', #not valid for C30/C60/C120
10154             },
10155             #220 NEFCompression 0=> 'Lossless' 1=> 'High Efficiency*' 4=> 'High Efficientcy'
10156             232 => {
10157             Name => 'FocusShiftNumberShots', #1-300
10158             RawConv => '$$self{FocusShiftNumberShots} = $val',
10159             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10160             },
10161             236 => {
10162             Name => 'FocusShiftStepWidth', #1(Narrow) to 10 (Wide)
10163             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10164             },
10165             240 => {
10166             Name => 'FocusShiftInterval',
10167             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10168             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
10169             },
10170             244 => {
10171             Name => 'FocusShiftExposureLock',
10172             Unknown => 1,
10173             PrintConv => \%offOn,
10174             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10175             },
10176             274 => { Name => 'PhotoShootingMenuBank', PrintConv => \%banksZ9 },
10177             276 => { Name => 'ExtendedMenuBanks', PrintConv => \%offOn }, #single tag from both Photo & Video menus
10178             308 => { Name => 'PhotoShootingMenuBankImageArea', RawConv => '$$self{ImageArea} = $val', PrintConv => \%imageAreaZ9 },
10179             #310 ImageQuality
10180             322 => { Name => 'AutoISO', PrintConv => \%offOn },
10181             324 => { Name => 'ISOAutoHiLimit', %isoAutoHiLimitZ7 },
10182             326 => { Name => 'ISOAutoFlashLimit', %isoAutoHiLimitZ7 },
10183             #332 ISOAutoShutterTime - Auto setting 0=> 'Auto (Slowest)', 1 => 'Auto (Slower)', 2=> 'Auto', 3=> 'Auto (Faster)', 4=> 'Auto (Fastest)'
10184             334 => {
10185             Name => 'ISOAutoShutterTime', #shutter speed is 2 ** (-$val/24)
10186             ValueConv => '$val / 8',
10187             Format => 'int16s',
10188             PrintConv => \%iSOAutoShutterTimeZ9,
10189             },
10190             #336 WhiteBalance
10191             #406 PictureControl
10192             #408 ColorSpace
10193             #410 ActiveD-Lighting
10194             #412 => { Name => 'NoiseReduction', PrintConv => \%offOn }, #Long Exposure Noise Reduction
10195             #414 HighISONoiseReduction
10196             #414 VignetteControl
10197             416 => { Name => 'MovieVignetteControl', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
10198             418 => { Name => 'DiffractionCompensation', PrintConv => \%offOn }, #value can be set from both the Photo Shoot Menu and the Video Shooting Menu
10199             #419 AutoDistortionControl #value can be set from both the Photo Shoot Menu and the Video Shooting Menu
10200             420 => { Name => 'FlickerReductionShooting', PrintConv => \%offOn },
10201             #422 MeteringMode
10202             424 => {
10203             Name => 'FlashControlMode', # this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
10204             RawConv => '$$self{FlashControlMode} = $val',
10205             PrintConv => \%flashControlModeZ7,
10206             },
10207             426 => {
10208             Name => 'FlashMasterCompensation',
10209             Format => 'int8s',
10210             Unknown => 1,
10211             ValueConv => '$val/6',
10212             ValueConvInv => '6 * $val',
10213             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
10214             PrintConvInv => '$val',
10215             },
10216             430 => {
10217             Name => 'FlashGNDistance',
10218             Condition => '$$self{FlashControlMode} == 2',
10219             Unknown => 1,
10220             ValueConv => '$val + 3',
10221             PrintConv => \%flashGNDistance,
10222             },
10223             434 => {
10224             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)
10225             Condition => '$$self{FlashControlMode} >= 3',
10226             Unknown => 1,
10227             ValueConv => '2 ** (-$val/3)',
10228             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
10229             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
10230             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
10231             },
10232             #442 flash wirelss control 0=> 'Off' 1=> 'CMD'
10233             444 => { Name => 'FlashRemoteControl', PrintConv => \%flashRemoteControlZ7, Unknown => 1 },
10234             456 => { Name => 'FlashWirelessOption', PrintConv => \%flashWirelessOptionZ7, Unknown => 1 },
10235             #526 FocusMode
10236             528 => { Name => 'AFAreaMode', RawConv => '$$self{AFAreaMode} = $val', PrintConv => \%aFAreaModeZ9},
10237             530 => { Name => 'VRMode', PrintConv => \%vRModeZ9 },
10238             534 => {
10239             Name => 'BracketSet',
10240             RawConv => '$$self{BracketSet} = $val',
10241             PrintConv => \%bracketSetZ9,
10242             },
10243             536 => {
10244             Name => 'BracketProgram',
10245             Condition => '$$self{BracketSet} < 3',
10246             Notes => 'AE and/or Flash Bracketing',
10247             PrintConv => \%bracketProgramZ9,
10248             },
10249             538 => {
10250             Name => 'BracketIncrement',
10251             Condition => '$$self{BracketSet} < 3',
10252             Notes => 'AE and/or Flash Bracketing',
10253             PrintConv => \%bracketIncrementZ9,
10254             },
10255             #544 BracketProgram for ADL
10256             556 => { Name => 'SecondarySlotFunction', PrintConv => \%secondarySlotFunctionZ9 },
10257             572 => { Name => 'DXCropAlert', PrintConv => \%offOn },
10258             574 => { Name => 'SubjectDetection', PrintConv => \%subjectDetectionZ9 },
10259             576 => {
10260             Name => 'DynamicAFAreaSize',
10261             Condition => '$$self{AFAreaMode} == 2',
10262             RawConv => '$$self{DynamicAFAreaSize} = $val',
10263             PrintConv => \%dynamicAfAreaModesZ9,
10264             },
10265             604 => {
10266             Name => 'MovieImageArea',
10267             Unknown => 1,
10268             Mask => 0x01, # without the mask 4 => 'FX', 5 => DX. only the 2nd Z-series field encountered with a mask
10269             PrintConv => \%imageAreaZ9b,
10270             },
10271             614 => { Name => 'MovieType', PrintConv => \%movieTypeZ9, Unknown => 1 },
10272             616 => { Name => 'MovieISOAutoHiLimit', %isoAutoHiLimitZ7 },
10273             618 => { Name => 'MovieISOAutoControlManualMode', PrintConv => \%offOn, Unknown => 1 },
10274             620 => { Name => 'MovieISOAutoManualMode', %isoAutoHiLimitZ7 },
10275             696 => { Name => 'MovieActiveD-Lighting', PrintConv => \%activeDLightingZ7, Unknown => 1 },
10276             698 => { Name => 'MovieHighISONoiseReduction', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
10277             704 => { Name => 'MovieFlickerReduction', PrintConv => \%movieFlickerReductionZ9 },
10278             706 => { Name => 'MovieMeteringMode', PrintConv => \%meteringModeZ7, Unknown => 1 },
10279             708 => { Name => 'MovieFocusMode', PrintConv => \%focusModeZ7, Unknown => 1 },
10280             710 => { Name => 'MovieAFAreaMode', PrintConv => \%aFAreaModeZ9 },
10281             712 => { Name => 'MovieVRMode', PrintConv => \%vRModeZ9, Unknown => 1 },
10282             716 => { Name => 'MovieElectronicVR', PrintConv => \%offOn, Unknown => 1 }, #distinct from MoveieVRMode
10283             718 => { Name => 'MovieSoundRecording', PrintConv => { 0 => 'Off', 1 => 'Auto', 2 => 'Manual' }, Unknown => 1 },
10284             720 => { Name => 'MicrophoneSensitivity', Unknown => 1 }, #1-20
10285             722 => { Name => 'MicrophoneAttenuator', PrintConv => \%offOn, Unknown => 1 }, #distinct from MoveieVRMode
10286             724 => { Name => 'MicrophoneFrequencyResponse', PrintConv => { 0 => 'Wide Range', 1 => 'Vocal Range' }, Unknown => 1 },
10287             726 => { Name => 'WindNoiseReduction', PrintConv => \%offOn, Unknown => 1 },
10288             748 => { Name => 'MovieToneMap', PrintConv => \%movieToneMapZ9, Unknown => 1 },
10289             754 => { Name => 'MovieFrameSize', PrintConv => \%movieFrameSizeZ9, Unknown => 1 },
10290             756 => { Name => 'MovieFrameRate', PrintConv => \%movieFrameRateZ7, Unknown => 1 },
10291             762 => { Name => 'MicrophoneJackPower', PrintConv => \%offOn, Unknown => 1 },
10292             763 => { Name => 'MovieDXCropAlert', PrintConv => \%offOn, Unknown => 1 },
10293             764 => { Name => 'MovieSubjectDetection', PrintConv => \%subjectDetectionZ9, Unknown => 1 },
10294             799 => {
10295             Name => 'CustomSettingsZ9',
10296             Format => 'undef[608]',
10297             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsZ9' },
10298             },
10299             1426 => { Name => 'Language', PrintConv => \%languageZ9, Unknown => 1 },
10300             1428 => { Name => 'TimeZone', PrintConv => \%timeZoneZ9, SeparateTable => 'TimeZone' },
10301             1434 => { Name => 'MonitorBrightness', ValueConv => '$val - 5', Unknown => 1 }, # settings: -5 to +5
10302             1456 => { Name => 'AFFineTune', PrintConv => \%offOn, Unknown => 1 },
10303             1552 => { Name => 'HDMIOutputResolution', PrintConv => \%hDMIOutputResolutionZ9 },
10304             1565 => { Name => 'SetClockFromLocationData', PrintConv => \%offOn, Unknown => 1 },
10305             1572 => { Name => 'AirplaneMode', PrintConv => \%offOn, Unknown => 1 },
10306             1573 => { Name => 'EmptySlotRelease', PrintConv => { 0 => 'Disable Release', 1 => 'Enable Release' }, Unknown => 1 },
10307             1608 => { Name => 'EnergySavingMode', PrintConv => \%offOn, Unknown => 1 },
10308             1632 => { Name => 'RecordLocationData', PrintConv => \%offOn, Unknown => 1 },
10309             1636 => { Name => 'USBPowerDelivery', PrintConv => \%offOn, Unknown => 1 },
10310             1645 => { Name => 'SensorShield', PrintConv => { 0 => 'Stays Open', 1 => 'Closes' }, Unknown => 1 },
10311             );
10312              
10313             %Image::ExifTool::Nikon::MenuSettingsZ9v3 = (
10314             %binaryDataAttrs,
10315             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10316             DATAMEMBER => [ 154, 204, 208, 248, 328, 444, 548, 554, 596 ],
10317             IS_SUBDIR => [ 847 ],
10318             NOTES => 'These tags are used by the Z9 firmware 3.00.',
10319             72 => {
10320             Name => 'HighFrameRate', #CH and C30/C60/C120 but not CL
10321             PrintConv => \%highFrameRateZ9,
10322             },
10323             154 => {
10324             Name => 'MultipleExposureMode',
10325             RawConv => '$$self{MultipleExposureMode} = $val',
10326             PrintConv => \%multipleExposureModeZ9,
10327             },
10328             156 => {Name => 'MultiExposureShots', Condition => '$$self{MultipleExposureMode} != 0'}, #range 2-9
10329             204 => {
10330             Name => 'Intervals',
10331             Format => 'int32u',
10332             RawConv => '$$self{IntervalShootingIntervals} = $val',
10333             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0', #not valid for C30/C60/C120
10334             },
10335             208 => {
10336             Name => 'ShotsPerInterval',
10337             Format => 'int32u',
10338             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
10339             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0', #not valid for C30/C60/C120
10340             },
10341             248 => {
10342             Name => 'FocusShiftNumberShots', #1-300
10343             RawConv => '$$self{FocusShiftNumberShots} = $val',
10344             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10345             },
10346             252 => {
10347             Name => 'FocusShiftStepWidth', #1(Narrow) to 10 (Wide)
10348             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10349             },
10350             256 => {
10351             Name => 'FocusShiftInterval',
10352             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10353             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
10354             },
10355             260 => {
10356             Name => 'FocusShiftExposureLock',
10357             Unknown => 1,
10358             PrintConv => \%offOn,
10359             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10360             },
10361             290 => { Name => 'PhotoShootingMenuBank', PrintConv => \%banksZ9 },
10362             292 => { Name => 'ExtendedMenuBanks', PrintConv => \%offOn }, # single tag from both Photo & Video menus
10363             328 => { Name => 'PhotoShootingMenuBankImageArea', RawConv => '$$self{ImageArea} = $val', PrintConv => \%imageAreaZ9 },
10364             342 => { Name => 'AutoISO', PrintConv => \%offOn },
10365             344 => { Name => 'ISOAutoHiLimit', %isoAutoHiLimitZ7 },
10366             346 => { Name => 'ISOAutoFlashLimit', %isoAutoHiLimitZ7 },
10367             354 => {
10368             Name => 'ISOAutoShutterTime', # shutter speed is 2 ** (-$val/24)
10369             ValueConv => '$val / 8',
10370             Format => 'int16s',
10371             PrintConv => \%iSOAutoShutterTimeZ9,
10372             },
10373             436 => { Name => 'MovieVignetteControl', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
10374             438 => { Name => 'DiffractionCompensation', PrintConv => \%offOn }, # value can be set from both the Photo Shoot Menu and the Video Shooting Menu
10375             440 => { Name => 'FlickerReductionShooting',PrintConv => \%offOn },
10376             444 => {
10377             Name => 'FlashControlMode', # this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
10378             RawConv => '$$self{FlashControlMode} = $val',
10379             PrintConv => \%flashControlModeZ7,
10380             },
10381             446 => {
10382             Name => 'FlashMasterCompensation',
10383             Format => 'int8s',
10384             Unknown => 1,
10385             ValueConv => '$val/6',
10386             ValueConvInv => '6 * $val',
10387             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
10388             PrintConvInv => '$val',
10389             },
10390             450 => {
10391             Name => 'FlashGNDistance',
10392             Condition => '$$self{FlashControlMode} == 2',
10393             Unknown => 1,
10394             ValueConv => '$val + 3',
10395             PrintConv => \%flashGNDistance,
10396             },
10397             454 => {
10398             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)
10399             Condition => '$$self{FlashControlMode} >= 3',
10400             Unknown => 1,
10401             ValueConv => '2 ** (-$val/3)',
10402             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
10403             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
10404             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
10405             },
10406             #462 flash wireless control 0=> 'Off' 1=> 'Optical AWL'
10407             #464 => { Name => 'FlashRemoteControl', PrintConv => \%flashRemoteControlZ7, Unknown => 1 },
10408             #476 => { Name => 'FlashWirelessOption', PrintConv => \%flashWirelessOptionZ7, Unknown => 1 },
10409             548 => { Name => 'AFAreaMode', RawConv => '$$self{AFAreaMode} = $val', PrintConv => \%aFAreaModeZ9},
10410             550 => { Name => 'VRMode', PrintConv => \%vRModeZ9},
10411             554 => {
10412             Name => 'BracketSet',
10413             RawConv => '$$self{BracketSet} = $val',
10414             PrintConv => \%bracketSetZ9,
10415             },
10416             556 => {
10417             Name => 'BracketProgram',
10418             Condition => '$$self{BracketSet} < 3',
10419             Notes => 'AE and/or Flash Bracketing',
10420             PrintConv => \%bracketProgramZ9,
10421             },
10422             558 => {
10423             Name => 'BracketIncrement',
10424             Condition => '$$self{BracketSet} < 3',
10425             Notes => 'AE and/or Flash Bracketing',
10426             PrintConv => \%bracketIncrementZ9,
10427             },
10428             576 => { Name => 'SecondarySlotFunction', PrintConv => \%secondarySlotFunctionZ9 },
10429             592 => { Name => 'DXCropAlert', PrintConv => \%offOn },
10430             594 => { Name => 'SubjectDetection', PrintConv => \%subjectDetectionZ9 },
10431             596 => {
10432             Name => 'DynamicAFAreaSize',
10433             Condition => '$$self{AFAreaMode} == 2',
10434             RawConv => '$$self{DynamicAFAreaSize} = $val',
10435             PrintConv => \%dynamicAfAreaModesZ9,
10436             },
10437             636 => { Name => 'HighFrequencyFlickerReduction', PrintConv => \%offOn, Unknown => 1 }, # new with firmware 3.0
10438             646 => {
10439             Name => 'MovieImageArea',
10440             Unknown => 1,
10441             Mask => 0x01, # without the mask 4 => 'FX' 5 => DX only the 2nd Z-series field encountered with a mask.
10442             PrintConv => \%imageAreaZ9b,
10443             },
10444             656 => { Name => 'MovieType', PrintConv => \%movieTypeZ9, Unknown => 1 },
10445             658 => { Name => 'MovieISOAutoHiLimit', %isoAutoHiLimitZ7 },
10446             660 => { Name => 'MovieISOAutoControlManualMode', PrintConv => \%offOn, Unknown => 1 },
10447             662 => { Name => 'MovieISOAutoManualMode', %isoAutoHiLimitZ7 },
10448             736 => { Name => 'MovieActiveD-Lighting', PrintConv => \%activeDLightingZ7, Unknown => 1 },
10449             738 => { Name => 'MovieHighISONoiseReduction', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
10450             744 => { Name => 'MovieFlickerReduction', PrintConv => \%movieFlickerReductionZ9 },
10451             746 => { Name => 'MovieMeteringMode', PrintConv => \%meteringModeZ7, Unknown => 1 },
10452             748 => { Name => 'MovieFocusMode', PrintConv => \%focusModeZ7, Unknown => 1 },
10453             750 => { Name => 'MovieAFAreaMode', PrintConv => \%aFAreaModeZ9 },
10454             752 => { Name => 'MovieVRMode', PrintConv => \%vRModeZ9, Unknown => 1 },
10455             756 => { Name => 'MovieElectronicVR', PrintConv => \%offOn, Unknown => 1 }, # distinct from MoveieVRMode
10456             758 => { Name => 'MovieSoundRecording', PrintConv => { 0 => 'Off', 1 => 'Auto', 2 => 'Manual' }, Unknown => 1 },
10457             760 => { Name => 'MicrophoneSensitivity', Unknown => 1 }, # 1-20
10458             762 => { Name => 'MicrophoneAttenuator', PrintConv => \%offOn, Unknown => 1 }, # distinct from MoveieVRMode
10459             764 => { Name => 'MicrophoneFrequencyResponse',PrintConv => { 0 => 'Wide Range', 1 => 'Vocal Range' }, Unknown => 1 },
10460             766 => { Name => 'WindNoiseReduction', PrintConv => \%offOn, Unknown => 1 },
10461             788 => { Name => 'MovieToneMap', PrintConv => \%movieToneMapZ9, Unknown => 1 },
10462             794 => { Name => 'MovieFrameSize', PrintConv => \%movieFrameSizeZ9, Unknown => 1 },
10463             796 => { Name => 'MovieFrameRate', PrintConv => \%movieFrameRateZ7, Unknown => 1 },
10464             802 => { Name => 'MicrophoneJackPower', PrintConv => \%offOn, Unknown => 1 },
10465             803 => { Name => 'MovieDXCropAlert', PrintConv => \%offOn, Unknown => 1 },
10466             804 => { Name => 'MovieSubjectDetection', PrintConv => \%subjectDetectionZ9, Unknown => 1 },
10467             812 => { Name => 'MovieHighResZoom', PrintConv => \%offOn, Unknown => 1 },
10468             847 => {
10469             Name => 'CustomSettingsZ9',
10470             Format => 'undef[608]',
10471             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsZ9' },
10472             },
10473             1474 => { Name => 'Language', PrintConv => \%languageZ9, Unknown => 1 },
10474             1476 => { Name => 'TimeZone', PrintConv => \%timeZoneZ9, SeparateTable => 'TimeZone' },
10475             1482 => { Name => 'MonitorBrightness', PrintConv => \%monitorBrightnessZ9, Unknown => 1 }, # settings: -5 to +5. Added with firmware 3.0: Lo1, Lo2, Hi1, Hi2
10476             1504 => { Name => 'AFFineTune', PrintConv => \%offOn, Unknown => 1 },
10477             1600 => { Name => 'HDMIOutputResolution', PrintConv => \%hDMIOutputResolutionZ9 },
10478             1613 => { Name => 'SetClockFromLocationData', PrintConv => \%offOn, Unknown => 1 },
10479             1620 => { Name => 'AirplaneMode', PrintConv => \%offOn, Unknown => 1 },
10480             1621 => { Name => 'EmptySlotRelease', PrintConv => { 0 => 'Disable Release', 1 => 'Enable Release' }, Unknown => 1 },
10481             1656 => { Name => 'EnergySavingMode', PrintConv => \%offOn, Unknown => 1 },
10482             1680 => { Name => 'RecordLocationData', PrintConv => \%offOn, Unknown => 1 },
10483             1684 => { Name => 'USBPowerDelivery', PrintConv => \%offOn, Unknown => 1 },
10484             1693 => { Name => 'SensorShield', PrintConv => { 0 => 'Stays Open', 1 => 'Closes' }, Unknown => 1 },
10485             1754 => {
10486             Name => 'FocusShiftAutoReset',
10487             Unknown => 1,
10488             PrintConv => \%offOn,
10489             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10490             },
10491             1810 => { #CSd4-a
10492             Name => 'PreReleaseBurstLength',
10493             PrintConv => {
10494             0 => 'None',
10495             1 => '0.3 Sec',
10496             2 => '0.5 Sec',
10497             3 => '1 Sec',
10498             },
10499             },
10500             1812 => { #CSd4-b
10501             Name => 'PostReleaseBurstLength',
10502             PrintConv => {
10503             0 => '1 Sec',
10504             1 => '2 Sec',
10505             2 => '3 Sec',
10506             3 => 'Max',
10507             },
10508             },
10509             #1824 ReleaseTimingIndicatorTypeADelay CSd14-b 0 => '1/200' ... 15 => '1/6'
10510             #1826 VerticalISOButton CSf2
10511             #1828 ExposureCompensationButton CSf2
10512             #1830 ISOButton CSf2
10513             #1890 ViewModeShowEffectsOfSettings CSd9-a 0=>'Always', 1=> 'Only When Flash Not Used'
10514             #1892 DispButton CSf2
10515             #1936 FocusPointDisplayOption3DTrackingColor CSa11-d 0=> 'White', 1= => 'Red'
10516             );
10517              
10518             # firmware version 4.x/5.x menu settings (ref 28)
10519             %Image::ExifTool::Nikon::MenuSettingsZ9v4 = (
10520             %binaryDataAttrs,
10521             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10522             DATAMEMBER => [ 72, 154, 204, 208, 248, 328, 444, 548, 554, 570, 596 ],
10523             IS_SUBDIR => [ 847 ],
10524             NOTES => 'These tags are used by the Z9 firmware 4.00, 4.10, 5.00 and 5.10.',
10525             72 => {
10526             Name => 'HighFrameRate', #CH and C30/C60/C120 but not CL
10527             PrintConv => \%highFrameRateZ9,
10528             Hook => '$varSize += 4 if $$self{FirmwareVersion} and $$self{FirmwareVersion} ge "05.10"',
10529             },
10530             #
10531             # Note: Offsets after this are shifted by +4 for firmware 5.1 (see Hook above)
10532             #
10533             154 => {
10534             Name => 'MultipleExposureMode',
10535             RawConv => '$$self{MultipleExposureMode} = $val',
10536             PrintConv => \%multipleExposureModeZ9,
10537             },
10538             156 => {Name => 'MultiExposureShots', Condition => '$$self{MultipleExposureMode} != 0'}, #range 2-9
10539             204 => {
10540             Name => 'Intervals',
10541             Format => 'int32u',
10542             RawConv => '$$self{IntervalShootingIntervals} = $val',
10543             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0', #not valid for C30/C60/C120
10544             },
10545             208 => {
10546             Name => 'ShotsPerInterval',
10547             Format => 'int32u',
10548             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
10549             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0', #not valid for C30/C60/C120
10550             },
10551             248 => {
10552             Name => 'FocusShiftNumberShots', #1-300
10553             RawConv => '$$self{FocusShiftNumberShots} = $val',
10554             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10555             },
10556             252 => {
10557             Name => 'FocusShiftStepWidth', #1(Narrow) to 10 (Wide)
10558             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10559             },
10560             256 => {
10561             Name => 'FocusShiftInterval',
10562             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10563             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
10564             },
10565             260 => {
10566             Name => 'FocusShiftExposureLock',
10567             Unknown => 1,
10568             PrintConv => \%offOn,
10569             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10570             },
10571             290 => { Name => 'PhotoShootingMenuBank', PrintConv => \%banksZ9 },
10572             292 => { Name => 'ExtendedMenuBanks', PrintConv => \%offOn }, # single tag from both Photo & Video menus
10573             328 => { Name => 'PhotoShootingMenuBankImageArea', RawConv => '$$self{ImageArea} = $val', PrintConv => \%imageAreaZ9 },
10574             #334 JPGCompression 0 => 'Size Priority', 1 => 'Optimal Quality',
10575             342 => { Name => 'AutoISO', PrintConv => \%offOn },
10576             344 => { Name => 'ISOAutoHiLimit', %isoAutoHiLimitZ7 },
10577             346 => { Name => 'ISOAutoFlashLimit', %isoAutoHiLimitZ7 },
10578             354 => {
10579             Name => 'ISOAutoShutterTime', # shutter speed is 2 ** (-$val/24)
10580             ValueConv => '$val / 8',
10581             Format => 'int16s',
10582             PrintConv => \%iSOAutoShutterTimeZ9,
10583             },
10584             436 => { Name => 'MovieVignetteControl', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
10585             438 => { Name => 'DiffractionCompensation', PrintConv => \%offOn }, # value can be set from both the Photo Shoot Menu and the Video Shooting Menu
10586             440 => { Name => 'FlickerReductionShooting',PrintConv => \%offOn },
10587             444 => {
10588             Name => 'FlashControlMode', # this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
10589             RawConv => '$$self{FlashControlMode} = $val',
10590             PrintConv => \%flashControlModeZ7,
10591             },
10592             446 => {
10593             Name => 'FlashMasterCompensation',
10594             Format => 'int8s',
10595             Unknown => 1,
10596             ValueConv => '$val/6',
10597             ValueConvInv => '6 * $val',
10598             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
10599             PrintConvInv => '$val',
10600             },
10601             450 => {
10602             Name => 'FlashGNDistance',
10603             Condition => '$$self{FlashControlMode} == 2',
10604             Unknown => 1,
10605             ValueConv => '$val + 3',
10606             PrintConv => \%flashGNDistance,
10607             },
10608             454 => {
10609             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)
10610             Condition => '$$self{FlashControlMode} >= 3',
10611             Unknown => 1,
10612             ValueConv => '2 ** (-$val/3)',
10613             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
10614             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
10615             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
10616             },
10617             #462 flash wireless control 0=> 'Off' 1=> 'Optical AWL'
10618             #464 => { Name => 'FlashRemoteControl', PrintConv => \%flashRemoteControlZ7, Unknown => 1 },
10619             #476 => { Name => 'FlashWirelessOption', PrintConv => \%flashWirelessOptionZ7, Unknown => 1 },
10620             548 => { Name => 'AFAreaMode', RawConv => '$$self{AFAreaMode} = $val', PrintConv => \%aFAreaModeZ9},
10621             550 => { Name => 'VRMode', PrintConv => \%vRModeZ9},
10622             554 => {
10623             Name => 'BracketSet',
10624             RawConv => '$$self{BracketSet} = $val',
10625             PrintConv => \%bracketSetZ9,
10626             },
10627             556 => {
10628             Name => 'BracketProgram',
10629             Condition => '$$self{BracketSet} < 3',
10630             Notes => 'AE and/or Flash Bracketing',
10631             PrintConv => \%bracketProgramZ9,
10632             },
10633             558 => {
10634             Name => 'BracketIncrement',
10635             Condition => '$$self{BracketSet} < 3',
10636             Notes => 'AE and/or Flash Bracketing',
10637             PrintConv => \%bracketIncrementZ9,
10638             },
10639             570 => { Name => 'HDR', RawConv => '$$self{HDR} = $val', PrintConv => \%multipleExposureModeZ9 },
10640             576 => { Name => 'SecondarySlotFunction', PrintConv => \%secondarySlotFunctionZ9 },
10641             582 => { Name => 'HDRLevel', Condition => '$$self{HDR} ne 0', PrintConv => \%hdrLevelZ8 },
10642             586 => { Name => 'Slot2JpgSize', PrintConv => { 0 => 'Large (8256x5504)', 1 => 'Medium (6192x4128)', 2 => 'Small (4128x2752)' }, Unknown => 1},
10643             592 => { Name => 'DXCropAlert', PrintConv => \%offOn },
10644             594 => { Name => 'SubjectDetection', PrintConv => \%subjectDetectionZ9 },
10645             596 => {
10646             Name => 'DynamicAFAreaSize',
10647             Condition => '$$self{AFAreaMode} == 2',
10648             RawConv => '$$self{DynamicAFAreaSize} = $val',
10649             PrintConv => \%dynamicAfAreaModesZ9,
10650             },
10651             636 => { Name => 'HighFrequencyFlickerReduction', PrintConv => \%offOn, Unknown => 1 }, # new with firmware 3.0
10652             646 => {
10653             Name => 'MovieImageArea',
10654             Unknown => 1,
10655             Mask => 0x01, # without the mask 4 => 'FX' 5 => DX only the 2nd Z-series field encountered with a mask.
10656             PrintConv => \%imageAreaZ9b,
10657             },
10658             656 => { Name => 'MovieType', PrintConv => \%movieTypeZ9, Unknown => 1 },
10659             658 => { Name => 'MovieISOAutoHiLimit', %isoAutoHiLimitZ7 },
10660             660 => { Name => 'MovieISOAutoControlManualMode', PrintConv => \%offOn, Unknown => 1 },
10661             662 => { Name => 'MovieISOAutoManualMode', %isoAutoHiLimitZ7 },
10662             736 => { Name => 'MovieActiveD-Lighting', PrintConv => \%activeDLightingZ7, Unknown => 1 },
10663             738 => { Name => 'MovieHighISONoiseReduction', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
10664             744 => { Name => 'MovieFlickerReduction', PrintConv => \%movieFlickerReductionZ9 },
10665             746 => { Name => 'MovieMeteringMode', PrintConv => \%meteringModeZ7, Unknown => 1 },
10666             748 => { Name => 'MovieFocusMode', PrintConv => \%focusModeZ7, Unknown => 1 },
10667             750 => { Name => 'MovieAFAreaMode', PrintConv => \%aFAreaModeZ9 },
10668             752 => { Name => 'MovieVRMode', PrintConv => \%vRModeZ9, Unknown => 1 },
10669             756 => { Name => 'MovieElectronicVR', PrintConv => \%offOn, Unknown => 1 }, # distinct from MoveieVRMode
10670             758 => { Name => 'MovieSoundRecording', PrintConv => { 0 => 'Off', 1 => 'Auto', 2 => 'Manual' }, Unknown => 1 },
10671             760 => { Name => 'MicrophoneSensitivity', Unknown => 1 }, # 1-20
10672             762 => { Name => 'MicrophoneAttenuator', PrintConv => \%offOn, Unknown => 1 }, # distinct from MoveieVRMode
10673             764 => { Name => 'MicrophoneFrequencyResponse',PrintConv => { 0 => 'Wide Range', 1 => 'Vocal Range' }, Unknown => 1 },
10674             766 => { Name => 'WindNoiseReduction', PrintConv => \%offOn, Unknown => 1 },
10675             788 => { Name => 'MovieToneMap', PrintConv => \%movieToneMapZ9, Unknown => 1 },
10676             794 => { Name => 'MovieFrameSize', PrintConv => \%movieFrameSizeZ9, Unknown => 1 },
10677             796 => { Name => 'MovieFrameRate', PrintConv => \%movieFrameRateZ7, Unknown => 1 },
10678             802 => { Name => 'MicrophoneJackPower', PrintConv => \%offOn, Unknown => 1 },
10679             803 => { Name => 'MovieDXCropAlert', PrintConv => \%offOn, Unknown => 1 },
10680             804 => { Name => 'MovieSubjectDetection', PrintConv => \%subjectDetectionZ9, Unknown => 1 },
10681             812 => { Name => 'MovieHighResZoom', PrintConv => \%offOn, Unknown => 1 },
10682             847 => {
10683             Name => 'CustomSettingsZ9v4',
10684             Format => 'undef[632]',
10685             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsZ9v4' },
10686             },
10687             1498 => { Name => 'Language', PrintConv => \%languageZ9, Unknown => 1 },
10688             1500 => { Name => 'TimeZone', PrintConv => \%timeZoneZ9, SeparateTable => 'TimeZone' },
10689             1506 => { Name => 'MonitorBrightness', PrintConv => \%monitorBrightnessZ9, Unknown => 1 }, # settings: -5 to +5. Added with firmware 3.0: Lo1, Lo2, Hi1, Hi2
10690             1528 => { Name => 'AFFineTune', PrintConv => \%offOn, Unknown => 1 },
10691             1532 => { Name => 'NonCPULens1FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1}, #should probably hide altogther if $val is 0
10692             1536 => { Name => 'NonCPULens2FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10693             1540 => { Name => 'NonCPULens3FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10694             1544 => { Name => 'NonCPULens4FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10695             1548 => { Name => 'NonCPULens5FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10696             1552 => { Name => 'NonCPULens6FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10697             1556 => { Name => 'NonCPULens7FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10698             1560 => { Name => 'NonCPULens8FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10699             1564 => { Name => 'NonCPULens9FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10700             1568 => { Name => 'NonCPULens10FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10701             1572 => { Name => 'NonCPULens11FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10702             1576 => { Name => 'NonCPULens12FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10703             1580 => { Name => 'NonCPULens13FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10704             1584 => { Name => 'NonCPULens14FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10705             1588 => { Name => 'NonCPULens15FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10706             1592 => { Name => 'NonCPULens16FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10707             1596 => { Name => 'NonCPULens17FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10708             1600 => { Name => 'NonCPULens18FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10709             1604 => { Name => 'NonCPULens19FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10710             1608 => { Name => 'NonCPULens20FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10711             1612 => { Name => 'NonCPULens1MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1}, #non-CPU aperture interface, values and storage differ from the Z8
10712             1616 => { Name => 'NonCPULens2MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10713             1620 => { Name => 'NonCPULens3MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10714             1624 => { Name => 'NonCPULens4MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10715             1628 => { Name => 'NonCPULens5MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10716             1632 => { Name => 'NonCPULens6MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10717             1636 => { Name => 'NonCPULens7MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10718             1640 => { Name => 'NonCPULens8MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10719             1644 => { Name => 'NonCPULens9MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10720             1648 => { Name => 'NonCPULens10MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10721             1652 => { Name => 'NonCPULens11MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10722             1656 => { Name => 'NonCPULens12MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10723             1660 => { Name => 'NonCPULens13MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10724             1664 => { Name => 'NonCPULens14MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10725             1668 => { Name => 'NonCPULens15MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10726             1672 => { Name => 'NonCPULens16MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10727             1676 => { Name => 'NonCPULens17MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10728             1680 => { Name => 'NonCPULens18MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10729             1684 => { Name => 'NonCPULens19MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10730             1688 => { Name => 'NonCPULens20MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10731             1704 => { Name => 'HDMIOutputResolution', PrintConv => \%hDMIOutputResolutionZ9 },
10732             1717 => { Name => 'SetClockFromLocationData', PrintConv => \%offOn, Unknown => 1 },
10733             1724 => { Name => 'AirplaneMode', PrintConv => \%offOn, Unknown => 1 },
10734             1725 => { Name => 'EmptySlotRelease', PrintConv => { 0 => 'Disable Release', 1 => 'Enable Release' }, Unknown => 1 },
10735             1760 => { Name => 'EnergySavingMode', PrintConv => \%offOn, Unknown => 1 },
10736             1784 => { Name => 'RecordLocationData', PrintConv => \%offOn, Unknown => 1 },
10737             1788 => { Name => 'USBPowerDelivery', PrintConv => \%offOn, Unknown => 1 },
10738             1797 => { Name => 'SensorShield', PrintConv => { 0 => 'Stays Open', 1 => 'Closes' }, Unknown => 1 },
10739             1862 => {
10740             Name => 'AutoCapturePreset',
10741             PrintConv => {
10742             0 => '1',
10743             1 => '2',
10744             2 => '3',
10745             3 => '4',
10746             4 => '5',
10747             },
10748             },
10749             1864 => {
10750             Name => 'FocusShiftAutoReset',
10751             Unknown => 1,
10752             PrintConv => \%offOn,
10753             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10754             },
10755             1922 => { #CSd4-a
10756             Name => 'PreReleaseBurstLength',
10757             PrintConv => {
10758             0 => 'None',
10759             1 => '0.3 Sec',
10760             2 => '0.5 Sec',
10761             3 => '1 Sec',
10762             },
10763             },
10764             1924 => { #CSd4-b
10765             Name => 'PostReleaseBurstLength',
10766             PrintConv => {
10767             0 => '1 Sec',
10768             1 => '2 Sec',
10769             2 => '3 Sec',
10770             3 => 'Max',
10771             },
10772             },
10773             1938 => { Name => 'VerticalISOButton', %buttonsZ9}, #CSf2
10774             1940 => { Name => 'ExposureCompensationButton', %buttonsZ9}, #CSf2
10775             1942 => { Name => 'ISOButton', %buttonsZ9}, #CSf2
10776             2002 => { Name => 'ViewModeShowEffectsOfSettings', PrintConv => { 0=>'Always', 1=> 'Only When Flash Not Used'}, Unknown => 1 }, #CSd9-a
10777             2004 => { Name => 'DispButton', %buttonsZ9}, #CSf2
10778             2048 => { #CSd6
10779             Name => 'ExposureDelay',
10780             Format => 'fixed32u',
10781             PrintConv => '$val ? sprintf("%.1f sec",$val/1000) : "Off"',
10782             },
10783             2052 => { #CSf2-m3
10784             Name => 'CommandDialFrameAdvanceZoom',
10785             Condition => '$$self{FirmwareVersion} and $$self{FirmwareVersion} ge "05.00"',
10786             PrintConv => \%dialsFrameAdvanceZoomPositionZ9,
10787             Unknown => 1
10788             },
10789             2054 => { #CSf2-n3
10790             Name => 'SubCommandDialFrameAdvanceZoom',
10791             Condition => '$$self{FirmwareVersion} and $$self{FirmwareVersion} ge "05.00"',
10792             PrintConv => \%dialsFrameAdvanceZoomPositionZ9,
10793             Unknown => 1
10794             },
10795             2056 => { Name => 'PlaybackButton', %buttonsZ9}, #CSf2
10796             2058 => { Name => 'WBButton', %buttonsZ9}, #CSf2
10797             2060 => { Name => 'BracketButton', %buttonsZ9}, #CSf2
10798             2062 => { Name => 'FlashModeButton', %buttonsZ9}, #CSf2
10799             2064 => { Name => 'LensFunc1ButtonPlaybackMode', %buttonsZ9}, #CSf2
10800             2066 => { Name => 'LensFunc2ButtonPlaybackMode', %buttonsZ9}, #CSf2
10801             2068 => { Name => 'PlaybackButtonPlaybackMode', %buttonsZ9}, #CSf2
10802             2070 => { Name => 'BracketButtonPlaybackMode', %buttonsZ9}, #CSf2
10803             2072 => { Name => 'FlashModeButtonPlaybackMode', %buttonsZ9}, #CSf2
10804             );
10805              
10806             # Flash information (ref JD)
10807             %Image::ExifTool::Nikon::FlashInfo0100 = (
10808             %binaryDataAttrs,
10809             DATAMEMBER => [ 9.2, 15, 16 ],
10810             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10811             NOTES => q{
10812             These tags are used by the D2H, D2Hs, D2X, D2Xs, D50, D70, D70s, D80 and
10813             D200.
10814             },
10815             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
10816             0 => {
10817             Name => 'FlashInfoVersion',
10818             Format => 'string[4]',
10819             Writable => 0,
10820             },
10821             4 => { #PH
10822             Name => 'FlashSource',
10823             PrintConv => {
10824             0 => 'None',
10825             1 => 'External',
10826             2 => 'Internal',
10827             },
10828             },
10829             # 5 - values: 46,48,50,54,78
10830             6 => {
10831             Format => 'int8u[2]',
10832             Name => 'ExternalFlashFirmware',
10833             SeparateTable => 'FlashFirmware',
10834             PrintConv => \%flashFirmware,
10835             },
10836             8 => {
10837             Name => 'ExternalFlashFlags',
10838             PrintConv => { 0 => '(none)',
10839             BITMASK => {
10840             0 => 'Fired', #28
10841             2 => 'Bounce Flash', #PH
10842             4 => 'Wide Flash Adapter',
10843             5 => 'Dome Diffuser', #28
10844             },
10845             },
10846             },
10847             9.1 => {
10848             Name => 'FlashCommanderMode',
10849             Mask => 0x80,
10850             PrintConv => { 0 => 'Off', 1 => 'On' },
10851             },
10852             9.2 => {
10853             Name => 'FlashControlMode',
10854             Mask => 0x7f,
10855             DataMember => 'FlashControlMode',
10856             RawConv => '$$self{FlashControlMode} = $val',
10857             PrintConv => \%flashControlMode,
10858             SeparateTable => 'FlashControlMode',
10859             },
10860             10 => [
10861             {
10862             Name => 'FlashOutput',
10863             Condition => '$$self{FlashControlMode} >= 0x06',
10864             ValueConv => '2 ** (-$val/6)',
10865             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
10866             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
10867             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
10868             },
10869             {
10870             Name => 'FlashCompensation',
10871             Format => 'int8s',
10872             Priority => 0,
10873             ValueConv => '-$val/6',
10874             ValueConvInv => '-6 * $val',
10875             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
10876             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
10877             },
10878             ],
10879             11 => {
10880             Name => 'FlashFocalLength',
10881             RawConv => '$val ? $val : undef',
10882             PrintConv => '"$val mm"',
10883             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
10884             },
10885             12 => {
10886             Name => 'RepeatingFlashRate',
10887             RawConv => '$val ? $val : undef',
10888             PrintConv => '"$val Hz"',
10889             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
10890             },
10891             13 => {
10892             Name => 'RepeatingFlashCount',
10893             RawConv => '$val ? $val : undef',
10894             },
10895             14 => { #PH
10896             Name => 'FlashGNDistance',
10897             SeparateTable => 1,
10898             PrintConv => \%flashGNDistance,
10899             },
10900             15 => {
10901             Name => 'FlashGroupAControlMode',
10902             Mask => 0x0f,
10903             DataMember => 'FlashGroupAControlMode',
10904             RawConv => '$$self{FlashGroupAControlMode} = $val',
10905             PrintConv => \%flashControlMode,
10906             SeparateTable => 'FlashControlMode',
10907             },
10908             16 => {
10909             Name => 'FlashGroupBControlMode',
10910             Mask => 0x0f,
10911             DataMember => 'FlashGroupBControlMode',
10912             RawConv => '$$self{FlashGroupBControlMode} = $val',
10913             PrintConv => \%flashControlMode,
10914             SeparateTable => 'FlashControlMode',
10915             },
10916             17 => [
10917             {
10918             Name => 'FlashGroupAOutput',
10919             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
10920             ValueConv => '2 ** (-$val/6)',
10921             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
10922             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
10923             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
10924             },
10925             {
10926             Name => 'FlashGroupACompensation',
10927             Format => 'int8s',
10928             ValueConv => '-$val/6',
10929             ValueConvInv => '-6 * $val',
10930             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
10931             PrintConvInv => '$val',
10932             },
10933             ],
10934             18 => [
10935             {
10936             Name => 'FlashGroupBOutput',
10937             Condition => '$$self{FlashGroupBControlMode} >= 0x06',
10938             ValueConv => '2 ** (-$val/6)',
10939             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
10940             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
10941             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
10942             },
10943             {
10944             Name => 'FlashGroupBCompensation',
10945             Format => 'int8s',
10946             ValueConv => '-$val/6',
10947             ValueConvInv => '-6 * $val',
10948             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
10949             PrintConvInv => '$val',
10950             },
10951             ],
10952             );
10953              
10954             # Flash information for D40, D40x, D3 and D300 (ref JD)
10955             %Image::ExifTool::Nikon::FlashInfo0102 = (
10956             %binaryDataAttrs,
10957             DATAMEMBER => [ 9.2, 16.1, 17.1, 17.2 ],
10958             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10959             NOTES => q{
10960             These tags are used by the D3 (firmware 1.x), D40, D40X, D60 and D300
10961             (firmware 1.00).
10962             },
10963             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
10964             0 => {
10965             Name => 'FlashInfoVersion',
10966             Format => 'string[4]',
10967             Writable => 0,
10968             },
10969             4 => { #PH
10970             Name => 'FlashSource',
10971             PrintConv => {
10972             0 => 'None',
10973             1 => 'External',
10974             2 => 'Internal',
10975             },
10976             },
10977             # 5 - values: 46,48,50,54,78
10978             6 => {
10979             Format => 'int8u[2]',
10980             Name => 'ExternalFlashFirmware',
10981             SeparateTable => 'FlashFirmware',
10982             PrintConv => \%flashFirmware,
10983             },
10984             8 => {
10985             Name => 'ExternalFlashFlags',
10986             PrintConv => { BITMASK => {
10987             0 => 'Fired', #28
10988             2 => 'Bounce Flash', #PH
10989             4 => 'Wide Flash Adapter',
10990             5 => 'Dome Diffuser', #28
10991             }},
10992             },
10993             9.1 => {
10994             Name => 'FlashCommanderMode',
10995             Mask => 0x80,
10996             PrintConv => { 0 => 'Off', 1 => 'On' },
10997             },
10998             9.2 => {
10999             Name => 'FlashControlMode',
11000             Mask => 0x7f,
11001             DataMember => 'FlashControlMode',
11002             RawConv => '$$self{FlashControlMode} = $val',
11003             PrintConv => \%flashControlMode,
11004             SeparateTable => 'FlashControlMode',
11005             },
11006             10 => [
11007             {
11008             Name => 'FlashOutput',
11009             Condition => '$$self{FlashControlMode} >= 0x06',
11010             ValueConv => '2 ** (-$val/6)',
11011             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11012             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11013             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11014             },
11015             {
11016             Name => 'FlashCompensation',
11017             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
11018             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
11019             Format => 'int8s',
11020             Priority => 0,
11021             ValueConv => '-$val/6',
11022             ValueConvInv => '-6 * $val',
11023             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
11024             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
11025             },
11026             ],
11027             12 => {
11028             Name => 'FlashFocalLength',
11029             RawConv => '$val ? $val : undef',
11030             PrintConv => '"$val mm"',
11031             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
11032             },
11033             13 => {
11034             Name => 'RepeatingFlashRate',
11035             RawConv => '$val ? $val : undef',
11036             PrintConv => '"$val Hz"',
11037             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
11038             },
11039             14 => {
11040             Name => 'RepeatingFlashCount',
11041             RawConv => '$val ? $val : undef',
11042             },
11043             15 => { #PH
11044             Name => 'FlashGNDistance',
11045             SeparateTable => 1,
11046             PrintConv => \%flashGNDistance,
11047             },
11048             16.1 => {
11049             Name => 'FlashGroupAControlMode',
11050             Mask => 0x0f,
11051             Notes => 'note: group A tags may apply to the built-in flash settings for some models',
11052             DataMember => 'FlashGroupAControlMode',
11053             RawConv => '$$self{FlashGroupAControlMode} = $val',
11054             PrintConv => \%flashControlMode,
11055             SeparateTable => 'FlashControlMode',
11056             },
11057             17.1 => {
11058             Name => 'FlashGroupBControlMode',
11059             Mask => 0xf0,
11060             Notes => 'note: group B tags may apply to group A settings for some models',
11061             DataMember => 'FlashGroupBControlMode',
11062             RawConv => '$$self{FlashGroupBControlMode} = $val',
11063             PrintConv => \%flashControlMode,
11064             SeparateTable => 'FlashControlMode',
11065             },
11066             17.2 => { #PH
11067             Name => 'FlashGroupCControlMode',
11068             Mask => 0x0f,
11069             Notes => 'note: group C tags may apply to group B settings for some models',
11070             DataMember => 'FlashGroupCControlMode',
11071             RawConv => '$$self{FlashGroupCControlMode} = $val',
11072             PrintConv => \%flashControlMode,
11073             SeparateTable => 'FlashControlMode',
11074             },
11075             18 => [
11076             {
11077             Name => 'FlashGroupAOutput',
11078             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
11079             ValueConv => '2 ** (-$val/6)',
11080             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11081             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11082             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11083             },
11084             {
11085             Name => 'FlashGroupACompensation',
11086             Format => 'int8s',
11087             ValueConv => '-$val/6',
11088             ValueConvInv => '-6 * $val',
11089             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11090             PrintConvInv => '$val',
11091             },
11092             ],
11093             19 => [
11094             {
11095             Name => 'FlashGroupBOutput',
11096             Condition => '$$self{FlashGroupBControlMode} >= 0x60',
11097             ValueConv => '2 ** (-$val/6)',
11098             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11099             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11100             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11101             },
11102             {
11103             Name => 'FlashGroupBCompensation',
11104             Format => 'int8s',
11105             ValueConv => '-$val/6',
11106             ValueConvInv => '-6 * $val',
11107             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11108             PrintConvInv => '$val',
11109             },
11110             ],
11111             20 => [ #PH
11112             {
11113             Name => 'FlashGroupCOutput',
11114             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
11115             ValueConv => '2 ** (-$val/6)',
11116             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11117             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11118             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11119             },
11120             {
11121             Name => 'FlashGroupCCompensation',
11122             Format => 'int8s',
11123             ValueConv => '-$val/6',
11124             ValueConvInv => '-6 * $val',
11125             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11126             PrintConvInv => '$val',
11127             },
11128             ],
11129             );
11130              
11131             # Flash information for D90 and D700 (ref PH)
11132             # - confirmed in detail for D800 (0105) - PH
11133             %Image::ExifTool::Nikon::FlashInfo0103 = (
11134             %binaryDataAttrs,
11135             DATAMEMBER => [ 9.2, 17.1, 18.1, 18.2 ],
11136             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
11137             NOTES => q{
11138             These tags are used by the D3 (firmware 2.x), D3X, D3S, D4, D90, D300
11139             (firmware 1.10), D300S, D600, D700, D800, D3000, D3100, D3200, D5000, D5100,
11140             D5200, D7000.
11141             },
11142             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
11143             0 => {
11144             Name => 'FlashInfoVersion',
11145             Format => 'string[4]',
11146             Writable => 0,
11147             },
11148             4 => { #PH
11149             Name => 'FlashSource',
11150             PrintConv => {
11151             0 => 'None',
11152             1 => 'External',
11153             2 => 'Internal',
11154             },
11155             },
11156             # 5 - values: 46,48,50,54,78
11157             6 => {
11158             Format => 'int8u[2]',
11159             Name => 'ExternalFlashFirmware',
11160             SeparateTable => 'FlashFirmware',
11161             PrintConv => \%flashFirmware,
11162             },
11163             8 => {
11164             Name => 'ExternalFlashFlags',
11165             PrintConv => { BITMASK => {
11166             0 => 'Fired', #28
11167             2 => 'Bounce Flash', #PH
11168             4 => 'Wide Flash Adapter',
11169             5 => 'Dome Diffuser', #28
11170             }},
11171             },
11172             9.1 => {
11173             Name => 'FlashCommanderMode',
11174             Mask => 0x80,
11175             PrintConv => { 0 => 'Off', 1 => 'On' },
11176             },
11177             9.2 => {
11178             Name => 'FlashControlMode',
11179             Mask => 0x7f,
11180             DataMember => 'FlashControlMode',
11181             RawConv => '$$self{FlashControlMode} = $val',
11182             PrintConv => \%flashControlMode,
11183             SeparateTable => 'FlashControlMode',
11184             },
11185             10 => [
11186             {
11187             Name => 'FlashOutput',
11188             Condition => '$$self{FlashControlMode} >= 0x06',
11189             ValueConv => '2 ** (-$val/6)',
11190             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11191             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11192             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11193             },
11194             {
11195             Name => 'FlashCompensation',
11196             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
11197             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
11198             Format => 'int8s',
11199             Priority => 0,
11200             ValueConv => '-$val/6',
11201             ValueConvInv => '-6 * $val',
11202             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
11203             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
11204             },
11205             ],
11206             12 => { #JD
11207             Name => 'FlashFocalLength',
11208             RawConv => '($val and $val != 255) ? $val : undef',
11209             PrintConv => '"$val mm"',
11210             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
11211             },
11212             13 => { #JD
11213             Name => 'RepeatingFlashRate',
11214             RawConv => '($val and $val != 255) ? $val : undef',
11215             PrintConv => '"$val Hz"',
11216             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
11217             },
11218             14 => { #JD
11219             Name => 'RepeatingFlashCount',
11220             RawConv => '($val and $val != 255) ? $val : undef',
11221             },
11222             15 => { #28
11223             Name => 'FlashGNDistance',
11224             SeparateTable => 1,
11225             PrintConv => \%flashGNDistance,
11226             },
11227             16 => { #28
11228             Name => 'FlashColorFilter',
11229             SeparateTable => 1,
11230             PrintConv => \%flashColorFilter,
11231             },
11232             17.1 => {
11233             Name => 'FlashGroupAControlMode',
11234             Mask => 0x0f,
11235             Notes => 'note: group A tags may apply to the built-in flash settings for some models',
11236             DataMember => 'FlashGroupAControlMode',
11237             RawConv => '$$self{FlashGroupAControlMode} = $val',
11238             PrintConv => \%flashControlMode,
11239             SeparateTable => 'FlashControlMode',
11240             },
11241             18.1 => {
11242             Name => 'FlashGroupBControlMode',
11243             Mask => 0xf0,
11244             Notes => 'note: group B tags may apply to group A settings for some models',
11245             DataMember => 'FlashGroupBControlMode',
11246             RawConv => '$$self{FlashGroupBControlMode} = $val',
11247             PrintConv => \%flashControlMode,
11248             SeparateTable => 'FlashControlMode',
11249             },
11250             18.2 => { #PH
11251             Name => 'FlashGroupCControlMode',
11252             Mask => 0x0f,
11253             Notes => 'note: group C tags may apply to group B settings for some models',
11254             DataMember => 'FlashGroupCControlMode',
11255             RawConv => '$$self{FlashGroupCControlMode} = $val',
11256             PrintConv => \%flashControlMode,
11257             SeparateTable => 'FlashControlMode',
11258             },
11259             0x13 => [
11260             {
11261             Name => 'FlashGroupAOutput',
11262             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
11263             ValueConv => '2 ** (-$val/6)',
11264             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11265             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11266             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11267             },
11268             {
11269             Name => 'FlashGroupACompensation',
11270             Format => 'int8s',
11271             ValueConv => '-$val/6',
11272             ValueConvInv => '-6 * $val',
11273             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11274             PrintConvInv => '$val',
11275             },
11276             ],
11277             0x14 => [
11278             {
11279             Name => 'FlashGroupBOutput',
11280             Condition => '$$self{FlashGroupBControlMode} >= 0x60',
11281             ValueConv => '2 ** (-$val/6)',
11282             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11283             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11284             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11285             },
11286             {
11287             Name => 'FlashGroupBCompensation',
11288             Format => 'int8s',
11289             ValueConv => '-$val/6',
11290             ValueConvInv => '-6 * $val',
11291             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11292             PrintConvInv => '$val',
11293             },
11294             ],
11295             0x15 => [ #PH
11296             {
11297             Name => 'FlashGroupCOutput',
11298             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
11299             ValueConv => '2 ** (-$val/6)',
11300             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11301             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11302             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11303             },
11304             {
11305             Name => 'FlashGroupCCompensation',
11306             Format => 'int8s',
11307             ValueConv => '-$val/6',
11308             ValueConvInv => '-6 * $val',
11309             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11310             PrintConvInv => '$val',
11311             },
11312             ],
11313             0x1b => { #PH
11314             Name => 'ExternalFlashCompensation',
11315             Format => 'int8s',
11316             Priority => 0,
11317             ValueConv => '-$val/6',
11318             ValueConvInv => '-6 * $val',
11319             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
11320             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
11321             },
11322             0x1d => { #PH
11323             Name => 'FlashExposureComp3',
11324             Format => 'int8s',
11325             # (does not include the built-in compensation for FlashType "Built-in,TTL&Comdr.")
11326             Notes => 'does not include the effect of flash bracketing',
11327             Priority => 0,
11328             ValueConv => '-$val/6',
11329             ValueConvInv => '-6 * $val',
11330             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
11331             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
11332             },
11333             0x27 => { #PH (same as ShotInfoD800 0x4d2 but also valid for repeating flash)
11334             Name => 'FlashExposureComp4',
11335             Format => 'int8s',
11336             Notes => 'includes the effect of flash bracketing. Valid for repeating flash',
11337             Priority => 0,
11338             ValueConv => '-$val/6',
11339             ValueConvInv => '-6 * $val',
11340             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
11341             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
11342             },
11343             # 0x2b - related to flash power (PH, D800, 96=full,62=1/4,2=1/128)
11344             );
11345              
11346             # Flash information for the D7100 (ref PH)
11347             # (this is VERY similar to FlashInfo0107, but there are a few differences that
11348             # would need to be resolved if these two definitions were to be combined)
11349             %Image::ExifTool::Nikon::FlashInfo0106 = (
11350             %binaryDataAttrs,
11351             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
11352             DATAMEMBER => [ 9.2, 17.1, 18.1, 18.2 ],
11353             NOTES => 'These tags are used by the Df, D610, D3300, D5300, D7100 and Coolpix A.',
11354             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
11355             0 => {
11356             Name => 'FlashInfoVersion',
11357             Format => 'string[4]',
11358             Writable => 0,
11359             },
11360             4 => {
11361             Name => 'FlashSource',
11362             PrintConv => {
11363             0 => 'None',
11364             1 => 'External',
11365             2 => 'Internal',
11366             },
11367             },
11368             6 => {
11369             Format => 'int8u[2]',
11370             Name => 'ExternalFlashFirmware',
11371             SeparateTable => 'FlashFirmware',
11372             PrintConv => \%flashFirmware,
11373             },
11374             8 => {
11375             Name => 'ExternalFlashFlags',
11376             PrintConv => { BITMASK => {
11377             0 => 'Fired',
11378             2 => 'Bounce Flash',
11379             4 => 'Wide Flash Adapter',
11380             5 => 'Dome Diffuser', # (NC, not true for the SB-910 anyway)
11381             # 7 - ? (set for SB-910 when an advanced option is used, eg. diff pattern)
11382             }},
11383             },
11384             9.1 => { # (NC)
11385             Name => 'FlashCommanderMode',
11386             Mask => 0x80,
11387             PrintConv => { 0 => 'Off', 1 => 'On' },
11388             },
11389             9.2 => {
11390             Name => 'FlashControlMode',
11391             Mask => 0x7f,
11392             DataMember => 'FlashControlMode',
11393             RawConv => '$$self{FlashControlMode} = $val',
11394             PrintConv => \%flashControlMode,
11395             SeparateTable => 'FlashControlMode',
11396             },
11397             # 10 - similar to 0x27 but zero sometimes when I don't think it should be
11398             12 => {
11399             Name => 'FlashFocalLength',
11400             Notes => 'only valid if flash pattern is "Standard Illumination"',
11401             RawConv => '($val and $val != 255) ? $val : undef',
11402             PrintConv => '"$val mm"',
11403             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
11404             },
11405             13 => {
11406             Name => 'RepeatingFlashRate',
11407             RawConv => '($val and $val != 255) ? $val : undef',
11408             PrintConv => '"$val Hz"',
11409             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
11410             },
11411             14 => {
11412             Name => 'RepeatingFlashCount',
11413             RawConv => '($val and $val != 255) ? $val : undef',
11414             },
11415             15 => { # (NC)
11416             Name => 'FlashGNDistance',
11417             SeparateTable => 1,
11418             PrintConv => \%flashGNDistance,
11419             },
11420             16 => {
11421             Name => 'FlashColorFilter',
11422             SeparateTable => 1,
11423             PrintConv => \%flashColorFilter,
11424             },
11425             17.1 => {
11426             Name => 'FlashGroupAControlMode',
11427             Mask => 0x0f,
11428             DataMember => 'FlashGroupAControlMode',
11429             RawConv => '$$self{FlashGroupAControlMode} = $val',
11430             PrintConv => \%flashControlMode,
11431             SeparateTable => 'FlashControlMode',
11432             },
11433             18.1 => {
11434             Name => 'FlashGroupBControlMode',
11435             Mask => 0xf0,
11436             DataMember => 'FlashGroupBControlMode',
11437             RawConv => '$$self{FlashGroupBControlMode} = $val',
11438             PrintConv => \%flashControlMode,
11439             SeparateTable => 'FlashControlMode',
11440             },
11441             18.2 => {
11442             Name => 'FlashGroupCControlMode',
11443             Mask => 0x0f,
11444             DataMember => 'FlashGroupCControlMode',
11445             RawConv => '$$self{FlashGroupCControlMode} = $val',
11446             PrintConv => \%flashControlMode,
11447             SeparateTable => 'FlashControlMode',
11448             },
11449             # 0x13 - same as 0x28 but not zero when flash group A is Off
11450             # 0x14 - same as 0x29 but not zero when flash group B is Off
11451             # 0x15 - same as 0x2a but not zero when flash group B is Off
11452             # 0x1a - changes with illumination pattern (0=normal,1=narrow,2=wide), but other values seen
11453             # 0x26 - changes when diffuser is used
11454             0x27 => [
11455             {
11456             Name => 'FlashOutput',
11457             Condition => '$$self{FlashControlMode} >= 0x06',
11458             ValueConv => '2 ** (-$val/6)',
11459             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11460             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11461             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11462             },
11463             {
11464             Name => 'FlashCompensation',
11465             Format => 'int8s',
11466             Priority => 0,
11467             ValueConv => '-$val/6',
11468             ValueConvInv => '-6 * $val',
11469             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
11470             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
11471             },
11472             ],
11473             0x28 => [
11474             {
11475             Name => 'FlashGroupAOutput',
11476             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
11477             ValueConv => '2 ** (-$val/6)',
11478             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11479             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11480             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11481             },
11482             {
11483             Name => 'FlashGroupACompensation',
11484             Format => 'int8s',
11485             ValueConv => '-$val/6',
11486             ValueConvInv => '-6 * $val',
11487             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11488             PrintConvInv => '$val',
11489             },
11490             ],
11491             0x29 => [
11492             {
11493             Name => 'FlashGroupBOutput',
11494             Condition => '$$self{FlashGroupBControlMode} >= 0x60',
11495             ValueConv => '2 ** (-$val/6)',
11496             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11497             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11498             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11499             },
11500             {
11501             Name => 'FlashGroupBCompensation',
11502             Format => 'int8s',
11503             ValueConv => '-$val/6',
11504             ValueConvInv => '-6 * $val',
11505             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11506             PrintConvInv => '$val',
11507             },
11508             ],
11509             0x2a => [
11510             {
11511             Name => 'FlashGroupCOutput',
11512             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
11513             ValueConv => '2 ** (-$val/6)',
11514             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11515             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11516             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11517             },
11518             {
11519             Name => 'FlashGroupCCompensation',
11520             Format => 'int8s',
11521             ValueConv => '-$val/6',
11522             ValueConvInv => '-6 * $val',
11523             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11524             PrintConvInv => '$val',
11525             },
11526             ],
11527             );
11528              
11529             # Flash information for the D4S/D750/D810/D5500/D7200 (0107)
11530             # and D5/D500/D850/D3400 (0108) (ref 28)
11531             %Image::ExifTool::Nikon::FlashInfo0107 = (
11532             %binaryDataAttrs,
11533             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
11534             DATAMEMBER => [ 17.1, 18.1, 18.2 ],
11535             NOTES => q{
11536             These tags are used by the D4S, D750, D810, D5500, D7200 (FlashInfoVersion
11537             0107) and the D5, D500, D850 and D3400 (FlashInfoVersion 0108).
11538             },
11539             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
11540             0 => {
11541             Name => 'FlashInfoVersion',
11542             Format => 'string[4]',
11543             Writable => 0,
11544             },
11545             4 => {
11546             Name => 'FlashSource',
11547             PrintConv => {
11548             0 => 'None',
11549             1 => 'External',
11550             2 => 'Internal',
11551             },
11552             },
11553             6 => {
11554             Format => 'int8u[2]',
11555             Name => 'ExternalFlashFirmware',
11556             SeparateTable => 'FlashFirmware',
11557             PrintConv => \%flashFirmware,
11558             },
11559             8.1 => {
11560             Name => 'ExternalFlashZoomOverride',
11561             Mask => 0x80,
11562             Notes => 'indicates that the user has overridden the flash zoom distance',
11563             PrintConv => { 0 => 'No', 1 => 'Yes' },
11564             },
11565             8.2 => {
11566             Name => 'ExternalFlashStatus',
11567             Mask => 0x01,
11568             PrintConv => {
11569             0 => 'Flash Not Attached',
11570             1 => 'Flash Attached',
11571             },
11572             },
11573             9.1 => {
11574             Name => 'ExternalFlashReadyState',
11575             Mask => 0x07,
11576             PrintConv => {
11577             0 => 'n/a',
11578             1 => 'Ready',
11579             6 => 'Not Ready',
11580             },
11581             },
11582             10 => {
11583             Name => 'FlashCompensation',
11584             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
11585             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
11586             Format => 'int8s',
11587             Priority => 0,
11588             ValueConv => '-$val/6',
11589             ValueConvInv => '-6 * $val',
11590             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
11591             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
11592             },
11593             12 => {
11594             Name => 'FlashFocalLength',
11595             Notes => 'only valid if flash pattern is "Standard Illumination"', #illumination pattern no no supported starting with the SB-910
11596             RawConv => '($val and $val != 255) ? $val : undef',
11597             PrintConv => '"$val mm"',
11598             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
11599             },
11600             13 => {
11601             Name => 'RepeatingFlashRate',
11602             RawConv => '($val and $val != 255) ? $val : undef',
11603             PrintConv => '"$val Hz"',
11604             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
11605             },
11606             14 => {
11607             Name => 'RepeatingFlashCount',
11608             RawConv => '($val and $val != 255) ? $val : undef',
11609             },
11610             15 => {
11611             Name => 'FlashGNDistance',
11612             SeparateTable => 1,
11613             PrintConv => \%flashGNDistance,
11614             },
11615             17.1 => { #PH
11616             Name => 'FlashGroupAControlMode',
11617             Mask => 0x0f,
11618             Notes => 'note: group A tags may apply to the built-in flash settings for some models',
11619             DataMember => 'FlashGroupAControlMode',
11620             RawConv => '$$self{FlashGroupAControlMode} = $val',
11621             PrintConv => \%flashControlMode,
11622             SeparateTable => 'FlashControlMode',
11623             },
11624             18.1 => { #PH
11625             Name => 'FlashGroupBControlMode',
11626             Mask => 0xf0,
11627             Notes => 'note: group B tags may apply to group A settings for some models',
11628             DataMember => 'FlashGroupBControlMode',
11629             RawConv => '$$self{FlashGroupBControlMode} = $val',
11630             PrintConv => \%flashControlMode,
11631             SeparateTable => 'FlashControlMode',
11632             },
11633             18.2 => { #PH
11634             Name => 'FlashGroupCControlMode',
11635             Mask => 0x0f,
11636             Notes => 'note: group C tags may apply to group B settings for some models',
11637             DataMember => 'FlashGroupCControlMode',
11638             RawConv => '$$self{FlashGroupCControlMode} = $val',
11639             PrintConv => \%flashControlMode,
11640             SeparateTable => 'FlashControlMode',
11641             },
11642             # 0x13 - very similar to 0x28
11643             # 0x18 or 0x19 may indicate flash illumination pattern (Standard, Center-weighted, Even)
11644             0x28 => [ #PH
11645             {
11646             Name => 'FlashGroupAOutput',
11647             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
11648             ValueConv => '2 ** (-$val/6)',
11649             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11650             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11651             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11652             },
11653             {
11654             Name => 'FlashGroupACompensation',
11655             Format => 'int8s',
11656             ValueConv => '-$val/6',
11657             ValueConvInv => '-6 * $val',
11658             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11659             PrintConvInv => '$val',
11660             },
11661             ],
11662             0x29 => [ #PH
11663             {
11664             Name => 'FlashGroupBOutput',
11665             Condition => '$$self{FlashGroupBControlMode} >= 0x06',
11666             ValueConv => '2 ** (-$val/6)',
11667             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11668             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11669             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11670             },
11671             {
11672             Name => 'FlashGroupBCompensation',
11673             Format => 'int8s',
11674             ValueConv => '-$val/6',
11675             ValueConvInv => '-6 * $val',
11676             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11677             PrintConvInv => '$val',
11678             },
11679             ],
11680             0x2a => [ #PH
11681             {
11682             Name => 'FlashGroupCOutput',
11683             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
11684             ValueConv => '2 ** (-$val/6)',
11685             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11686             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11687             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11688             },
11689             {
11690             Name => 'FlashGroupCCompensation',
11691             Format => 'int8s',
11692             ValueConv => '-$val/6',
11693             ValueConvInv => '-6 * $val',
11694             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11695             PrintConvInv => '$val',
11696             },
11697             ],
11698             );
11699              
11700             # Flash information for the Z7II (ref 28)
11701             # (likey similar to FlashInfo010 and FlashInfo0108 with addition of support for radio controlled units such as the SB-5000?
11702             %Image::ExifTool::Nikon::FlashInfo0300 = (
11703             %binaryDataAttrs,
11704             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
11705             DATAMEMBER => [ 9.2, 17.1, 18.1, 18.2 ],
11706             0 => {
11707             Name => 'FlashInfoVersion',
11708             Format => 'string[4]',
11709             Writable => 0,
11710             },
11711             4 => {
11712             Name => 'FlashSource',
11713             PrintConv => {
11714             0 => 'None',
11715             1 => 'External',
11716             2 => 'Internal',
11717             },
11718             },
11719             6 => {
11720             Name => 'ExternalFlashFirmware',
11721             Format => 'int8u[2]',
11722             SeparateTable => 'FlashFirmware',
11723             PrintConv => \%flashFirmware,
11724             },
11725             8 => {
11726             Name => 'ExternalFlashFlags',
11727             PrintConv => { BITMASK => {
11728             0 => 'Flash Ready', #flash status is 'Not Ready' when this bit is off and FlashSource is non-zero
11729             # 1 - ? (observed with SB-900)
11730             2 => 'Bounce Flash',
11731             4 => 'Wide Flash Adapter',
11732             7 => 'Zoom Override', #override takes place when the Wide Flash Adapter is dropped in place and/or the zoom level is overriden on via flash menu
11733             }},
11734             },
11735             9.1 => {
11736             Name => 'FlashCommanderMode',
11737             Mask => 0x80,
11738             PrintConv => { 0 => 'Off', 1 => 'On' },
11739             },
11740             9.2 => {
11741             Name => 'FlashControlMode',
11742             Mask => 0x7f,
11743             DataMember => 'FlashControlMode',
11744             RawConv => '$$self{FlashControlMode} = $val',
11745             PrintConv => \%flashControlMode,
11746             SeparateTable => 'FlashControlMode',
11747             },
11748             10 => {
11749             Name => 'FlashCompensation',
11750             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
11751             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
11752             Condition => '$$self{FlashControlMode} == 0x01 or $$self{FlashControlMode} == 0x02', #only valid for TTL and TTL-BL modes
11753             Format => 'int8s',
11754             Priority => 0,
11755             ValueConv => '-$val/6',
11756             ValueConvInv => '-6 * $val',
11757             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
11758             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
11759             },
11760             13 => {
11761             Name => 'RepeatingFlashRate',
11762             RawConv => '($val and $val != 255) ? $val : undef',
11763             PrintConv => '"$val Hz"',
11764             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
11765             },
11766             14 => {
11767             Name => 'RepeatingFlashCount',
11768             RawConv => '($val and $val != 255) ? $val : undef',
11769             },
11770             15 => {
11771             Name => 'FlashGNDistance',
11772             SeparateTable => 1,
11773             PrintConv => \%flashGNDistance,
11774             },
11775             16 => {
11776             Name => 'FlashColorFilter',
11777             SeparateTable => 1,
11778             PrintConv => \%flashColorFilter,
11779             },
11780             17.1 => { #PH
11781             Name => 'FlashGroupAControlMode',
11782             Mask => 0x0f,
11783             Notes => 'note: group A tags may apply to the built-in flash settings for some models',
11784             DataMember => 'FlashGroupAControlMode',
11785             RawConv => '$$self{FlashGroupAControlMode} = $val',
11786             PrintConv => \%flashControlMode,
11787             SeparateTable => 'FlashControlMode',
11788             },
11789             18.1 => { #PH
11790             Name => 'FlashGroupBControlMode',
11791             Mask => 0xf0,
11792             Notes => 'note: group B tags may apply to group A settings for some models',
11793             DataMember => 'FlashGroupBControlMode',
11794             RawConv => '$$self{FlashGroupBControlMode} = $val',
11795             PrintConv => \%flashControlMode,
11796             SeparateTable => 'FlashControlMode',
11797             },
11798             18.2 => { #PH
11799             Name => 'FlashGroupCControlMode',
11800             Mask => 0x0f,
11801             Notes => 'note: group C tags may apply to group B settings for some models',
11802             DataMember => 'FlashGroupCControlMode',
11803             RawConv => '$$self{FlashGroupCControlMode} = $val',
11804             PrintConv => \%flashControlMode,
11805             SeparateTable => 'FlashControlMode',
11806             },
11807             33 => {
11808             Name => 'FlashOutput',
11809             Condition => '$$self{FlashControlMode} >= 0x06', #only valid for M mode
11810             ValueConv => '2 ** (-$val/6)',
11811             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11812             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11813             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11814             },
11815             37 => {
11816             Name => 'FlashIlluminationPattern',
11817             PrintConv => {
11818             0 => 'Standard',
11819             1 => 'Center-weighted',
11820             2 => 'Even',
11821             },
11822             },
11823             38 => {
11824             Name => 'FlashFocalLength',
11825             Notes => 'only valid if flash pattern is "Standard Illumination"',
11826             RawConv => '($val and $val != 255) ? $val : undef',
11827             PrintConv => '"$val mm"',
11828             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
11829             },
11830             40 => [ #PH
11831             {
11832             Name => 'FlashGroupAOutput',
11833             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
11834             ValueConv => '2 ** (-$val/6)',
11835             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11836             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11837             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11838             },
11839             {
11840             Name => 'FlashGroupACompensation',
11841             Format => 'int8s',
11842             ValueConv => '-($val-2)/6',
11843             ValueConvInv => '-6 * $val + 2',
11844             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11845             PrintConvInv => '$val',
11846             },
11847             ],
11848             41 => [ #PH
11849             {
11850             Name => 'FlashGroupBOutput',
11851             Condition => '$$self{FlashGroupBControlMode} >= 0x06',
11852             ValueConv => '2 ** (-$val/6)',
11853             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11854             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11855             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11856             },
11857             {
11858             Name => 'FlashGroupBCompensation',
11859             Format => 'int8s',
11860             ValueConv => '-($val-2)/6',
11861             ValueConvInv => '-6 * $val + 2',
11862             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11863             PrintConvInv => '$val',
11864             },
11865             ],
11866             42 => [ #PH
11867             {
11868             Name => 'FlashGroupCOutput',
11869             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
11870             ValueConv => '2 ** (-$val/6)',
11871             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11872             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11873             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11874             },
11875             {
11876             Name => 'FlashGroupCCompensation',
11877             Format => 'int8s',
11878             ValueConv => '-($val-2)/6',
11879             ValueConvInv => '-6 * $val + 2',
11880             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11881             PrintConvInv => '$val',
11882             },
11883             ],
11884             );
11885             # Unknown Flash information
11886             %Image::ExifTool::Nikon::FlashInfoUnknown = (
11887             %binaryDataAttrs,
11888             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
11889             0 => {
11890             Name => 'FlashInfoVersion',
11891             Format => 'string[4]',
11892             Writable => 0,
11893             },
11894             );
11895              
11896             # Multi exposure / image overlay information (ref PH)
11897             %Image::ExifTool::Nikon::MultiExposure = (
11898             %binaryDataAttrs,
11899             FORMAT => 'int32u',
11900             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
11901             0 => {
11902             Name => 'MultiExposureVersion',
11903             Format => 'string[4]',
11904             Writable => 0,
11905             },
11906             1 => {
11907             Name => 'MultiExposureMode',
11908             PrintConv => {
11909             0 => 'Off',
11910             1 => 'Multiple Exposure',
11911             2 => 'Image Overlay',
11912             3 => 'HDR', #31
11913             },
11914             },
11915             2 => 'MultiExposureShots',
11916             3 => {
11917             Name => 'MultiExposureAutoGain',
11918             PrintConv => \%offOn,
11919             },
11920             );
11921              
11922             # Multi exposure2 / image overlay information (ref 39)
11923             %Image::ExifTool::Nikon::MultiExposure2 = (
11924             %binaryDataAttrs,
11925             FORMAT => 'int32u',
11926             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
11927             0 => {
11928             Name => 'MultiExposureVersion',
11929             Format => 'string[4]',
11930             Writable => 0,
11931             },
11932             1 => {
11933             Name => 'MultiExposureMode',
11934             PrintConv => {
11935             0 => 'Off',
11936             1 => 'Multiple Exposure',
11937             3 => 'HDR',
11938             },
11939             },
11940             2 => 'MultiExposureShots',
11941             3 => {
11942             Name => 'MultiExposureOverlayMode',
11943             PrintConv => {
11944             0 => 'Add',
11945             1 => 'Average',
11946             2 => 'Light',
11947             3 => 'Dark',
11948             },
11949             },
11950             );
11951              
11952             # HDR information (ref 32)
11953             %Image::ExifTool::Nikon::HDRInfo = (
11954             %binaryDataAttrs,
11955             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
11956             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
11957             0 => {
11958             Name => 'HDRInfoVersion',
11959             Format => 'string[4]',
11960             Writable => 0,
11961             },
11962             4 => {
11963             Name => 'HDR',
11964             PrintConv => {
11965             0 => 'Off',
11966             1 => 'On (normal)',
11967             48 => 'Auto', #PH (NC)
11968             },
11969             },
11970             5 => {
11971             Name => 'HDRLevel',
11972             PrintConv => {
11973             0 => 'Auto',
11974             1 => '1 EV',
11975             2 => '2 EV',
11976             3 => '3 EV',
11977             # 5 - seen for 1J4
11978             255 => 'n/a', #PH
11979             },
11980             },
11981             6 => {
11982             Name => 'HDRSmoothing',
11983             PrintConv => {
11984             0 => 'Off',
11985             1 => 'Normal',
11986             2 => 'Low',
11987             3 => 'High',
11988             48 => 'Auto', #PH (NC)
11989             255 => 'n/a', #PH
11990             },
11991             },
11992             7 => { #PH (P330, HDRInfoVersion=0101)
11993             Name => 'HDRLevel2',
11994             PrintConv => {
11995             0 => 'Auto',
11996             1 => '1 EV',
11997             2 => '2 EV',
11998             3 => '3 EV',
11999             255 => 'n/a',
12000             },
12001             },
12002             );
12003              
12004             # ref 39 (Z9)
12005             %Image::ExifTool::Nikon::HDRInfo2 = (
12006             %binaryDataAttrs,
12007             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
12008             0 => {
12009             Name => 'HDRInfoVersion', # 0200
12010             Format => 'string[4]',
12011             Writable => 0,
12012             },
12013             4 => {
12014             Name => 'HDR',
12015             PrintConv => {
12016             0 => 'Off',
12017             1 => 'On (normal)',
12018             },
12019             },
12020             5 => {
12021             Name => 'HDRLevel',
12022             PrintConv => {
12023             0 => 'n/a',
12024             1 => 'Normal',
12025             2 => 'Low',
12026             3 => 'High',
12027             4 => 'High+',
12028             5 => 'Auto',
12029             },
12030             },
12031             );
12032              
12033             # location information (ref PH)
12034             %Image::ExifTool::Nikon::LocationInfo = (
12035             %binaryDataAttrs,
12036             DATAMEMBER => [ 4 ],
12037             GROUPS => { 0 => 'MakerNotes', 2 => 'Location' },
12038             NOTES => 'Tags written by some Nikon GPS-equipped cameras like the AW100.',
12039             0 => {
12040             Name => 'LocationInfoVersion',
12041             Format => 'undef[4]',
12042             },
12043             4 => {
12044             Name => 'TextEncoding',
12045             DataMember => 'TextEncoding',
12046             RawConv => q{
12047             $$self{TextEncoding} = $Image::ExifTool::Nikon::nikonTextEncoding{$val} if $val;
12048             return $val;
12049             },
12050             PrintConv => \%Image::ExifTool::Nikon::nikonTextEncoding,
12051             },
12052             # (the CountryCode and Location tag names chosen to correspond with XMP::iptcCore)
12053             5 => {
12054             Name => 'CountryCode',
12055             Format => 'undef[3]',
12056             ValueConv => '$val=~s/\0.*//s; $val', # truncate at null
12057             ValueConvInv => '$val',
12058             },
12059             8 => 'POILevel', #forum5782
12060             9 => {
12061             Name => 'Location',
12062             Format => 'undef[70]',
12063             RawConv => '$$self{TextEncoding} ? $self->Decode($val,$$self{TextEncoding},"MM") : $val',
12064             RawConvInv => '$$self{TextEncoding} ? $self->Encode($val,$$self{TextEncoding},"MM") : $val',
12065             },
12066             );
12067              
12068             # MakerNotes0x51 - compression info for Z8 and Z9
12069             %Image::ExifTool::Nikon::MakerNotes0x51 = (
12070             %binaryDataAttrs,
12071             GROUPS => { 0 => 'MakerNotes' },
12072             0 => {
12073             Name => 'FirmwareVersion51',
12074             Format => 'string[8]',
12075             Writable => 0,
12076             ValueConv => 'join ".", $val =~ /../g',
12077             },
12078             10 => {
12079             Name => 'NEFCompression',
12080             Format => 'int16u',
12081             SeparateTable => 'NEFCompression',
12082             PrintConv => \%nefCompression,
12083             },
12084             );
12085              
12086             # MakerNotes0x56 - burst info for Z8 and Z9
12087             %Image::ExifTool::Nikon::MakerNotes0x56 = (
12088             %binaryDataAttrs,
12089             GROUPS => { 0 => 'MakerNotes' },
12090             DATAMEMBER => [ 4, 12 ],
12091             0 => {
12092             Name => 'FirmwareVersion56',
12093             Format => 'string[4]',
12094             Writable => 0,
12095             ValueConv => '$val =~ s/(\d{2})/$1./; $val',
12096             },
12097             4 => {
12098             Name => 'BurstFlag',
12099             RawConv => '$$self{BurstFlag} = $val; undef',
12100             Hidden => 1,
12101             },
12102             # decoding of Burst tags ref forum17835 and
12103             # https://www.dpreview.com/forums/threads/nc_fllst-dat-for-the-z9-figured-out-what-its-for-and-deciphered-it.4757978/
12104             4.1 => {
12105             Name => 'BurstStartSlotNumber',
12106             Format => 'int32u',
12107             Condition => '$$self{BurstFlag}',
12108             Mask => 0x20000000,
12109             ValueConv => '$val + 1',
12110             ValueConvInv => '$val - 1',
12111             },
12112             4.2 => {
12113             Name => 'BurstStartFolderNumber',
12114             Format => 'int32u',
12115             Condition => '$$self{BurstFlag}',
12116             Mask => 0x1ff80000,
12117             },
12118             4.3 => {
12119             Name => 'BurstStartImageNumber',
12120             Format => 'int32u',
12121             Condition => '$$self{BurstFlag}',
12122             Mask => 0x0007ffe0,
12123             },
12124             4.4 => {
12125             Name => 'BurstStartImageType',
12126             Format => 'int32u',
12127             Condition => '$$self{BurstFlag}',
12128             Mask => 0x0000001f,
12129             PrintConv => {
12130             0 => 'JPG',
12131             2 => 'NEF',
12132             3 => 'TIF',
12133             4 => 'NDF',
12134             5 => 'MOV',
12135             6 => 'NEV',
12136             7 => 'MP4',
12137             },
12138             },
12139             8 => {
12140             Name => 'BurstShotNumber',
12141             Format => 'int32u',
12142             Condition => '$$self{BurstFlag}',
12143             },
12144             12 => {
12145             Name => 'PixelShiftActive', # 1 => Pixel shift enabled (either directly or thru Focus Shift Shooting with Z8 fw 3.0)
12146             RawConv => '$$self{PixelShiftActive} = $val',
12147             PrintConv => { 0 => 'No', 1 => 'Yes' },
12148             #Hidden => 1
12149             },
12150             );
12151              
12152             # extra info found in IFD0 of NEF files (ref PH, Z6/Z7)
12153             %Image::ExifTool::Nikon::NEFInfo = (
12154             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
12155             NOTES => q{
12156             As-yet unknown information found in SubIFD1 tag 0xc7d5 of NEF images from
12157             cameras such as the Z6 and Z7, and NRW images from some Coolpix cameras.
12158             },
12159             # 0x01 - undef[12]
12160             # 0x02 - undef[148]
12161             # 0x03 - undef[284]
12162             # 0x04 - undef[148,212]
12163             0x05 => { #28
12164             Name => 'DistortionInfo', # Z-series distortion correction information
12165             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::DistortionInfo' },
12166             },
12167             0x06 => { #28
12168             Name => 'VignetteInfo', # Z-series vignette correction information
12169             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::VignetteInfo' },
12170             },
12171             # 0x07 - undef[104] #possibly Z-series diffration correction information (#28)
12172             # 0x08 - undef[24]
12173             # 0x09 - undef[36]
12174             );
12175              
12176             # Z-series distortion correction information (correction model is appears to be a cubic polynomial) (ref 28)
12177             %Image::ExifTool::Nikon::DistortionInfo = (
12178             %binaryDataAttrs,
12179             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
12180             0 => {
12181             Name => 'DistortionCorrectionVersion',
12182             Format => 'string[4]',
12183             },
12184             4 => {
12185             Name => 'DistortionCorrection', #used by ACR to determine whether the built-in lens profile is applied
12186             Format => 'int8u',
12187             PrintConv => {
12188             0 => 'No Lens Attached', #to prevent reporting 'Unknown'
12189             1 => 'On (Optional)',
12190             2 => 'Off',
12191             3 => 'On (Required)',
12192             },
12193             },
12194             0x14 => {
12195             Name => 'RadialDistortionCoefficient1',
12196             Format => 'rational64s',
12197             PrintConv => 'sprintf("%.5f",$val)',
12198             },
12199             0x1c => {
12200             Name => 'RadialDistortionCoefficient2',
12201             Format => 'rational64s',
12202             PrintConv => 'sprintf("%.5f",$val)',
12203             },
12204             0x24 => {
12205             Name => 'RadialDistortionCoefficient3',
12206             Format => 'rational64s',
12207             PrintConv => 'sprintf("%.5f",$val)',
12208             },
12209             );
12210              
12211             # Z-series vignette correction information (correction model seems to be using a 6th order even polynomial) (ref 28)
12212             %Image::ExifTool::Nikon::VignetteInfo = (
12213             %binaryDataAttrs,
12214             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
12215             0 => {
12216             Name => 'VignetteCorrectionVersion',
12217             Format => 'string[4]',
12218             },
12219             #0x10 Degree of vignette correction polynomial? (always 8? - decodes for the first 3 coefficents follow, the 4th at 0x4c/0x50 seems to always be 0)
12220             0x24 => {
12221             Name => 'VignetteCoefficient1',
12222             Format => 'rational64s',
12223             PrintConv => 'sprintf("%.5f",$val)',
12224             },
12225             0x34 => {
12226             Name => 'VignetteCoefficient2',
12227             Format => 'rational64s',
12228             PrintConv => 'sprintf("%.5f",$val)',
12229             },
12230             0x44 => {
12231             Name => 'VignetteCoefficient3',
12232             Format => 'rational64s',
12233             PrintConv => 'sprintf("%.5f",$val)',
12234             },
12235             );
12236              
12237             # tags in Nikon QuickTime videos (PH - observations with Coolpix S3)
12238             # (similar information in Kodak,Minolta,Nikon,Olympus,Pentax and Sanyo videos)
12239             %Image::ExifTool::Nikon::MOV = (
12240             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
12241             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
12242             FIRST_ENTRY => 0,
12243             NOTES => q{
12244             This information is found in MOV and QT videos from some Nikon cameras.
12245             },
12246             0x00 => {
12247             Name => 'Make',
12248             Format => 'string[24]',
12249             },
12250             0x18 => {
12251             Name => 'Model',
12252             Description => 'Camera Model Name',
12253             Format => 'string[8]',
12254             },
12255             # (01 00 at offset 0x20)
12256             0x26 => {
12257             Name => 'ExposureTime',
12258             Format => 'int32u',
12259             ValueConv => '$val ? 10 / $val : 0',
12260             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
12261             },
12262             0x2a => {
12263             Name => 'FNumber',
12264             Format => 'rational64u',
12265             PrintConv => 'sprintf("%.1f",$val)',
12266             },
12267             0x32 => {
12268             Name => 'ExposureCompensation',
12269             Format => 'rational64s',
12270             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
12271             },
12272             0x44 => {
12273             Name => 'WhiteBalance',
12274             Format => 'int16u',
12275             PrintConv => {
12276             0 => 'Auto',
12277             1 => 'Daylight',
12278             2 => 'Shade',
12279             3 => 'Fluorescent', #2
12280             4 => 'Tungsten',
12281             5 => 'Manual',
12282             },
12283             },
12284             0x48 => {
12285             Name => 'FocalLength',
12286             Format => 'rational64u',
12287             PrintConv => 'sprintf("%.1f mm",$val)',
12288             },
12289             0xaf => {
12290             Name => 'Software',
12291             Format => 'string[16]',
12292             },
12293             0xdf => { # (this is a guess ... could also be offset 0xdb)
12294             Name => 'ISO',
12295             Format => 'int16u',
12296             RawConv => '$val < 50 ? undef : $val', # (not valid for Coolpix L10)
12297             },
12298             );
12299              
12300             # Nikon metadata in AVI videos (PH)
12301             %Image::ExifTool::Nikon::AVI = (
12302             NOTES => 'Nikon-specific RIFF tags found in AVI videos.',
12303             GROUPS => { 0 => 'MakerNotes', 2 => 'Video' },
12304             nctg => {
12305             Name => 'NikonTags',
12306             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AVITags' },
12307             },
12308             ncth => {
12309             Name => 'ThumbnailImage',
12310             Groups => { 2 => 'Preview' },
12311             Binary => 1,
12312             },
12313             ncvr => {
12314             Name => 'NikonVers',
12315             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AVIVers' },
12316             },
12317             ncvw => {
12318             Name => 'PreviewImage',
12319             Groups => { 2 => 'Preview' },
12320             RawConv => 'length($val) ? $val : undef',
12321             Binary => 1,
12322             },
12323             );
12324              
12325             # version information in AVI videos (PH)
12326             %Image::ExifTool::Nikon::AVIVers = (
12327             GROUPS => { 0 => 'MakerNotes', 2 => 'Video' },
12328             PROCESS_PROC => \&ProcessNikonAVI,
12329             FORMAT => 'string',
12330             0x01 => 'MakerNoteType',
12331             0x02 => {
12332             Name => 'MakerNoteVersion',
12333             Format => 'int8u',
12334             ValueConv => 'my @a = reverse split " ", $val; join ".", @a;',
12335             },
12336             );
12337              
12338             # tags in AVI videos (PH)
12339             %Image::ExifTool::Nikon::AVITags = (
12340             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
12341             PROCESS_PROC => \&ProcessNikonAVI,
12342             FORMAT => 'string',
12343             NOTES => q{
12344             These tags and the AVIVer tags below are found in proprietary-format records
12345             of Nikon AVI videos.
12346             },
12347             0x03 => 'Make',
12348             0x04 => 'Model',
12349             0x05 => {
12350             Name => 'Software',
12351             Format => 'undef',
12352             ValueConv => '$val =~ tr/\0//d; $val',
12353             },
12354             0x06 => 'Equipment', # "NIKON DIGITAL CAMERA"
12355             0x07 => { # (guess)
12356             Name => 'Orientation',
12357             Format => 'int16u',
12358             Groups => { 2 => 'Image' },
12359             PrintConv => \%Image::ExifTool::Exif::orientation,
12360             },
12361             0x08 => {
12362             Name => 'ExposureTime',
12363             Format => 'rational64u',
12364             Groups => { 2 => 'Image' },
12365             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
12366             },
12367             0x09 => {
12368             Name => 'FNumber',
12369             Format => 'rational64u',
12370             Groups => { 2 => 'Image' },
12371             PrintConv => 'sprintf("%.1f",$val)',
12372             },
12373             0x0a => {
12374             Name => 'ExposureCompensation',
12375             Format => 'rational64s',
12376             Groups => { 2 => 'Image' },
12377             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
12378             },
12379             0x0b => {
12380             Name => 'MaxApertureValue',
12381             Format => 'rational64u',
12382             ValueConv => '2 ** ($val / 2)',
12383             PrintConv => 'sprintf("%.1f",$val)',
12384             },
12385             0x0c => {
12386             Name => 'MeteringMode', # (guess)
12387             Format => 'int16u',
12388             PrintConv => {
12389             0 => 'Unknown',
12390             1 => 'Average',
12391             2 => 'Center-weighted average',
12392             3 => 'Spot',
12393             4 => 'Multi-spot',
12394             5 => 'Multi-segment',
12395             6 => 'Partial',
12396             255 => 'Other',
12397             },
12398             },
12399             0x0d => { # val: 0
12400             Name => 'Nikon_AVITags_0x000d',
12401             Format => 'int16u',
12402             Flags => [ 'Hidden', 'Unknown' ],
12403             },
12404             0x0e => { # val: 0
12405             Name => 'Nikon_AVITags_0x000e',
12406             Format => 'int16u',
12407             Flags => [ 'Hidden', 'Unknown' ],
12408             },
12409             0x0f => {
12410             Name => 'FocalLength',
12411             Format => 'rational64u',
12412             PrintConv => 'sprintf("%.1f mm",$val)',
12413             },
12414             0x10 => {
12415             Name => 'XResolution',
12416             Format => 'rational64u',
12417             Groups => { 2 => 'Image' },
12418             },
12419             0x11 => {
12420             Name => 'YResolution',
12421             Format => 'rational64u',
12422             Groups => { 2 => 'Image' },
12423             },
12424             0x12 => {
12425             Name => 'ResolutionUnit',
12426             Format => 'int16u',
12427             Groups => { 2 => 'Image' },
12428             PrintConv => {
12429             1 => 'None',
12430             2 => 'inches',
12431             3 => 'cm',
12432             },
12433             },
12434             0x13 => {
12435             Name => 'DateTimeOriginal', # (guess)
12436             Description => 'Date/Time Original',
12437             Groups => { 2 => 'Time' },
12438             PrintConv => '$self->ConvertDateTime($val)',
12439             },
12440             0x14 => {
12441             Name => 'CreateDate', # (guess)
12442             Groups => { 2 => 'Time' },
12443             PrintConv => '$self->ConvertDateTime($val)',
12444             },
12445             0x15 => {
12446             Name => 'Nikon_AVITags_0x0015',
12447             Format => 'int16u',
12448             Flags => [ 'Hidden', 'Unknown' ],
12449             },
12450             0x16 => {
12451             Name => 'Duration',
12452             Format => 'rational64u',
12453             PrintConv => '"$val s"',
12454             },
12455             0x17 => { # val: 1
12456             Name => 'Nikon_AVITags_0x0017',
12457             Format => 'int16u',
12458             Flags => [ 'Hidden', 'Unknown' ],
12459             },
12460             0x18 => 'FocusMode',
12461             0x19 => { # vals: -5, -2, 3, 5, 6, 8, 11, 12, 14, 20, 22
12462             Name => 'Nikon_AVITags_0x0019',
12463             Format => 'int32s',
12464             Flags => [ 'Hidden', 'Unknown' ],
12465             },
12466             0x1b => { # vals: 1 (640x480), 1.25 (320x240)
12467             Name => 'DigitalZoom',
12468             Format => 'rational64u',
12469             },
12470             0x1c => { # (same as Nikon_0x000a)
12471             Name => 'Nikon_AVITags_0x001c',
12472             Format => 'rational64u',
12473             Flags => [ 'Hidden', 'Unknown' ],
12474             },
12475             0x1d => 'ColorMode',
12476             0x1e => { # string[8] - val: "AUTO"
12477             Name => 'Sharpness', # (guess, could also be ISOSelection)
12478             },
12479             0x1f => { # string[16] - val: "AUTO"
12480             Name => 'WhiteBalance', # (guess, could also be ImageAdjustment)
12481             },
12482             0x20 => { # string[4] - val: "OFF"
12483             Name => 'NoiseReduction', # (guess)
12484             },
12485             0x801a => { # val: 0 (why is the 0x8000 bit set in the ID?)
12486             Name => 'Nikon_AVITags_0x801a',
12487             Format => 'int32s',
12488             Flags => [ 'Hidden', 'Unknown' ],
12489             }
12490             );
12491              
12492             # Nikon NCDT atoms (ref PH)
12493             %Image::ExifTool::Nikon::NCDT = (
12494             GROUPS => { 0 => 'MakerNotes', 1 => 'Nikon', 2 => 'Video' },
12495             NOTES => q{
12496             Nikon-specific QuickTime tags found in the NCDT atom of MOV videos from
12497             various Nikon models.
12498             },
12499             NCHD => {
12500             Name => 'MakerNoteVersion',
12501             Format => 'undef',
12502             ValueConv => q{
12503             $val =~ s/\0$//; # remove trailing null
12504             $val =~ s/([\0-\x1f])/'.'.ord($1)/ge;
12505             $val =~ s/\./ /; return $val;
12506             },
12507             },
12508             NCTG => {
12509             Name => 'NikonTags',
12510             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::NCTG' },
12511             },
12512             NCTH => {
12513             Name => 'ThumbnailImage',
12514             Groups => { 2 => 'Preview' },
12515             Format => 'undef',
12516             Binary => 1,
12517             },
12518             NCVW => {
12519             Name => 'PreviewImage',
12520             Groups => { 2 => 'Preview' },
12521             Format => 'undef',
12522             Binary => 1,
12523             },
12524             NCDB => { # (often 0 bytes long, or 4 null bytes)
12525             Name => 'NikonNCDB',
12526             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::NCDB' },
12527             },
12528             NCM1 => {
12529             Name => 'PreviewImage1',
12530             Groups => { 2 => 'Preview' },
12531             Format => 'undef',
12532             Binary => 1,
12533             RawConv => 'length $val ? $val : undef',
12534             },
12535             NCM2 => { #PH (guess - have only seen 0 bytes)
12536             Name => 'PreviewImage2',
12537             Groups => { 2 => 'Preview' },
12538             Format => 'undef',
12539             Binary => 1,
12540             RawConv => 'length $val ? $val : undef',
12541             },
12542             );
12543              
12544             # Nikon NCDB tags from MOV videos (ref PH)
12545             %Image::ExifTool::Nikon::NCDB = (
12546             GROUPS => { 0 => 'MakerNotes', 1 => 'Nikon', 2 => 'Video' },
12547             # the following probably contain encrypted data -- look into decryping these!
12548             # OP01 - 320 bytes, starts with "0200" (D600,D610,D810,D3200,D5200)
12549             # - 638 bytes, starts with "0200" (D7100)
12550             # OP02 - 2048 bytes, starts with "0200" (D810)
12551             );
12552              
12553             # Nikon NCTG tags from MOV videos (ref PH)
12554             %Image::ExifTool::Nikon::NCTG = (
12555             PROCESS_PROC => \&ProcessNikonMOV,
12556             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
12557             NOTES => q{
12558             These tags are found in proprietary-format records of the NCTG atom in MOV
12559             videos from some Nikon cameras.
12560             },
12561             0x01 => 'Make',
12562             0x02 => 'Model',
12563             0x03 => 'Software',
12564             0x11 => {
12565             Name => 'CreateDate', #(guess, but matches QuickTime CreateDate)
12566             Groups => { 2 => 'Time' },
12567             PrintConv => '$self->ConvertDateTime($val)',
12568             },
12569             0x12 => {
12570             Name => 'DateTimeOriginal', #(guess, but time is 1 sec before tag 0x11)
12571             Description => 'Date/Time Original',
12572             Groups => { 2 => 'Time' },
12573             PrintConv => '$self->ConvertDateTime($val)',
12574             },
12575             0x13 => {
12576             Name => 'FrameCount',
12577             # int32u[2]: "467 0", "1038 0", "1127 0"
12578             ValueConv => '$val =~ s/ 0$//; $val', # (not sure what the extra "0" is for)
12579             },
12580             # 0x14 - int32u[2]: "0 0"
12581             # 0x15 - int32u[2]: "0 0"
12582             0x16 => {
12583             Name => 'FrameRate',
12584             Groups => { 2 => 'Video' },
12585             PrintConv => 'int($val * 1000 + 0.5) / 1000',
12586             },
12587             # 0x17 - rational62u: same value as FrameRate
12588             # 0x18 - int16u: 1, 2
12589             0x19 => {
12590             Name => 'TimeZone',
12591             Groups => { 2 => 'Time' },
12592             },
12593             # 0x21 - int16u: 1, 2
12594             0x22 => {
12595             Name => 'FrameWidth',
12596             Groups => { 2 => 'Video' },
12597             },
12598             0x23 => {
12599             Name => 'FrameHeight',
12600             Groups => { 2 => 'Video' },
12601             },
12602             # 0x24 - int16u: 1, 2
12603             # 0x31 - int16u: 0, 1, 2
12604             0x32 => { #(guess)
12605             Name => 'AudioChannels',
12606             Groups => { 2 => 'Audio' },
12607             },
12608             0x33 => {
12609             Name => 'AudioBitsPerSample',
12610             Groups => { 2 => 'Audio' },
12611             },
12612             0x34 => {
12613             Name => 'AudioSampleRate',
12614             Groups => { 2 => 'Audio' },
12615             },
12616             # 0x101 - int16u[4]: "160 120 1280 720", "160 120 3840 2160"
12617             # 0x102 - int16u[8]: "640 360 0 0 0 0 0 0", "640 360 1920 1080 0 0 0 0"
12618             # 0x1001 - int16s: 0
12619             0x1002 => {
12620             Name => 'NikonDateTime', #?
12621             Groups => { 2 => 'Time' },
12622             PrintConv => '$self->ConvertDateTime($val)',
12623             },
12624             # 0x1011 - int32u: 0
12625             # 0x1012 - int32u: 0
12626             0x1013 => { #HayoBaan
12627             Name => 'ElectronicVR',
12628             PrintConv => \%offOn,
12629             },
12630             # 0x1014 - int16u: 1
12631             # 0x1021 - int32u[32]: all zeros
12632             #
12633             # 0x110**** tags correspond to 0x**** tags in Exif::Main
12634             #
12635             0x110829a => { #34
12636             Name => 'ExposureTime',
12637             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
12638             },
12639             0x110829d => { #34
12640             Name => 'FNumber',
12641             PrintConv => 'Image::ExifTool::Exif::PrintFNumber($val)',
12642             },
12643             0x1108822 => {
12644             Name => 'ExposureProgram',
12645             PrintConv => {
12646             0 => 'Not Defined',
12647             1 => 'Manual',
12648             2 => 'Program AE',
12649             3 => 'Aperture-priority AE',
12650             4 => 'Shutter speed priority AE',
12651             5 => 'Creative (Slow speed)',
12652             6 => 'Action (High speed)',
12653             7 => 'Portrait',
12654             8 => 'Landscape',
12655             # 9 => 'Bulb', # (non-standard Canon value)
12656             },
12657             },
12658             0x1109204 => {
12659             Name => 'ExposureCompensation',
12660             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
12661             },
12662             0x1109207 => {
12663             Name => 'MeteringMode',
12664             PrintConv => {
12665             0 => 'Unknown',
12666             1 => 'Average',
12667             2 => 'Center-weighted average',
12668             3 => 'Spot',
12669             4 => 'Multi-spot',
12670             5 => 'Multi-segment',
12671             6 => 'Partial',
12672             255 => 'Other',
12673             },
12674             },
12675             0x110920a => { #34
12676             Name => 'FocalLength',
12677             PrintConv => 'sprintf("%.1f mm",$val)',
12678             },
12679             0x110a431 => 'SerialNumber',
12680             0x110a432 => {
12681             Name => 'LensInfo',
12682             PrintConv => \&Image::ExifTool::Exif::PrintLensInfo,
12683             },
12684             0x110a433 => 'LensMake',
12685             0x110a434 => 'LensModel',
12686             0x110a435 => 'LensSerialNumber',
12687             #
12688             # 0x120**** tags correspond to 0x**** tags in GPS::Main
12689             #
12690             0x1200000 => {
12691             Name => 'GPSVersionID',
12692             Groups => { 1 => 'GPS', 2 => 'Location' },
12693             PrintConv => '$val =~ tr/ /./; $val',
12694             },
12695             0x1200001 => {
12696             Name => 'GPSLatitudeRef',
12697             Groups => { 1 => 'GPS', 2 => 'Location' },
12698             PrintConv => {
12699             N => 'North',
12700             S => 'South',
12701             },
12702             },
12703             0x1200002 => {
12704             Name => 'GPSLatitude',
12705             Groups => { 1 => 'GPS', 2 => 'Location' },
12706             ValueConv => q{
12707             require Image::ExifTool::GPS;
12708             Image::ExifTool::GPS::ToDegrees($val);
12709             },
12710             PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1)',
12711             },
12712             0x1200003 => {
12713             Name => 'GPSLongitudeRef',
12714             Groups => { 1 => 'GPS', 2 => 'Location' },
12715             PrintConv => {
12716             E => 'East',
12717             W => 'West',
12718             },
12719             },
12720             0x1200004 => {
12721             Name => 'GPSLongitude',
12722             Groups => { 1 => 'GPS', 2 => 'Location' },
12723             ValueConv => q{
12724             require Image::ExifTool::GPS;
12725             Image::ExifTool::GPS::ToDegrees($val);
12726             },
12727             PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1)',
12728             },
12729             0x1200005 => {
12730             Name => 'GPSAltitudeRef',
12731             Groups => { 1 => 'GPS', 2 => 'Location' },
12732             PrintConv => {
12733             0 => 'Above Sea Level',
12734             1 => 'Below Sea Level',
12735             },
12736             },
12737             0x1200006 => {
12738             Name => 'GPSAltitude',
12739             Groups => { 1 => 'GPS', 2 => 'Location' },
12740             PrintConv => '$val =~ /^(inf|undef)$/ ? $val : "$val m"',
12741             },
12742             0x1200007 => {
12743             Name => 'GPSTimeStamp',
12744             Groups => { 1 => 'GPS', 2 => 'Time' },
12745             ValueConv => q{
12746             require Image::ExifTool::GPS;
12747             Image::ExifTool::GPS::ConvertTimeStamp($val);
12748             },
12749             PrintConv => 'Image::ExifTool::GPS::PrintTimeStamp($val)',
12750             },
12751             0x1200008 => {
12752             Name => 'GPSSatellites',
12753             Groups => { 1 => 'GPS', 2 => 'Location' },
12754             },
12755             0x1200010 => {
12756             Name => 'GPSImgDirectionRef',
12757             Groups => { 1 => 'GPS', 2 => 'Location' },
12758             PrintConv => {
12759             M => 'Magnetic North',
12760             T => 'True North',
12761             },
12762             },
12763             0x1200011 => {
12764             Name => 'GPSImgDirection',
12765             Groups => { 1 => 'GPS', 2 => 'Location' },
12766             },
12767             0x1200012 => {
12768             Name => 'GPSMapDatum',
12769             Groups => { 1 => 'GPS', 2 => 'Location' },
12770             },
12771             0x120001d => {
12772             Name => 'GPSDateStamp',
12773             Groups => { 1 => 'GPS', 2 => 'Time' },
12774             ValueConv => 'Image::ExifTool::Exif::ExifDate($val)',
12775             },
12776             #
12777             # 0x200**** tags correspond to 0x**** tags in Nikon::Main
12778             # (must be duplicated here so tagInfo "Table" entry will point to correct table.
12779             # Also there would be a problem with the PRINT_CONV from the Main table)
12780             #
12781             0x2000001 => {
12782             Name => 'MakerNoteVersion',
12783             PrintConv => '$_=$val;s/^(\d{2})/$1\./;s/^0//;$_',
12784             },
12785             0x2000005 => 'WhiteBalance',
12786             0x2000007 => { Name => 'FocusMode', Writable => 'string' }, #34
12787             0x200000b => 'WhiteBalanceFineTune',
12788             0x200001b => {
12789             Name => 'CropHiSpeed',
12790             Writable => 'int16u',
12791             Count => 7,
12792             PrintConv => \%cropHiSpeed,
12793             },
12794             0x200001e => {
12795             Name => 'ColorSpace',
12796             PrintConv => {
12797             1 => 'sRGB',
12798             2 => 'Adobe RGB',
12799             },
12800             },
12801             0x200001f => {
12802             Name => 'VRInfo',
12803             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::VRInfo' },
12804             },
12805             0x2000022 => {
12806             Name => 'ActiveD-Lighting',
12807             Writable => 'int16u',
12808             PrintConv => {
12809             0 => 'Off',
12810             1 => 'Low',
12811             3 => 'Normal',
12812             5 => 'High',
12813             7 => 'Extra High',
12814             8 => 'Extra High 1',
12815             9 => 'Extra High 2',
12816             10 => 'Extra High 3',
12817             11 => 'Extra High 4',
12818             0xffff => 'Auto',
12819             },
12820             },
12821             0x2000023 => [
12822             { #PH (D300, but also found in D3,D3S,D3X,D90,D300S,D700,D3000,D5000)
12823             Name => 'PictureControlData',
12824             Condition => '$$valPt =~ /^01/',
12825             Writable => 'undef',
12826             Permanent => 0,
12827             Flags => [ 'Binary', 'Protected' ],
12828             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl' },
12829             },{ #28
12830             Name => 'PictureControlData',
12831             Condition => '$$valPt =~ /^02/',
12832             Writable => 'undef',
12833             Permanent => 0,
12834             Flags => [ 'Binary', 'Protected' ],
12835             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl2' },
12836             },{
12837             Name => 'PictureControlData',
12838             Condition => '$$valPt =~ /^03/',
12839             Writable => 'undef',
12840             Permanent => 0,
12841             Flags => [ 'Binary', 'Protected' ],
12842             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl3' },
12843             },{
12844             Name => 'PictureControlData',
12845             Writable => 'undef',
12846             Permanent => 0,
12847             Flags => [ 'Binary', 'Protected' ],
12848             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControlUnknown' },
12849             },
12850             ],
12851             0x2000024 => {
12852             Name => 'WorldTime',
12853             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::WorldTime' },
12854             },
12855             0x2000025 => { #34
12856             Name => 'ISOInfo',
12857             SubDirectory => {
12858             TagTable => 'Image::ExifTool::Nikon::ISOInfo',
12859             ByteOrder => 'BigEndian', # (BigEndian even for D810, which is a little-endian camera)
12860             },
12861             },
12862             0x200002a => { #23 (this tag added with D3 firmware 1.10 -- also written by Nikon utilities)
12863             Name => 'VignetteControl',
12864             Writable => 'int16u',
12865             PrintConv => {
12866             0 => 'Off',
12867             1 => 'Low',
12868             3 => 'Normal',
12869             5 => 'High',
12870             },
12871             },
12872             0x200002c => {
12873             Name => 'UnknownInfo',
12874             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::UnknownInfo' },
12875             },
12876             # 0x200002d - int16u[3]: "512 0 0", "512 1 14", "512 3 10"
12877             0x2000032 => {
12878             Name => 'UnknownInfo2',
12879             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::UnknownInfo2' },
12880             },
12881             0x2000039 => {
12882             Name => 'LocationInfo',
12883             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LocationInfo' },
12884             },
12885             0x200003f => 'WhiteBalanceFineTune',
12886             # 0x200003f - rational64s[2]: "0 0"
12887             # 0x2000042 - undef[6]: "0100\x03\0"
12888             # 0x2000043 - undef[12]: all zeros
12889             # 0x200004d - undef[84]: "0100\0\0\0\0x020100\0\0\0\x010100\0\0\0\x05\0\0\..."
12890             0x200004e => {
12891             Name => 'NikonSettings',
12892             SubDirectory => { TagTable => 'Image::ExifTool::NikonSettings::Main' },
12893             },
12894             # 0x2000055 - undef[8]: "0100\x01\0\0\0"
12895             0x2000083 => {
12896             Name => 'LensType',
12897             # credit to Tom Christiansen (ref 7) for figuring this out...
12898             PrintConv => q[$_ = $val ? Image::ExifTool::DecodeBits($val,
12899             {
12900             0 => 'MF',
12901             1 => 'D',
12902             2 => 'G',
12903             3 => 'VR',
12904             4 => '1', #PH
12905             # bit 5 set for FT-1 adapter? - PH
12906             6 => 'E', #PH (electromagnetic aperture mechanism)
12907             # bit 7 set for AF-P lenses? - PH
12908             }) : 'AF';
12909             # remove commas and change "D G" to just "G"
12910             s/,//g; s/\bD G\b/G/;
12911             s/ E\b// and s/^(G )?/E /; # put "E" at the start instead of "G"
12912             s/ 1// and $_ = "1 $_"; # put "1" at start
12913             return $_;
12914             ],
12915             },
12916             0x2000084 => {
12917             Name => "Lens",
12918             # short focal, long focal, aperture at short focal, aperture at long focal
12919             PrintConv => \&Image::ExifTool::Exif::PrintLensInfo,
12920             },
12921             0x2000087 => {
12922             Name => 'FlashMode',
12923             Writable => 'int8u',
12924             PrintConv => {
12925             0 => 'Did Not Fire',
12926             1 => 'Fired, Manual', #14
12927             3 => 'Not Ready', #28
12928             7 => 'Fired, External', #14
12929             8 => 'Fired, Commander Mode',
12930             9 => 'Fired, TTL Mode',
12931             18 => 'LED Light', #G.F. (movie LED light)
12932             },
12933             },
12934             0x2000098 => [
12935             { #8
12936             Condition => '$$valPt =~ /^0100/', # D100, D1X - PH
12937             Name => 'LensData0100',
12938             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LensData00' },
12939             },
12940             { #8
12941             Condition => '$$valPt =~ /^0101/', # D70, D70s - PH
12942             Name => 'LensData0101',
12943             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LensData01' },
12944             },
12945             # note: this information is encrypted if the version is 02xx
12946             { #8
12947             # 0201 - D200, D2Hs, D2X and D2Xs
12948             # 0202 - D40, D40X and D80
12949             # 0203 - D300
12950             Condition => '$$valPt =~ /^020[1-3]/',
12951             Name => 'LensData0201',
12952             SubDirectory => {
12953             TagTable => 'Image::ExifTool::Nikon::LensData01',
12954             ProcessProc => \&ProcessNikonEncrypted,
12955             WriteProc => \&ProcessNikonEncrypted,
12956             DecryptStart => 4,
12957             },
12958             },
12959             { #PH
12960             Condition => '$$valPt =~ /^0204/', # D90, D7000
12961             Name => 'LensData0204',
12962             SubDirectory => {
12963             TagTable => 'Image::ExifTool::Nikon::LensData0204',
12964             ProcessProc => \&ProcessNikonEncrypted,
12965             WriteProc => \&ProcessNikonEncrypted,
12966             DecryptStart => 4,
12967             },
12968             },
12969             {
12970             Condition => '$$valPt =~ /^040[01]/', # 0=1J1/1V1, 1=1J2
12971             Name => 'LensData0400',
12972             SubDirectory => {
12973             TagTable => 'Image::ExifTool::Nikon::LensData0400',
12974             ProcessProc => \&ProcessNikonEncrypted,
12975             WriteProc => \&ProcessNikonEncrypted,
12976             DecryptStart => 4,
12977             },
12978             },
12979             {
12980             Condition => '$$valPt =~ /^0402/', # 1J3/1S1/1V2
12981             Name => 'LensData0402',
12982             SubDirectory => {
12983             TagTable => 'Image::ExifTool::Nikon::LensData0402',
12984             ProcessProc => \&ProcessNikonEncrypted,
12985             WriteProc => \&ProcessNikonEncrypted,
12986             DecryptStart => 4,
12987             },
12988             },
12989             {
12990             Condition => '$$valPt =~ /^0403/', # 1J4,1J5
12991             Name => 'LensData0403',
12992             SubDirectory => {
12993             TagTable => 'Image::ExifTool::Nikon::LensData0403',
12994             ProcessProc => \&ProcessNikonEncrypted,
12995             WriteProc => \&ProcessNikonEncrypted,
12996             DecryptStart => 4,
12997             },
12998             },
12999             {
13000             Condition => '$$valPt =~ /^080[012]/', # Z6/Z7/Z9
13001             Name => 'LensData0800',
13002             SubDirectory => {
13003             TagTable => 'Image::ExifTool::Nikon::LensData0800',
13004             ProcessProc => \&ProcessNikonEncrypted,
13005             WriteProc => \&ProcessNikonEncrypted,
13006             DecryptStart => 4,
13007             ByteOrder => 'LittleEndian',
13008             # 0x5a0c - NikonMeteringMode for some Z6 ver1.00 samples (ref PH)
13009             },
13010             },
13011             {
13012             Name => 'LensDataUnknown',
13013             SubDirectory => {
13014             TagTable => 'Image::ExifTool::Nikon::LensDataUnknown',
13015             ProcessProc => \&ProcessNikonEncrypted,
13016             WriteProc => \&ProcessNikonEncrypted,
13017             DecryptStart => 4,
13018             },
13019             },
13020             ],
13021             0x20000a7 => { # Number of shots taken by camera so far (ref 2)
13022             Name => 'ShutterCount',
13023             PrintConv => '$val == 4294965247 ? "n/a" : $val',
13024             },
13025             0x20000a8 => [
13026             {
13027             Name => 'FlashInfo0100',
13028             Condition => '$$valPt =~ /^010[01]/',
13029             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0100' },
13030             },
13031             {
13032             Name => 'FlashInfo0102',
13033             Condition => '$$valPt =~ /^0102/',
13034             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0102' },
13035             },
13036             {
13037             Name => 'FlashInfo0103',
13038             # (0104 for D7000, 0105 for D800)
13039             Condition => '$$valPt =~ /^010[345]/',
13040             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0103' },
13041             },
13042             {
13043             Name => 'FlashInfo0106', # (0106 for D7100)
13044             Condition => '$$valPt =~ /^0106/',
13045             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0106' },
13046             },
13047             {
13048             Name => 'FlashInfo0107', # (0107 for D4S/D750/D810/D5500/D7200, 0108 for D5/D500/D3400)
13049             Condition => '$$valPt =~ /^010[78]/',
13050             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0107' },
13051             },
13052             {
13053             Name => 'FlashInfoUnknown',
13054             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfoUnknown' },
13055             },
13056             ],
13057             0x20000ab => { Name => 'VariProgram', Writable => 'string' }, #2 (scene mode for DSLR's - PH)
13058             0x20000b1 => { #34
13059             Name => 'HighISONoiseReduction',
13060             Writable => 'int16u',
13061             PrintConv => {
13062             0 => 'Off',
13063             1 => 'Minimal', # for high ISO (>800) when setting is "Off"
13064             2 => 'Low', # Low,Normal,High take effect for ISO > 400
13065             3 => 'Medium Low',
13066             4 => 'Normal',
13067             5 => 'Medium High',
13068             6 => 'High',
13069             },
13070             },
13071             0x20000b7 => [{
13072             Name => 'AFInfo2',
13073             # LiveView-enabled DSLRs introduced starting in 2007 (D3/D300)
13074             Condition => '$$valPt =~ /^0100/',
13075             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0100' },
13076             },{
13077             Name => 'AFInfo2',
13078             # All Expeed 5 processor and most Expeed 4 processor models from 2016 - D5, D500, D850, D3400, D3500, D7500 (D5600 is v0100)
13079             Condition => '$$valPt =~ /^0101/',
13080             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0101' },
13081             },{
13082             Name => 'AFInfo2',
13083             # Nikon 1 Series cameras
13084             Condition => '$$valPt =~ /^020[01]/',
13085             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0200' },
13086             },{
13087             Name => 'AFInfo2',
13088             # Expeed 6 processor models - D6, D780, Z5, Z6, Z7, Z30, Z50, Z6_2, Z7_2 and Zfc
13089             Condition => '$$valPt =~ /^030[01]/',
13090             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0300' },
13091             },{
13092             Name => 'AFInfo2',
13093             # Expeed 7 processor models - Z8 & Z9 (AFInfo2Version 0400), Z6iii & Zf (AFInfo2Version 0401)
13094             # and Z50ii (AFInfo2Version 0402)
13095             Condition => '$$valPt =~ /^040[012]/',
13096             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0400' },
13097             }],
13098             # 0x20000c0 - undef[8]:
13099             # 34 01 0c 00 90 01 0c 00
13100             # 34 01 0c 00 9c 01 0c 00
13101             # 3c 01 0c 00 9c 01 0c 00
13102             # 3c 01 0c 00 a8 01 0c 00
13103             0x20000c3 => {
13104             Name => 'BarometerInfo',
13105             SubDirectory => {
13106             TagTable => 'Image::ExifTool::Nikon::BarometerInfo',
13107             # (little-endian in II EXIF, big-endian in MOV)
13108             },
13109             },
13110             );
13111              
13112             # Nikon XMP tags written in NKSC metadata
13113             %Image::ExifTool::Nikon::ast = (
13114             GROUPS => { 0 => 'XMP', 1 => 'XMP-ast', 2 => 'Image' },
13115             PROCESS_PROC => \&Image::ExifTool::XMP::ProcessXMP,
13116             NAMESPACE => 'ast',
13117             VARS => { ID_FMT => 'none' },
13118             NOTES => 'Tags used by Nikon NX Studio in Nikon NKSC sidecar files and trailers.',
13119             about => { },
13120             version => { },
13121             XMLPackets => {
13122             SubDirectory => { TagTable => 'Image::ExifTool::XMP::Main' },
13123             Encoding => 'Base64',
13124             Binary => 1,
13125             },
13126             IPTC => {
13127             SubDirectory => { TagTable => 'Image::ExifTool::IPTC::Main' },
13128             Encoding => 'Base64',
13129             Binary => 1,
13130             },
13131             GPSVersionID => { Groups => { 2 => 'Location' }, %base64bytes },
13132             GPSLatitudeRef => {
13133             Groups => { 2 => 'Location' },
13134             %base64int32u,
13135             PrintConv => { 0 => 'North', 1 => 'South' }, #PH (NC)
13136             },
13137             GPSLatitude => { Groups => { 2 => 'Location' }, %base64coord },
13138             GPSLongitudeRef => {
13139             Groups => { 2 => 'Location' },
13140             %base64int32u,
13141             PrintConv => { 2 => 'East', 3 => 'West' }, #PH (NC)
13142             },
13143             GPSLongitude => { Groups => { 2 => 'Location' }, %base64coord },
13144             GPSAltitudeRef => {
13145             Groups => { 2 => 'Location' },
13146             %base64bytes,
13147             PrintConv => {
13148             0 => 'Above Sea Level',
13149             1 => 'Below Sea Level',
13150             },
13151             },
13152             GPSAltitude => {
13153             Groups => { 2 => 'Location' },
13154             %base64double,
13155             PrintConv => '"$val m"',
13156             },
13157             GPSMapDatum => { Groups => { 2 => 'Location' } },
13158             GPSImgDirection => {
13159             Groups => { 2 => 'Location' },
13160             %base64double,
13161             PrintConv => 'sprintf("%.2f", $val)',
13162             },
13163             GPSImgDirectionRef => {
13164             Groups => { 2 => 'Location' },
13165             PrintConv => {
13166             M => 'Magnetic North',
13167             T => 'True North',
13168             },
13169             },
13170             );
13171             %Image::ExifTool::Nikon::sdc = (
13172             GROUPS => { 0 => 'XMP', 1 => 'XMP-sdc', 2 => 'Image' },
13173             PROCESS_PROC => \&Image::ExifTool::XMP::ProcessXMP,
13174             NAMESPACE => 'sdc',
13175             VARS => { ID_FMT => 'none' },
13176             about => { },
13177             version => { },
13178             appversion => { Name => 'AppVersion' },
13179             appname => { Name => 'AppName' },
13180             );
13181             %Image::ExifTool::Nikon::nine = (
13182             GROUPS => { 0 => 'XMP', 1 => 'XMP-nine', 2 => 'Image' },
13183             PROCESS_PROC => \&Image::ExifTool::XMP::ProcessXMP,
13184             NAMESPACE => 'nine',
13185             VARS => { ID_FMT => 'none' },
13186             about => { },
13187             version => { },
13188             Label => { },
13189             Rating => { },
13190             Trim => { %base64bin },
13191             NineEdits => {
13192             SubDirectory => {
13193             TagTable => 'Image::ExifTool::Nikon::NineEdits',
13194             IgnoreProp => { userData => 1 }, # remove "UserData" from already overly long tag names
13195             },
13196             Binary => 1,
13197             },
13198             );
13199             %Image::ExifTool::Nikon::NineEdits = (
13200             GROUPS => { 0 => 'XML', 1 => 'NineEdits', 2 => 'Image' },
13201             PROCESS_PROC => \&Image::ExifTool::XMP::ProcessXMP,
13202             VARS => { ID_FMT => 'none' },
13203             NOTES => 'XML-based tags used to store editing information.',
13204             filterParametersBinary => { %base64bin },
13205             filterParametersExportExportData => { %base64bin },
13206             filterParametersCustomCustomData => { %base64bin },
13207             );
13208              
13209             # Nikon composite tags
13210             %Image::ExifTool::Nikon::Composite = (
13211             GROUPS => { 2 => 'Camera' },
13212             LensSpec => {
13213             Require => {
13214             0 => 'Nikon:Lens',
13215             1 => 'Nikon:LensType',
13216             },
13217             ValueConv => '"$val[0] $val[1]"',
13218             PrintConv => '"$prt[0] $prt[1]"',
13219             },
13220             LensID => {
13221             SeparateTable => 'Nikon LensID', # print values in a separate table
13222             Require => {
13223             0 => 'Nikon:LensIDNumber',
13224             1 => 'LensFStops',
13225             2 => 'MinFocalLength',
13226             3 => 'MaxFocalLength',
13227             4 => 'MaxApertureAtMinFocal',
13228             5 => 'MaxApertureAtMaxFocal',
13229             6 => 'MCUVersion',
13230             7 => 'Nikon:LensType',
13231             },
13232             # construct lens ID string as per ref 11
13233             ValueConv => 'sprintf("%.2X"." %.2X"x7, @raw)',
13234             PrintConv => \%nikonLensIDs,
13235             PrintInt => 1,
13236             },
13237             AutoFocus => {
13238             Require => {
13239             0 => 'Nikon:FocusMode',
13240             },
13241             ValueConv => '($val[0] =~ /^Manual/i) ? 0 : 1',
13242             PrintConv => \%offOn,
13243             },
13244             PhaseDetectAF => {
13245             Require => {
13246             0 => 'Nikon:FocusPointSchema',
13247             1 => 'Nikon:AFDetectionMethod',
13248             },
13249             ValueConv => '(($val[1]) == 0) ? ($val[0]) : 0', # for backward compatibility, report FocusPointSchema when AFDetectionMethod indicates Phase Detect is on
13250             PrintConv => {
13251             0 => 'Off', #contrast detect or hybrid detect
13252             1 => 'On (51-point)', #PH
13253             2 => 'On (11-point)', #PH
13254             3 => 'On (39-point)', #29 (D7000)
13255             7 => 'On (153-point)', #PH (D5/D500/D850)
13256             #8 => 'On (81-point)', #38 will not see this value - only available in hybrid detect
13257             9 => 'On (105-point)', #28 (D6)
13258             },
13259             },
13260             ContrastDetectAF => {
13261             Require => {
13262             0 => 'Nikon:FocusMode',
13263             1 => 'Nikon:AFDetectionMethod',
13264             },
13265             ValueConv => '(($val[0] !~ /^Manual/i) and ($val[1] == 1)) ? 1 : 0',
13266             PrintConv => \%offOn,
13267             },
13268             );
13269              
13270             # add our composite tags
13271             Image::ExifTool::AddCompositeTags('Image::ExifTool::Nikon');
13272              
13273             #------------------------------------------------------------------------------
13274             # Process Nikon AVI tags (D5000 videos)
13275             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
13276             # Returns: 1 on success
13277             sub ProcessNikonAVI($$$)
13278             {
13279 0     0 0 0 my ($et, $dirInfo, $tagTablePtr) = @_;
13280 0         0 my $dataPt = $$dirInfo{DataPt};
13281 0   0     0 my $pos = $$dirInfo{DirStart} || 0;
13282 0         0 my $dirEnd = $pos + $$dirInfo{DirLen};
13283 0         0 $et->VerboseDir($dirInfo, undef, $$dirInfo{DirLen});
13284 0         0 SetByteOrder('II');
13285 0         0 while ($pos + 4 <= $dirEnd) {
13286 0         0 my $tag = Get16u($dataPt, $pos);
13287 0         0 my $size = Get16u($dataPt, $pos + 2);
13288 0         0 $pos += 4;
13289 0 0       0 last if $pos + $size > $dirEnd;
13290 0         0 $et->HandleTag($tagTablePtr, $tag, undef,
13291             DataPt => $dataPt,
13292             Start => $pos,
13293             Size => $size,
13294             );
13295 0         0 $pos += $size;
13296             }
13297 0         0 return 1;
13298             }
13299              
13300             #------------------------------------------------------------------------------
13301             # Print conversion for Nikon AF points
13302             # Inputs: 0) value to convert (as a string of hex bytes),
13303             # 1) lookup for AF point bit number (starting at 1), or array ref
13304             sub PrintAFPoints($$)
13305             {
13306 0     0 0 0 my ($val, $afPoints) = @_;
13307 0         0 my ($i, $j, @points);
13308 0         0 $val =~ tr/ //d; # remove spaces from hex string
13309 0         0 my @dat = unpack 'C*', pack 'H*', $val; # convert to array of bytes
13310             # loop through all bytes to find active AF points
13311 0         0 for ($i=0; $i<=@dat; ++$i) {
13312 0 0       0 next unless $dat[$i];
13313 0         0 for ($j=0; $j<8; ++$j) {
13314 0 0       0 next unless $dat[$i] & (1 << $j);
13315 0 0       0 my $point = ref $afPoints eq 'HASH' ? $$afPoints{$i*8+$j+1} : $$afPoints[$i*8+$j];
13316 0 0       0 push @points, $point if defined $point;
13317             }
13318             }
13319 0 0       0 return '(none)' unless @points;
13320             # sort the points and return as comma-separated string
13321             return join ',', sort {
13322 0 0       0 return $a cmp $b if length($a) == length($b);
  0         0  
13323 0 0       0 return substr($a,0,1).'0'.substr($a,1,1) cmp $b if length($a) == 2;
13324 0         0 return $a cmp substr($b,0,1).'0'.substr($b,1,1);
13325             } @points;
13326             }
13327              
13328             #------------------------------------------------------------------------------
13329             # Inverse print conversion for AF points
13330             # Inputs: 0) AF point string, 1) AF point hash or array ref
13331             # Returns: AF point data as a string of hex bytes
13332             sub PrintAFPointsInv($$)
13333             {
13334 16     16 0 36 my ($val, $afPoints) = @_;
13335 16         58 my @points = ($val =~ /[A-Za-z]\d+/g);
13336 16 50       85 my $size = int((scalar(ref $afPoints eq 'HASH' ? keys %$afPoints : @$afPoints) + 7) / 8);
13337 16         54 my @dat = (0) x $size;
13338 16 50       50 if (@points) {
13339 0         0 my (%bitNum, $point);
13340 0 0       0 if (ref $afPoints eq 'HASH') {
13341 0         0 $bitNum{$$afPoints{$_}} = $_ foreach keys %$afPoints; # build reverse lookup
13342             } else {
13343 0         0 $bitNum{$$afPoints[$_]} = $_ + 1 foreach 0..$#$afPoints;
13344             }
13345 0         0 foreach $point (@points) {
13346 0 0       0 my $bitNum = $bitNum{uc $point} or next;
13347 0         0 my $byte = int(($bitNum - 1) / 8);
13348 0         0 $dat[$byte] |= (1 << (($bitNum - 1) % 8));
13349             }
13350             }
13351 16         218 return join(" ", unpack("H2"x$size, pack('C*', @dat)));
13352             }
13353              
13354             #------------------------------------------------------------------------------
13355             # Get AF point name for grid-type AF
13356             # Inputs: 0) AF point number, 1) number of columns, 2) true for inverse conversion
13357             # Returns: AF point name, or undef
13358             sub GetAFPointGrid($$;$)
13359             {
13360 0     0 0 0 my ($val, $ncol, $inv) = @_;
13361 0 0       0 if ($inv) {
13362 0 0       0 return undef unless $val =~ /^([A-J])(\d+)$/i;
13363 0         0 return (ord(uc($1))-65) * $ncol + $2 - 1;
13364             } else {
13365 0         0 my $row = int(($val + 0.5) / $ncol) & 0xff;
13366 0         0 my $col = $val - $ncol * $row + 1;
13367 0         0 return chr(65+$row) . $col;
13368             }
13369             }
13370              
13371             #------------------------------------------------------------------------------
13372             # Print conversion for grid-type AF points
13373             # Inputs: 0) value to convert (as a string of hex bytes),
13374             # 1) number of columns in grid
13375             sub PrintAFPointsGrid($$)
13376             {
13377 0     0 0 0 my ($val, $ncol) = @_;
13378 0         0 my ($i, $j, @points);
13379 0         0 $val =~ tr/ //d; # remove spaces from hex string
13380 0         0 my @dat = unpack 'C*', pack 'H*', $val; # convert to array of bytes
13381             # loop through all bytes to find active AF points
13382 0         0 for ($i=0; $i<@dat; ++$i) {
13383 0 0       0 next unless $dat[$i];
13384 0         0 for ($j=0; $j<8; ++$j) {
13385 0 0       0 next unless $dat[$i] & (1 << $j);
13386 0         0 my $point = GetAFPointGrid($i*8 + $j, $ncol);
13387 0 0       0 push @points, $point if defined $point;
13388             }
13389             }
13390 0 0       0 return '(none)' unless @points;
13391 0         0 return join ',', @points; # return as comma-separated string
13392             }
13393              
13394             #------------------------------------------------------------------------------
13395             # Inverse print conversion for AF points
13396             # Inputs: 0) AF point string, 1) number of columns, 2) size of data
13397             # Returns: AF point data as a string of hex bytes
13398             sub PrintAFPointsGridInv($$$)
13399             {
13400 0     0 0 0 my ($val, $ncol, $size) = @_;
13401 0         0 my @points = ($val =~ /[A-Za-z]\d+/g);
13402 0         0 my @dat = (0) x $size;
13403 0         0 foreach (@points) {
13404 0         0 my $n = GetAFPointGrid($_, $ncol, 1);
13405 0 0       0 next unless defined $n;
13406 0         0 my $byte = int($n / 8);
13407 0 0       0 next if $byte > $size;
13408 0         0 $dat[$byte] |= (1 << ($n - $byte * 8));
13409             }
13410 0         0 return join(" ", unpack("H2"x$size, pack('C*', @dat)));
13411             }
13412              
13413             #------------------------------------------------------------------------------
13414             # Print conversion for relative Left/Right AF points (ref 28)
13415             # Inputs: 0) column, 1) number of columns
13416             # Returns: AF point data as a string (e.g. '2L of Center' or 'C' or '3R of Center')
13417             sub PrintAFPointsLeftRight($$)
13418             {
13419 0     0 0 0 my ($col, $ncol) = @_;
13420 0         0 my $center = ($ncol + 1) / 2;
13421 0 0       0 return 'n/a' if $col == 0; #out of focus
13422 0 0       0 return 'C' if $col == $center;
13423 0 0       0 return sprintf('%d', $center - $col) . 'L of Center' if $col < $center;
13424 0 0       0 return sprintf('%d', $col - $center) . 'R of Center' if $col > $center;
13425             }
13426              
13427             #------------------------------------------------------------------------------
13428             # Print conversion for relative Up/Down AF points (ref 28)
13429             # Inputs: 0) row, 1) number of rows
13430             # Returns: AF point data as a string (e.g. '2U from Center' or 'C' or '3D from Center')
13431             sub PrintAFPointsUpDown($$)
13432             {
13433 0     0 0 0 my ($row, $nrow) = @_;
13434 0         0 my $center = ($nrow + 1) / 2;
13435 0 0       0 return 'n/a' if $row == 0; #out of focus
13436 0 0       0 return 'C' if $row == $center;
13437 0 0       0 return sprintf('%d', $center - $row) . 'U from Center' if $row < $center;
13438 0 0       0 return sprintf('%d', $row - $center) . 'D from Center' if $row > $center;
13439             }
13440              
13441             #------------------------------------------------------------------------------
13442             # Print PictureControl value
13443             # Inputs: 0) value (with 0x80 subtracted),
13444             # 1) 'Normal' (0 value) string (default 'Normal')
13445             # 2) format string for numbers (default '%+d'), 3) v2 divisor
13446             # Returns: PrintConv value
13447             sub PrintPC($;$$$)
13448             {
13449 0     0 0 0 my ($val, $norm, $fmt, $div) = @_;
13450 0 0 0     0 return $norm || 'Normal' if $val == 0;
13451 0 0       0 return 'n/a' if $val == 0x7f;
13452 0 0       0 return 'Auto' if $val == -128;
13453             # -127 = custom curve created in Camera Control Pro (show as "User" by D3) - ref 28
13454 0 0       0 return 'User' if $val == -127; #28
13455 0   0     0 return sprintf($fmt || '%+d', $val / ($div || 1));
      0        
13456             }
13457              
13458             #------------------------------------------------------------------------------
13459             # Inverse of PrintPC
13460             # Inputs: 0) PrintConv value (after subracting 0x80 from raw value), 1) v2 divisor
13461             # Returns: unconverted value
13462             # Notes: raw values: 0=Auto, 1=User, 0xff=n/a, ... 0x7f=-1, 0x80=0, 0x81=1, ...
13463             sub PrintPCInv($;$)
13464             {
13465 114     114 0 258 my ($val, $div) = @_;
13466 114 100 100     1109 return $val * ($div || 1) if $val =~ /^[-+]?\d+(\.\d+)?$/;
13467 114 50       160 return 0x7f if $val =~ /n\/a/i;
13468 114 100       165 return -128 if $val =~ /auto/i;
13469 111 50       121 return -127 if $val =~ /user/i; #28
13470 111         431 return 0;
13471             }
13472              
13473             #------------------------------------------------------------------------------
13474             # Convert unknown LensID values
13475             # Inputs: 0) value, 1) flag for inverse conversion, 2) PrintConv hash ref
13476             sub LensIDConv($$$)
13477             {
13478 0     0 0 0 my ($val, $inv, $conv) = @_;
13479 0 0       0 return undef if $inv;
13480             # multiple lenses with the same LensID are distinguished by decimal values
13481 0 0       0 if ($$conv{"$val.1"}) {
13482 0         0 my ($i, @vals, @user);
13483 0         0 for ($i=1; ; ++$i) {
13484 0 0       0 my $lens = $$conv{"$val.$i"} or last;
13485 0 0       0 if ($Image::ExifTool::userLens{$lens}) {
13486 0         0 push @user, $lens;
13487             } else {
13488 0         0 push @vals, $lens;
13489             }
13490             }
13491 0 0       0 return join(' or ', @user) if @user;
13492 0         0 return join(' or ', @vals);
13493             }
13494             # Sigma has been changing the LensIDNumber on some new lenses
13495             # and with some Sigma lenses the LensFStops changes! (argh!)
13496             # Also, older cameras my not set bits 4-7 of LensType
13497 0         0 my $pat = $val;
13498 0         0 $pat =~ s/^\w+ \w+/.. ../; # ignore LensIDNumber and LensFStops
13499 0         0 $pat =~ s/\w(\w)$/.$1/; # ignore bits 4-7 of LensType
13500 0         0 my @ids = sort grep /^$pat$/, keys %$conv;
13501 0 0       0 if (@ids) {
13502             # first try different LensFStops (2nd value)
13503 0         0 ($pat = $val) =~ s/ \w+/ ../;
13504 0         0 my @good = grep /^$pat$/, @ids;
13505 0 0       0 return $$conv{$good[0]} if @good;
13506             # then try different LensIDNumber (1st value)
13507 0         0 ($pat = $val) =~ s/^\w+/../;
13508 0         0 @good = grep /^$pat$/, @ids;
13509 0 0       0 return "Unknown ($val) $$conv{$good[0]} ?" if @good;
13510             # older cameras may not set bits 4-7 of LensType
13511 0         0 ($pat = $val) =~ s/\w(\w)$/.$1/;
13512 0         0 @good = grep /^$pat$/, @ids;
13513 0 0       0 return "Unknown ($val) $$conv{$good[0]} ?" if @good;
13514             }
13515 0         0 return undef;
13516             }
13517              
13518             #------------------------------------------------------------------------------
13519             # Clean up formatting of string values
13520             # Inputs: 0) string value, 1) ExifTool ref
13521             # Returns: formatted string value
13522             # - removes trailing spaces and changes case to something more sensible
13523             sub FormatString($$)
13524             {
13525 159     159 0 252 my ($str, $et) = @_;
13526             # limit string length (can be very long for some unknown tags)
13527 159         415 my $lim = $et->Options('LimitLongValues');
13528 159 50 33     354 if (length($str) > $lim and $lim >= 5) {
13529 0         0 $str = substr($str,0,$lim-5) . "[...]";
13530             } else {
13531 159         664 $str =~ s/\s+$//; # remove trailing white space
13532             # Don't change case of non-words (no vowels)
13533 159 100       437 if ($str =~ /[AEIOUY]/) {
13534             # change all letters but the first to lower case,
13535             # but only in words containing a vowel
13536 103 100       517 if ($str =~ s/\b([AEIOUY])([A-Z]+)/$1\L$2/g) {
13537 56         112 $str =~ s/\bAf\b/AF/; # patch for "AF"
13538             # patch for a number of models that write improper string
13539             # terminator for ImageStabilization (VR-OFF, VR-ON)
13540 56         86 $str =~ s/ +.$//s;
13541             }
13542 103 100       458 if ($str =~ s/\b([A-Z])([A-Z]*[AEIOUY][A-Z]*)/$1\L$2/g) {
13543 46         92 $str =~ s/\bRaw\b/RAW/; # patch for "RAW"
13544             }
13545             }
13546             }
13547 159         380 return $str;
13548             }
13549              
13550             #------------------------------------------------------------------------------
13551             # decoding tables from ref 4
13552             my @xlat = (
13553             [ 0xc1,0xbf,0x6d,0x0d,0x59,0xc5,0x13,0x9d,0x83,0x61,0x6b,0x4f,0xc7,0x7f,0x3d,0x3d,
13554             0x53,0x59,0xe3,0xc7,0xe9,0x2f,0x95,0xa7,0x95,0x1f,0xdf,0x7f,0x2b,0x29,0xc7,0x0d,
13555             0xdf,0x07,0xef,0x71,0x89,0x3d,0x13,0x3d,0x3b,0x13,0xfb,0x0d,0x89,0xc1,0x65,0x1f,
13556             0xb3,0x0d,0x6b,0x29,0xe3,0xfb,0xef,0xa3,0x6b,0x47,0x7f,0x95,0x35,0xa7,0x47,0x4f,
13557             0xc7,0xf1,0x59,0x95,0x35,0x11,0x29,0x61,0xf1,0x3d,0xb3,0x2b,0x0d,0x43,0x89,0xc1,
13558             0x9d,0x9d,0x89,0x65,0xf1,0xe9,0xdf,0xbf,0x3d,0x7f,0x53,0x97,0xe5,0xe9,0x95,0x17,
13559             0x1d,0x3d,0x8b,0xfb,0xc7,0xe3,0x67,0xa7,0x07,0xf1,0x71,0xa7,0x53,0xb5,0x29,0x89,
13560             0xe5,0x2b,0xa7,0x17,0x29,0xe9,0x4f,0xc5,0x65,0x6d,0x6b,0xef,0x0d,0x89,0x49,0x2f,
13561             0xb3,0x43,0x53,0x65,0x1d,0x49,0xa3,0x13,0x89,0x59,0xef,0x6b,0xef,0x65,0x1d,0x0b,
13562             0x59,0x13,0xe3,0x4f,0x9d,0xb3,0x29,0x43,0x2b,0x07,0x1d,0x95,0x59,0x59,0x47,0xfb,
13563             0xe5,0xe9,0x61,0x47,0x2f,0x35,0x7f,0x17,0x7f,0xef,0x7f,0x95,0x95,0x71,0xd3,0xa3,
13564             0x0b,0x71,0xa3,0xad,0x0b,0x3b,0xb5,0xfb,0xa3,0xbf,0x4f,0x83,0x1d,0xad,0xe9,0x2f,
13565             0x71,0x65,0xa3,0xe5,0x07,0x35,0x3d,0x0d,0xb5,0xe9,0xe5,0x47,0x3b,0x9d,0xef,0x35,
13566             0xa3,0xbf,0xb3,0xdf,0x53,0xd3,0x97,0x53,0x49,0x71,0x07,0x35,0x61,0x71,0x2f,0x43,
13567             0x2f,0x11,0xdf,0x17,0x97,0xfb,0x95,0x3b,0x7f,0x6b,0xd3,0x25,0xbf,0xad,0xc7,0xc5,
13568             0xc5,0xb5,0x8b,0xef,0x2f,0xd3,0x07,0x6b,0x25,0x49,0x95,0x25,0x49,0x6d,0x71,0xc7 ],
13569             [ 0xa7,0xbc,0xc9,0xad,0x91,0xdf,0x85,0xe5,0xd4,0x78,0xd5,0x17,0x46,0x7c,0x29,0x4c,
13570             0x4d,0x03,0xe9,0x25,0x68,0x11,0x86,0xb3,0xbd,0xf7,0x6f,0x61,0x22,0xa2,0x26,0x34,
13571             0x2a,0xbe,0x1e,0x46,0x14,0x68,0x9d,0x44,0x18,0xc2,0x40,0xf4,0x7e,0x5f,0x1b,0xad,
13572             0x0b,0x94,0xb6,0x67,0xb4,0x0b,0xe1,0xea,0x95,0x9c,0x66,0xdc,0xe7,0x5d,0x6c,0x05,
13573             0xda,0xd5,0xdf,0x7a,0xef,0xf6,0xdb,0x1f,0x82,0x4c,0xc0,0x68,0x47,0xa1,0xbd,0xee,
13574             0x39,0x50,0x56,0x4a,0xdd,0xdf,0xa5,0xf8,0xc6,0xda,0xca,0x90,0xca,0x01,0x42,0x9d,
13575             0x8b,0x0c,0x73,0x43,0x75,0x05,0x94,0xde,0x24,0xb3,0x80,0x34,0xe5,0x2c,0xdc,0x9b,
13576             0x3f,0xca,0x33,0x45,0xd0,0xdb,0x5f,0xf5,0x52,0xc3,0x21,0xda,0xe2,0x22,0x72,0x6b,
13577             0x3e,0xd0,0x5b,0xa8,0x87,0x8c,0x06,0x5d,0x0f,0xdd,0x09,0x19,0x93,0xd0,0xb9,0xfc,
13578             0x8b,0x0f,0x84,0x60,0x33,0x1c,0x9b,0x45,0xf1,0xf0,0xa3,0x94,0x3a,0x12,0x77,0x33,
13579             0x4d,0x44,0x78,0x28,0x3c,0x9e,0xfd,0x65,0x57,0x16,0x94,0x6b,0xfb,0x59,0xd0,0xc8,
13580             0x22,0x36,0xdb,0xd2,0x63,0x98,0x43,0xa1,0x04,0x87,0x86,0xf7,0xa6,0x26,0xbb,0xd6,
13581             0x59,0x4d,0xbf,0x6a,0x2e,0xaa,0x2b,0xef,0xe6,0x78,0xb6,0x4e,0xe0,0x2f,0xdc,0x7c,
13582             0xbe,0x57,0x19,0x32,0x7e,0x2a,0xd0,0xb8,0xba,0x29,0x00,0x3c,0x52,0x7d,0xa8,0x49,
13583             0x3b,0x2d,0xeb,0x25,0x49,0xfa,0xa3,0xaa,0x39,0xa7,0xc5,0xa7,0x50,0x11,0x36,0xfb,
13584             0xc6,0x67,0x4a,0xf5,0xa5,0x12,0x65,0x7e,0xb0,0xdf,0xaf,0x4e,0xb3,0x61,0x7f,0x2f ]
13585             );
13586              
13587             my ($ci0, $cj0, $ck0, $decryptStart); # decryption parameters
13588              
13589             # Decrypt Nikon data block (ref 4)
13590             # Inputs: 0) reference to data block, 1) optional start offset (default 0)
13591             # 2) optional number of bytes to decode (default to the end of the data)
13592             # 3) optional serial number key (undef to continue previous decryption)
13593             # 4) optional shutter count key
13594             # Returns: data block with specified data decrypted
13595             # Notes: The first time this is called for a given encrypted data block the serial/count
13596             # keys must be defined, and $start must be the offset for initialization of the
13597             # decryption parameters (ie. the beginning of the encrypted data, which isn't
13598             # necessarily inside the data block if $len is zero). Subsequent calls for
13599             # the same data block do not specify the serial/count keys, and may be used
13600             # to decrypt data at any start point within the full data block.
13601             sub Decrypt($;$$$$)
13602             {
13603 5     5 0 25 my ($dataPt, $start, $len, $serial, $count) = @_;
13604 5         11 my ($ch, $cj, $ck);
13605              
13606 5 100       10 $start or $start = 0;
13607 5         10 my $maxLen = length($$dataPt) - $start;
13608 5 100 66     17 $len = $maxLen if not defined $len or $len > $maxLen;
13609 5 100 66     20 if (defined $serial and defined $count) {
13610             # initialize decryption parameters
13611 4         8 my $key = 0;
13612 4         18 $key ^= ($count >> ($_*8)) & 0xff foreach 0..3;
13613 4         13 $ci0 = $xlat[0][$serial & 0xff];
13614 4         8 $cj0 = $xlat[1][$key];
13615 4         7 $ck0 = 0x60;
13616 4         7 undef $decryptStart;
13617             }
13618 5 100       11 if (defined $decryptStart) {
13619             # initialize decryption parameters for this start position
13620 1         2 my $n = $start - $decryptStart;
13621 1         4 $cj = ($cj0 + $ci0 * ($n * $ck0 + ($n * ($n - 1))/2)) & 0xff;
13622 1         2 $ck = ($ck0 + $n) & 0xff;
13623             } else {
13624 4         4 $decryptStart = $start;
13625 4         10 ($cj, $ck) = ($cj0, $ck0);
13626             }
13627 5 100       11 return $$dataPt if $len <= 0;
13628 4         61 my @data = unpack('C*', substr($$dataPt, $start, $len));
13629 4         11 foreach $ch (@data) {
13630 616         600 $cj = ($cj + $ci0 * $ck) & 0xff;
13631 616         547 $ck = ($ck + 1) & 0xff;
13632 616         582 $ch ^= $cj;
13633             }
13634 4         43 return substr($$dataPt, 0, $start) . pack('C*', @data) . substr($$dataPt, $start+$len);
13635             }
13636              
13637             #------------------------------------------------------------------------------
13638             # Get serial number for use as a decryption key
13639             # Inputs: 0) ExifTool object ref, 1) serial number string
13640             # Returns: serial key integer or undef if no serial number provided
13641             sub SerialKey($$)
13642             {
13643 32     32 0 62 my ($et, $serial) = @_;
13644             # use serial number as key if integral
13645 32 50 66     285 return $serial if not defined $serial or $serial =~ /^\d+$/;
13646 0 0       0 return 0x22 if $$et{Model} =~ /\bD50$/; # D50 (ref 8)
13647 0         0 return 0x60; # D200 (ref 10), D40X (ref PH), etc
13648             }
13649              
13650             #------------------------------------------------------------------------------
13651             # Extract information from "NIKON APP" trailer (ref PH)
13652             # Inputs: 0) ExifTool ref, 1) Optional dirInfo ref for returning trailer info
13653             # Returns: true on success
13654             sub ProcessNikonApp($;$)
13655             {
13656 0     0 0 0 local $_;
13657 0         0 my ($et, $dirInfo) = @_;
13658 0         0 my $raf = $$et{RAF};
13659 0 0 0     0 my $offset = $dirInfo ? $$dirInfo{Offset} || 0 : 0;
13660 0         0 my $buff;
13661              
13662 0 0 0     0 return 0 unless $raf->Seek(-20-$offset, 2) and $raf->Read($buff, 20) == 20 and
      0        
13663             substr($buff,-16) eq "\0\0\0\0\0\0/NIKON APP"; # check magic number
13664              
13665 0         0 my $verbose = $et->Options('Verbose');
13666 0         0 my $fileEnd = $raf->Tell();
13667 0         0 my $trailerLen = unpack('N', $buff);
13668 0 0       0 $trailerLen > $fileEnd and $et->Warn('Bad NikonApp trailer size'), return 0;
13669 0 0       0 if ($dirInfo) {
13670 0         0 $$dirInfo{DirLen} = $trailerLen;
13671 0         0 $$dirInfo{DataPos} = $fileEnd - $trailerLen;
13672 0 0       0 if ($$dirInfo{OutFile}) {
13673 0 0 0     0 if ($$et{DEL_GROUP}{NikonApp}) {
    0 0        
13674 0         0 $et->VPrint(0, " Deleting NikonApp trailer ($trailerLen bytes)\n");
13675 0         0 ++$$et{CHANGED};
13676             # just copy the trailer when writing (read directly into output buffer)
13677             } elsif ($trailerLen > $fileEnd or not $raf->Seek($$dirInfo{DataPos}, 0) or
13678 0         0 $raf->Read(${$$dirInfo{OutFile}}, $trailerLen) != $trailerLen)
13679             {
13680 0         0 return 0;
13681             }
13682 0         0 return 1;
13683             }
13684 0 0 0     0 $et->DumpTrailer($dirInfo) if $verbose or $$et{HTML_DUMP};
13685             }
13686 0 0 0     0 unless ($trailerLen >= 0x40 and $raf->Seek($fileEnd - $trailerLen, 0) and
      0        
      0        
13687             $raf->Read($buff, 0x40) == 0x40 and $buff =~ m(NIKON APP\0))
13688             {
13689 0         0 $et->Warn('Error reading NikonApp trailer');
13690 0         0 return 0;
13691             }
13692 0         0 $$et{SET_GROUP0} = 'NikonApp';
13693 0         0 while ($raf->Read($buff, 8) == 8) {
13694 0         0 my ($id, $len) = unpack('N2', $buff);
13695 0 0       0 if ($len & 0x80000000) {
13696 0         0 $et->Warn('Invalid NikonApp record length');
13697 0         0 last;
13698             }
13699 0 0 0     0 last if $id == 0 and $len == 0;
13700 0 0       0 unless ($raf->Read($buff, $len) == $len) {
13701 0         0 $et->Warn('Truncated NikonApp record');
13702 0         0 last;
13703             }
13704 0 0       0 if ($id == 1) {
13705 0         0 require Image::ExifTool::XMP;
13706 0         0 Image::ExifTool::XMP::ProcessXMP($et, { DataPt => \$buff });
13707             } else { # (haven't seen any other types of records)
13708 0         0 $et->Warn("Unknown NikonApp record $id");
13709 0         0 last;
13710             }
13711             }
13712 0         0 delete $$et{SET_GROUP0};
13713 0         0 return 1;
13714             }
13715              
13716             #------------------------------------------------------------------------------
13717             # Read Nikon NCTG tags in MOV videos
13718             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
13719             # Returns: 1 on success
13720             sub ProcessNikonMOV($$$)
13721             {
13722 0     0 0 0 my ($et, $dirInfo, $tagTablePtr) = @_;
13723 0         0 my $dataPt = $$dirInfo{DataPt};
13724 0         0 my $dataPos = $$dirInfo{DataPos};
13725 0         0 my %needTags = ( 0x110a431 => 0, 0x20000a7 => undef ); # needed for decryption
13726 0         0 $et->VerboseDir($$dirInfo{DirName}, 0, $$dirInfo{DirLen});
13727 0         0 my $pass;
13728             # do two passes so we can pre-scan for necessary decryption keys
13729 0         0 for ($pass=0; $pass<2; ++$pass) {
13730 0         0 my $pos = $$dirInfo{DirStart};
13731 0         0 my $end = $pos + $$dirInfo{DirLen};
13732 0         0 while ($pos + 8 < $end) {
13733 0         0 my $tag = Get32u($dataPt, $pos);
13734 0         0 my $fmt = Get16u($dataPt, $pos + 4); # (same format code as EXIF)
13735 0         0 my $count = Get16u($dataPt, $pos + 6);
13736 0         0 $pos += 8;
13737 0         0 my $fmtStr = $Image::ExifTool::Exif::formatName[$fmt];
13738 0 0       0 unless ($fmtStr) {
13739 0 0       0 $et->Warn(sprintf("Unknown format ($fmt) for $$dirInfo{DirName} tag 0x%x",$tag)) if $pass;
13740 0         0 last;
13741             }
13742 0         0 my $size = $count * $Image::ExifTool::Exif::formatSize[$fmt];
13743 0 0       0 if ($pos + $size > $end) {
13744 0 0       0 $et->Warn(sprintf("Truncated data for $$dirInfo{DirName} tag 0x%x",$tag)) if $pass;
13745 0         0 last;
13746             }
13747 0 0       0 if ($pass) {
    0          
13748 0         0 my $rational;
13749 0         0 my $val = ReadValue($dataPt, $pos, $fmtStr, $count, $size, \$rational);
13750             my $key = $et->HandleTag($tagTablePtr, $tag, $val,
13751             DataPt => $dataPt,
13752             DataPos => $dataPos,
13753             Format => $fmtStr,
13754             Start => $pos,
13755             Size => $size,
13756             Base => $$dirInfo{Base},
13757 0         0 );
13758 0 0       0 if ($key) {
13759 0 0       0 $$et{TAG_EXTRA}{$key}{Rational} = $rational if $rational;
13760 0 0       0 $$et{TAG_EXTRA}{$key}{BinVal} = substr($$dataPt, $pos, $size) if $$et{OPTIONS}{SaveBin};
13761             }
13762             } elsif (exists $needTags{$tag}) {
13763 0         0 $needTags{$tag} = ReadValue($dataPt, $pos, $fmtStr, $count, $size);
13764 0         0 $$et{NikonSerialKey} = SerialKey($et, $needTags{0x110a431});
13765 0         0 $$et{NikonCountKey} = $needTags{0x20000a7};
13766             }
13767 0         0 $pos += $size; # is this padded to an even offset????
13768             }
13769             }
13770 0         0 return 1;
13771             }
13772              
13773             #------------------------------------------------------------------------------
13774             # Get offset of end-of-data for a tag
13775             # Inputs: 0) tag table ref, 1) tag ID, 2) true to not calculate end for a SubDirectory
13776             # Returns: offset of tag value end, undef if it can't be determined
13777             sub GetTagEnd($$;$)
13778             {
13779 3     3 0 6 my ($tagTablePtr, $tagID, $ignoreSubdir) = @_;
13780 3         5 my $tagInfo = $$tagTablePtr{$tagID};
13781 3 50       7 $tagInfo = $$tagInfo[0] if ref $tagInfo eq 'ARRAY';
13782             # (can't pre-determine position of offset-based subdirectories)
13783 3 0 33     7 return undef if $ignoreSubdir and $$tagInfo{SubDirectory};
13784 3   50     13 my $fmt = $$tagInfo{Format} || $$tagTablePtr{FORMAT} || 'int8u';
13785 3 100       12 my $nm = $fmt =~ s/\[(\d+)\]$// ? $1 : 1;
13786 3 50       8 my $sz = Image::ExifTool::FormatSize($fmt) or return undef;
13787 3         7 return int($tagID) + $sz * $nm;
13788             }
13789              
13790             #------------------------------------------------------------------------------
13791             # Initialize SubDirectory KnownStart/KnownEnd limits of known tags (used in decryption)
13792             # Inputs: 0) tagInfo ref containing this SubDirectory, 2) tag table ref for encrypted subdir
13793             # Notes: KnownStart/KnownEnd are relative to the SubDirectory Start. If KnownStart/KnownEnd
13794             # aren't set then the entire data is decrypted, so all of this effort is just for speed.
13795             sub InitEncryptedSubdir($$)
13796             {
13797 3     3 0 5 my ($tagInfo, $tagTablePtr) = @_;
13798             #
13799             # for encrypted NIKON_OFFSETS tables we loop through all SubDirectory tags in this table
13800             # and set the KnownEnd for each of these according to the last tag in the child tables
13801             #
13802 3         4 my $vars = $$tagTablePtr{VARS};
13803 3 50       9 $vars or $vars = $$tagTablePtr{VARS} = { };
13804 3 50 33     9 if ($$vars{NIKON_OFFSETS} and not $$vars{NIKON_INITIALIZED}) {
13805 0         0 $$vars{NIKON_INITIALIZED} = 1;
13806 0         0 my $tagID;
13807 0         0 foreach $tagID (TagTableKeys($tagTablePtr)) {
13808 0         0 my $tagInfo = $$tagTablePtr{$tagID};
13809 0 0       0 next unless ref $tagInfo eq 'HASH';
13810 0 0       0 my $subdir = $$tagInfo{SubDirectory} or next;
13811 0         0 my $tbl = GetTagTable($$subdir{TagTable});
13812 0         0 my ($last) = sort { $b <=> $a } TagTableKeys($tbl); # (reverse sort)
  0         0  
13813 0         0 $$subdir{KnownEnd} = GetTagEnd($tbl, $last, 1);
13814             }
13815             }
13816             #
13817             # for other encrypted Nikon tables we set the KnownStart/KnownEnd entries in the
13818             # SubDirectory of the parent tag
13819             #
13820 3 50       8 unless ($$tagInfo{NikonInitialized}) {
13821 3         4 $$tagInfo{NikonInitialized} = 1;
13822 3         5 my $subdir = $$tagInfo{SubDirectory};
13823 3   50     8 my $start = $$subdir{DecryptStart} || 0;
13824 3         5 my $off = $$subdir{DirOffset};
13825 3         7 my @tagIDs = sort { $a <=> $b } TagTableKeys($tagTablePtr);
  65         73  
13826 3 100       8 if (defined $off) {
13827 1         2 $off += $start; # (DirOffset, if specified, is relative to DecryptStart)
13828             } else {
13829             # ignore tags that come before the start of encryption
13830 2   66     13 shift @tagIDs while @tagIDs and $tagIDs[0] < $start;
13831 2         3 $off = 0;
13832             }
13833 3 50       6 if (@tagIDs) {
13834 3         6 my ($first, $last) = @tagIDs[0,-1];
13835 3         8 my $lastInfo = $$tagTablePtr{$last};
13836 3 50       7 $lastInfo = $$lastInfo[0] if ref $lastInfo eq 'ARRAY';
13837 3 100       10 $$subdir{KnownStart} = int($first) + $off if $first + $off > $start;
13838 3         9 $$subdir{KnownEnd} = GetTagEnd($tagTablePtr, $last);
13839 3 50       7 if (defined $$subdir{KnownEnd}) {
13840 3         11 $$subdir{KnownEnd} += $off;
13841             } else {
13842 0         0 warn "Internal error setting KnownEnd for $$tagTablePtr{SHORT_NAME}\n";
13843             }
13844             } else {
13845 0         0 $$subdir{KnownStart} = $$subdir{KnownEnd} = $start;
13846             }
13847             }
13848             }
13849              
13850             #------------------------------------------------------------------------------
13851             # Prepare to process NIKON_OFFSETS directory and decrypt necessary data
13852             # Inputs: 0) ExifTool ref, 1) data ref, 2) tag table ref, 3) decrypt start,
13853             # 4) decrypt mode (0=piecewise, 1=continuous to end of last known section, 2=all)
13854             # Returns: end of decrypted data (or undef for piecewise decryption)
13855             sub PrepareNikonOffsets($$$$$)
13856             {
13857 0     0 0 0 my ($et, $dataPt, $tagTablePtr, $start, $decryptMode) = @_;
13858 0         0 my $offset = $$tagTablePtr{VARS}{NIKON_OFFSETS};
13859 0         0 my $dataLen = length $$dataPt;
13860 0 0 0     0 return undef if $offset + 4 > $dataLen or $offset < $start;
13861 0         0 my $serial = $$et{NikonSerialKey};
13862 0         0 my $count = $$et{NikonCountKey};
13863 0         0 my $dpos = $offset + 4; # decrypt up to NumberOffsets
13864 0         0 $$dataPt = Decrypt($dataPt, $start, $dpos - $start, $serial, $count);
13865 0         0 my $numOffsets = Get32u($dataPt, $offset);
13866 0         0 my $more = $numOffsets * 4; # more bytes to decrypt entire offsets table
13867 0 0       0 return undef if $offset + 4 + $more > $dataLen;
13868 0         0 $$dataPt = Decrypt($dataPt, $dpos, $more);
13869 0         0 $dpos += $more;
13870 0         0 my $unknown = $et->Options('Unknown');
13871 0         0 my ($i, @offInfo, $end);
13872             # extract non-zero offsets and create unknown subdirectories if Unknown > 1
13873 0         0 for ($i=0; $i<$numOffsets; ++$i) {
13874 0         0 my $pos = $offset + 4 + 4 * $i;
13875 0 0       0 my $off = Get32u($dataPt, $pos) or next;
13876 0         0 my $tagInfo = $$tagTablePtr{$pos};
13877 0         0 my $known = 0;
13878 0 0       0 if ($tagInfo) {
    0          
13879 0 0 0     0 $known = 1 if ref $tagInfo ne 'HASH' or not $$tagInfo{Unknown};
13880             } elsif ($unknown > 1) {
13881             # create new table for unknown information
13882 0         0 my $tbl = sprintf('Image::ExifTool::Nikon::UnknownInfo%.2x', $pos);
13883 29     29   364 no strict 'refs';
  29         67  
  29         126784  
13884 0 0       0 unless (%$tbl) {
13885 0         0 %$tbl = ( %binaryDataAttrs, GROUPS => { 0=>'MakerNotes', 2=>'Unknown' } );
13886 0         0 GetTagTable($tbl);
13887             }
13888             # add unknown entry in offset table for this subdirectory
13889 0         0 $tagInfo = AddTagToTable($tagTablePtr, $pos, {
13890             Name => sprintf('UnknownOffset%.2x', $pos),
13891             Format => 'int32u',
13892             SubDirectory => { TagTable => $tbl },
13893             Unknown => 2,
13894             });
13895             }
13896 0         0 push @offInfo, [ $pos, $off, $known ]; # save parameters for non-zero offsets
13897             }
13898             # sort offsets in ascending order, and use the differences to calculate
13899             # directory lengths and update the SubDirectory DirLen's accordingly
13900 0 0       0 my @sorted = sort { $$a[1] <=> $$b[1] or $$a[0] <=> $$b[0] } @offInfo;
  0         0  
13901 0         0 push @sorted, [ 0, length($$dataPt), 0 ];
13902 0         0 for ($i=0; $i<@sorted-1; ++$i) {
13903 0         0 my $pos = $sorted[$i][0];
13904 0         0 my $len = $sorted[$i+1][1] - $sorted[$i][1];
13905 0         0 my $tagInfo = $$tagTablePtr{$pos};
13906             $tagInfo = $et->GetTagInfo($tagTablePtr, $pos) if $tagInfo and
13907 0 0 0     0 not (ref $tagInfo eq 'HASH' and $$tagInfo{AlwaysDecrypt});
      0        
13908             # set DirLen in SubDirectory entry
13909 0         0 my $subdir;
13910 0 0 0     0 $$subdir{DirLen} = $len if ref $tagInfo eq 'HASH' and defined($subdir=$$tagInfo{SubDirectory});
13911 0 0 0     0 if ($decryptMode) {
    0 0        
13912             # keep track of end of last known directory
13913 0 0       0 $end = $sorted[$i+1][1] if $sorted[$i][2];
13914             } elsif ($tagInfo and (ref $tagInfo ne 'HASH' or not $$tagInfo{Unknown})) {
13915             # decrypt data piecewise as necessary
13916 0         0 my $n = $len;
13917 0 0 0     0 if ($subdir and $$subdir{KnownEnd}) {
13918 0         0 $n = $$subdir{KnownEnd};
13919 0 0       0 if ($n > $len) {
13920 0 0       0 $et->Warn("Data too short for $$tagInfo{Name}",1) unless $$tagInfo{AlwaysDecrypt};
13921 0         0 $n = $len;
13922             }
13923             }
13924 0         0 $$dataPt = Decrypt($dataPt, $sorted[$i][1], $n);
13925             }
13926             }
13927 0 0       0 if ($decryptMode) {
13928             # decrypt the remaining required data
13929 0 0 0     0 $end = length $$dataPt if $decryptMode == 2 or not $end or $end < $dpos;
      0        
13930 0         0 $$dataPt = Decrypt($dataPt, $dpos, $end - $dpos);
13931             }
13932 0         0 return $end;
13933             }
13934              
13935             #------------------------------------------------------------------------------
13936             # Read/Write Nikon Encrypted data block
13937             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
13938             # Returns: 1 on success when reading, or new directory when writing (IsWriting set)
13939             sub ProcessNikonEncrypted($$$)
13940             {
13941 122     122 0 221 my ($et, $dirInfo, $tagTablePtr) = @_;
13942 122 100       363 $et or return 1; # allow dummy access
13943 3         5 my $serial = $$et{NikonSerialKey};
13944 3         7 my $count = $$et{NikonCountKey};
13945 3 50 33     33 unless (defined $serial and defined $count and $serial =~ /^\d+$/ and $count =~ /^\d+$/) {
      33        
      33        
13946 0 0 0     0 if (defined $serial or defined $count) {
13947 0         0 my $msg;
13948 0 0 0     0 if (defined $serial and defined $count) {
13949 0 0       0 $msg = $serial =~ /^\d+$/ ? 'invalid ShutterCount' : 'invalid SerialNumber';
13950             } else {
13951 0 0       0 $msg = defined $serial ? 'no ShutterCount' : 'no SerialNumber';
13952             }
13953 0         0 $et->Warn("Can't decrypt Nikon information ($msg key)");
13954             }
13955 0         0 delete $$et{NikonSerialKey};
13956 0         0 delete $$et{NikonCountKey};
13957 0         0 return 0;
13958             }
13959 3         7 my $oldOrder = GetByteOrder();
13960 3         6 my $isWriting = $$dirInfo{IsWriting};
13961 3 50       12 my $verbose = $isWriting ? 0 : $et->Options('Verbose');
13962 3         5 my $tagInfo = $$dirInfo{TagInfo};
13963 3         5 my $dirStart = $$dirInfo{DirStart};
13964 3         4 my $data = substr(${$$dirInfo{DataPt}}, $dirStart, $$dirInfo{DirLen});
  3         8  
13965              
13966 3         6 my ($start, $len, $offset, $recrypt, $newSerial, $newCount, $didDecrypt);
13967              
13968             # must re-encrypt when writing if serial number or shutter count changes
13969 3 50       6 if ($isWriting) {
13970 0 0       0 if ($$et{NewNikonSerialKey}) {
13971 0         0 $newSerial = $$et{NewNikonSerialKey};
13972 0         0 $recrypt = 1;
13973             }
13974 0 0       0 if ($$et{NewNikonCountKey}) {
13975 0         0 $newCount = $$et{NewNikonCountKey};
13976 0         0 $recrypt = 1;
13977             }
13978             }
13979 3 50 33     14 if ($tagInfo and $$tagInfo{SubDirectory}) {
13980             # initialize SubDirectory entries used in encryption (KnownStart, KnownEnd)
13981 3         12 InitEncryptedSubdir($tagInfo, $tagTablePtr);
13982 3         3 my $subdir = $$tagInfo{SubDirectory};
13983 3   50     9 $start = $$subdir{DecryptStart} || 0;
13984             # DirOffset, if specified, is the offset to the start of the
13985             # directory relative to start of encrypted data
13986 3 100       5 $offset = defined $$subdir{DirOffset} ? $$subdir{DirOffset} + $start : 0;
13987             # must set byte ordering before calling PrepareNikonOffsets()
13988 3 100       9 SetByteOrder($$subdir{ByteOrder}) if $$subdir{ByteOrder};
13989             # prepare for processing NIKON_OFFSETS directory if necessary
13990 3   33     15 my $unknown = $verbose > 2 || $et->Options('Unknown') > 1;
13991             # decrypt mode: 0=piecewise, 1=continuous to end of last known section, 2=all
13992 3 0       9 my $dMode = $isWriting ? ($recrypt ? 2 : 1) : ($unknown ? 2 : 0);
    50          
    50          
13993 3 50       11 if ($$tagTablePtr{VARS}{NIKON_OFFSETS}) {
    50          
13994 0         0 $len = PrepareNikonOffsets($et, \$data, $tagTablePtr, $start, $dMode);
13995 0         0 $didDecrypt = 1;
13996             } elsif ($dMode < 2) {
13997 3 100 66     14 if ($dMode == 0 and $$subdir{KnownStart}) {
13998             # initialize decryption parameters for address DecryptStart address
13999 1         6 Decrypt(\$data, $start, 0, $serial, $count);
14000             # reset serial/count keys so we don't re-initialize below
14001 1         2 undef $serial;
14002 1         2 undef $count;
14003             # change decryption start to skip unnecessary data
14004 1         2 $start = $$subdir{KnownStart};
14005             }
14006 3 50       8 $len = $$subdir{KnownEnd} - $start if $$subdir{KnownEnd};
14007             }
14008             } else {
14009 0         0 $start = $offset = 0;
14010             }
14011 3         6 my $maxLen = length($data) - $start;
14012             # decrypt all the data unless the length was specified
14013 3 50 33     13 $len = $maxLen unless $len and $len < $maxLen;
14014              
14015 3 50       10 $data = Decrypt(\$data, $start, $len, $serial, $count) unless $didDecrypt;
14016              
14017 3 50       7 if ($verbose > 2) {
14018 0         0 $et->VerboseDir("Decrypted $$tagInfo{Name}");
14019             $et->VerboseDump(\$data,
14020 0         0 Prefix => $$et{INDENT} . ' ',
14021             # (remove this because it is useful to have decrypted offsets start at 0)
14022             #DataPos => $dirStart + $$dirInfo{DataPos} + ($$dirInfo{Base} || 0),
14023             );
14024             }
14025             # process the decrypted information
14026             my %subdirInfo = (
14027             DataPt => \$data,
14028             DirStart => $offset,
14029             DirLen => length($data) - $offset,
14030             DirName => $$dirInfo{DirName},
14031             DataPos => $$dirInfo{DataPos} + $dirStart,
14032             Base => $$dirInfo{Base},
14033 3         19 );
14034 3         4 my $rtnVal;
14035 3 50       8 if ($isWriting) {
14036 0         0 my $changed = $$et{CHANGED};
14037 0         0 $rtnVal = $et->WriteBinaryData(\%subdirInfo, $tagTablePtr);
14038             # must re-encrypt if serial number or shutter count changes
14039 0 0       0 if ($recrypt) {
14040 0 0       0 $serial = $newSerial if defined $newSerial;
14041 0 0       0 $count = $newCount if defined $newCount;
14042 0         0 ++$$et{CHANGED};
14043             }
14044 0 0       0 if ($changed == $$et{CHANGED}) {
14045 0         0 undef $rtnVal; # nothing changed so use original data
14046             } else {
14047             # add back any un-encrypted data at start
14048 0 0       0 $rtnVal = substr($data, 0, $offset) . $rtnVal if $offset;
14049             # re-encrypt data (symmetrical algorithm)
14050 0         0 $rtnVal = Decrypt(\$rtnVal, $start, $len, $serial, $count);
14051 0         0 $et->VPrint(2, $$et{INDENT}, " [recrypted $$tagInfo{Name}]");
14052             }
14053             } else {
14054 3         11 $rtnVal = $et->ProcessBinaryData(\%subdirInfo, $tagTablePtr);
14055             }
14056 3         10 SetByteOrder($oldOrder);
14057 3         11 return $rtnVal;
14058             }
14059              
14060             #------------------------------------------------------------------------------
14061             # Pre-scan EXIF directory to extract specific tags
14062             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) required tagID hash ref
14063             # Returns: 1 if directory was scanned successfully
14064             sub PrescanExif($$$)
14065             {
14066 24     24 0 53 my ($et, $dirInfo, $tagHash) = @_;
14067 24         69 my $dataPt = $$dirInfo{DataPt};
14068 24   100     91 my $dataPos = $$dirInfo{DataPos} || 0;
14069 24         50 my $dataLen = $$dirInfo{DataLen};
14070 24   50     62 my $dirStart = $$dirInfo{DirStart} || 0;
14071 24   50     62 my $base = $$dirInfo{Base} || 0;
14072 24         55 my $raf = $$dirInfo{RAF};
14073 24         39 my ($index, $numEntries, $data, $buff);
14074              
14075             # get number of entries in IFD
14076 24 50 33     114 if ($dirStart >= 0 and $dirStart <= $dataLen-2) {
14077 24         113 $numEntries = Get16u($dataPt, $dirStart);
14078             # reset $numEntries to read from file if necessary
14079 24 50       97 undef $numEntries if $dirStart + 2 + 12 * $numEntries > $dataLen;
14080             }
14081             # read IFD from file if necessary
14082 24 50       67 unless ($numEntries) {
14083 0 0       0 $raf or return 0;
14084 0         0 $dataPos += $dirStart; # read data from the start of the directory
14085 0 0 0     0 $raf->Seek($dataPos + $base, 0) and $raf->Read($data, 2) == 2 or return 0;
14086 0         0 $numEntries = Get16u(\$data, 0);
14087 0         0 my $len = 12 * $numEntries;
14088 0 0       0 $raf->Read($buff, $len) == $len or return 0;
14089 0         0 $data .= $buff;
14090             # update variables for the newly loaded IFD (already updated dataPos)
14091 0         0 $dataPt = \$data;
14092 0         0 $dataLen = length $data;
14093 0         0 $dirStart = 0;
14094             }
14095             # loop through Nikon MakerNote IFD entries
14096 24         83 for ($index=0; $index<$numEntries; ++$index) {
14097 597         630 my $entry = $dirStart + 2 + 12 * $index;
14098 597         691 my $tagID = Get16u($dataPt, $entry);
14099 597 100       1088 next unless exists $$tagHash{$tagID}; # only extract required tags
14100 8         18 my $format = Get16u($dataPt, $entry+2);
14101 8 50 33     42 next if $format < 1 or $format > 13;
14102 8         23 my $count = Get32u($dataPt, $entry+4);
14103 8         19 my $size = $count * $Image::ExifTool::Exif::formatSize[$format];
14104 8         17 my $formatStr = $Image::ExifTool::Exif::formatName[$format];
14105 8         15 my $valuePtr = $entry + 8; # pointer to value within $$dataPt
14106 8 100       453 if ($size > 4) {
14107 1 50       3 next if $size > 0x1000000; # set a reasonable limit on data size (16MB)
14108 1         3 $valuePtr = Get32u($dataPt, $valuePtr);
14109             # convert offset to pointer in $$dataPt
14110             # (don't yet handle EntryBased or FixOffsets)
14111 1         2 $valuePtr -= $dataPos;
14112 1 50 33     7 if ($valuePtr < 0 or $valuePtr+$size > $dataLen) {
14113 0 0 0     0 next unless $raf and $raf->Seek($base + $valuePtr + $dataPos,0) and
      0        
14114             $raf->Read($buff,$size) == $size;
14115 0         0 $$tagHash{$tagID} = ReadValue(\$buff,0,$formatStr,$count,$size);
14116 0         0 next;
14117             }
14118             }
14119 8         31 $$tagHash{$tagID} = ReadValue($dataPt,$valuePtr,$formatStr,$count,$size);
14120             }
14121 24         52 return 1;
14122             }
14123              
14124             #------------------------------------------------------------------------------
14125             # Process Nikon Capture history data
14126             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
14127             # Returns: 1 on success
14128             sub ProcessNikonCaptureEditVersions($$$)
14129             {
14130 0     0 0 0 my ($et, $dirInfo, $tagTablePtr) = @_;
14131 0         0 require Image::ExifTool::NikonCapture;
14132 0         0 return Image::ExifTool::NikonCapture::ProcessNikonCaptureEditVersions($et, $dirInfo, $tagTablePtr);
14133             }
14134              
14135             #------------------------------------------------------------------------------
14136             # Process Nikon Capture Offsets IFD (ref PH)
14137             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
14138             # Returns: 1 on success
14139             # Notes: This isn't a normal IFD, but is close...
14140             sub ProcessNikonCaptureOffsets($$$)
14141             {
14142 2     2 0 5 my ($et, $dirInfo, $tagTablePtr) = @_;
14143 2         6 my $dataPt = $$dirInfo{DataPt};
14144 2         6 my $dirStart = $$dirInfo{DirStart};
14145 2         4 my $dirLen = $$dirInfo{DirLen};
14146 2         4 my $success = 0;
14147 2 50       7 return 0 unless $dirLen > 2;
14148 2         9 my $count = Get16u($dataPt, $dirStart);
14149 2 50 33     15 return 0 unless $count and $count * 12 + 2 <= $dirLen;
14150 2 50       7 if ($et->Options('Verbose')) {
14151 0         0 $et->VerboseDir('NikonCaptureOffsets', $count);
14152             }
14153 2         4 my $index;
14154 2         8 for ($index=0; $index<$count; ++$index) {
14155 6         9 my $pos = $dirStart + 12 * $index + 2;
14156 6         15 my $tagID = Get32u($dataPt, $pos);
14157 6         15 my $value = Get32u($dataPt, $pos + 4);
14158 6 50       16 $et->HandleTag($tagTablePtr, $tagID, $value,
14159             Index => $index,
14160             DataPt => $dataPt,
14161             Start => $pos,
14162             Size => 12,
14163             ) and $success = 1;
14164             }
14165 2         6 return $success;
14166             }
14167              
14168             #------------------------------------------------------------------------------
14169             # Read Nikon NKA file
14170             # Inputs: 0) ExifTool ref, 1) dirInfo ref
14171             # Returns: 1 on success
14172             sub ProcessNKA($$)
14173             {
14174 0     0 0 0 my ($et, $dirInfo) = @_;
14175 0         0 my $raf = $$et{RAF};
14176 0         0 my $buff;
14177 0 0       0 $raf->Read($buff, 0x35) == 0x35 or return 0;
14178 0         0 my $len = unpack('x49V', $buff);
14179 0 0       0 $raf->Read($buff, $len) == $len or return 0;
14180 0         0 $et->SetFileType('NKA', 'application/x-nikon-nxstudio');
14181 0         0 my %dirInfo = ( DataPt => \$buff, DataPos => 0x35 );
14182 0         0 my $tagTablePtr = GetTagTable('Image::ExifTool::XMP::XML');
14183 0         0 return $et->ProcessDirectory(\%dirInfo, $tagTablePtr);
14184             }
14185              
14186             #------------------------------------------------------------------------------
14187             # Read/write Nikon MakerNotes directory
14188             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
14189             # Returns: 1 on success, otherwise returns 0 and sets a Warning when reading
14190             # or new directory when writing (IsWriting set in dirInfo)
14191             sub ProcessNikon($$$)
14192             {
14193 326     326 0 680 my ($et, $dirInfo, $tagTablePtr) = @_;
14194 326 100       1083 $et or return 1; # allow dummy access
14195              
14196             # pre-scan IFD to get SerialNumber (0x001d) and ShutterCount (0x00a7) for use in decryption
14197 24         120 my %needTags = ( 0x001d => 0, 0x00a7 => undef );
14198 24         148 PrescanExif($et, $dirInfo, \%needTags);
14199 24         119 $$et{NikonSerialKey} = SerialKey($et, $needTags{0x001d});
14200 24         71 $$et{NikonCountKey} = $needTags{0x00a7};
14201              
14202             # process Nikon makernotes
14203 24         38 my $rtnVal;
14204 24 100       72 if ($$dirInfo{IsWriting}) {
14205             # get new decryptino keys if they are being changed
14206 8         60 my $serial = $et->GetNewValue($Image::ExifTool::Nikon::Main{0x001d});
14207 8         30 my $count = $et->GetNewValue($Image::ExifTool::Nikon::Main{0x00a7});
14208 8         19 $$et{NewNikonSerialKey} = SerialKey($et, $serial);
14209 8         22 $$et{NewNikonCountKey} = $count;
14210 8         75 $rtnVal = Image::ExifTool::Exif::WriteExif($et, $dirInfo, $tagTablePtr);
14211 8         24 delete $$et{NewNikonSerialKey};
14212 8         18 delete $$et{NewNikonCountKey};
14213             } else {
14214 16         120 $rtnVal = Image::ExifTool::Exif::ProcessExif($et, $dirInfo, $tagTablePtr);
14215             }
14216 24         72 delete $$et{NikonSerialKey};
14217 24         50 delete $$et{NikonCountKey};
14218 24         84 return $rtnVal;
14219             }
14220              
14221             1; # end
14222              
14223             __END__