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   10030 use strict;
  29         86  
  29         1686  
61 29     29   187 use vars qw($VERSION %nikonLensIDs %nikonTextEncoding);
  29         78  
  29         2197  
62 29     29   175 use Image::ExifTool qw(:DataAccess :Utils);
  29         63  
  29         8966  
63 29     29   57153 use Image::ExifTool::NikonCustom qw(%buttonsZ8 %buttonsZ9);
  29         197  
  29         26431  
64 29     29   2039 use Image::ExifTool::Exif;
  29         93  
  29         1348  
65 29     29   894 use Image::ExifTool::GPS;
  29         67  
  29         950  
66 29     29   11415 use Image::ExifTool::XMP;
  29         758  
  29         1267459  
67              
68             $VERSION = '4.55';
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             #
687             '00 40 2D 2D 2C 2C 00 00' => 'Carl Zeiss Distagon T* 3.5/18 ZF.2',
688             '00 48 27 27 24 24 00 00' => 'Carl Zeiss Distagon T* 2.8/15 ZF.2', #MykytaKozlov
689             '00 48 32 32 24 24 00 00' => 'Carl Zeiss Distagon T* 2.8/21 ZF.2',
690             '00 54 38 38 18 18 00 00' => 'Carl Zeiss Distagon T* 2/25 ZF.2',
691             '00 54 3C 3C 18 18 00 00' => 'Carl Zeiss Distagon T* 2/28 ZF.2',
692             '00 54 44 44 0C 0C 00 00' => 'Carl Zeiss Distagon T* 1.4/35 ZF.2',
693             '00 54 44 44 18 18 00 00' => 'Carl Zeiss Distagon T* 2/35 ZF.2',
694             '00 54 50 50 0C 0C 00 00' => 'Carl Zeiss Planar T* 1.4/50 ZF.2',
695             '00 54 50 50 18 18 00 00' => 'Carl Zeiss Makro-Planar T* 2/50 ZF.2',
696             '00 54 62 62 0C 0C 00 00' => 'Carl Zeiss Planar T* 1.4/85 ZF.2',
697             '00 54 68 68 18 18 00 00' => 'Carl Zeiss Makro-Planar T* 2/100 ZF.2',
698             '00 54 72 72 18 18 00 00' => 'Carl Zeiss Apo Sonnar T* 2/135 ZF.2',
699             '02 54 3C 3C 0C 0C 00 00' => 'Zeiss Otus 1.4/28 ZF.2', #30
700             '00 54 53 53 0C 0C 00 00' => 'Zeiss Otus 1.4/55', #IB
701             '01 54 62 62 0C 0C 00 00' => 'Zeiss Otus 1.4/85',
702             '03 54 68 68 0C 0C 00 00' => 'Zeiss Otus 1.4/100', #IB
703             '52 54 44 44 18 18 00 00' => 'Zeiss Milvus 35mm f/2',
704             '53 54 50 50 0C 0C 00 00' => 'Zeiss Milvus 50mm f/1.4', #IB
705             '54 54 50 50 18 18 00 00' => 'Zeiss Milvus 50mm f/2 Macro',
706             '55 54 62 62 0C 0C 00 00' => 'Zeiss Milvus 85mm f/1.4', #IB
707             '56 54 68 68 18 18 00 00' => 'Zeiss Milvus 100mm f/2 Macro',
708             #
709             '00 54 56 56 30 30 00 00' => 'Coastal Optical Systems 60mm 1:4 UV-VIS-IR Macro Apo',
710             #
711             '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)
712             'BF 3C 1B 1B 30 30 01 04' => 'Irix 11mm f/4 Firefly', #30 (guessing the Blackstone version may be the same ID - PH)
713             #
714             '4A 40 11 11 2C 0C 4D 02' => 'Samyang 8mm f/3.5 Fish-Eye CS',
715             '4A 48 24 24 24 0C 4D 02.1' => 'Samyang 10mm f/2.8 ED AS NCS CS',
716             '4A 48 1E 1E 24 0C 4D 02' => 'Samyang 12mm f/2.8 ED AS NCS Fish-Eye', #Jurgen Sahlberg
717             '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
718             '4A 4C 24 24 1E 6C 4D 06' => 'Samyang 14mm f/2.4 Premium',
719             '4A 54 29 29 18 0C 4D 02' => 'Samyang 16mm f/2.0 ED AS UMC CS', #Jon Bloom (by email)
720             '4A 60 36 36 0C 0C 4D 02' => 'Samyang 24mm f/1.4 ED AS UMC',
721             '4A 60 44 44 0C 0C 4D 02' => 'Samyang 35mm f/1.4 AS UMC',
722             '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
723             #
724             '9A 4C 50 50 14 14 9C 06' => 'Yongnuo YN50mm F1.8N',
725             '9F 48 48 48 24 24 A1 06' => 'Yongnuo YN40mm F2.8N', #30
726             '9F 54 68 68 18 18 A2 06' => 'Yongnuo YN100mm F2N', #30
727             '9F 4C 44 44 18 18 A1 06' => 'Yongnuo YN35mm F2', #30
728             '9F 4D 50 50 14 14 A0 06' => 'Yongnuo YN50mm F1.8N', #30
729             #
730             '02 40 44 5C 2C 34 02 00' => 'Exakta AF 35-70mm 1:3.5-4.5 MC',
731             #
732             '07 3E 30 43 2D 35 03 00' => 'Soligor AF Zoom 19-35mm 1:3.5-4.5 MC',
733             '03 43 5C 81 35 35 02 00' => 'Soligor AF C/D Zoom UMCS 70-210mm 1:4.5',
734             '12 4A 5C 81 31 3D 09 00' => 'Soligor AF C/D Auto Zoom+Macro 70-210mm 1:4-5.6 UMCS',
735             '12 36 69 97 35 42 09 00' => 'Soligor AF Zoom 100-400mm 1:4.5-6.7 MC',
736             #
737             '00 00 00 00 00 00 00 01' => 'Manual Lens No CPU',
738             #
739             '00 00 48 48 53 53 00 01' => 'Loreo 40mm F11-22 3D Lens in a Cap 9005', #PH
740             '00 47 10 10 24 24 00 00' => 'Fisheye Nikkor 8mm f/2.8 AiS',
741             '00 47 3C 3C 24 24 00 00' => 'Nikkor 28mm f/2.8 AiS', #35
742             # '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)
743             '00 57 50 50 14 14 00 00' => 'Nikkor 50mm f/1.8 AI', #35
744             '00 48 50 50 18 18 00 00' => 'Nikkor H 50mm f/2',
745             '00 48 68 68 24 24 00 00' => 'Series E 100mm f/2.8',
746             '00 4C 6A 6A 20 20 00 00' => 'Nikkor 105mm f/2.5 AiS',
747             '00 48 80 80 30 30 00 00' => 'Nikkor 200mm f/4 AiS',
748             '00 40 11 11 2C 2C 00 00' => 'Samyang 8mm f/3.5 Fish-Eye',
749             '00 58 64 64 20 20 00 00' => 'Soligor C/D Macro MC 90mm f/2.5',
750             '4A 58 30 30 14 0C 4D 02' => 'Rokinon 20mm f/1.8 ED AS UMC', #30
751             #
752             'A0 56 44 44 14 14 A2 06' => 'Sony FE 35mm F1.8', #IB (Techart adapter)
753             'A0 37 5C 8E 34 3C A2 06' => 'Sony FE 70-300mm F4.5-5.6 G OSS', #IB (Techart adapter)
754             );
755              
756             # text encoding used in LocationInfo (ref PH)
757             %nikonTextEncoding = (
758             0 => 'n/a',
759             1 => 'UTF8',
760             # UTF16 is a guess here: it could also be Unicode or JIS,
761             # but I chose UTF16 due to the similarity with the QuickTime stringEncoding
762             2 => 'UTF16',
763             );
764              
765             # flash firmware decoding (ref JD)
766             my %flashFirmware = (
767             '0 0' => 'n/a',
768             '1 1' => '1.01 (SB-800 or Metz 58 AF-1)',
769             '1 3' => '1.03 (SB-800)',
770             '2 1' => '2.01 (SB-800)',
771             '2 4' => '2.04 (SB-600)',
772             '2 5' => '2.05 (SB-600)',
773             '3 1' => '3.01 (SU-800 Remote Commander)',
774             '4 1' => '4.01 (SB-400)',
775             '4 2' => '4.02 (SB-400)',
776             '4 4' => '4.04 (SB-400)',
777             '5 1' => '5.01 (SB-900)',
778             '5 2' => '5.02 (SB-900)',
779             '6 1' => '6.01 (SB-700)', #https://exiftool.org/forum/index.php/topic,5034.0.html
780             '7 1' => '7.01 (SB-910)', #PH
781             '14 3' => '14.03 (SB-5000)', #28
782             OTHER => sub {
783             my ($val, $inv) = @_;
784             return sprintf('%d.%.2d (Unknown model)', split(' ', $val)) unless $inv;
785             return "$1 $2" if $val =~ /(\d+)\.(\d+)/;
786             return '0 0';
787             },
788             );
789              
790             # flash Guide Number (GN) distance settings (ref 28)
791             my %flashGNDistance = (
792             0 => 0, 19 => '2.8 m',
793             1 => '0.1 m', 20 => '3.2 m',
794             2 => '0.2 m', 21 => '3.6 m',
795             3 => '0.3 m', 22 => '4.0 m',
796             4 => '0.4 m', 23 => '4.5 m',
797             5 => '0.5 m', 24 => '5.0 m',
798             6 => '0.6 m', 25 => '5.6 m',
799             7 => '0.7 m', 26 => '6.3 m',
800             8 => '0.8 m', 27 => '7.1 m',
801             9 => '0.9 m', 28 => '8.0 m',
802             10 => '1.0 m', 29 => '9.0 m',
803             11 => '1.1 m', 30 => '10.0 m',
804             12 => '1.3 m', 31 => '11.0 m',
805             13 => '1.4 m', 32 => '13.0 m',
806             14 => '1.6 m', 33 => '14.0 m',
807             15 => '1.8 m', 34 => '16.0 m',
808             16 => '2.0 m', 35 => '18.0 m',
809             17 => '2.2 m', 36 => '20.0 m',
810             18 => '2.5 m', 255 => 'n/a',
811             );
812              
813             # flash color filter values (ref 28)
814             my %flashColorFilter = (
815             0x00 => 'None',
816             1 => 'FL-GL1 or SZ-2FL Fluorescent', # (green) (SZ model ref PH)
817             2 => 'FL-GL2',
818             9 => 'TN-A1 or SZ-2TN Incandescent', # (orange) (SZ model ref PH)
819             10 => 'TN-A2',
820             65 => 'Red',
821             66 => 'Blue',
822             67 => 'Yellow',
823             68 => 'Amber',
824             128 => 'Incandescent', #SZ-4TN Incandescent
825             );
826              
827             # flash control mode values (ref JD)
828             my %flashControlMode = (
829             0x00 => 'Off',
830             0x01 => 'iTTL-BL',
831             0x02 => 'iTTL',
832             0x03 => 'Auto Aperture',
833             0x04 => 'Automatic', #28
834             0x05 => 'GN (distance priority)', #28 (Guide Number, but called "GN" in manual)
835             0x06 => 'Manual',
836             0x07 => 'Repeating Flash',
837             );
838              
839             my %activeDLightingZ7 = (
840             0 => 'Off',
841             2 => 'Low',
842             3 => 'Normal',
843             4 => 'High',
844             5 => 'Extra High',
845             );
846              
847             my %aFAreaModeCD = ( #contrast detect modes
848             0 => 'Contrast-detect', # (D3)
849             1 => 'Contrast-detect (normal area)', # (D90/D5000)
850             # (D90 and D5000 give value of 2 when set to 'Face Priority' and
851             # 'Subject Tracking', but I didn't have a face to shoot at or a
852             # moving subject to track so perhaps this value changes dynamically)
853             2 => 'Contrast-detect (wide area)', # (D90/D5000)
854             3 => 'Contrast-detect (face priority)', # (ViewNX)
855             4 => 'Contrast-detect (subject tracking)', # (ViewNX)
856             128 => 'Single', #PH (1V3)
857             129 => 'Auto (41 points)', #PH (NC)
858             130 => 'Subject Tracking (41 points)', #PH (NC)
859             131 => 'Face Priority (41 points)', #PH (NC)
860             192 => 'Pinpoint', #PH (Z7)
861             193 => 'Single', #PH (Z7)
862             194 => 'Dynamic', #PH (Z7)
863             195 => 'Wide (S)', #PH (Z7)
864             196 => 'Wide (L)', #PH (Z7)
865             197 => 'Auto', #PH (Z7)
866             198 => 'Auto (People)', #28 (Z7) #if no faces are detected, will record as 'Auto'. Camera setting recorded in AFAreaMode field in the MakerNotes area
867             199 => 'Auto (Animal)', #28 (Z7) #if no animals are detected, will record as 'Auto'. Camera setting recorded in AFAreaMode field in the MakerNotes area
868             200 => 'Normal-area AF', #28 (D6)
869             201 => 'Wide-area AF', #28 (D6)
870             202 => 'Face-priority AF', #28 (D6)
871             203 => 'Subject-tracking AF', #28 (D6)
872             204 => 'Dynamic Area (S)', #28 (Z9)
873             205 => 'Dynamic Area (M)', #28 (Z9)
874             206 => 'Dynamic Area (L)', #28 (Z9)
875             207 => '3D-tracking', #28 (Z9)
876             208 => 'Wide-Area (C1/C2)', #28 (Z8, Z9)
877             );
878              
879             my %aFAreaModePD = ( #phase detect modes
880             0 => 'Single Area', # (called "Single Point" in manual - PH)
881             1 => 'Dynamic Area', #PH
882             2 => 'Dynamic Area (closest subject)', #PH
883             3 => 'Group Dynamic', #PH
884             4 => 'Dynamic Area (9 points)', #JD/28
885             5 => 'Dynamic Area (21 points)', #28
886             6 => 'Dynamic Area (51 points)', #28
887             7 => 'Dynamic Area (51 points, 3D-tracking)', #PH/28
888             8 => 'Auto-area',
889             9 => 'Dynamic Area (3D-tracking)', #PH (D5000 "3D-tracking (11 points)")
890             10 => 'Single Area (wide)', #PH
891             11 => 'Dynamic Area (wide)', #PH
892             12 => 'Dynamic Area (wide, 3D-tracking)', #PH
893             13 => 'Group Area', #PH
894             14 => 'Dynamic Area (25 points)', #PH
895             15 => 'Dynamic Area (72 points)', #PH
896             16 => 'Group Area (HL)', #28
897             17 => 'Group Area (VL)', #28
898             18 => 'Dynamic Area (49 points)', #28
899             128 => 'Single', #PH (1J1,1J2,1J3,1J4,1S1,1S2,1V2,1V3)
900             129 => 'Auto (41 points)', #PH (1J1,1J2,1J3,1J4,1S1,1S2,1V1,1V2,1V3,AW1)
901             130 => 'Subject Tracking (41 points)', #PH (1J1,1J4,1J3)
902             131 => 'Face Priority (41 points)', #PH (1J1,1J3,1S1,1V2,AW1)
903             # 134 - seen for 1V1[PhaseDetectAF=0] (PH)
904             # 135 - seen for 1J2[PhaseDetectAF=4] (PH)
905             192 => 'Pinpoint', #PH (NC)
906             193 => 'Single', #PH (NC)
907             194 => 'Dynamic', #28 (Z7)
908             195 => 'Wide (S)', #PH (NC)
909             196 => 'Wide (L)', #PH (NC)
910             197 => 'Auto', #PH (NC)
911             199 => 'Auto', #28 (Z7) Z7 has also been observed to record 197 for Auto-area (same camera, different firmware versions, early production model)
912             );
913              
914             my %aFAreaModeZ9 = (
915             0 => 'Pinpoint',
916             1 => 'Single',
917             2 => 'Dynamic',
918             3 => 'Wide (S)',
919             4 => 'Wide (L)',
920             5 => '3D',
921             6 => 'Auto',
922             11 => 'Subject Tracking',
923             12 => 'Wide (C1)',
924             13 => 'Wide (C2)',
925             );
926              
927             my %aFDetectionMethod = (
928             0 => 'Phase Detect', #thru viewfinder
929             1 => 'Contrast Detect', #LiveView
930             2 => 'Hybrid', #Z-series and D780
931             );
932              
933              
934             my %banksZ9 = (
935             0 => 'A',
936             1 => 'B',
937             2 => 'C',
938             3 => 'D',
939             );
940              
941             my %bracketIncrementZ9 = (
942             0 => '0.3',
943             1 => '0.5',
944             2 => '0.7',
945             3 => '1.0',
946             4 => '2.0',
947             5 => '3.0',
948             6 => '1.3',
949             7 => '1.5',
950             8 => '1.7',
951             9 => '2.3',
952             10 => '2.5',
953             11 => '2.7',
954             );
955              
956             my %bracketSetZ9 = (
957             0 => 'AE/Flash',
958             1 => 'AE',
959             2 => 'Flash',
960             3 => 'White Balance',
961             4 => 'Active-D Lighting',
962             );
963              
964             my %bracketProgramZ9 = (
965             0 => 'Disabled',
966             2 => '2F',
967             3 => '3F',
968             4 => '4F',
969             5 => '5F',
970             7 => '7F',
971             9 => '9F',
972             );
973              
974             my %dialsFrameAdvanceZoomPositionZ9 = (
975             0 => 'Hold',
976             1 => 'Focus Point',
977             2 => 'Face Priority',
978             );
979              
980             my %dynamicAfAreaModesZ9 = (
981             0 => 'Small',
982             1 => 'Medium',
983             2 => 'Large',
984             );
985              
986             my %flashControlModeZ7 = (
987             0 => 'TTL',
988             1 => 'Auto External Flash',
989             2 => 'GN (distance priority)',
990             3 => 'Manual',
991             4 => 'Repeating Flash',
992             );
993              
994             my %flashRemoteControlZ7 = (
995             0 => 'Group',
996             1 => 'Quick Wireless',
997             2 => 'Remote Repeating',
998             );
999              
1000             my %flashWirelessOptionZ7 = (
1001             0 => 'Off',
1002             1 => 'Optical AWL',
1003             2 => 'Optical/Radio AWL',
1004             3 => 'Radio AWL',
1005             );
1006              
1007             my %focusModeZ7 = (
1008             0 => 'Manual',
1009             1 => 'AF-S',
1010             2 => 'AF-C',
1011             4 => 'AF-F', # full frame
1012             );
1013              
1014             my %hDMIOutputResolutionZ9 = (
1015             0 => 'Auto',
1016             1 => '4320p',
1017             2 => '2160p',
1018             3 => '1080p',
1019             4 => '1080i',
1020             5 => '720p',
1021             #6 => '576p',
1022             #7 => '480p',
1023             );
1024              
1025             my %hdrLevelZ8 = (
1026             0 => 'Auto',
1027             1 => 'Extra High',
1028             2 => 'High',
1029             3 => 'Normal',
1030             4 => 'Low',
1031             );
1032              
1033             my %highFrameRateZ9 = (
1034             0 => 'Off',
1035             1 => 'CH',
1036             2 => 'CH*', #28 (Z6III)
1037             3 => 'C30',
1038             5 => 'C60',
1039             4 => 'C120',
1040             6 => 'C15',
1041             );
1042              
1043             my %imageAreaD6 = (
1044             0 => 'FX (36x24)',
1045             1 => 'DX (24x16)',
1046             2 => '5:4 (30x24)',
1047             3 => '1.2x (30x20)',
1048             4 => '1:1 (24x24)',
1049             6 => '16:9',
1050             );
1051              
1052             my %imageAreaZ9 = (
1053             0 => 'FX',
1054             1 => 'DX',
1055             4 => '16:9',
1056             8 => '1:1',
1057             );
1058              
1059             my %imageAreaZ9b = (
1060             0 => 'FX',
1061             1 => 'DX',
1062             );
1063              
1064             my %infoZSeries = (
1065             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
1066             Notes => 'Z Series cameras thru July 2025',
1067             );
1068              
1069             my %iSOAutoHiLimitZ6III = ( #28
1070             5 => 'ISO 200',
1071             6 => 'ISO 250',
1072             7 => 'ISO 320',
1073             8 => 'ISO 400',
1074             9 => 'ISO 500',
1075             10 => 'ISO 640',
1076             11 => 'ISO 800',
1077             12 => 'ISO 1000',
1078             13 => 'ISO 1250',
1079             14 => 'ISO 1600',
1080             15 => 'ISO 2000',
1081             16 => 'ISO 2500',
1082             17 => 'ISO 3200',
1083             18 => 'ISO 4000',
1084             19 => 'ISO 5000',
1085             20 => 'ISO 6400',
1086             21 => 'ISO 8000',
1087             22 => 'ISO 10000',
1088             23 => 'ISO 12800',
1089             24 => 'ISO 16000',
1090             25 => 'ISO 20000',
1091             26 => 'ISO 25600',
1092             27 => 'ISO 32000',
1093             28 => 'ISO 40000',
1094             29 => 'ISO 51200',
1095             30 => 'ISO 64000',
1096             31 => 'ISO Hi 0.3',
1097             32 => 'ISO Hi 0.7',
1098             33 => 'ISO Hi 1.0',
1099             35 => 'ISO Hi 1.7',
1100             );
1101              
1102             my %isoAutoHiLimitZ7 = (
1103             Format => 'int16u',
1104             Unknown => 1,
1105             ValueConv => '($val-104)/8',
1106             ValueConvInv => '8 * ($val + 104)',
1107             SeparateTable => 'ISOAutoHiLimitZ7',
1108             PrintConv => {
1109             0 => 'ISO 64', 17 => 'ISO 3200',
1110             1 => 'ISO 80', 18 => 'ISO 4000',
1111             2 => 'ISO 100', 19 => 'ISO 5000',
1112             3 => 'ISO 125', 20 => 'ISO 6400',
1113             4 => 'ISO 160', 21 => 'ISO 8000',
1114             5 => 'ISO 200', 22 => 'ISO 10000',
1115             6 => 'ISO 250', 23 => 'ISO 12800',
1116             7 => 'ISO 320', 24 => 'ISO 16000',
1117             8 => 'ISO 400', 25 => 'ISO 20000',
1118             9 => 'ISO 500', 26 => 'ISO 25600',
1119             10 => 'ISO 640', 27 => 'ISO Hi 0.3',
1120             11 => 'ISO 800', 28 => 'ISO Hi 0.7',
1121             12 => 'ISO 1000', 29 => 'ISO Hi 1.0',
1122             13 => 'ISO 1250', 32 => 'ISO Hi 2.0',
1123             14 => 'ISO 1600',
1124             15 => 'ISO 2000',
1125             16 => 'ISO 2500',
1126             },
1127             );
1128              
1129             my %iSOAutoShutterTimeZ9 = (
1130             -15 => 'Auto', #z9 firmware 1.00 maps both 'Auto' and '30 s' to -15
1131             -12 => '15 s',
1132             -9 => '8 s',
1133             -6 => '4 s',
1134             -3 => '2 s',
1135             0 => '1 s',
1136             1 => '1/1.3 s',
1137             2 => '1/1.6 s',
1138             3 => '1/2 s',
1139             4 => '1/2.5 s',
1140             5 => '1/3 s',
1141             6 => '1/4 s',
1142             7 => '1/5 s',
1143             8 => '1/6 s',
1144             9 => '1/8 s',
1145             10 => '1/10 s',
1146             11 => '1/13 s',
1147             12 => '1/15 s',
1148             13 => '1/20 s',
1149             14 => '1/25 s',
1150             15 => '1/30 s',
1151             16 => '1/40 s',
1152             17 => '1/50 s',
1153             18 => '1/60 s',
1154             19 => '1/80 s',
1155             20 => '1/100 s',
1156             21 => '1/120 s',
1157             22 => '1/160 s',
1158             23 => '1/200 s',
1159             24 => '1/250 s',
1160             25 => '1/320 s',
1161             26 => '1/400 s',
1162             27 => '1/500 s',
1163             28 => '1/640 s',
1164             29 => '1/800 s',
1165             30 => '1/1000 s',
1166             31 => '1/1250 s',
1167             32 => '1/1600 s',
1168             33 => '1/2000 s',
1169             34 => '1/2500 s',
1170             35 => '1/3200 s',
1171             36 => '1/4000 s',
1172             37 => '1/5000 s',
1173             37.5 => '1/6000 s',
1174             38 => '1/6400 s',
1175             39 => '1/8000 s',
1176             40 => '1/10000 s',
1177             40.5 => '1/12000 s',
1178             41 => '1/13000 s',
1179             42 => '1/16000 s',
1180             );
1181              
1182             my %languageZ9 = (
1183             4 => 'English',
1184             5 => 'Spanish',
1185             7 => 'French',
1186             15 => 'Portuguese'
1187             );
1188              
1189             my %meteringModeZ7 = (
1190             0 => 'Matrix',
1191             1 => 'Center',
1192             2 => 'Spot',
1193             3 => 'Highlight'
1194             );
1195              
1196             my %monitorBrightnessZ9 = (
1197             0 => '-5',
1198             1 => '-4',
1199             2 => '-3',
1200             3 => '-2',
1201             4 => '-1',
1202             5 => '0',
1203             6 => '1',
1204             7 => '2',
1205             8 => '3',
1206             9 => '4',
1207             10 => '5',
1208             14 => 'Hi1',
1209             15 => 'Hi2',
1210             16 => 'Lo2',
1211             17 => 'Lo1',
1212             );
1213              
1214             my %movieFlickerReductionZ9 = (
1215             0 => 'Auto',
1216             1 => '50Hz',
1217             2 => '60Hz',
1218             );
1219              
1220             my %movieFrameRateZ6III = ( #28
1221             0 => '240p',
1222             1 => '200p',
1223             2 => '120p',
1224             3 => '100p',
1225             4 => '60p',
1226             5 => '50p',
1227             6 => '30p',
1228             7 => '25p',
1229             8 => '24p',
1230             );
1231              
1232             my %movieFrameRateZ7 = (
1233             0 => '120p',
1234             1 => '100p',
1235             2 => '60p',
1236             3 => '50p',
1237             4 => '30p',
1238             5 => '25p',
1239             6 => '24p',
1240             );
1241              
1242             my %movieFrameSizeZ9 = (
1243             1 => '1920x1080',
1244             2 => '3840x2160',
1245             3 => '7680x4320',
1246             7 => '5376x3024', #28 (Z6III)
1247             );
1248              
1249             my %movieSlowMotion = (
1250             0 => 'Off',
1251             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]
1252             2 => 'On (5x)', # 120p recording with playback @ 24p [1920 x 1080; 20p x 5]
1253             );
1254              
1255             my %movieToneMapZ9 = (
1256             0 => 'SDR',
1257             1 => 'HLG',
1258             2 => 'N-Log',
1259             );
1260              
1261             my %movieTypeZ9 = (
1262             1 => 'H.264 8-bit (MP4)',
1263             2 => 'H.265 8-bit (MOV)',
1264             3 => 'H.265 10-bit (MOV)',
1265             4 => 'ProRes 422 HQ 10-bit (MOV)',
1266             5 => 'ProRes RAW HQ 12-bit (MOV)',
1267             6 => 'NRAW 12-bit (NEV)'
1268             );
1269              
1270             my %multipleExposureModeZ9 = (
1271             0 => 'Off',
1272             1 => 'On',
1273             2 => 'On (Series)',
1274             );
1275              
1276             my %nonCPULensApertureZ8 = ( # 2**(val/6) rounded - non-CPU aperture interface, values and storage differ from the Z8
1277             Format => 'int16u',
1278             Unknown => 1,
1279             SeparateTable => 'NonCPULensApertureZ8',
1280             PrintConv => {
1281             12 => 'f/1.2', 128 => 'f/6.3',
1282             24 => 'f/1.4', 136 => 'f/7.1',
1283             40 => 'f/1.8', 144 => 'f/8',
1284             48 => 'f/2.0', 156 => 'f/9.5',
1285             64 => 'f/2.5', 168 => 'f/11',
1286             72 => 'f/2.8', 180 => 'f/13',
1287             84 => 'f/3.3', 188 => 'f/15',
1288             88 => 'f/3.5', 192 => 'f/16',
1289             96 => 'f/4.0', 204 => 'f/19',
1290             104 => 'f/4.5', 216 => 'f/22',
1291             112 => 'f/5.0', 313 => 'N/A', #camera menu shows "--" indicating value has not been set for the lens,
1292             120 => 'f/5.6',
1293             },
1294             );
1295              
1296             my %offLowNormalHighZ7 = (
1297             0 => 'Off',
1298             1 => 'Low',
1299             2 => 'Normal',
1300             3 => 'High',
1301             );
1302              
1303             my %pixelShiftDelay = (
1304             0 => 'Off',
1305             1 => '1 s',
1306             2 => '2 s',
1307             3 => '3 s',
1308             4 => '5 s',
1309             5 => '10 s',
1310             );
1311              
1312             my %pixelShiftNumberShots = (
1313             0 => '4',
1314             1 => '8',
1315             2 => '16',
1316             3 => '32',
1317             );
1318              
1319             my %portraitImpressionBalanceZ8 = (
1320             0 => 'Off',
1321             1 => 'Mode 1',
1322             2 => 'Mode 2',
1323             3 => 'Mode 3',
1324             );
1325              
1326             my %releaseModeZ7 = (
1327             0 => 'Continuous Low',
1328             1 => 'Continuous High',
1329             2 => 'Continuous High (Extended)',
1330             4 => 'Timer',
1331             5 => 'Single Frame',
1332             );
1333              
1334             my %secondarySlotFunctionZ9 = (
1335             0 => 'Overflow',
1336             1 => 'Backup',
1337             2 => 'NEF Primary + JPG Secondary',
1338             3 => 'JPG Primary + JPG Secondary',
1339             );
1340              
1341             my %subjectDetectionAreaMZ6III = ( #28
1342             0 => 'Off',
1343             1 => 'All',
1344             2 => 'Wide (L)',
1345             3 => 'Wide (S)',
1346             );
1347              
1348             my %subjectDetectionZ9 = (
1349             0 => 'Off',
1350             1 => 'Auto',
1351             2 => 'People',
1352             3 => 'Animals',
1353             4 => 'Vehicles',
1354             5 => 'Birds',
1355             6 => 'Airplanes',
1356             7 => 'Faces', #introduced with Z9 firmware 5.30 as an Auto Capture option
1357             );
1358              
1359             my %timeZoneZ9 = (
1360             3 => '+10:00 (Sydney)',
1361             5 => '+09:00 (Tokyo)',
1362             6 => '+08:00 (Beijing, Honk Kong, Sinapore)',
1363             10 => '+05:45 (Kathmandu)',
1364             11 => '+05:30 (New Dehli)',
1365             12 => '+05:00 (Islamabad)',
1366             13 => '+04:30 (Kabul)',
1367             14 => '+04:00 (Abu Dhabi)',
1368             15 => '+03:30 (Tehran)',
1369             16 => '+03:00 (Moscow, Nairobi)',
1370             17 => '+02:00 (Athens, Helsinki)',
1371             18 => '+01:00 (Madrid, Paris, Berlin)',
1372             19 => '+00:00 (London)',
1373             20 => '-01:00 (Azores)',
1374             21 => '-02:00 (Fernando de Noronha)',
1375             22 => '-03:00 (Buenos Aires, Sao Paulo)',
1376             23 => '-03:30 (Newfoundland)',
1377             24 => '-04:00 (Manaus, Caracas)',
1378             25 => '-05:00 (New York, Toronto, Lima)',
1379             26 => '-06:00 (Chicago, Mexico City)',
1380             27 => '-07:00 (Denver)',
1381             28 => '-08:00 (Los Angeles, Vancouver)',
1382             29 => '-09:00 (Anchorage)',
1383             30 => '-10:00 (Hawaii)',
1384             );
1385              
1386              
1387             my %vRModeZ9 = (
1388             0 => 'Off',
1389             1 => 'Normal',
1390             2 => 'Sport',
1391             );
1392              
1393             my %retouchValues = ( #PH
1394             0 => 'None',
1395             3 => 'B & W',
1396             4 => 'Sepia',
1397             5 => 'Trim',
1398             6 => 'Small Picture',
1399             7 => 'D-Lighting',
1400             8 => 'Red Eye',
1401             9 => 'Cyanotype',
1402             10 => 'Sky Light',
1403             11 => 'Warm Tone',
1404             12 => 'Color Custom',
1405             13 => 'Image Overlay',
1406             14 => 'Red Intensifier',
1407             15 => 'Green Intensifier',
1408             16 => 'Blue Intensifier',
1409             17 => 'Cross Screen',
1410             18 => 'Quick Retouch',
1411             19 => 'NEF Processing',
1412             23 => 'Distortion Control',
1413             25 => 'Fisheye',
1414             26 => 'Straighten',
1415             29 => 'Perspective Control',
1416             30 => 'Color Outline',
1417             31 => 'Soft Filter',
1418             32 => 'Resize', #31
1419             33 => 'Miniature Effect',
1420             34 => 'Skin Softening', # (S9200)
1421             35 => 'Selected Frame', #31 (frame exported from MOV)
1422             37 => 'Color Sketch', #31
1423             38 => 'Selective Color', # (S9200)
1424             39 => 'Glamour', # (S3500)
1425             40 => 'Drawing', # (S9200)
1426             44 => 'Pop', # (S3500)
1427             45 => 'Toy Camera Effect 1', # (S3500)
1428             46 => 'Toy Camera Effect 2', # (S3500)
1429             47 => 'Cross Process (red)', # (S3500)
1430             48 => 'Cross Process (blue)', # (S3500)
1431             49 => 'Cross Process (green)', # (S3500)
1432             50 => 'Cross Process (yellow)', # (S3500)
1433             51 => 'Super Vivid', # (S3500)
1434             52 => 'High-contrast Monochrome', # (S3500)
1435             53 => 'High Key', # (S3500)
1436             54 => 'Low Key', # (S3500)
1437             );
1438              
1439             # AF points for AFInfo models with 11 focus points
1440             my %afPoints11 = (
1441             0 => '(none)',
1442             0x7ff => 'All 11 Points',
1443             BITMASK => {
1444             0 => 'Center',
1445             1 => 'Top',
1446             2 => 'Bottom',
1447             3 => 'Mid-left',
1448             4 => 'Mid-right',
1449             5 => 'Upper-left',
1450             6 => 'Upper-right',
1451             7 => 'Lower-left',
1452             8 => 'Lower-right',
1453             9 => 'Far Left',
1454             10 => 'Far Right',
1455             },
1456             );
1457              
1458             # AF point indices for models with 51 focus points, eg. D3 (ref JD/PH)
1459             # A1 A2 A3 A4 A5 A6 A7 A8 A9
1460             # B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11
1461             # C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11
1462             # D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11
1463             # E1 E2 E3 E4 E5 E6 E7 E8 E9
1464             my %afPoints51 = (
1465             1 => 'C6', 11 => 'C5', 21 => 'C9', 31 => 'C11',41 => 'A2', 51 => 'D1',
1466             2 => 'B6', 12 => 'B5', 22 => 'B9', 32 => 'B11',42 => 'D3',
1467             3 => 'A5', 13 => 'A4', 23 => 'A8', 33 => 'D11',43 => 'E2',
1468             4 => 'D6', 14 => 'D5', 24 => 'D9', 34 => 'C4', 44 => 'C2',
1469             5 => 'E5', 15 => 'E4', 25 => 'E8', 35 => 'B4', 45 => 'B2',
1470             6 => 'C7', 16 => 'C8', 26 => 'C10',36 => 'A3', 46 => 'A1',
1471             7 => 'B7', 17 => 'B8', 27 => 'B10',37 => 'D4', 47 => 'D2',
1472             8 => 'A6', 18 => 'A7', 28 => 'A9', 38 => 'E3', 48 => 'E1',
1473             9 => 'D7', 19 => 'D8', 29 => 'D10',39 => 'C3', 49 => 'C1',
1474             10 => 'E6', 20 => 'E7', 30 => 'E9', 40 => 'B3', 50 => 'B1',
1475             );
1476              
1477             # AF point indices for models with 39 focus points, eg. D7000 (ref 29)
1478             # A1 A2 A3
1479             # B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11
1480             # C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11
1481             # D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11
1482             # E1 E2 E3
1483             my %afPoints39 = (
1484             1 => 'C6', 11 => 'C5', 21 => 'D9', 31 => 'C3',
1485             2 => 'B6', 12 => 'B5', 22 => 'C10',32 => 'B3',
1486             3 => 'A2', 13 => 'A1', 23 => 'B10',33 => 'D3',
1487             4 => 'D6', 14 => 'D5', 24 => 'D10',34 => 'C2',
1488             5 => 'E2', 15 => 'E1', 25 => 'C11',35 => 'B2',
1489             6 => 'C7', 16 => 'C8', 26 => 'B11',36 => 'D2',
1490             7 => 'B7', 17 => 'B8', 27 => 'D11',37 => 'C1',
1491             8 => 'A3', 18 => 'D8', 28 => 'C4', 38 => 'B1',
1492             9 => 'D7', 19 => 'C9', 29 => 'B4', 39 => 'D1',
1493             10 => 'E3', 20 => 'B9', 30 => 'D4',
1494             );
1495              
1496             # AF point indices for models with 105 focus points, eg. D6 (ref 28)
1497             # - 7 rows (A-G) with 15 columns (1-15), center is D8
1498             my %afPoints105 = (
1499             1 => 'D8', 28 => 'G7', 55 => 'F13', 82 => 'E4',
1500             2 => 'C8', 29 => 'D6', 56 => 'G13', 83 => 'F4',
1501             3 => 'B8', 30 => 'C6', 57 => 'D14', 84 => 'G4',
1502             4 => 'A8', 31 => 'B6', 58 => 'C14', 85 => 'D3',
1503             5 => 'E8', 32 => 'A6', 59 => 'B14', 86 => 'C3',
1504             6 => 'F8', 33 => 'E6', 60 => 'A14', 87 => 'B3',
1505             7 => 'G8', 34 => 'F6', 61 => 'E14', 88 => 'A3',
1506             8 => 'D9', 35 => 'G6', 62 => 'F14', 89 => 'E3',
1507             9 => 'C9', 36 => 'D11', 63 => 'G14', 90 => 'F3',
1508             10 => 'B9', 37 => 'C11', 64 => 'D15', 91 => 'G3',
1509             11 => 'A9', 38 => 'B11', 65 => 'C15', 92 => 'D2',
1510             12 => 'E9', 39 => 'A11', 66 => 'B15', 93 => 'C2',
1511             13 => 'F9', 40 => 'E11', 67 => 'A15', 94 => 'B2',
1512             14 => 'G9', 41 => 'F11', 68 => 'E15', 95 => 'A2',
1513             15 => 'D10', 42 => 'G11', 69 => 'F15', 96 => 'E2',
1514             16 => 'C10', 43 => 'D12', 70 => 'G15', 97 => 'F2',
1515             17 => 'B10', 44 => 'C12', 71 => 'D5', 98 => 'G2',
1516             18 => 'A10', 45 => 'B12', 72 => 'C5', 99 => 'D1',
1517             19 => 'E10', 46 => 'A12', 73 => 'B5', 100 => 'C1',
1518             20 => 'F10', 47 => 'E12', 74 => 'A5', 101 => 'B1',
1519             21 => 'G10', 48 => 'F12', 75 => 'E5', 102 => 'A1',
1520             22 => 'D7', 49 => 'G12', 76 => 'F5', 103 => 'E1',
1521             23 => 'C7', 50 => 'D13', 77 => 'G5', 104 => 'F1',
1522             24 => 'B7', 51 => 'C13', 78 => 'D4', 105 => 'G1',
1523             25 => 'A7', 52 => 'B13', 79 => 'C4',
1524             26 => 'E7', 53 => 'A13', 80 => 'B4',
1525             27 => 'F7', 54 => 'E13', 81 => 'A4',
1526             );
1527              
1528             # AF point indices for models with 135 focus points, eg. 1J1 (ref PH)
1529             # - 9 rows (A-I) with 15 columns (1-15), center is E8
1530             # - odd columns, columns 2 and 14, and the remaining corner points are
1531             # not used in 41-point mode
1532             my %afPoints135 = (
1533             1 => 'E8', 28 => 'E10', 55 => 'E13', 82 => 'E6', 109 => 'E3',
1534             2 => 'D8', 29 => 'D10', 56 => 'D13', 83 => 'D6', 110 => 'D3',
1535             3 => 'C8', 30 => 'C10', 57 => 'C13', 84 => 'C6', 111 => 'C3',
1536             4 => 'B8', 31 => 'B10', 58 => 'B13', 85 => 'B6', 112 => 'B3',
1537             5 => 'A8', 32 => 'A10', 59 => 'A13', 86 => 'A6', 113 => 'A3',
1538             6 => 'F8', 33 => 'F10', 60 => 'F13', 87 => 'F6', 114 => 'F3',
1539             7 => 'G8', 34 => 'G10', 61 => 'G13', 88 => 'G6', 115 => 'G3',
1540             8 => 'H8', 35 => 'H10', 62 => 'H13', 89 => 'H6', 116 => 'H3',
1541             9 => 'I8', 36 => 'I10', 63 => 'I13', 90 => 'I6', 117 => 'I3',
1542             10 => 'E9', 37 => 'E11', 64 => 'E14', 91 => 'E5', 118 => 'E2',
1543             11 => 'D9', 38 => 'D11', 65 => 'D14', 92 => 'D5', 119 => 'D2',
1544             12 => 'C9', 39 => 'C11', 66 => 'C14', 93 => 'C5', 120 => 'C2',
1545             13 => 'B9', 40 => 'B11', 67 => 'B14', 94 => 'B5', 121 => 'B2',
1546             14 => 'A9', 41 => 'A11', 68 => 'A14', 95 => 'A5', 122 => 'A2',
1547             15 => 'F9', 42 => 'F11', 69 => 'F14', 96 => 'F5', 123 => 'F2',
1548             16 => 'G9', 43 => 'G11', 70 => 'G14', 97 => 'G5', 124 => 'G2',
1549             17 => 'H9', 44 => 'H11', 71 => 'H14', 98 => 'H5', 125 => 'H2',
1550             18 => 'I9', 45 => 'I11', 72 => 'I14', 99 => 'I5', 126 => 'I2',
1551             19 => 'E7', 46 => 'E12', 73 => 'E15', 100 => 'E4', 127 => 'E1',
1552             20 => 'D7', 47 => 'D12', 74 => 'D15', 101 => 'D4', 128 => 'D1',
1553             21 => 'C7', 48 => 'C12', 75 => 'C15', 102 => 'C4', 129 => 'C1',
1554             22 => 'B7', 49 => 'B12', 76 => 'B15', 103 => 'B4', 130 => 'B1',
1555             23 => 'A7', 50 => 'A12', 77 => 'A15', 104 => 'A4', 131 => 'A1',
1556             24 => 'F7', 51 => 'F12', 78 => 'F15', 105 => 'F4', 132 => 'F1',
1557             25 => 'G7', 52 => 'G12', 79 => 'G15', 106 => 'G4', 133 => 'G1',
1558             26 => 'H7', 53 => 'H12', 80 => 'H15', 107 => 'H4', 134 => 'H1',
1559             27 => 'I7', 54 => 'I12', 81 => 'I15', 108 => 'I4', 135 => 'I1',
1560             );
1561              
1562             # AF point indices for models with 153 focus points, eg. D5,D500 (ref PH)
1563             # - 9 rows (A-I) with 17 columns (1-17), center is E9
1564             # - 55 of these are selectable cross points (odd rows and columns 1,3,4,6,7,9,11,12,14,15,17)
1565             my %afPoints153 = (
1566             1 => 'E9', 32 => 'A8', 63 => 'I13', 94 => 'B17', 125 => 'H4',
1567             2 => 'D9', 33 => 'F8', 64 => 'E14', 95 => 'A17', 126 => 'I4',
1568             3 => 'C9', 34 => 'G8', 65 => 'D14', 96 => 'F17', 127 => 'E3',
1569             4 => 'B9', 35 => 'H8', 66 => 'C14', 97 => 'G17', 128 => 'D3',
1570             5 => 'A9', 36 => 'I8', 67 => 'B14', 98 => 'H17', 129 => 'C3',
1571             6 => 'F9', 37 => 'E7', 68 => 'A14', 99 => 'I17', 130 => 'B3',
1572             7 => 'G9', 38 => 'D7', 69 => 'F14', 100 => 'E6', 131 => 'A3',
1573             8 => 'H9', 39 => 'C7', 70 => 'G14', 101 => 'D6', 132 => 'F3',
1574             9 => 'I9', 40 => 'B7', 71 => 'H14', 102 => 'C6', 133 => 'G3',
1575             10 => 'E10', 41 => 'A7', 72 => 'I14', 103 => 'B6', 134 => 'H3',
1576             11 => 'D10', 42 => 'F7', 73 => 'E15', 104 => 'A6', 135 => 'I3',
1577             12 => 'C10', 43 => 'G7', 74 => 'D15', 105 => 'F6', 136 => 'E2',
1578             13 => 'B10', 44 => 'H7', 75 => 'C15', 106 => 'G6', 137 => 'D2',
1579             14 => 'A10', 45 => 'I7', 76 => 'B15', 107 => 'H6', 138 => 'C2',
1580             15 => 'F10', 46 => 'E12', 77 => 'A15', 108 => 'I6', 139 => 'B2',
1581             16 => 'G10', 47 => 'D12', 78 => 'F15', 109 => 'E5', 140 => 'A2',
1582             17 => 'H10', 48 => 'C12', 79 => 'G15', 110 => 'D5', 141 => 'F2',
1583             18 => 'I10', 49 => 'B12', 80 => 'H15', 111 => 'C5', 142 => 'G2',
1584             19 => 'E11', 50 => 'A12', 81 => 'I15', 112 => 'B5', 143 => 'H2',
1585             20 => 'D11', 51 => 'F12', 82 => 'E16', 113 => 'A5', 144 => 'I2',
1586             21 => 'C11', 52 => 'G12', 83 => 'D16', 114 => 'F5', 145 => 'E1',
1587             22 => 'B11', 53 => 'H12', 84 => 'C16', 115 => 'G5', 146 => 'D1',
1588             23 => 'A11', 54 => 'I12', 85 => 'B16', 116 => 'H5', 147 => 'C1',
1589             24 => 'F11', 55 => 'E13', 86 => 'A16', 117 => 'I5', 148 => 'B1',
1590             25 => 'G11', 56 => 'D13', 87 => 'F16', 118 => 'E4', 149 => 'A1',
1591             26 => 'H11', 57 => 'C13', 88 => 'G16', 119 => 'D4', 150 => 'F1',
1592             27 => 'I11', 58 => 'B13', 89 => 'H16', 120 => 'C4', 151 => 'G1',
1593             28 => 'E8', 59 => 'A13', 90 => 'I16', 121 => 'B4', 152 => 'H1',
1594             29 => 'D8', 60 => 'F13', 91 => 'E17', 122 => 'A4', 153 => 'I1',
1595             30 => 'C8', 61 => 'G13', 92 => 'D17', 123 => 'F4',
1596             31 => 'B8', 62 => 'H13', 93 => 'C17', 124 => 'G4',
1597             );
1598              
1599             # AF point indices for models with 81 Auto-area focus points, eg. Z6/Z7/Z50 (ref 38)
1600             # - 9 rows (A-I) with 9 columns (1-9), center is E5
1601             #
1602             # 7 6 5 4 3 2 1 0
1603             # 00 : [H5][G5][F5][A5][B5][C5][D5][E5]
1604             # 01 : [G6][F6][A6][B6][C6][D6][E6][I5]
1605             # 02 : [F4][A4][B4][C4][D4][E4][I6][H6]
1606             # 03 : [A7][B7][C7][D7][E7][I4][H4][G4]
1607             # 04 : [B3][C3][D3][E3][I7][H7][G7][F7]
1608             # 05 : [C8][D8][E8][I3][H3][G3][F3][A3]
1609             # 06 : [D2][E2][I8][H8][G8][F8][A8][B8]
1610             # 07 : [E9][I2][H2][G2][F2][A2][B2][C2]
1611             # 08 : [I9][H9][G9][F9][A9][B9][C9][D9]
1612             # 09 : [H1][G1][F1][A1][B1][C1][D1][E1]
1613             # 0a : [ ][ ][ ][ ][ ][ ][ ][I1]
1614             my %afPoints81 = (
1615             1 => 'E5', 18 => 'I6', 35 => 'H7', 52 => 'G8', 69 => 'F9',
1616             2 => 'D5', 19 => 'E4', 36 => 'I7', 53 => 'H8', 70 => 'G9',
1617             3 => 'C5', 20 => 'D4', 37 => 'E3', 54 => 'I8', 71 => 'H9',
1618             4 => 'B5', 21 => 'C4', 38 => 'D3', 55 => 'E2', 72 => 'I9',
1619             5 => 'A5', 22 => 'B4', 39 => 'C3', 56 => 'D2', 73 => 'E1',
1620             6 => 'F5', 23 => 'A4', 40 => 'B3', 57 => 'C2', 74 => 'D1',
1621             7 => 'G5', 24 => 'F4', 41 => 'A3', 58 => 'B2', 75 => 'C1',
1622             8 => 'H5', 25 => 'G4', 42 => 'F3', 59 => 'A2', 76 => 'B1',
1623             9 => 'I5', 26 => 'H4', 43 => 'G3', 60 => 'F2', 77 => 'A1',
1624             10 => 'E6', 27 => 'I4', 44 => 'H3', 61 => 'G2', 78 => 'F1',
1625             11 => 'D6', 28 => 'E7', 45 => 'I3', 62 => 'H2', 79 => 'G1',
1626             12 => 'C6', 29 => 'D7', 46 => 'E8', 63 => 'I2', 80 => 'H1',
1627             13 => 'B6', 30 => 'C7', 47 => 'D8', 64 => 'E9', 81 => 'I1',
1628             14 => 'A6', 31 => 'B7', 48 => 'C8', 65 => 'D9',
1629             15 => 'F6', 32 => 'A7', 49 => 'B8', 66 => 'C9',
1630             16 => 'G6', 33 => 'F7', 50 => 'A8', 67 => 'B9',
1631             17 => 'H6', 34 => 'G7', 51 => 'F8', 68 => 'A9',
1632             );
1633              
1634             # 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)
1635             # - 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
1636             my @afPoints231 = (qw(
1637             A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 A16 A17 A18 A19 A20 A21
1638             B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 B12 B13 B14 B15 B16 B17 B18 B19 B20 B21
1639             C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 C16 C17 C18 C19 C20 C21
1640             D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13 D14 D15 D16 D17 D18 D19 D20 D21
1641             E1 E2 E3 E4 E5 E6 E7 E8 E9 E10 E11 E12 E13 E14 E15 E16 E17 E18 E19 E20 E21
1642             F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21
1643             G1 G2 G3 G4 G5 G6 G7 G8 G9 G10 G11 G12 G13 G14 G15 G16 G17 G18 G19 G20 G21
1644             H1 H2 H3 H4 H5 H6 H7 H8 H9 H10 H11 H12 H13 H14 H15 H16 H17 H18 H19 H20 H21
1645             I1 I2 I3 I4 I5 I6 I7 I8 I9 I10 I11 I12 I13 I14 I15 I16 I17 I18 I19 I20 I21
1646             J1 J2 J3 J4 J5 J6 J7 J8 J9 J10 J11 J12 J13 J14 J15 J16 J17 J18 J19 J20 J21
1647             K1 K2 K3 K4 K5 K6 K7 K8 K9 K10 K11 K12 K13 K14 K15 K16 K17 K18 K19 K20 K21
1648             ));
1649              
1650             # 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)
1651             # - 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
1652             #
1653             my @afPoints299 = (qw(
1654             A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 A16 A17 A18 A19 A20 A21 A22 A23
1655             B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 B12 B13 B14 B15 B16 B17 B18 B19 B20 B21 B22 B23
1656             C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 C16 C17 C18 C19 C20 C21 C22 C23
1657             D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13 D14 D15 D16 D17 D18 D19 D20 D21 D22 D23
1658             E1 E2 E3 E4 E5 E6 E7 E8 E9 E10 E11 E12 E13 E14 E15 E16 E17 E18 E19 E20 E21 E22 E23
1659             F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23
1660             G1 G2 G3 G4 G5 G6 G7 G8 G9 G10 G11 G12 G13 G14 G15 G16 G17 G18 G19 G20 G21 G22 G23
1661             H1 H2 H3 H4 H5 H6 H7 H8 H9 H10 H11 H12 H13 H14 H15 H16 H17 H18 H19 H20 H21 H22 H23
1662             I1 I2 I3 I4 I5 I6 I7 I8 I9 I10 I11 I12 I13 I14 I15 I16 I17 I18 I19 I20 I21 I22 I23
1663             J1 J2 J3 J4 J5 J6 J7 J8 J9 J10 J11 J12 J13 J14 J15 J16 J17 J18 J19 J20 J21 J22 J23
1664             K1 K2 K3 K4 K5 K6 K7 K8 K9 K10 K11 K12 K13 K14 K15 K16 K17 K18 K19 K20 K21 K22 K23
1665             L1 L2 L3 L4 L5 L6 L7 L8 L9 L10 L11 L12 L13 L14 L15 L16 L17 L18 L19 L20 L21 L22 L23
1666             M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12 M13 M14 M15 M16 M17 M18 M19 M20 M21 M22 M23
1667             ));
1668              
1669             # 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)
1670             # - 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)
1671             #
1672             my @afPoints405 = (qw(
1673             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
1674             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
1675             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
1676             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
1677             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
1678             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
1679             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
1680             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
1681             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
1682             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
1683             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
1684             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
1685             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
1686             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
1687             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
1688             ));
1689              
1690             my %cropHiSpeed = ( #IB
1691             0 => 'Off',
1692             1 => '1.3x Crop', # (1.3x Crop, Large)
1693             2 => 'DX Crop', # (1.5x)
1694             3 => '5:4 Crop',
1695             4 => '3:2 Crop', # (1.2x, ref 36)
1696             6 => '16:9 Crop',
1697             8 => '2.7x Crop', #36 (D4/D500)
1698             9 => 'DX Movie 16:9 Crop', # (DX during movie recording, Large)
1699             10 => '1.3x Movie Crop', #36 (D4/D500)
1700             11 => 'FX Uncropped',
1701             12 => 'DX Uncropped',
1702             13 => '2.8x Movie Crop', #28 (D5/D6) 5584/1936
1703             14 => '1.4x Movie Crop', #28 (D5/D6) 5584/3856
1704             15 => '1.5x Movie Crop', #36 (D4/D500) 5600/3872
1705             17 => 'FX 1:1 Crop',
1706             18 => 'DX 1:1 Crop',
1707             OTHER => sub {
1708             my ($val, $inv, $conv) = @_;
1709             return undef if $inv;
1710             my @a = split ' ', $val;
1711             return "Unknown ($val)" unless @a == 7;
1712             $a[0] = $$conv{$a[0]} || "Unknown ($a[0])";
1713             return "$a[0] ($a[1]x$a[2] cropped to $a[3]x$a[4] at pixel $a[5],$a[6])";
1714             },
1715             );
1716              
1717             my %flashGroupOptionsMode = (
1718             0 => 'TTL',
1719             1 => 'Manual',
1720             2 => 'Auto',
1721             3 => 'Off',
1722             );
1723              
1724             my %nefCompression = ( #28 relocated to MakerNotes_0x51 at offset x'0a (Z9)
1725             1 => 'Lossy (type 1)', # (older models)
1726             2 => 'Uncompressed', #JD - D100 (even though TIFF compression is set!)
1727             3 => 'Lossless',
1728             4 => 'Lossy (type 2)',
1729             5 => 'Striped packed 12 bits', #IB
1730             6 => 'Uncompressed (reduced to 12 bit)', #IB
1731             7 => 'Unpacked 12 bits', #IB (padded to 16)
1732             8 => 'Small', #IB
1733             9 => 'Packed 12 bits', #IB (2 pixels in 3 bytes)
1734             10 => 'Packed 14 bits', #28 (4 pixels in 7 bytes, eg. D6 uncompressed 14 bit)
1735             13 => 'High Efficiency', #28
1736             14 => 'High Efficiency*', #28
1737             );
1738              
1739             my %noYes = ( 0 => 'No' , 1 => 'Yes', );
1740             my %offOn = ( 0 => 'Off', 1 => 'On' );
1741             my %onOff = ( 0 => 'On', 1 => 'Off' );
1742              
1743             # common attributes for writable BinaryData directories
1744             my %binaryDataAttrs = (
1745             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
1746             WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
1747             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
1748             WRITABLE => 1,
1749             FIRST_ENTRY => 0,
1750             );
1751              
1752             my %base64bin = ( ValueConv => 'Image::ExifTool::XMP::DecodeBase64($val)' );
1753             my %base64int32u = ( ValueConv => 'my $val=Image::ExifTool::XMP::DecodeBase64($val); unpack("V",$$val)' );
1754             my %base64bytes = ( ValueConv => 'my $val=Image::ExifTool::XMP::DecodeBase64($val); join(".",unpack("C*",$$val))' );
1755             my %base64double = (
1756             ValueConv => q{
1757             my $val=Image::ExifTool::XMP::DecodeBase64($val);
1758             my $saveOrder = GetByteOrder();
1759             SetByteOrder('II');
1760             $val = GetDouble($val,0);
1761             SetByteOrder($saveOrder);
1762             return $val;
1763             },
1764             );
1765             my %base64coord = (
1766             ValueConv => q{
1767             my $val=Image::ExifTool::XMP::DecodeBase64($val);
1768             my $saveOrder = GetByteOrder();
1769             SetByteOrder('II');
1770             $val = GetDouble($val,0) + GetDouble($val,8)/60 + GetDouble($val,16)/3600;
1771             SetByteOrder($saveOrder);
1772             return $val;
1773             },
1774             PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1)',
1775             );
1776             # Nikon maker note tags
1777             %Image::ExifTool::Nikon::Main = (
1778             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikon,
1779             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikon,
1780             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
1781             WRITABLE => 1,
1782             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
1783             PRINT_CONV => \&FormatString,
1784             0x0001 => { #2
1785             # the format differs for different models. for D70, this is a string '0210',
1786             # but for the E775 it is binary: "\x00\x01\x00\x00"
1787             Name => 'MakerNoteVersion',
1788             Writable => 'undef',
1789             Count => 4,
1790             # convert to string if binary
1791             ValueConv => '$_=$val; /^[\x00-\x09]/ and $_=join("",unpack("CCCC",$_)); $_',
1792             ValueConvInv => '$val',
1793             PrintConv => '$_=$val;s/^(\d{2})/$1\./;s/^0//;$_',
1794             PrintConvInv => '$_=$val;s/\.//;"0$_"',
1795             },
1796             0x0002 => {
1797             # this is the ISO actually used by the camera
1798             # (may be different than ISO setting if auto)
1799             Name => 'ISO',
1800             Writable => 'int16u',
1801             Count => 2,
1802             Priority => 0, # the EXIF ISO is more reliable
1803             Groups => { 2 => 'Image' },
1804             # D300 sets this to undef with 4 zero bytes when LO ISO is used - PH
1805             RawConv => '$val eq "\0\0\0\0" ? undef : $val',
1806             # first number is 1 for "Hi ISO" modes (H0.3, H0.7 and H1.0 on D80) - PH
1807             PrintConv => '$_=$val;s/^0 //;s/^1 (\d+)/Hi $1/;$_',
1808             PrintConvInv => '$_=$val;/^\d+/ ? "0 $_" : (s/Hi ?//i ? "1 $_" : $_)',
1809             },
1810             # Note: we attempt to fix the case of these string values (typically written in all caps)
1811             0x0003 => { Name => 'ColorMode', Writable => 'string' },
1812             0x0004 => { Name => 'Quality', Writable => 'string' },
1813             0x0005 => { Name => 'WhiteBalance', Writable => 'string' },
1814             0x0006 => { Name => 'Sharpness', Writable => 'string' },
1815             0x0007 => {
1816             Name => 'FocusMode',
1817             RawConv => '$$self{FocusMode} = $val',
1818             Writable => 'string',
1819             },
1820             # FlashSetting (better named FlashSyncMode, ref 28) values:
1821             # "Normal", "Slow", "Rear Slow", "RED-EYE", "RED-EYE SLOW"
1822             0x0008 => { Name => 'FlashSetting', Writable => 'string' },
1823             # FlashType observed values:
1824             # internal: "Built-in,TTL", "Built-in,RPT", "Comdr.", "NEW_TTL"
1825             # external: "Optional,TTL", "Optional,RPT", "Optional,M", "Comdr."
1826             # both: "Built-in,TTL&Comdr."
1827             # no flash: ""
1828             0x0009 => { Name => 'FlashType', Writable => 'string' }, #2 (count varies by model - PH)
1829             # 0x000a - rational values: 5.6 to 9.33 - found in Coolpix models - PH
1830             # (seems constant for a given camera model, but not correlated with scale factor)
1831             0x000b => { #2
1832             Name => 'WhiteBalanceFineTune',
1833             Writable => 'int16s',
1834             Count => -1, # older models write 1 value, newer DSLR's write 2 - PH
1835             },
1836             0x000c => { # (D1X)
1837             Name => 'WB_RBLevels',
1838             Writable => 'rational64u',
1839             Count => 4, # (not sure what the last 2 values are for)
1840             },
1841             0x000d => { #15
1842             Name => 'ProgramShift',
1843             Writable => 'undef',
1844             Count => 4,
1845             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1846             ValueConvInv => q{
1847             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1848             $a<-128 or $a>127 ? undef : pack("c4",$a,1,6,0);
1849             },
1850             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1851             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1852             },
1853             0x000e => {
1854             Name => 'ExposureDifference',
1855             Writable => 'undef',
1856             Count => 4,
1857             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1858             ValueConvInv => q{
1859             my $a = int($val*12 + ($val>0 ? 0.5 : -0.5));
1860             $a<-128 or $a>127 ? undef : pack("c4",$a,1,12,0);
1861             },
1862             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
1863             PrintConvInv => '$val',
1864             },
1865             0x000f => { Name => 'ISOSelection', Writable => 'string' }, #2
1866             0x0010 => {
1867             Name => 'DataDump',
1868             Writable => 0,
1869             Binary => 1,
1870             },
1871             0x0011 => {
1872             Name => 'PreviewIFD',
1873             Groups => { 1 => 'PreviewIFD', 2 => 'Image' },
1874             Flags => 'SubIFD',
1875             SubDirectory => {
1876             TagTable => 'Image::ExifTool::Nikon::PreviewIFD',
1877             Start => '$val',
1878             },
1879             },
1880             0x0012 => { #2 (camera setting: combination of command dial and menus - PH)
1881             Name => 'FlashExposureComp',
1882             Description => 'Flash Exposure Compensation',
1883             Writable => 'undef',
1884             Count => 4,
1885             # (includes the built-in compensation for FlashType "Built-in,TTL&Comdr.")
1886             Notes => q{
1887             may be set even if flash does not fire. Does not include the effect of
1888             flash bracketing.
1889             },
1890             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1891             ValueConvInv => q{
1892             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1893             $a<-128 or $a>127 ? undef : pack("c4",$a,1,6,0);
1894             },
1895             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1896             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1897             },
1898             # D70 - another ISO tag
1899             0x0013 => { #2
1900             Name => 'ISOSetting',
1901             Writable => 'int16u',
1902             Count => 2,
1903             PrintConv => '$_=$val;s/^0 //;$_',
1904             PrintConvInv => '"0 $val"',
1905             },
1906             0x0014 => [
1907             { #4
1908             Name => 'ColorBalanceA',
1909             Condition => '$format eq "undef" and $count == 2560',
1910             SubDirectory => {
1911             TagTable => 'Image::ExifTool::Nikon::ColorBalanceA',
1912             ByteOrder => 'BigEndian',
1913             },
1914             },
1915             { #IB
1916             Name => 'NRWData',
1917             Condition => '$$valPt =~ /^NRW 0100/',
1918             Drop => 1, # 'Drop' because it is large and not found in JPEG images
1919             SubDirectory => {
1920             TagTable => 'Image::ExifTool::Nikon::ColorBalanceB',
1921             },
1922             },
1923             { #IB
1924             Name => 'NRWData',
1925             Condition => '$$valPt =~ /^NRW /',
1926             Drop => 1, # 'Drop' because it is large and not found in JPEG images
1927             SubDirectory => {
1928             TagTable => 'Image::ExifTool::Nikon::ColorBalanceC',
1929             },
1930             },
1931             ],
1932             # 0x0015 - string[8]: "AUTO "
1933             # D70 Image boundary?? top x,y bot-right x,y
1934             0x0016 => { #2
1935             Name => 'ImageBoundary',
1936             Writable => 'int16u',
1937             Count => 4,
1938             },
1939             0x0017 => { #28
1940             Name => 'ExternalFlashExposureComp', #PH (setting from external flash unit)
1941             Writable => 'undef',
1942             Count => 4,
1943             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1944             ValueConvInv => q{
1945             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1946             $a<-128 or $a>127 ? undef : pack("c4",$a,1,6,0);
1947             },
1948             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1949             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1950             },
1951             0x0018 => { #5
1952             Name => 'FlashExposureBracketValue',
1953             Writable => 'undef',
1954             Count => 4,
1955             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1956             ValueConvInv => q{
1957             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1958             $a<-128 or $a>127 ? undef : pack("c4",$a,1,6,0);
1959             },
1960             PrintConv => 'sprintf("%.1f",$val)',
1961             PrintConvInv => '$val',
1962             },
1963             0x0019 => { #5
1964             Name => 'ExposureBracketValue',
1965             Writable => 'rational64s',
1966             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]
1967             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1968             },
1969             0x001a => { #PH
1970             Name => 'ImageProcessing',
1971             Writable => 'string',
1972             },
1973             0x001b => { #15
1974             Name => 'CropHiSpeed',
1975             Writable => 'int16u',
1976             Count => 7,
1977             PrintConv => \%cropHiSpeed,
1978             },
1979             0x001c => { #28 (D3 "the application of CSb6 to the selected metering mode")
1980             Name => 'ExposureTuning',
1981             Writable => 'undef',
1982             Count => 3,
1983             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1984             ValueConvInv => q{
1985             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1986             $a<-128 or $a>127 ? undef : pack("c3",$a,1,6);
1987             },
1988             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1989             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1990             },
1991             0x001d => { #4
1992             Name => 'SerialNumber',
1993             # Note: this has been known to change even if the serial number on the body
1994             # stays the same if some parts of the camera were replaced by Nikon service
1995             Writable => 'string',
1996             Protected => 1,
1997             Notes => q{
1998             this value is used as a key to decrypt other information -- writing this tag
1999             causes the other information to be re-encrypted with the new key
2000             },
2001             PrintConv => undef, # disable default PRINT_CONV
2002             },
2003             0x001e => { #14
2004             Name => 'ColorSpace',
2005             Writable => 'int16u',
2006             PrintConv => {
2007             1 => 'sRGB',
2008             2 => 'Adobe RGB',
2009             4 => 'BT.2100', #observed on Z8 with Tone Mode set to HLG
2010             },
2011             },
2012             0x001f => { #PH
2013             Name => 'VRInfo',
2014             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::VRInfo' },
2015             },
2016             0x0020 => { #16
2017             Name => 'ImageAuthentication',
2018             Writable => 'int8u',
2019             PrintConv => \%offOn,
2020             },
2021             0x0021 => { #PH
2022             Name => 'FaceDetect',
2023             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FaceDetect' },
2024             },
2025             0x0022 => { #21
2026             Name => 'ActiveD-Lighting',
2027             Writable => 'int16u',
2028             PrintConv => {
2029             0 => 'Off',
2030             1 => 'Low',
2031             3 => 'Normal',
2032             5 => 'High',
2033             7 => 'Extra High', #10
2034             8 => 'Extra High 1', #PH
2035             9 => 'Extra High 2', #PH
2036             10 => 'Extra High 3', #PH
2037             11 => 'Extra High 4', #PH
2038             0xffff => 'Auto', #10
2039             },
2040             },
2041             0x0023 => [
2042             { #PH (D300, but also found in D3,D3S,D3X,D90,D300S,D700,D3000,D5000)
2043             Name => 'PictureControlData',
2044             Condition => '$$valPt =~ /^01/',
2045             Writable => 'undef',
2046             Permanent => 0,
2047             Flags => [ 'Binary', 'Protected' ],
2048             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl' },
2049             },{ #28
2050             Name => 'PictureControlData',
2051             Condition => '$$valPt =~ /^02/',
2052             Writable => 'undef',
2053             Permanent => 0,
2054             Flags => [ 'Binary', 'Protected' ],
2055             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl2' },
2056             },{
2057             Name => 'PictureControlData',
2058             Condition => '$$valPt =~ /^03/',
2059             Writable => 'undef',
2060             Permanent => 0,
2061             Flags => [ 'Binary', 'Protected' ],
2062             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl3' },
2063             },{
2064             Name => 'PictureControlData',
2065             Writable => 'undef',
2066             Permanent => 0,
2067             Flags => [ 'Binary', 'Protected' ],
2068             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControlUnknown' },
2069             },
2070             ],
2071             0x0024 => { #JD
2072             Name => 'WorldTime',
2073             SubDirectory => {
2074             TagTable => 'Image::ExifTool::Nikon::WorldTime',
2075             # (CaptureNX does flip the byte order of this record)
2076             },
2077             },
2078             0x0025 => { #PH
2079             Name => 'ISOInfo',
2080             SubDirectory => {
2081             TagTable => 'Image::ExifTool::Nikon::ISOInfo',
2082             ByteOrder => 'BigEndian',
2083             },
2084             },
2085             0x002a => { #23 (this tag added with D3 firmware 1.10 -- also written by Nikon utilities)
2086             Name => 'VignetteControl',
2087             Writable => 'int16u',
2088             PrintConv => {
2089             0 => 'Off',
2090             1 => 'Low',
2091             3 => 'Normal',
2092             5 => 'High',
2093             },
2094             },
2095             0x002b => { #PH
2096             Name => 'DistortInfo',
2097             SubDirectory => {
2098             TagTable => 'Image::ExifTool::Nikon::DistortInfo',
2099             },
2100             },
2101             0x002c => { #29 (D7000)
2102             Name => 'UnknownInfo',
2103             SubDirectory => {
2104             TagTable => 'Image::ExifTool::Nikon::UnknownInfo',
2105             ByteOrder => 'BigEndian', #(NC)
2106             },
2107             },
2108             # 0x2d - "512 0 0","512 3 10","512 1 14",...
2109             0x0032 => { #PH
2110             Name => 'UnknownInfo2',
2111             SubDirectory => {
2112             TagTable => 'Image::ExifTool::Nikon::UnknownInfo2',
2113             ByteOrder => 'BigEndian', #(NC)
2114             },
2115             },
2116             0x0034 => { #forum9646
2117             Name => 'ShutterMode',
2118             Writable => 'int16u',
2119             RawConv => '$$self{ShutterMode} = $val',
2120             DataMember => 'ShutterMode',
2121             PrintConv => {
2122             0 => 'Mechanical',
2123             16 => 'Electronic',
2124             # 33 => ? seen for 1J2
2125             48 => 'Electronic Front Curtain',
2126             64 => 'Electronic (Movie)', #JanSkoda (Z6II)
2127             80 => 'Auto (Mechanical)', #JanSkoda (Z6II)
2128             81 => 'Auto (Electronic Front Curtain)', #JanSkoda (Z6II)
2129             96 => 'Electronic (High Speed)', #28 Z9 at C30/C60/C120 frame rates
2130             },
2131             },
2132             0x0035 => [{ #32
2133             Name => 'HDRInfo',
2134             Condition => '$count != 6',
2135             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::HDRInfo' },
2136             },{
2137             Name => 'HDRInfo2',
2138             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::HDRInfo2' },
2139             }],
2140             0x0037 => { #XavierJubier
2141             Name => 'MechanicalShutterCount',
2142             Writable => 'int32u',
2143             },
2144             0x0039 => {
2145             Name => 'LocationInfo',
2146             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LocationInfo' },
2147             },
2148             0x003d => { #IB
2149             Name => 'BlackLevel',
2150             Writable => 'int16u',
2151             Count => 4,
2152             # (may need to divide by 4 for some images, eg. D3300/D5300, 12 bit - ref IB)
2153             },
2154             0x003e => { #28
2155             Name => 'ImageSizeRAW',
2156             PrintConv => {
2157             1 => 'Large',
2158             2 => 'Medium',
2159             3 => 'Small',
2160             },
2161             },
2162             0x003f => { #https://github.com/darktable-org/darktable/issues/12282
2163             Name => 'WhiteBalanceFineTune',
2164             Writable => 'rational64s',
2165             Count => 2,
2166             },
2167             0x0044 => { #28
2168             Name => 'JPGCompression',
2169             RawConv => '($val) ? $val : undef', # undef for raw files
2170             PrintConv => {
2171             1 => 'Size Priority',
2172             3 => 'Optimal Quality',
2173             },
2174             },
2175             0x0045 => { #IB
2176             Name => 'CropArea',
2177             Notes => 'left, top, width, height',
2178             Writable => 'int16u',
2179             Count => 4,
2180             },
2181             0x004e => { #28
2182             Name => 'NikonSettings',
2183             Writable => 'undef',
2184             Permanent => 0,
2185             Flags => [ 'Binary', 'Protected' ],
2186             SubDirectory => { TagTable => 'Image::ExifTool::NikonSettings::Main' },
2187             },
2188             0x004f => { #IB (D850)
2189             Name => 'ColorTemperatureAuto',
2190             Writable => 'int16u',
2191             },
2192             0x0051 => { #28 (Z9)
2193             Name => 'MakerNotes0x51',
2194             Writable => 'undef',
2195             #Hidden => 1,
2196             Permanent => 0,
2197             Flags => [ 'Binary', 'Protected' ],
2198             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::MakerNotes0x51' },
2199             },
2200             #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)
2201             0x0056 => { #28 (Z9)
2202             Name => 'MakerNotes0x56',
2203             Writable => 'undef',
2204             #Hidden => 1,
2205             Permanent => 0,
2206             Flags => [ 'Binary', 'Protected' ],
2207             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::MakerNotes0x56' },
2208             },
2209             #0x005e #28 possibly DiffractionCompensation block? Certainly offset 0x04 within block contains tag DiffractionCompensation
2210             0x0080 => { Name => 'ImageAdjustment', Writable => 'string' },
2211             0x0081 => { Name => 'ToneComp', Writable => 'string' }, #2
2212             0x0082 => { Name => 'AuxiliaryLens', Writable => 'string' },
2213             0x0083 => {
2214             Name => 'LensType',
2215             Writable => 'int8u',
2216             # credit to Tom Christiansen (ref 7) for figuring this out...
2217             # (note that older models don't seem to set bits 4-7 (0xf0), so the
2218             # LensType may be different with different models, ref Kenneth Cochran)
2219             PrintConv => q[$_ = $val ? Image::ExifTool::DecodeBits($val,
2220             {
2221             0 => 'MF',
2222             1 => 'D',
2223             2 => 'G',
2224             3 => 'VR',
2225             4 => '1', #PH
2226             5 => 'FT-1', #PH/IB
2227             6 => 'E', #PH (electromagnetic aperture mechanism)
2228             7 => 'AF-P', #PH/IB
2229             }) : 'AF';
2230             # remove commas and change "D G" to just "G"
2231             s/,//g; s/\bD G\b/G/;
2232             s/ E\b// and s/^(G )?/E /; # put "E" at the start instead of "G"
2233             s/ 1// and $_ = "1 $_"; # put "1" at start
2234             s/FT-1 // and $_ .= ' FT-1'; # put "FT-1" at end
2235             return $_;
2236             ],
2237             PrintConvInv => q[
2238             my $bits = 0;
2239             $bits |= 0x01 if $val =~ /\bMF\b/i; # bit 0
2240             $bits |= 0x02 if $val =~ /\bD\b/i; # bit 1
2241             $bits |= 0x06 if $val =~ /\bG\b/i; # bits 1 and 2
2242             $bits |= 0x08 if $val =~ /\bVR\b/i; # bit 3
2243             $bits |= 0x10 if $val =~ /\b1\b/; # bit 4
2244             $bits |= 0x20 if $val =~ /\bFT-1/i; # bit 5
2245             $bits |= 0x80 if $val =~ /\bAF-P/i; # bit 7 (not used by all models)
2246             $bits |= 0x46 if $val =~ /\bE\b/i; # bits 1, 2 and 6
2247             return $bits;
2248             ],
2249             },
2250             0x0084 => { #2
2251             Name => "Lens",
2252             Writable => 'rational64u',
2253             Count => 4,
2254             # short focal, long focal, aperture at short focal, aperture at long focal
2255             PrintConv => \&Image::ExifTool::Exif::PrintLensInfo,
2256             PrintConvInv => \&Image::ExifTool::Exif::ConvertLensInfo,
2257             },
2258             0x0085 => {
2259             Name => 'ManualFocusDistance',
2260             Writable => 'rational64u',
2261             },
2262             0x0086 => {
2263             Name => 'DigitalZoom',
2264             Writable => 'rational64u',
2265             },
2266             0x0087 => { #5
2267             Name => 'FlashMode',
2268             Writable => 'int8u',
2269             PrintConv => {
2270             0 => 'Did Not Fire',
2271             1 => 'Fired, Manual', #14
2272             3 => 'Not Ready', #28
2273             #5 observed on Z9 firing remote SB-5000 via WR-R11a optical awl
2274             7 => 'Fired, External', #14
2275             8 => 'Fired, Commander Mode',
2276             9 => 'Fired, TTL Mode',
2277             18 => 'LED Light', #G.F. (movie LED light)
2278             },
2279             },
2280             0x0088 => [
2281             {
2282             Name => 'AFInfo',
2283             Condition => '$$self{Model} =~ /^NIKON D/i',
2284             SubDirectory => {
2285             TagTable => 'Image::ExifTool::Nikon::AFInfo',
2286             ByteOrder => 'BigEndian',
2287             },
2288             },
2289             {
2290             Name => 'AFInfo',
2291             SubDirectory => {
2292             TagTable => 'Image::ExifTool::Nikon::AFInfo',
2293             ByteOrder => 'LittleEndian',
2294             },
2295             },
2296             ],
2297             0x0089 => { #5
2298             Name => 'ShootingMode',
2299             Writable => 'int16u',
2300             # the meaning of bit 5 seems to change: For the D200 it indicates "Auto ISO" - PH
2301             Notes => 'for the D70, Bit 5 = Unused LE-NR Slowdown',
2302             # credit to Tom Christiansen (ref 7) for figuring this out...
2303             # The (new?) bit 5 seriously complicates our life here: after firmwareB's
2304             # 1.03, bit 5 turns on when you ask for BUT DO NOT USE the long-range
2305             # noise reduction feature, probably because even not using it, it still
2306             # slows down your drive operation to 50% (1.5fps max not 3fps). But no
2307             # longer does !$val alone indicate single-frame operation. - TC, D70
2308             # The following comments are from Warren Hatch:
2309             # Bits 4,6,8 indicate bracketing mode.
2310             # - all 0's => Bracketing Off
2311             # - bit 4 on with bits 6,8 off => Exposure Bracketing On
2312             # - bits 4,6 on => WB bracketing On
2313             # - 4,8 on => ADL Bracketing On
2314             # Bit 2 gives tethered status: Off=>Not Tethered; On=Tethered.
2315             # - that this simply indicates a camera is connected via a cord to a PC
2316             # (doesn't necessarily mean that the shutter was tripped by the computer)
2317             # Bits 0,1,3,7,9 relate to how the shutter is tripped in concert with the
2318             # Release Mode dial [although I cannot cause bit 7 to flip with any of my gear and
2319             # I suspect it is no longer used for the D500]. Regardless, the ReleaseMode tag
2320             # offers a superior decoding of this information for the D4s, D810 and D500.
2321             # Bit 5 indicates whether or not AutoISO is enabled.
2322             PrintConv => q[
2323             $_ = '';
2324             unless ($val & 0x87) {
2325             return 'Single-Frame' unless $val;
2326             $_ = 'Single-Frame, ';
2327             }
2328             return $_ . Image::ExifTool::DecodeBits($val,
2329             {
2330             0 => 'Continuous',
2331             1 => 'Delay',
2332             2 => 'PC Control',
2333             3 => 'Self-timer', #forum6281 (NC)
2334             4 => 'Exposure Bracketing',
2335             5 => $$self{Model}=~/D70\b/ ? 'Unused LE-NR Slowdown' : 'Auto ISO',
2336             6 => 'White-Balance Bracketing',
2337             7 => 'IR Control',
2338             8 => 'D-Lighting Bracketing', #forum6281 (NC)
2339             11 => 'Pre-capture', #28 Z9 pre-release burst
2340             });
2341             ],
2342             },
2343             # 0x008a - called "AutoBracketRelease" by ref 15 [but this seems wrong]
2344             # values: 0,255 (when writing NEF only), or 1,2 (when writing JPEG or JPEG+NEF)
2345             # --> makes odd, repeating pattern in sequential NEF images (ref 28)
2346             0x008b => { #8
2347             Name => 'LensFStops',
2348             ValueConv => 'my ($a,$b,$c)=unpack("C3",$val); $c ? $a*($b/$c) : 0',
2349             ValueConvInv => 'my $a=int($val*12+0.5);$a<256 ? pack("C4",$a,1,12,0) : undef',
2350             PrintConv => 'sprintf("%.2f", $val)',
2351             PrintConvInv => '$val',
2352             Writable => 'undef',
2353             Count => 4,
2354             },
2355             0x008c => {
2356             Name => 'ContrastCurve', #JD
2357             Writable => 'undef',
2358             Flags => [ 'Binary', 'Protected', 'Drop' ], # (drop because not found in Nikon JPEG's)
2359             },
2360             # ColorHue: MODE1/MODE1a=sRGB, MODE2=Adobe RGB, MODE3a=more saturated sRGB
2361             # --> should really be called ColorSpace or ColorMode, but that would conflict with other tags
2362             0x008d => { Name => 'ColorHue' , Writable => 'string' }, #2
2363             # SceneMode takes on the following values: PORTRAIT, PARTY/INDOOR, NIGHT PORTRAIT,
2364             # BEACH/SNOW, LANDSCAPE, SUNSET, NIGHT SCENE, MUSEUM, FIREWORKS, CLOSE UP, COPY,
2365             # BACK LIGHT, PANORAMA ASSIST, SPORT, DAWN/DUSK
2366             0x008f => { Name => 'SceneMode', Writable => 'string' }, #2
2367             # LightSource shows 3 values COLORED SPEEDLIGHT NATURAL.
2368             # (SPEEDLIGHT when flash goes. Have no idea about difference between other two.)
2369             0x0090 => { Name => 'LightSource', Writable => 'string' }, #2
2370             0x0091 => [ #18
2371             { #PH
2372             Condition => '$$valPt =~ /^0209/',
2373             Name => 'ShotInfoD40',
2374             SubDirectory => {
2375             TagTable => 'Image::ExifTool::Nikon::ShotInfoD40',
2376             DecryptStart => 4,
2377             ByteOrder => 'BigEndian',
2378             },
2379             },
2380             {
2381             Condition => '$$valPt =~ /^0208/',
2382             Name => 'ShotInfoD80',
2383             SubDirectory => {
2384             TagTable => 'Image::ExifTool::Nikon::ShotInfoD80',
2385             DecryptStart => 4,
2386             # (Capture NX can change the makernote byte order, but this stays big-endian)
2387             ByteOrder => 'BigEndian',
2388             },
2389             },
2390             { #PH (D90, firmware 1.00)
2391             Condition => '$$valPt =~ /^0213/',
2392             Name => 'ShotInfoD90',
2393             SubDirectory => {
2394             TagTable => 'Image::ExifTool::Nikon::ShotInfoD90',
2395             DecryptStart => 4,
2396             ByteOrder => 'BigEndian',
2397             },
2398             },
2399             { #PH (D3, firmware 0.37 and 1.00)
2400             Condition => '$$valPt =~ /^0210/ and $count == 5399',
2401             Name => 'ShotInfoD3a',
2402             SubDirectory => {
2403             TagTable => 'Image::ExifTool::Nikon::ShotInfoD3a',
2404             DecryptStart => 4,
2405             ByteOrder => 'BigEndian',
2406             },
2407             },
2408             { #PH (D3, firmware 1.10, 2.00 and 2.01 [count 5408], and 2.02 [count 5412])
2409             Condition => '$$valPt =~ /^0210/ and ($count == 5408 or $count == 5412)',
2410             Name => 'ShotInfoD3b',
2411             SubDirectory => {
2412             TagTable => 'Image::ExifTool::Nikon::ShotInfoD3b',
2413             DecryptStart => 4,
2414             ByteOrder => 'BigEndian',
2415             },
2416             },
2417             { #PH (D3X, firmware 1.00)
2418             Condition => '$$valPt =~ /^0214/ and $count == 5409',
2419             Name => 'ShotInfoD3X',
2420             SubDirectory => {
2421             TagTable => 'Image::ExifTool::Nikon::ShotInfoD3X',
2422             DecryptStart => 4,
2423             ByteOrder => 'BigEndian',
2424             },
2425             },
2426             { #PH (D3S, firmware 0.16 and 1.00)
2427             Condition => '$$valPt =~ /^0218/ and ($count == 5356 or $count == 5388)',
2428             Name => 'ShotInfoD3S',
2429             SubDirectory => {
2430             TagTable => 'Image::ExifTool::Nikon::ShotInfoD3S',
2431             DecryptStart => 4,
2432             ByteOrder => 'BigEndian',
2433             },
2434             },
2435             { #JD (D300, firmware 0.25 and 1.00)
2436             # D3 and D300 use the same version number, but the length is different
2437             Condition => '$$valPt =~ /^0210/ and $count == 5291',
2438             Name => 'ShotInfoD300a',
2439             SubDirectory => {
2440             TagTable => 'Image::ExifTool::Nikon::ShotInfoD300a',
2441             DecryptStart => 4,
2442             ByteOrder => 'BigEndian',
2443             },
2444             },
2445             { #PH (D300, firmware version 1.10)
2446             # yet again the same ShotInfoVersion for different data
2447             Condition => '$$valPt =~ /^0210/ and $count == 5303',
2448             Name => 'ShotInfoD300b',
2449             SubDirectory => {
2450             TagTable => 'Image::ExifTool::Nikon::ShotInfoD300b',
2451             DecryptStart => 4,
2452             ByteOrder => 'BigEndian',
2453             },
2454             },
2455             { #PH (D300S, firmware version 1.00)
2456             # yet again the same ShotInfoVersion for different data
2457             Condition => '$$valPt =~ /^0216/ and $count == 5311',
2458             Name => 'ShotInfoD300S',
2459             SubDirectory => {
2460             TagTable => 'Image::ExifTool::Nikon::ShotInfoD300S',
2461             DecryptStart => 4,
2462             ByteOrder => 'BigEndian',
2463             },
2464             },
2465             # 0225 - D600
2466             { #29 (D700 firmware version 1.02f)
2467             Condition => '$$valPt =~ /^0212/ and $count == 5312',
2468             Name => 'ShotInfoD700',
2469             SubDirectory => {
2470             TagTable => 'Image::ExifTool::Nikon::ShotInfoD700',
2471             DecryptStart => 4,
2472             ByteOrder => 'BigEndian',
2473             },
2474             },
2475             { #28 (D780 firmware version 1.00)
2476             Condition => '$$valPt =~ /^0245/',
2477             Name => 'ShotInfoD780',
2478             SubDirectory => {
2479             TagTable => 'Image::ExifTool::Nikon::ShotInfoD780',
2480             DecryptStart => 4,
2481             ByteOrder => 'LittleEndian',
2482             },
2483             },
2484             { #28 (D7500 firmware version 1.00h)
2485             Condition => '$$valPt =~ /^0242/',
2486             Name => 'ShotInfoD7500',
2487             SubDirectory => {
2488             TagTable => 'Image::ExifTool::Nikon::ShotInfoD7500',
2489             DecryptStart => 4,
2490             ByteOrder => 'LittleEndian',
2491             },
2492             },
2493             { #PH (D800 firmware 1.01a)
2494             Condition => '$$valPt =~ /^0222/',
2495             Name => 'ShotInfoD800',
2496             SubDirectory => {
2497             TagTable => 'Image::ExifTool::Nikon::ShotInfoD800',
2498             DecryptStart => 4,
2499             ByteOrder => 'BigEndian',
2500             },
2501             },
2502             { #28 (D810 firmware 1.01)
2503             Condition => '$$valPt =~ /^0233/',
2504             Name => 'ShotInfoD810',
2505             SubDirectory => {
2506             TagTable => 'Image::ExifTool::Nikon::ShotInfoD810',
2507             DecryptStart => 4,
2508             ByteOrder => 'LittleEndian',
2509             },
2510             },
2511             { #28 (D850 firmware 1.00b)
2512             Condition => '$$valPt =~ /^0243/',
2513             Name => 'ShotInfoD850',
2514             SubDirectory => {
2515             TagTable => 'Image::ExifTool::Nikon::ShotInfoD850',
2516             DecryptStart => 4,
2517             ByteOrder => 'LittleEndian',
2518             },
2519             },
2520             # 0217 - D3000
2521             # 0219 - D3100
2522             # 0224 - D3200
2523             { #PH
2524             Condition => '$$valPt =~ /^0215/ and $count == 6745',
2525             Name => 'ShotInfoD5000',
2526             SubDirectory => {
2527             TagTable => 'Image::ExifTool::Nikon::ShotInfoD5000',
2528             DecryptStart => 4,
2529             ByteOrder => 'BigEndian',
2530             },
2531             },
2532             { #PH
2533             Condition => '$$valPt =~ /^0221/ and $count == 8902',
2534             Name => 'ShotInfoD5100',
2535             SubDirectory => {
2536             TagTable => 'Image::ExifTool::Nikon::ShotInfoD5100',
2537             DecryptStart => 4,
2538             ByteOrder => 'BigEndian',
2539             },
2540             },
2541             { #PH
2542             Condition => '$$valPt =~ /^0226/ and $count == 11587',
2543             Name => 'ShotInfoD5200',
2544             SubDirectory => {
2545             TagTable => 'Image::ExifTool::Nikon::ShotInfoD5200',
2546             DecryptStart => 4,
2547             ByteOrder => 'BigEndian',
2548             },
2549             },
2550             { #29 (D7000 firmware version 1.01b)
2551             Condition => '$$valPt =~ /^0220/',
2552             Name => 'ShotInfoD7000',
2553             SubDirectory => {
2554             TagTable => 'Image::ExifTool::Nikon::ShotInfoD7000',
2555             DecryptStart => 4,
2556             ByteOrder => 'BigEndian',
2557             },
2558             },
2559             { # (D4 firmware version 1.00g)
2560             Condition => '$$valPt =~ /^0223/',
2561             Name => 'ShotInfoD4',
2562             SubDirectory => {
2563             TagTable => 'Image::ExifTool::Nikon::ShotInfoD4',
2564             DecryptStart => 4,
2565             ByteOrder => 'BigEndian',
2566             },
2567             },
2568             { # (D4S firmware version 1.00d and 1.01a)
2569             Condition => '$$valPt =~ /^0231/',
2570             Name => 'ShotInfoD4S',
2571             SubDirectory => {
2572             TagTable => 'Image::ExifTool::Nikon::ShotInfoD4S',
2573             DecryptStart => 4,
2574             ByteOrder => 'LittleEndian',
2575             },
2576             },
2577             { #28 (D500 firmware version 1.00 and D5 firmware version 1.10a)
2578             Condition => '$$valPt =~ /^023[89]/',
2579             Name => 'ShotInfoD500',
2580             SubDirectory => {
2581             TagTable => 'Image::ExifTool::Nikon::ShotInfoD500',
2582             DecryptStart => 4,
2583             ByteOrder => 'LittleEndian',
2584             },
2585             },
2586             { # (D6 firmware version 1.00, ref 28)
2587             Condition => '$$valPt =~ /^0246/',
2588             Name => 'ShotInfoD6',
2589             SubDirectory => {
2590             TagTable => 'Image::ExifTool::Nikon::ShotInfoD6',
2591             DecryptStart => 4,
2592             ByteOrder => 'LittleEndian',
2593             },
2594             },
2595             { # (D610 firmware version 1.00)
2596             Condition => '$$valPt =~ /^0232/',
2597             Name => 'ShotInfoD610',
2598             SubDirectory => {
2599             TagTable => 'Image::ExifTool::Nikon::ShotInfoD610',
2600             DecryptStart => 4,
2601             ByteOrder => 'BigEndian',
2602             },
2603             },
2604             { # (Z6_3 firmware version 1.00, ref 28)
2605             Condition => '$$valPt =~ /^08(09|10|11)/', #0809=Z6iii 0810=Z50ii #0811=Z5ii
2606             Name => 'ShotInfoZ6III',
2607             SubDirectory => {
2608             TagTable => 'Image::ExifTool::Nikon::ShotInfoZ6III',
2609             DecryptStart => 4,
2610             ByteOrder => 'LittleEndian',
2611             },
2612             },
2613             { # (Z6_2 firmware version 1.00 and Z7_2 firmware versions 1.00 & 1.01, ref 28)
2614             # 0800=Z6/Z7 0801=Z50 0802=Z5 0803=Z6II/Z7II 0804=Zfc 0807=Z30 0808=Zf
2615             Condition => '$$valPt =~ /^080[0123478]/',
2616             Name => 'ShotInfoZ7II',
2617             SubDirectory => {
2618             TagTable => 'Image::ExifTool::Nikon::ShotInfoZ7II',
2619             DecryptStart => 4,
2620             ByteOrder => 'LittleEndian',
2621             },
2622             },
2623             { # (Z8 firmware version 1.00 ref 28)
2624             Condition => '$$valPt =~ /^0806/',
2625             Name => 'ShotInfoZ8',
2626             SubDirectory => {
2627             TagTable => 'Image::ExifTool::Nikon::ShotInfoZ8',
2628             DecryptStart => 4,
2629             ByteOrder => 'LittleEndian',
2630             },
2631             },
2632             { # (Z9 firmware version 1.00 ref 28)
2633             Condition => '$$valPt =~ /^0805/',
2634             Name => 'ShotInfoZ9',
2635             SubDirectory => {
2636             TagTable => 'Image::ExifTool::Nikon::ShotInfoZ9',
2637             DecryptStart => 4,
2638             ByteOrder => 'LittleEndian',
2639             },
2640             },
2641             { # D7100=0227
2642             Condition => '$$valPt =~ /^0[28]/',
2643             Name => 'ShotInfo02xx',
2644             Drop => 50000, # drop if too large (>64k for Z6iii)
2645             SubDirectory => {
2646             TagTable => 'Image::ExifTool::Nikon::ShotInfo',
2647             ProcessProc => \&ProcessNikonEncrypted,
2648             WriteProc => \&ProcessNikonEncrypted,
2649             DecryptStart => 4,
2650             ByteOrder => 'BigEndian',
2651             },
2652             },
2653             {
2654             Name => 'ShotInfoUnknown',
2655             Writable => 0,
2656             SubDirectory => {
2657             TagTable => 'Image::ExifTool::Nikon::ShotInfo',
2658             ByteOrder => 'BigEndian',
2659             },
2660             },
2661             ],
2662             0x0092 => { #2
2663             Name => 'HueAdjustment',
2664             Writable => 'int16s',
2665             },
2666             # 0x0093 - ref 15 calls this Saturation, but this is wrong - PH
2667             0x0093 => { #21
2668             Name => 'NEFCompression',
2669             Writable => 'int16u',
2670             SeparateTable => 'NEFCompression',
2671             PrintConv => \%nefCompression,
2672             },
2673             0x0094 => { Name => 'SaturationAdj', Writable => 'int16s' },
2674             0x0095 => { Name => 'NoiseReduction', Writable => 'string' }, # ("Off" or "FPNR"=long exposure NR)
2675             0x0096 => { # (not found in NRW files, but also not in all NEF's)
2676             Name => 'NEFLinearizationTable', # same table as DNG LinearizationTable (ref JD)
2677             Writable => 'undef',
2678             Flags => [ 'Binary', 'Protected' ],
2679             },
2680             0x0097 => [ #4
2681             # (NOTE: these are byte-swapped by NX when byte order changes)
2682             {
2683             Condition => '$$valPt =~ /^0100/', # (D100 and Coolpix models)
2684             Name => 'ColorBalance0100',
2685             SubDirectory => {
2686             Start => '$valuePtr + 72',
2687             TagTable => 'Image::ExifTool::Nikon::ColorBalance1',
2688             },
2689             },
2690             {
2691             Condition => '$$valPt =~ /^0102/', # (D2H)
2692             Name => 'ColorBalance0102',
2693             SubDirectory => {
2694             Start => '$valuePtr + 10',
2695             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2696             },
2697             },
2698             {
2699             Condition => '$$valPt =~ /^0103/', # (D70/D70s)
2700             Name => 'ColorBalance0103',
2701             # D70: at file offset 'tag-value + base + 20', 4 16 bits numbers,
2702             # v[0]/v[1] , v[2]/v[3] are the red/blue multipliers.
2703             SubDirectory => {
2704             Start => '$valuePtr + 20',
2705             TagTable => 'Image::ExifTool::Nikon::ColorBalance3',
2706             },
2707             },
2708             {
2709             Condition => '$$valPt =~ /^0205/', # (D50)
2710             Name => 'ColorBalance0205',
2711             SubDirectory => {
2712             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2713             ProcessProc => \&ProcessNikonEncrypted,
2714             WriteProc => \&ProcessNikonEncrypted,
2715             DecryptStart => 4,
2716             DirOffset => 14, # (start of directory relative to DecryptStart)
2717             },
2718             },
2719             { # (D3/D3X/D300/D700=0209,D300S=0212,D3S=0214)
2720             Condition => '$$valPt =~ /^02(09|12|14)/',
2721             Name => 'ColorBalance0209',
2722             SubDirectory => {
2723             TagTable => 'Image::ExifTool::Nikon::ColorBalance4',
2724             ProcessProc => \&ProcessNikonEncrypted,
2725             WriteProc => \&ProcessNikonEncrypted,
2726             DecryptStart => 284,
2727             DirOffset => 10,
2728             },
2729             },
2730             { # (D2X/D2Xs=0204,D2Hs=0206,D200=0207,D40/D40X/D80=0208,D60=0210)
2731             Condition => '$$valPt =~ /^02(\d{2})/ and $1 < 11',
2732             Name => 'ColorBalance02',
2733             SubDirectory => {
2734             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2735             ProcessProc => \&ProcessNikonEncrypted,
2736             WriteProc => \&ProcessNikonEncrypted,
2737             DecryptStart => 284,
2738             DirOffset => 6,
2739             },
2740             },
2741             {
2742             Condition => '$$valPt =~ /^0211/', # (D90/D5000)
2743             Name => 'ColorBalance0211',
2744             SubDirectory => {
2745             TagTable => 'Image::ExifTool::Nikon::ColorBalance4',
2746             ProcessProc => \&ProcessNikonEncrypted,
2747             WriteProc => \&ProcessNikonEncrypted,
2748             DecryptStart => 284,
2749             DirOffset => 16,
2750             },
2751             },
2752             {
2753             Condition => '$$valPt =~ /^0213/', # (D3000)
2754             Name => 'ColorBalance0213',
2755             SubDirectory => {
2756             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2757             ProcessProc => \&ProcessNikonEncrypted,
2758             WriteProc => \&ProcessNikonEncrypted,
2759             DecryptStart => 284,
2760             DirOffset => 10,
2761             },
2762             },
2763             { # (D3100=0215,D7000/D5100=0216,D4/D600/D800/D800E/D3200=0217)
2764             Condition => '$$valPt =~ /^021[567]/',
2765             Name => 'ColorBalance0215',
2766             SubDirectory => {
2767             TagTable => 'Image::ExifTool::Nikon::ColorBalance4',
2768             ProcessProc => \&ProcessNikonEncrypted,
2769             WriteProc => \&ProcessNikonEncrypted,
2770             DecryptStart => 284,
2771             DirOffset => 4,
2772             },
2773             },
2774             { #PH (NC)
2775             # (D5300=0219, D3300=0221, D4S=0222, D750/D810=0223, D3400/D3500/D5500/D5600/D7200=0224)
2776             Condition => '$$valPt =~ /^02(19|2[1234])/',
2777             Name => 'ColorBalance0219',
2778             SubDirectory => {
2779             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2780             ProcessProc => \&ProcessNikonEncrypted,
2781             WriteProc => \&ProcessNikonEncrypted,
2782             DecryptStart => 4,
2783             DirOffset => 0x7c,
2784             },
2785             },
2786             { # (D610/Df=0220, CoolpixA=0601)
2787             Name => 'ColorBalanceUnknown1',
2788             Condition => '$$valPt =~ /^0(220|6)/',
2789             SubDirectory => {
2790             TagTable => 'Image::ExifTool::Nikon::ColorBalanceUnknown',
2791             ProcessProc => \&ProcessNikonEncrypted,
2792             WriteProc => \&ProcessNikonEncrypted, # (necessary to recrypt this if serial number changed)
2793             DecryptStart => 284,
2794             },
2795             },
2796             { # (D5200/D7200=0218, D5/D500=0225, D7500=0226, D850=0227, D6/D780=0228,
2797             # 1J1/1J2/1V1=0400, 1V2=0401, 1J3/1S1=0402, 1AW1=0403, Z6/Z7=0800)
2798             Name => 'ColorBalanceUnknown2',
2799             Condition => '$$valPt =~ /^0(18|[248])/',
2800             SubDirectory => {
2801             TagTable => 'Image::ExifTool::Nikon::ColorBalanceUnknown2',
2802             ProcessProc => \&ProcessNikonEncrypted,
2803             WriteProc => \&ProcessNikonEncrypted, # (necessary to recrypt this if serial number changed)
2804             DecryptStart => 4,
2805             },
2806             },
2807             {
2808             # (CoolpixP7700/P7800=0500, CoolpixP330/P520=0502)
2809             Name => 'ColorBalanceUnknown',
2810             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::ColorBalanceUnknown' },
2811             },
2812             ],
2813             0x0098 => [
2814             { #8
2815             Condition => '$$valPt =~ /^0100/', # D100, D1X - PH
2816             Name => 'LensData0100',
2817             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LensData00' },
2818             },
2819             { #8
2820             Condition => '$$valPt =~ /^0101/', # D70, D70s - PH
2821             Name => 'LensData0101',
2822             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LensData01' },
2823             },
2824             # note: this information is encrypted if the version is 02xx
2825             { #8
2826             # 0201 - D200, D2Hs, D2X and D2Xs
2827             # 0202 - D40, D40X and D80
2828             # 0203 - D300
2829             Condition => '$$valPt =~ /^020[1-3]/',
2830             Name => 'LensData0201',
2831             SubDirectory => {
2832             TagTable => 'Image::ExifTool::Nikon::LensData01',
2833             ProcessProc => \&ProcessNikonEncrypted,
2834             WriteProc => \&ProcessNikonEncrypted,
2835             DecryptStart => 4,
2836             },
2837             },
2838             { #PH
2839             Condition => '$$valPt =~ /^0204/', # D90, D7000
2840             Name => 'LensData0204',
2841             SubDirectory => {
2842             TagTable => 'Image::ExifTool::Nikon::LensData0204',
2843             ProcessProc => \&ProcessNikonEncrypted,
2844             WriteProc => \&ProcessNikonEncrypted,
2845             DecryptStart => 4,
2846             },
2847             },
2848             {
2849             Condition => '$$valPt =~ /^040[01]/', # 0=1J1/1V1, 1=1J2
2850             Name => 'LensData0400',
2851             SubDirectory => {
2852             TagTable => 'Image::ExifTool::Nikon::LensData0400',
2853             ProcessProc => \&ProcessNikonEncrypted,
2854             WriteProc => \&ProcessNikonEncrypted,
2855             DecryptStart => 4,
2856             },
2857             },
2858             {
2859             Condition => '$$valPt =~ /^0402/', # 1J3/1S1/1V2
2860             Name => 'LensData0402',
2861             SubDirectory => {
2862             TagTable => 'Image::ExifTool::Nikon::LensData0402',
2863             ProcessProc => \&ProcessNikonEncrypted,
2864             WriteProc => \&ProcessNikonEncrypted,
2865             DecryptStart => 4,
2866             },
2867             },
2868             {
2869             Condition => '$$valPt =~ /^0403/', # 1J4,1J5
2870             Name => 'LensData0403',
2871             SubDirectory => {
2872             TagTable => 'Image::ExifTool::Nikon::LensData0403',
2873             ProcessProc => \&ProcessNikonEncrypted,
2874             WriteProc => \&ProcessNikonEncrypted,
2875             DecryptStart => 4,
2876             },
2877             },
2878             {
2879             Condition => '$$valPt =~ /^080[012]/', # Z6/Z7/Z9
2880             Name => 'LensData0800',
2881             SubDirectory => {
2882             TagTable => 'Image::ExifTool::Nikon::LensData0800',
2883             ProcessProc => \&ProcessNikonEncrypted,
2884             WriteProc => \&ProcessNikonEncrypted,
2885             DecryptStart => 4,
2886             ByteOrder => 'LittleEndian',
2887             },
2888             },
2889             {
2890             Name => 'LensDataUnknown',
2891             SubDirectory => {
2892             TagTable => 'Image::ExifTool::Nikon::LensDataUnknown',
2893             ProcessProc => \&ProcessNikonEncrypted,
2894             WriteProc => \&ProcessNikonEncrypted,
2895             DecryptStart => 4,
2896             },
2897             },
2898             ],
2899             0x0099 => { #2/15
2900             Name => 'RawImageCenter',
2901             Writable => 'int16u',
2902             Count => 2,
2903             },
2904             0x009a => { #10
2905             Name => 'SensorPixelSize',
2906             Writable => 'rational64u',
2907             Count => 2,
2908             PrintConv => '$val=~s/ / x /;"$val um"',
2909             PrintConvInv => '$val=~tr/a-zA-Z/ /;$val',
2910             },
2911             0x009c => { #14
2912             # L2/L3 has these modes (from owner's manual): - PH
2913             # Portrait Assist: FACE-PRIORITY AF,PORTRAIT,PORTRAIT LEFT,PORTRAIT RIGHT,
2914             # PORTRAIT CLOSE-UP,PORTRAIT COUPLE,PORTRAIT-FIGURE
2915             # Landscape Assist:LANDSCAPE,SCENIC VIEW,ARCHITECTURE,GROUP RIGHT,GROUP LEFT
2916             # Sports Assist: SPORTS,SPORT SPECTATOR,SPORT COMPOSITE
2917             # P7100 has test modes: - PH
2918             # CREATIVE MONOCHROME,PAINTING,CROSS PROCESS,SOFT,NOSTALGIC SEPIA,
2919             # HIGH KEY,LOW KEY,SELECTIVE COLOR,ZOOM EXPOSURE EXP.,DEFOCUS DURING
2920             Name => 'SceneAssist',
2921             Writable => 'string',
2922             },
2923             0x009d => { #NealKrawetz
2924             Name => 'DateStampMode',
2925             Writable => 'int16u',
2926             Notes => 'feature to imprint date/time on image',
2927             PrintConv => { #PH
2928             0 => 'Off',
2929             1 => 'Date & Time',
2930             2 => 'Date',
2931             3 => 'Date Counter', # (NC) (D3500)
2932             },
2933             },
2934             0x009e => { #JD
2935             Name => 'RetouchHistory',
2936             Writable => 'int16u',
2937             Count => 10,
2938             # trim off extra "None" values
2939             ValueConv => '$val=~s/( 0)+$//; $val',
2940             ValueConvInv => 'my $n=($val=~/ \d+/g);$n < 9 ? $val . " 0" x (9-$n) : $val',
2941             PrintConvColumns => 2,
2942             PrintConv => [
2943             \%retouchValues,
2944             \%retouchValues,
2945             \%retouchValues,
2946             \%retouchValues,
2947             \%retouchValues,
2948             \%retouchValues,
2949             \%retouchValues,
2950             \%retouchValues,
2951             \%retouchValues,
2952             \%retouchValues,
2953             ],
2954             },
2955             0x00a0 => { Name => 'SerialNumber', Writable => 'string' }, #2
2956             0x00a2 => { # size of compressed image data plus EOI segment (ref 10)
2957             Name => 'ImageDataSize',
2958             Writable => 'int32u',
2959             },
2960             # 0x00a3 - int8u: 0 (All DSLR's but D1,D1H,D1X,D100)
2961             # 0x00a4 - version number found only in NEF images from DSLR models except the
2962             # D1,D1X,D2H and D100. Value is "0200" for all available samples except images
2963             # edited by Nikon Capture Editor 4.3.1 W and 4.4.2 which have "0100" - PH
2964             0x00a5 => { #15
2965             Name => 'ImageCount',
2966             Writable => 'int32u',
2967             },
2968             0x00a6 => { #15
2969             Name => 'DeletedImageCount',
2970             Writable => 'int32u',
2971             },
2972             # the sum of 0xa5 and 0xa6 is equal to 0xa7 ShutterCount (D2X,D2Hs,D2H,D200, ref 10)
2973             0x00a7 => { # Number of shots taken by camera so far (ref 2)
2974             Name => 'ShutterCount',
2975             Writable => 'int32u',
2976             Protected => 1,
2977             PrintConv => '$val == 4294965247 ? "n/a" : $val',
2978             PrintConvInv => '$val eq "n/a" ? 4294965247 : $val',
2979             Notes => q{
2980             includes both mechanical and electronic shutter activations for models with
2981             this feature. This value is used as a key to decrypt other information, and
2982             writing this tag causes the other information to be re-encrypted with the
2983             new key
2984             },
2985             },
2986             0x00a8 => [#JD
2987             {
2988             Name => 'FlashInfo0100',
2989             Condition => '$$valPt =~ /^010[01]/',
2990             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0100' },
2991             },
2992             {
2993             Name => 'FlashInfo0102',
2994             Condition => '$$valPt =~ /^0102/',
2995             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0102' },
2996             },
2997             {
2998             Name => 'FlashInfo0103',
2999             # (0104 for D7000, 0105 for D800)
3000             Condition => '$$valPt =~ /^010[345]/',
3001             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0103' },
3002             },
3003             {
3004             Name => 'FlashInfo0106', # (Df, D610, D3300, D5300, D7100, Coolpix A)
3005             Condition => '$$valPt =~ /^0106/',
3006             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0106' },
3007             },
3008             {
3009             Name => 'FlashInfo0107', # (0107 for D4S/D750/D810/D5500/D7200, 0108 for D5/D500/D3400)
3010             Condition => '$$valPt =~ /^010[78]/',
3011             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0107' },
3012             },
3013             {
3014             Name => 'FlashInfo0300', # (Z7II)
3015             Condition => '$$valPt =~ /^030[01]/',
3016             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0300' },
3017             },
3018             {
3019             Name => 'FlashInfoUnknown',
3020             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfoUnknown' },
3021             },
3022             ],
3023             0x00a9 => { Name => 'ImageOptimization',Writable => 'string' },#2
3024             0x00aa => { Name => 'Saturation', Writable => 'string' }, #2
3025             0x00ab => { Name => 'VariProgram', Writable => 'string' }, #2 (scene mode for DSLR's - PH)
3026             0x00ac => { Name => 'ImageStabilization',Writable=> 'string' }, #14
3027             0x00ad => { Name => 'AFResponse', Writable => 'string' }, #14
3028             0x00b0 => [{ #PH
3029             Name => 'MultiExposure',
3030             Condition => '$$valPt =~ /^0100/',
3031             SubDirectory => {
3032             TagTable => 'Image::ExifTool::Nikon::MultiExposure',
3033             # Note: this endianness varies with model, but Nikon software may change
3034             # metadata endianness (although it is unknown how it affects this record),
3035             # so for now don't specify ByteOrder although it may be wrong if the
3036             # file is rewritten by Nikon software --> see comments for FileInfo
3037             },
3038             },{
3039             Name => 'MultiExposure',
3040             Condition => '$$valPt =~ /^0101/',
3041             SubDirectory => {
3042             TagTable => 'Image::ExifTool::Nikon::MultiExposure',
3043             ByteOrder => 'LittleEndian',
3044             },
3045             },{
3046             Name => 'MultiExposure2',
3047             Condition => '$$valPt =~ /^010[23]/', # 0102 is NC (PH)
3048             SubDirectory => {
3049             TagTable => 'Image::ExifTool::Nikon::MultiExposure2',
3050             },
3051             }],
3052             0x00b1 => { #14/PH/JD (D80)
3053             Name => 'HighISONoiseReduction',
3054             Writable => 'int16u',
3055             PrintConv => {
3056             0 => 'Off',
3057             1 => 'Minimal', # for high ISO (>800) when setting is "Off"
3058             2 => 'Low', # Low,Normal,High take effect for ISO > 400
3059             3 => 'Medium Low',
3060             4 => 'Normal',
3061             5 => 'Medium High',
3062             6 => 'High',
3063             },
3064             },
3065             # 0x00b2 (string: "NORMAL ", 0xc3's, 0xff's or 0x20's)
3066             0x00b3 => { #14
3067             Name => 'ToningEffect',
3068             Writable => 'string',
3069             },
3070             0x00b6 => { #PH
3071             Name => 'PowerUpTime',
3072             Groups => { 2 => 'Time' },
3073             Shift => 'Time',
3074             # not clear whether "powered up" means "turned on" or "power applied" - PH
3075             Notes => 'date/time when camera was last powered up',
3076             Writable => 'undef',
3077             # must use RawConv so byte order is correct
3078             RawConv => sub {
3079             my $val = shift;
3080             return $val if length $val < 7;
3081             my $shrt = GetByteOrder() eq 'II' ? 'v' : 'n';
3082             my @date = unpack("${shrt}C5", $val);
3083             return sprintf('%.4d:%.2d:%.2d %.2d:%.2d:%.2d', @date);
3084             },
3085             RawConvInv => sub {
3086             my $val = shift;
3087             my $shrt = GetByteOrder() eq 'II' ? 'v' : 'n';
3088             my @date = ($val =~ /\d+/g);
3089             return pack("${shrt}C6", @date, 0);
3090             },
3091             PrintConv => '$self->ConvertDateTime($val)',
3092             PrintConvInv => '$self->InverseDateTime($val,0)',
3093             },
3094             0x00b7 => [{
3095             Name => 'AFInfo2',
3096             # LiveView-enabled DSLRs introduced starting in 2007 (D3/D300)
3097             Condition => '$$valPt =~ /^0100/',
3098             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0100' },
3099             },{
3100             Name => 'AFInfo2',
3101             # All Expeed 5 processor and most Expeed 4 processor models from 2016 - D5, D500, D850, D3400, D3500, D7500 (D5600 is v0100)
3102             Condition => '$$valPt =~ /^0101/',
3103             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0101' },
3104             },{
3105             Name => 'AFInfo2',
3106             # Nikon 1 Series cameras
3107             Condition => '$$valPt =~ /^020[01]/',
3108             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0200' },
3109             },{
3110             Name => 'AFInfo2',
3111             # Expeed 6 processor models - D6, D780, Z5, Z6, Z7, Z30, Z50, Z6_2, Z7_2 and Zfc
3112             Condition => '$$valPt =~ /^030[01]/',
3113             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0300' },
3114             },{
3115             Name => 'AFInfo2',
3116             # Expeed 7 processor models - Z8 & Z9 (AFInfo2Version 0400), Z6iii & Zf (AFInfo2Version 0401)
3117             # and Z50ii (AFInfo2Version 0402)
3118             Condition => '$$valPt =~ /^040[012]/',
3119             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0400' },
3120             }],
3121             0x00b8 => [{ #PH
3122             Name => 'FileInfo',
3123             # unfortunately, some newer models write this as little-endian
3124             # (and CaptureNX can change the byte order of the maker notes,
3125             # but leaves this structure unchanged)
3126             # - it will be an ongoing pain to keep this list of models up-to-date,
3127             # so if only one ordering yields valid DirectoryNumber and FileNumber values,
3128             # use it, otherwise default to a-priori knowledge of the camera model
3129             # (assume that a valid DirectoryNumber is 100-999, and a valid FileNumber
3130             # is 0000-9999, although I have some samples with a DirectoryNumber of 99)
3131             Condition => q{
3132             if (length($$valPt) >= 0) {
3133             my ($dir, $file) = unpack('x6vv', $$valPt);
3134             my $littleEndian = ($dir >= 100 and $dir <= 999 and $file <= 9999);
3135             ($dir, $file) = unpack('x6nn', $$valPt);
3136             my $bigEndian = ($dir >= 100 and $dir <= 999 and $file <= 9999);
3137             return $littleEndian if $littleEndian xor $bigEndian;
3138             }
3139             return $$self{Model} =~ /^NIKON (D4S|D750|D810|D3300|D5200|D5300|D5500|D7100)$/;
3140             },
3141             SubDirectory => {
3142             TagTable => 'Image::ExifTool::Nikon::FileInfo',
3143             ByteOrder => 'LittleEndian',
3144             },
3145             },{
3146             Name => 'FileInfo',
3147             SubDirectory => {
3148             TagTable => 'Image::ExifTool::Nikon::FileInfo',
3149             ByteOrder => 'BigEndian',
3150             },
3151             }],
3152             0x00b9 => { #28
3153             Name => 'AFTune',
3154             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFTune' },
3155             },
3156             # 0x00ba - custom curve data? (ref 28?) (only in NEF images)
3157             0x00bb => { #forum6281
3158             Name => 'RetouchInfo',
3159             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::RetouchInfo' },
3160             },
3161             # 0x00bc - NEFThumbnail? (forum6281)
3162             0x00bd => { #PH (P6000)
3163             Name => 'PictureControlData',
3164             Writable => 'undef',
3165             Permanent => 0,
3166             Flags => [ 'Binary', 'Protected' ],
3167             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl' },
3168             },
3169             0x00bf => {
3170             Name => 'SilentPhotography',
3171             PrintConv => \%offOn,
3172             },
3173             0x00c3 => {
3174             Name => 'BarometerInfo',
3175             SubDirectory => {
3176             TagTable => 'Image::ExifTool::Nikon::BarometerInfo',
3177             # (little-endian in II EXIF, big-endian in MOV)
3178             },
3179             },
3180             0x0e00 => {
3181             Name => 'PrintIM',
3182             Description => 'Print Image Matching',
3183             Writable => 0,
3184             SubDirectory => {
3185             TagTable => 'Image::ExifTool::PrintIM::Main',
3186             },
3187             },
3188             # 0x0e01 - In D70 NEF files produced by Nikon Capture, the data for this tag extends 4 bytes
3189             # past the end of the maker notes. Very odd. I hope these 4 bytes aren't useful because
3190             # they will get lost by any utility that blindly copies the maker notes (not ExifTool) - PH
3191             0x0e01 => {
3192             Name => 'NikonCaptureData',
3193             Writable => 'undef',
3194             Permanent => 0,
3195             # (Drop because may be too large for JPEG images)
3196             Flags => [ 'Binary', 'Protected', 'Drop' ],
3197             Notes => q{
3198             this data is dropped when copying Nikon MakerNotes since it may be too large
3199             to fit in the EXIF segment of a JPEG image, but it may be copied as a block
3200             into existing Nikon MakerNotes later if desired
3201             },
3202             SubDirectory => {
3203             DirName => 'NikonCapture',
3204             TagTable => 'Image::ExifTool::NikonCapture::Main',
3205             },
3206             },
3207             # 0x0e05 written by Nikon Capture to NEF files, values of 1 and 2 - PH
3208             0x0e09 => { #12
3209             Name => 'NikonCaptureVersion',
3210             Writable => 'string',
3211             Permanent => 0,
3212             PrintConv => undef, # (avoid applying default print conversion to string)
3213             },
3214             # 0x0e0e is in D70 Nikon Capture files (not out-of-the-camera D70 files) - PH
3215             0x0e0e => { #PH
3216             Name => 'NikonCaptureOffsets',
3217             Writable => 'undef',
3218             Permanent => 0,
3219             SubDirectory => {
3220             TagTable => 'Image::ExifTool::Nikon::CaptureOffsets',
3221             Validate => '$val =~ /^0100/',
3222             Start => '$valuePtr + 4',
3223             },
3224             },
3225             0x0e10 => { #17
3226             Name => 'NikonScanIFD',
3227             Groups => { 1 => 'NikonScan', 2 => 'Image' },
3228             Flags => 'SubIFD',
3229             SubDirectory => {
3230             TagTable => 'Image::ExifTool::Nikon::Scan',
3231             Start => '$val',
3232             },
3233             },
3234             0x0e13 => [{ # PH/https://exiftool.org/forum/index.php/topic,2737.0.html
3235             Name => 'NikonCaptureEditVersions',
3236             Condition => '$self->Options("ExtractEmbedded")',
3237             Notes => q{
3238             the L option may be used to decode settings from the stored
3239             edit versions, otherwise this is extracted as a binary data block
3240             },
3241             Writable => 'undef',
3242             Permanent => 0,
3243             Drop => 1, # (may be too large for JPEG images)
3244             SubDirectory => {
3245             DirName => 'NikonCaptureEditVersions',
3246             TagTable => 'Image::ExifTool::NikonCapture::Main',
3247             ProcessProc => \&ProcessNikonCaptureEditVersions,
3248             WriteProc => sub { return undef }, # (writing not yet supported)
3249             },
3250             },{
3251             Name => 'NikonCaptureEditVersions',
3252             Writable => 'undef',
3253             Permanent => 0,
3254             Flags => [ 'Binary', 'Protected', 'Drop' ],
3255             }],
3256             0x0e1d => { #JD
3257             Name => 'NikonICCProfile',
3258             Flags => [ 'Binary', 'Protected' ],
3259             Writable => 'undef', # must be defined here so tag will be extracted if specified
3260             WriteCheck => q{
3261             require Image::ExifTool::ICC_Profile;
3262             return Image::ExifTool::ICC_Profile::ValidateICC(\$val);
3263             },
3264             SubDirectory => {
3265             DirName => 'NikonICCProfile',
3266             TagTable => 'Image::ExifTool::ICC_Profile::Main',
3267             },
3268             },
3269             0x0e1e => { #PH
3270             Name => 'NikonCaptureOutput',
3271             Writable => 'undef',
3272             Permanent => 0,
3273             Flags => [ 'Binary', 'Protected' ],
3274             SubDirectory => {
3275             TagTable => 'Image::ExifTool::Nikon::CaptureOutput',
3276             Validate => '$val =~ /^0100/',
3277             },
3278             },
3279             0x0e22 => { #28
3280             Name => 'NEFBitDepth',
3281             Writable => 'int16u',
3282             Count => 4,
3283             Protected => 1,
3284             PrintConv => {
3285             '0 0 0 0' => 'n/a (JPEG)',
3286             '8 8 8 0' => '8 x 3', # TIFF RGB
3287             '16 16 16 0' => '16 x 3', # TIFF 16-bit RGB
3288             '12 0 0 0' => 12,
3289             '14 0 0 0' => 14,
3290             },
3291             },
3292             );
3293              
3294             # NikonScan IFD entries (ref 17)
3295             %Image::ExifTool::Nikon::Scan = (
3296             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
3297             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
3298             WRITE_GROUP => 'NikonScan',
3299             WRITABLE => 1,
3300             GROUPS => { 0 => 'MakerNotes', 1 => 'NikonScan', 2 => 'Image' },
3301             VARS => { MINOR_ERRORS => 1 }, # this IFD is non-essential and often corrupted
3302             NOTES => 'This information is written by the Nikon Scan software.',
3303             0x02 => { Name => 'FilmType', Writable => 'string', },
3304             0x40 => { Name => 'MultiSample', Writable => 'string' },
3305             0x41 => { Name => 'BitDepth', Writable => 'int16u' },
3306             0x50 => {
3307             Name => 'MasterGain',
3308             Writable => 'rational64s',
3309             PrintConv => 'sprintf("%.2f",$val)',
3310             PrintConvInv => '$val',
3311             },
3312             0x51 => {
3313             Name => 'ColorGain',
3314             Writable => 'rational64s',
3315             Count => 3,
3316             PrintConv => 'sprintf("%.2f %.2f %.2f",split(" ",$val))',
3317             PrintConvInv => '$val',
3318             },
3319             0x60 => {
3320             Name => 'ScanImageEnhancer',
3321             Writable => 'int32u',
3322             PrintConv => \%offOn,
3323             },
3324             0x100 => { Name => 'DigitalICE', Writable => 'string' },
3325             0x110 => {
3326             Name => 'ROCInfo',
3327             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::ROC' },
3328             },
3329             0x120 => {
3330             Name => 'GEMInfo',
3331             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::GEM' },
3332             },
3333             0x200 => { Name => 'DigitalDEEShadowAdj', Writable => 'int32u' },
3334             0x201 => { Name => 'DigitalDEEThreshold', Writable => 'int32u' },
3335             0x202 => { Name => 'DigitalDEEHighlightAdj',Writable => 'int32u' },
3336             );
3337              
3338             # ref 17
3339             %Image::ExifTool::Nikon::ROC = (
3340             %binaryDataAttrs,
3341             FORMAT => 'int32u',
3342             GROUPS => { 0 => 'MakerNotes', 1 => 'NikonScan', 2 => 'Image' },
3343             0 => {
3344             Name => 'DigitalROC',
3345             ValueConv => '$val / 10',
3346             ValueConvInv => 'int($val * 10)',
3347             },
3348             );
3349              
3350             # ref 17
3351             %Image::ExifTool::Nikon::GEM = (
3352             %binaryDataAttrs,
3353             FORMAT => 'int32u',
3354             GROUPS => { 0 => 'MakerNotes', 1 => 'NikonScan', 2 => 'Image' },
3355             0 => {
3356             Name => 'DigitalGEM',
3357             ValueConv => '$val<95 ? $val/20-1 : 4',
3358             ValueConvInv => '$val == 4 ? 95 : int(($val + 1) * 20)',
3359             },
3360             );
3361              
3362             # Vibration Reduction information - PH (D300)
3363             %Image::ExifTool::Nikon::VRInfo = (
3364             %binaryDataAttrs,
3365             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3366             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3367             0 => {
3368             Name => 'VRInfoVersion',
3369             Format => 'undef[4]',
3370             Writable => 0,
3371             },
3372             4 => {
3373             Name => 'VibrationReduction',
3374             PrintConv => {
3375             0 => 'n/a', # (1V1 with a non-VR lens)
3376             1 => 'On',
3377             2 => 'Off',
3378             },
3379             },
3380             # 5 - values: 0, 1 (VR On), 2 (VR Off)
3381             6 => [{
3382             Name => 'VRMode',
3383             PrintConv => {
3384             0 => 'Off',
3385             1 => 'Normal', #39 (was 'Sport')
3386             3 => 'Sport', #39 (was 'Normal')
3387             },
3388             %infoZSeries,
3389             },{
3390             Name => 'VRMode',
3391             PrintConv => {
3392             0 => 'Normal',
3393             1 => 'On (1)', #PH (NC)
3394             2 => 'Active', # (1J1)
3395             3 => 'Sport', #PH (Z7)
3396             },
3397             }],
3398             # 7 - values: 0, 1
3399             8 => { #39
3400             Name => 'VRType',
3401             PrintConv => {
3402             2 => 'In-body', # (IBIS)
3403             3 => 'In-body + Lens', # (IBIS + VR)
3404             },
3405             },
3406             );
3407              
3408             # Face detection information - PH (S8100)
3409             %Image::ExifTool::Nikon::FaceDetect = (
3410             %binaryDataAttrs,
3411             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
3412             FORMAT => 'int16u',
3413             DATAMEMBER => [ 0x03 ],
3414             0x01 => {
3415             Name => 'FaceDetectFrameSize',
3416             Format => 'int16u[2]',
3417             },
3418             0x03 => {
3419             Name => 'FacesDetected',
3420             DataMember => 'FacesDetected',
3421             RawConv => '$$self{FacesDetected} = $val',
3422             },
3423             0x04 => {
3424             Name => 'Face1Position',
3425             Format => 'int16u[4]',
3426             RawConv => '$$self{FacesDetected} < 1 ? undef : $val',
3427             Notes => q{
3428             top, left, width and height of face detect area in coordinates of
3429             FaceDetectFrameSize
3430             },
3431             },
3432             0x08 => {
3433             Name => 'Face2Position',
3434             Format => 'int16u[4]',
3435             RawConv => '$$self{FacesDetected} < 2 ? undef : $val',
3436             },
3437             0x0c => {
3438             Name => 'Face3Position',
3439             Format => 'int16u[4]',
3440             RawConv => '$$self{FacesDetected} < 3 ? undef : $val',
3441             },
3442             0x10 => {
3443             Name => 'Face4Position',
3444             Format => 'int16u[4]',
3445             RawConv => '$$self{FacesDetected} < 4 ? undef : $val',
3446             },
3447             0x14 => {
3448             Name => 'Face5Position',
3449             Format => 'int16u[4]',
3450             RawConv => '$$self{FacesDetected} < 5 ? undef : $val',
3451             },
3452             0x18 => {
3453             Name => 'Face6Position',
3454             Format => 'int16u[4]',
3455             RawConv => '$$self{FacesDetected} < 6 ? undef : $val',
3456             },
3457             0x1c => {
3458             Name => 'Face7Position',
3459             Format => 'int16u[4]',
3460             RawConv => '$$self{FacesDetected} < 7 ? undef : $val',
3461             },
3462             0x20 => {
3463             Name => 'Face8Position',
3464             Format => 'int16u[4]',
3465             RawConv => '$$self{FacesDetected} < 8 ? undef : $val',
3466             },
3467             0x24 => {
3468             Name => 'Face9Position',
3469             Format => 'int16u[4]',
3470             RawConv => '$$self{FacesDetected} < 9 ? undef : $val',
3471             },
3472             0x28 => {
3473             Name => 'Face10Position',
3474             Format => 'int16u[4]',
3475             RawConv => '$$self{FacesDetected} < 10 ? undef : $val',
3476             },
3477             0x2c => {
3478             Name => 'Face11Position',
3479             Format => 'int16u[4]',
3480             RawConv => '$$self{FacesDetected} < 11 ? undef : $val',
3481             },
3482             0x30 => {
3483             Name => 'Face12Position',
3484             Format => 'int16u[4]',
3485             RawConv => '$$self{FacesDetected} < 12 ? undef : $val',
3486             },
3487             );
3488              
3489             # Picture Control information - PH (D300,P6000)
3490             %Image::ExifTool::Nikon::PictureControl = (
3491             %binaryDataAttrs,
3492             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3493             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3494             0 => {
3495             Name => 'PictureControlVersion',
3496             Format => 'undef[4]',
3497             Writable => 0,
3498             },
3499             4 => {
3500             Name => 'PictureControlName',
3501             Format => 'string[20]',
3502             # make lower case with a leading capital for each word
3503             PrintConv => \&FormatString,
3504             PrintConvInv => 'uc($val)',
3505             },
3506             24 => {
3507             Name => 'PictureControlBase',
3508             Format => 'string[20]',
3509             PrintConv => \&FormatString,
3510             PrintConvInv => 'uc($val)',
3511             },
3512             # beginning at byte 44, there is some interesting information.
3513             # here are the observed bytes for each PictureControlMode:
3514             # 44 45 46 47 48 49 50 51 52 53 54 55 56 57
3515             # STANDARD 00 01 00 00 00 80 83 80 80 80 80 ff ff ff
3516             # NEUTRAL 03 c2 00 00 00 ff 82 80 80 80 80 ff ff ff
3517             # VIVID 00 c3 00 00 00 80 84 80 80 80 80 ff ff ff
3518             # MONOCHROME 06 4d 00 01 02 ff 82 80 80 ff ff 80 80 ff
3519             # Neutral2 03 c2 01 00 02 ff 80 7f 81 00 7f ff ff ff (custom)
3520             # (note that up to 9 different custom picture controls can be stored)
3521             # --> bytes 44 and 45 are swapped if CaptureNX changes the byte order
3522             #
3523             48 => { #21
3524             Name => 'PictureControlAdjust',
3525             PrintConv => {
3526             0 => 'Default Settings',
3527             1 => 'Quick Adjust',
3528             2 => 'Full Control',
3529             },
3530             },
3531             49 => {
3532             Name => 'PictureControlQuickAdjust',
3533             # settings: -2 to +2 (n/a for Neutral and Monochrome modes)
3534             DelValue => 0xff,
3535             ValueConv => '$val - 0x80',
3536             ValueConvInv => '$val + 0x80',
3537             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3538             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3539             },
3540             50 => {
3541             Name => 'Sharpness',
3542             # settings: 0 to 9, Auto
3543             ValueConv => '$val - 0x80',
3544             ValueConvInv => '$val + 0x80',
3545             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"No Sharpening","%d")',
3546             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3547             },
3548             51 => {
3549             Name => 'Contrast',
3550             # settings: -3 to +3, Auto
3551             ValueConv => '$val - 0x80',
3552             ValueConvInv => '$val + 0x80',
3553             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3554             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3555             },
3556             52 => {
3557             Name => 'Brightness',
3558             # settings: -1 to +1
3559             ValueConv => '$val - 0x80',
3560             ValueConvInv => '$val + 0x80',
3561             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3562             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3563             },
3564             53 => {
3565             Name => 'Saturation',
3566             # settings: -3 to +3, Auto (n/a for Monochrome mode)
3567             DelValue => 0xff,
3568             ValueConv => '$val - 0x80',
3569             ValueConvInv => '$val + 0x80',
3570             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3571             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3572             },
3573             54 => {
3574             Name => 'HueAdjustment',
3575             # settings: -3 to +3 (n/a for Monochrome mode)
3576             DelValue => 0xff,
3577             ValueConv => '$val - 0x80',
3578             ValueConvInv => '$val + 0x80',
3579             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None")',
3580             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3581             },
3582             55 => {
3583             Name => 'FilterEffect',
3584             # settings: Off,Yellow,Orange,Red,Green (n/a for color modes)
3585             DelValue => 0xff,
3586             PrintHex => 1,
3587             PrintConv => {
3588             0x80 => 'Off',
3589             0x81 => 'Yellow',
3590             0x82 => 'Orange',
3591             0x83 => 'Red',
3592             0x84 => 'Green',
3593             0xff => 'n/a',
3594             },
3595             },
3596             56 => {
3597             Name => 'ToningEffect',
3598             # settings: B&W,Sepia,Cyanotype,Red,Yellow,Green,Blue-Green,Blue,
3599             # Purple-Blue,Red-Purple (n/a for color modes)
3600             DelValue => 0xff,
3601             PrintHex => 1,
3602             PrintConvColumns => 2,
3603             PrintConv => {
3604             0x80 => 'B&W',
3605             0x81 => 'Sepia',
3606             0x82 => 'Cyanotype',
3607             0x83 => 'Red',
3608             0x84 => 'Yellow',
3609             0x85 => 'Green',
3610             0x86 => 'Blue-green',
3611             0x87 => 'Blue',
3612             0x88 => 'Purple-blue',
3613             0x89 => 'Red-purple',
3614             0xff => 'n/a',
3615             # 0x04 - seen for D810 (PH)
3616             },
3617             },
3618             57 => { #21
3619             Name => 'ToningSaturation',
3620             # settings: B&W,Sepia,Cyanotype,Red,Yellow,Green,Blue-Green,Blue,
3621             # Purple-Blue,Red-Purple (n/a unless ToningEffect is used)
3622             DelValue => 0xff,
3623             ValueConv => '$val - 0x80',
3624             ValueConvInv => '$val + 0x80',
3625             PrintConv => '$val==0x7f ? "n/a" : $val',
3626             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3627             },
3628             );
3629              
3630             # Picture Control information V2 (ref 28)
3631             %Image::ExifTool::Nikon::PictureControl2 = (
3632             %binaryDataAttrs,
3633             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3634             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3635             0 => {
3636             Name => 'PictureControlVersion',
3637             Format => 'undef[4]',
3638             Writable => 0,
3639             },
3640             4 => {
3641             Name => 'PictureControlName',
3642             Format => 'string[20]',
3643             # make lower case with a leading capital for each word
3644             PrintConv => \&FormatString,
3645             PrintConvInv => 'uc($val)',
3646             },
3647             24 => {
3648             Name => 'PictureControlBase',
3649             Format => 'string[20]',
3650             PrintConv => \&FormatString,
3651             PrintConvInv => 'uc($val)',
3652             },
3653             # beginning at byte 44, there is some interesting information.
3654             # here are the observed bytes for each PictureControlMode:
3655             # 44 45 46 47 48 49 50 51 52 53 54 55 56 57
3656             # STANDARD 00 01 00 00 00 80 83 80 80 80 80 ff ff ff
3657             # NEUTRAL 03 c2 00 00 00 ff 82 80 80 80 80 ff ff ff
3658             # VIVID 00 c3 00 00 00 80 84 80 80 80 80 ff ff ff
3659             # MONOCHROME 06 4d 00 01 02 ff 82 80 80 ff ff 80 80 ff
3660             # Neutral2 03 c2 01 00 02 ff 80 7f 81 00 7f ff ff ff (custom)
3661             # (note that up to 9 different custom picture controls can be stored)
3662             # --> bytes 44 and 45 are swapped if CaptureNX changes the byte order
3663             #
3664             48 => { #21
3665             Name => 'PictureControlAdjust',
3666             PrintConv => {
3667             0 => 'Default Settings',
3668             1 => 'Quick Adjust',
3669             2 => 'Full Control',
3670             },
3671             },
3672             49 => {
3673             Name => 'PictureControlQuickAdjust',
3674             # settings: -2 to +2 (n/a for Neutral and Monochrome modes)
3675             DelValue => 0xff,
3676             ValueConv => '$val - 0x80',
3677             ValueConvInv => '$val + 0x80',
3678             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3679             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3680             },
3681             51 => {
3682             Name => 'Sharpness',
3683             DelValue => 0xff,
3684             ValueConv => '$val - 0x80',
3685             ValueConvInv => '$val + 0x80',
3686             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3687             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3688             },
3689             53 => {
3690             Name => 'Clarity',
3691             DelValue => 0xff,
3692             ValueConv => '$val - 0x80',
3693             ValueConvInv => '$val + 0x80',
3694             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3695             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv2($val,4)',
3696             },
3697             55 => {
3698             Name => 'Contrast',
3699             DelValue => 0xff,
3700             ValueConv => '$val - 0x80',
3701             ValueConvInv => '$val + 0x80',
3702             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3703             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3704             },
3705             57 => { #21
3706             Name => 'Brightness',
3707             # settings: -1 to +1
3708             ValueConv => '$val - 0x80',
3709             ValueConvInv => '$val + 0x80',
3710             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,undef,"%.2f",4)',
3711             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3712             },
3713             59 => {
3714             Name => 'Saturation',
3715             DelValue => 0xff,
3716             ValueConv => '$val - 0x80',
3717             ValueConvInv => '$val + 0x80',
3718             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3719             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3720             },
3721             61 => {
3722             Name => 'Hue',
3723             DelValue => 0xff,
3724             ValueConv => '$val - 0x80',
3725             ValueConvInv => '$val + 0x80',
3726             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3727             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3728             },
3729             63 => {
3730             Name => 'FilterEffect',
3731             # settings: Off,Yellow,Orange,Red,Green (n/a for color modes)
3732             DelValue => 0xff,
3733             PrintHex => 1,
3734             PrintConv => {
3735             0x80 => 'Off',
3736             0x81 => 'Yellow',
3737             0x82 => 'Orange',
3738             0x83 => 'Red',
3739             0x84 => 'Green',
3740             0xff => 'n/a',
3741             },
3742             },
3743             64 => {
3744             Name => 'ToningEffect',
3745             # settings: B&W,Sepia,Cyanotype,Red,Yellow,Green,Blue-Green,Blue,
3746             # Purple-Blue,Red-Purple (n/a for color modes)
3747             DelValue => 0xff,
3748             PrintHex => 1,
3749             PrintConvColumns => 2,
3750             PrintConv => {
3751             0x80 => 'B&W',
3752             0x81 => 'Sepia',
3753             0x82 => 'Cyanotype',
3754             0x83 => 'Red',
3755             0x84 => 'Yellow',
3756             0x85 => 'Green',
3757             0x86 => 'Blue-green',
3758             0x87 => 'Blue',
3759             0x88 => 'Purple-blue',
3760             0x89 => 'Red-purple',
3761             0xff => 'n/a',
3762             },
3763             },
3764             65 => {
3765             Name => 'ToningSaturation',
3766             DelValue => 0xff,
3767             ValueConv => '$val - 0x80', #$val == 0x7f (n/a) for "B&W"
3768             ValueConvInv => '$val + 0x80',
3769             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3770             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3771              
3772             },
3773             );
3774              
3775             # Picture Control information V3 (ref PH, Z7)
3776             %Image::ExifTool::Nikon::PictureControl3 = (
3777             %binaryDataAttrs,
3778             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3779             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3780             0 => {
3781             Name => 'PictureControlVersion',
3782             Format => 'undef[4]',
3783             Writable => 0,
3784             },
3785             8 => {
3786             Name => 'PictureControlName',
3787             Format => 'string[20]',
3788             # make lower case with a leading capital for each word
3789             PrintConv => \&FormatString,
3790             PrintConvInv => 'uc($val)',
3791             },
3792             # 48 - looks like PictureControl2 byte 45
3793             28 => {
3794             Name => 'PictureControlBase',
3795             Format => 'string[20]',
3796             PrintConv => \&FormatString,
3797             PrintConvInv => 'uc($val)',
3798             },
3799             54 => { # (NC)
3800             Name => 'PictureControlAdjust',
3801             PrintConv => {
3802             0 => 'Default Settings',
3803             1 => 'Quick Adjust',
3804             2 => 'Full Control',
3805             },
3806             },
3807             55 => { # (NC)
3808             Name => 'PictureControlQuickAdjust',
3809             DelValue => 0xff,
3810             ValueConv => '$val - 0x80',
3811             ValueConvInv => '$val + 0x80',
3812             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3813             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3814             },
3815             57 => {
3816             Name => 'Sharpness',
3817             DelValue => 0xff,
3818             ValueConv => '$val - 0x80',
3819             ValueConvInv => '$val + 0x80',
3820             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3821             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3822             },
3823             59 => {
3824             Name => 'MidRangeSharpness',
3825             DelValue => 0xff,
3826             ValueConv => '$val - 0x80',
3827             ValueConvInv => '$val + 0x80',
3828             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3829             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3830             },
3831             61 => {
3832             Name => 'Clarity',
3833             DelValue => 0xff,
3834             ValueConv => '$val - 0x80',
3835             ValueConvInv => '$val + 0x80',
3836             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3837             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv2($val,4)',
3838             },
3839             63 => {
3840             Name => 'Contrast',
3841             DelValue => 0xff,
3842             ValueConv => '$val - 0x80',
3843             ValueConvInv => '$val + 0x80',
3844             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3845             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3846             },
3847             65 => { #21
3848             Name => 'Brightness',
3849             ValueConv => '$val - 0x80',
3850             ValueConvInv => '$val + 0x80',
3851             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,undef,"%.2f",4)',
3852             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3853             },
3854             67 => {
3855             Name => 'Saturation',
3856             DelValue => 0xff,
3857             ValueConv => '$val - 0x80',
3858             ValueConvInv => '$val + 0x80',
3859             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3860             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3861             },
3862             69 => {
3863             Name => 'Hue',
3864             DelValue => 0xff,
3865             ValueConv => '$val - 0x80',
3866             ValueConvInv => '$val + 0x80',
3867             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3868             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3869             },
3870             71 => { # (NC)
3871             Name => 'FilterEffect',
3872             DelValue => 0xff,
3873             PrintHex => 1,
3874             PrintConv => {
3875             0x80 => 'Off',
3876             0x81 => 'Yellow',
3877             0x82 => 'Orange',
3878             0x83 => 'Red',
3879             0x84 => 'Green',
3880             0xff => 'n/a',
3881             },
3882             },
3883             72 => { # (NC)
3884             Name => 'ToningEffect',
3885             DelValue => 0xff,
3886             PrintHex => 1,
3887             PrintConvColumns => 2,
3888             PrintConv => {
3889             0x80 => 'B&W',
3890             0x81 => 'Sepia',
3891             0x82 => 'Cyanotype',
3892             0x83 => 'Red',
3893             0x84 => 'Yellow',
3894             0x85 => 'Green',
3895             0x86 => 'Blue-green',
3896             0x87 => 'Blue',
3897             0x88 => 'Purple-blue',
3898             0x89 => 'Red-purple',
3899             0xff => 'n/a',
3900             },
3901             },
3902             73 => { # (NC)
3903             Name => 'ToningSaturation',
3904             DelValue => 0xff,
3905             ValueConv => '$val - 0x80',
3906             ValueConvInv => '$val + 0x80',
3907             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3908             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3909              
3910             },
3911             );
3912              
3913             # Unknown Picture Control information
3914             %Image::ExifTool::Nikon::PictureControlUnknown = (
3915             %binaryDataAttrs,
3916             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3917             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3918             0 => {
3919             Name => 'PictureControlVersion',
3920             Format => 'undef[4]',
3921             Writable => 0,
3922             },
3923             );
3924              
3925             # World Time information - JD (D300)
3926             %Image::ExifTool::Nikon::WorldTime = (
3927             %binaryDataAttrs,
3928             GROUPS => { 0 => 'MakerNotes', 2 => 'Time' },
3929             0 => {
3930             Name => 'TimeZone',
3931             Format => 'int16s',
3932             PrintConv => q{
3933             my $sign = $val < 0 ? '-' : '+';
3934             my $h = int(abs($val) / 60);
3935             sprintf("%s%.2d:%.2d", $sign, $h, abs($val)-60*$h);
3936             },
3937             PrintConvInv => q{
3938             $val =~ /Z$/ and return 0;
3939             $val =~ /([-+])(\d{1,2}):?(\d{2})$/ and return $1 . ($2 * 60 + $3);
3940             $val =~ /^(\d{2})(\d{2})$/ and return $1 * 60 + $2;
3941             return undef;
3942             },
3943             },
3944             2 => {
3945             Name => 'DaylightSavings',
3946             PrintConv => { 0 => 'No', 1 => 'Yes' },
3947             },
3948             3 => {
3949             Name => 'DateDisplayFormat',
3950             PrintConv => {
3951             0 => 'Y/M/D',
3952             1 => 'M/D/Y',
3953             2 => 'D/M/Y',
3954             },
3955             },
3956             );
3957              
3958             # ISO information - PH (D300)
3959             %Image::ExifTool::Nikon::ISOInfo = (
3960             %binaryDataAttrs,
3961             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3962             0 => {
3963             Name => 'ISO',
3964             Notes => 'val = 100 * 2**(raw/12-5)',
3965             Priority => 0, # because people like to see rounded-off values if they exist
3966             ValueConv => '100*exp(($val/12-5)*log(2))',
3967             ValueConvInv => '(log($val/100)/log(2)+5)*12',
3968             PrintConv => 'int($val + 0.5)',
3969             PrintConvInv => '$val',
3970             },
3971             # 1 - 0x01
3972             # 2 - 0x0c (probably the ISO divisor above)
3973             # 3 - 0x00
3974             4 => {
3975             Name => 'ISOExpansion',
3976             Format => 'int16u',
3977             PrintHex => 1,
3978             PrintConvColumns => 2,
3979             PrintConv => {
3980             0x000 => 'Off',
3981             0x101 => 'Hi 0.3',
3982             0x102 => 'Hi 0.5',
3983             0x103 => 'Hi 0.7',
3984             0x104 => 'Hi 1.0',
3985             0x105 => 'Hi 1.3', # (Hi 1.3-1.7 may be possible with future models)
3986             0x106 => 'Hi 1.5',
3987             0x107 => 'Hi 1.7',
3988             0x108 => 'Hi 2.0', #(NC) - D3 should have this mode
3989             0x109 => 'Hi 2.3', #IB
3990             0x10a => 'Hi 2.5', #IB
3991             0x10b => 'Hi 2.7', #IB
3992             0x10c => 'Hi 3.0', #IB
3993             0x10d => 'Hi 3.3', #IB
3994             0x10e => 'Hi 3.5', #IB
3995             0x10f => 'Hi 3.7', #IB
3996             0x110 => 'Hi 4.0', #IB
3997             0x111 => 'Hi 4.3', #IB
3998             0x112 => 'Hi 4.5', #IB
3999             0x113 => 'Hi 4.7', #IB
4000             0x114 => 'Hi 5.0', #IB
4001             0x201 => 'Lo 0.3',
4002             0x202 => 'Lo 0.5',
4003             0x203 => 'Lo 0.7',
4004             0x204 => 'Lo 1.0',
4005             },
4006             },
4007             # bytes 6-11 same as 0-4 in my samples (why is this duplicated?)
4008             6 => {
4009             Name => 'ISO2',
4010             Notes => 'val = 100 * 2**(raw/12-5)',
4011             ValueConv => '100*exp(($val/12-5)*log(2))',
4012             ValueConvInv => '(log($val/100)/log(2)+5)*12',
4013             PrintConv => 'int($val + 0.5)',
4014             PrintConvInv => '$val',
4015             },
4016             # 7 - 0x01
4017             # 8 - 0x0c (probably the ISO divisor above)
4018             # 9 - 0x00
4019             10 => {
4020             Name => 'ISOExpansion2',
4021             Format => 'int16u',
4022             PrintHex => 1,
4023             PrintConvColumns => 2,
4024             PrintConv => {
4025             0x000 => 'Off',
4026             0x101 => 'Hi 0.3',
4027             0x102 => 'Hi 0.5',
4028             0x103 => 'Hi 0.7',
4029             0x104 => 'Hi 1.0',
4030             0x105 => 'Hi 1.3', # (Hi 1.3-1.7 may be possible with future models)
4031             0x106 => 'Hi 1.5',
4032             0x107 => 'Hi 1.7',
4033             0x108 => 'Hi 2.0', #(NC) - D3 should have this mode
4034             0x201 => 'Lo 0.3',
4035             0x202 => 'Lo 0.5',
4036             0x203 => 'Lo 0.7',
4037             0x204 => 'Lo 1.0',
4038             },
4039             },
4040             # bytes 12-13: 00 00
4041             );
4042              
4043             # distortion information - PH (D5000)
4044             %Image::ExifTool::Nikon::DistortInfo = (
4045             %binaryDataAttrs,
4046             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4047             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
4048             0 => {
4049             Name => 'DistortionVersion',
4050             Format => 'undef[4]',
4051             Writable => 0,
4052             Unknown => 1,
4053             },
4054             4 => {
4055             Name => 'AutoDistortionControl',
4056             PrintConv => {
4057             0 => 'Off',
4058             1 => 'On',
4059             2 => 'On (underwater)', # (1AW1)
4060             },
4061             },
4062             );
4063              
4064             # unknown information - PH (D7000)
4065             %Image::ExifTool::Nikon::UnknownInfo = (
4066             %binaryDataAttrs,
4067             FORMAT => 'int32u',
4068             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4069             0 => {
4070             Name => 'UnknownInfoVersion',
4071             Condition => '$$valPt =~ /^\d{4}/',
4072             Format => 'undef[4]',
4073             Writable => 0,
4074             Unknown => 1,
4075             },
4076             # (bytes 6/7 and 8/9 are swapped if CaptureNX changes the byte order)
4077             );
4078              
4079             # more unknown information - PH (D7000)
4080             %Image::ExifTool::Nikon::UnknownInfo2 = (
4081             %binaryDataAttrs,
4082             FORMAT => 'int32u',
4083             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4084             0 => {
4085             Name => 'UnknownInfo2Version',
4086             Condition => '$$valPt =~ /^\d{4}/',
4087             Format => 'undef[4]',
4088             Writable => 0,
4089             Unknown => 1,
4090             },
4091             # (byte 4 may be changed from 1 to 0 when rewritten by CaptureNX)
4092             );
4093              
4094             # Nikon AF information (ref 13)
4095             %Image::ExifTool::Nikon::AFInfo = (
4096             %binaryDataAttrs,
4097             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4098             0 => {
4099             Name => 'AFAreaMode',
4100             PrintConv => {
4101             0 => 'Single Area',
4102             1 => 'Dynamic Area',
4103             2 => 'Dynamic Area (closest subject)',
4104             3 => 'Group Dynamic',
4105             4 => 'Single Area (wide)',
4106             5 => 'Dynamic Area (wide)',
4107             },
4108             },
4109             1 => {
4110             Name => 'AFPoint',
4111             Notes => 'in some focus modes this value is not meaningful',
4112             PrintConvColumns => 2,
4113             PrintConv => {
4114             0 => 'Center',
4115             1 => 'Top',
4116             2 => 'Bottom',
4117             3 => 'Mid-left',
4118             4 => 'Mid-right',
4119             5 => 'Upper-left',
4120             6 => 'Upper-right',
4121             7 => 'Lower-left',
4122             8 => 'Lower-right',
4123             9 => 'Far Left',
4124             10 => 'Far Right',
4125             # (have also seen values of 11 and 12 when AFPointsInFocus is "(none)" - PH S3500)
4126             },
4127             },
4128             2 => {
4129             Name => 'AFPointsInFocus',
4130             Format => 'int16u',
4131             PrintConvColumns => 2,
4132             PrintConv => \%afPoints11,
4133             },
4134             );
4135              
4136             %Image::ExifTool::Nikon::AFInfo2V0100 = (
4137             %binaryDataAttrs,
4138             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4139             DATAMEMBER => [ 0, 4, 6 ],
4140             NOTES => q{
4141             AF information for Nikon cameras with LiveView that were introduced 2007
4142             thru 2015 (and the D5600 in 2016), including D3, D4, D3000, D3100-D3300,
4143             D5000-D5600, D6x0, D700, D7000, D7100, D810
4144             },
4145             0 => {
4146             Name => 'AFInfo2Version',
4147             Format => 'undef[4]',
4148             Writable => 0,
4149             RawConv => '$$self{AFInfo2Version} = $val',
4150             },
4151             4 => {
4152             Name => 'AFDetectionMethod', #specifies phase detect or contrast detect
4153             RawConv => '$$self{AFDetectionMethod} = $val',
4154             PrintConv => \%aFDetectionMethod ,
4155             },
4156             5 => [
4157             {
4158             Name => 'AFAreaMode',
4159             Condition => '$$self{AFDetectionMethod} == 0',
4160             PrintConv => \%aFAreaModePD, #phase detect
4161             },
4162             {
4163             Name => 'AFAreaMode',
4164             PrintConv => \%aFAreaModeCD, #contrast detect
4165             },
4166             ],
4167             6 => {
4168             Name => 'FocusPointSchema',
4169             RawConv => '$$self{FocusPointSchema} = $val',
4170             #Hidden => 1,
4171             PrintConv => {
4172             0 => 'Off', # LiveView or manual focus or no focus
4173             1 => '51-point', # (D3/D3S/D3X/D4/D4S/D300/D300S/D700/D750/D800/D800E/D810/D7100/D7200)
4174             2 => '11-point', # (D90/D3000/D3100/D3200/D3300/D5000/D5100)
4175             3 => '39-point', # (D600/D610/D5200/D5300/D5500/D5600/D7000/Df)
4176             },
4177             },
4178             7 => [
4179             { #PH/JD
4180             Name => 'PrimaryAFPoint',
4181             Condition => '$$self{FocusPointSchema} == 1', #51 focus-point models
4182             Notes => q{
4183             models with 51-point AF -- 5 rows (A-E) and 11 columns (1-11): D3, D3S, D3X,
4184             D4, D4S, D300, D300S, D700, D750, D800, D800E, D810, D7100 and D7200
4185             },
4186             PrintConvColumns => 5,
4187             PrintConv => {
4188             0 => '(none)',
4189             %afPoints51,
4190             1 => 'C6 (Center)', # (add " (Center)" to central point)
4191             },
4192             },{ #10
4193             Name => 'PrimaryAFPoint',
4194             Notes => 'models with 11-point AF: D90, D3000-D3300, D5000 and D5100',
4195             Condition => '$$self{FocusPointSchema} == 2', #11 focus-point models
4196             PrintConvColumns => 2,
4197             PrintConv => {
4198             0 => '(none)',
4199             1 => 'Center',
4200             2 => 'Top',
4201             3 => 'Bottom',
4202             4 => 'Mid-left',
4203             5 => 'Upper-left',
4204             6 => 'Lower-left',
4205             7 => 'Far Left',
4206             8 => 'Mid-right',
4207             9 => 'Upper-right',
4208             10 => 'Lower-right',
4209             11 => 'Far Right',
4210             },
4211             },{ #29
4212             Name => 'PrimaryAFPoint',
4213             Condition => '$$self{FocusPointSchema} == 3', #39 focus-point models
4214             Notes => 'models with 39-point AF: D600, D610, D5200-D5600, D7000 and Df',
4215             PrintConvColumns => 5,
4216             PrintConv => {
4217             0 => '(none)',
4218             %afPoints39,
4219             1 => 'C6 (Center)', # (add " (Center)" to central point)
4220             },
4221             },
4222             {
4223             Name => 'PrimaryAFPoint',
4224             Condition => '$$self{FocusPointSchema} == 0', #LiveView or manual focus or no focus (reporting only for purposes of backward compatibility with v13.19 and earlier)
4225             PrintConv => { 0 => '(none)', },
4226             },
4227             ],
4228             8 => [
4229             { #JD/PH
4230             Name => 'AFPointsUsed',
4231             Condition => '$$self{FocusPointSchema} == 1', # 51 focus-point models
4232             Notes => q{
4233             models with 51-point AF -- 5 rows: A1-9, B1-11, C1-11, D1-11, E1-9. Center
4234             point is C6
4235             },
4236             Format => 'undef[7]',
4237             ValueConv => 'join(" ", unpack("H2"x7, $val))',
4238             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4239             PrintConv => sub { PrintAFPoints(shift, \%afPoints51) },
4240             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints51) },
4241             },
4242             { #10
4243             Name => 'AFPointsUsed',
4244             Condition => '$$self{FocusPointSchema} == 2', # 11 focus-point models
4245             Notes => 'models with 11-point AF',
4246             # read as int16u in little-endian byte order
4247             Format => 'undef[2]',
4248             ValueConv => 'unpack("v",$val)',
4249             ValueConvInv => 'pack("v",$val)',
4250             PrintConvColumns => 2,
4251             PrintConv => {
4252             0 => '(none)',
4253             0x7ff => 'All 11 Points',
4254             BITMASK => {
4255             0 => 'Center',
4256             1 => 'Top',
4257             2 => 'Bottom',
4258             3 => 'Mid-left',
4259             4 => 'Upper-left',
4260             5 => 'Lower-left',
4261             6 => 'Far Left',
4262             7 => 'Mid-right',
4263             8 => 'Upper-right',
4264             9 => 'Lower-right',
4265             10 => 'Far Right',
4266             },
4267             },
4268             },
4269             { #29/PH
4270             Name => 'AFPointsUsed',
4271             Condition => '$$self{FocusPointSchema} == 3', # 39 focus-point models
4272             Notes => q{
4273             models with 39-point AF -- 5 rows: A1-3, B1-11, C1-11, D1-11, E1-3. Center
4274             point is C6
4275             },
4276             Format => 'undef[5]',
4277             ValueConv => 'join(" ", unpack("H2"x5, $val))',
4278             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4279             PrintConv => sub { PrintAFPoints(shift, \%afPoints39) },
4280             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints39) },
4281             },
4282             {
4283             Name => 'AFPointsUsed',
4284             Condition => '$$self{FocusPointSchema} == 0', #LiveView or manual focus or no focus (reporting only for purposes of backward compatibility with v13.19 and earlier)
4285             PrintConv => { 0 => '(none)', },
4286             },
4287             ],
4288             0x10 => { #PH (D90 and D5000)
4289             Name => 'AFImageWidth',
4290             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4291             Format => 'int16u',
4292             RawConv => '$val ? $val : undef',
4293             Notes => 'this and the following tags are valid only for contrast-detect AF',
4294             },
4295             0x12 => { #PH
4296             Name => 'AFImageHeight',
4297             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4298             Format => 'int16u',
4299             RawConv => '$val ? $val : undef',
4300             },
4301             0x14 => { #PH
4302             Name => 'AFAreaXPosition',
4303             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4304             Notes => 'center of AF area in AFImage coordinates',
4305             Format => 'int16u',
4306             RawConv => '$val ? $val : undef',
4307             },
4308             0x16 => { #PH
4309             Name => 'AFAreaYPosition',
4310             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4311             Format => 'int16u',
4312             RawConv => '$val ? $val : undef',
4313             },
4314             0x18 => { #PH
4315             Name => 'AFAreaWidth',
4316             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4317             Format => 'int16u',
4318             Notes => 'size of AF area in AFImage coordinates',
4319             RawConv => '$val ? $val : undef',
4320             },
4321             0x1a => { #PH
4322             Name => 'AFAreaHeight',
4323             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4324             Format => 'int16u',
4325             RawConv => '$val ? $val : undef',
4326             },
4327             0x1c => [
4328             { #PH
4329             Name => 'ContrastDetectAFInFocus',
4330             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4331             PrintConv => { 0 => 'No', 1 => 'Yes' },
4332             },{ #PH (D500, see forum11190)
4333             Name => 'AFPointsSelected',
4334             Condition => '$$self{FocusPointSchema} == 7',
4335             Format => 'undef[20]',
4336             ValueConv => 'join(" ", unpack("H2"x20, $val))',
4337             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4338             PrintConv => sub { PrintAFPoints(shift, \%afPoints153) },
4339             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints153) },
4340             },
4341             # (#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]
4342             #{ #PH (D3400) (NC "selected")
4343             # Name => 'AFPointsSelected',
4344             # Condition => '$$self{FocusPointSchema} == 2',
4345             # Format => 'int16u',
4346             # PrintConv => \%afPoints11,
4347             #},
4348             ],
4349             );
4350              
4351             %Image::ExifTool::Nikon::AFInfo2V0101 = (
4352             %binaryDataAttrs,
4353             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4354             DATAMEMBER => [ 0, 4, 5, 6 ],
4355             NOTES => q{
4356             AF information for Nikon cameras D5, D500, D850, D3400, D3500 and D7500
4357             },
4358             0 => {
4359             Name => 'AFInfo2Version',
4360             Format => 'undef[4]',
4361             Writable => 0,
4362             RawConv => '$$self{AFInfo2Version} = $val',
4363             },
4364             4 => {
4365             Name => 'AFDetectionMethod',
4366             RawConv => '$$self{AFDetectionMethod} = $val',
4367             PrintConv => \%aFDetectionMethod,
4368             },
4369             5 => [
4370             {
4371             Name => 'AFAreaMode',
4372             Condition => '$$self{AFDetectionMethod} == 0',
4373             RawConv => '$$self{AFAreaMode} = $val',
4374             PrintConv => \%aFAreaModePD, #phase detect
4375             },
4376             {
4377             Name => 'AFAreaMode',
4378             RawConv => '$$self{AFAreaMode} = $val',
4379             PrintConv => \%aFAreaModeCD, #contrast detect
4380             },
4381             ],
4382             6 => {
4383             Name => 'FocusPointSchema',
4384             RawConv => '$$self{FocusPointSchema} = $val',
4385             #Hidden => 1,
4386             PrintConv => {
4387             0 => 'Off', # LiveView or manual focus or no focus
4388             1 => '51-point', # (D7500)
4389             2 => '11-point', # (D3400/D3500)
4390             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)
4391             },
4392             },
4393             8 => [
4394             { #JD/PH
4395             Name => 'AFPointsUsed',
4396             Condition => '$$self{FocusPointSchema} == 1', #51 focus-point models
4397             Notes => q{
4398             models with 51-point AF -- 5 rows: A1-9, B1-11, C1-11, D1-11, E1-9. Center
4399             point is C6
4400             },
4401             Format => 'undef[7]',
4402             ValueConv => 'join(" ", unpack("H2"x7, $val))',
4403             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4404             PrintConv => sub { PrintAFPoints(shift, \%afPoints51) },
4405             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints51) },
4406             },{ #10
4407             Name => 'AFPointsUsed',
4408             Condition => '$$self{FocusPointSchema} == 2', #11 focus-point models
4409             Notes => 'models with 11-point AF',
4410             # read as int16u in little-endian byte order
4411             Format => 'undef[2]',
4412             ValueConv => 'unpack("v",$val)',
4413             ValueConvInv => 'pack("v",$val)',
4414             PrintConvColumns => 2,
4415             PrintConv => {
4416             0 => '(none)',
4417             0x7ff => 'All 11 Points',
4418             BITMASK => {
4419             0 => 'Center',
4420             1 => 'Top',
4421             2 => 'Bottom',
4422             3 => 'Mid-left',
4423             4 => 'Upper-left',
4424             5 => 'Lower-left',
4425             6 => 'Far Left',
4426             7 => 'Mid-right',
4427             8 => 'Upper-right',
4428             9 => 'Lower-right',
4429             10 => 'Far Right',
4430             },
4431             },
4432             },
4433             { #PH (D5,D500, D850)
4434             Name => 'AFPointsUsed', #when focus is not obtained, will report '(none)' otherwise will report a single point from among AFPointsSelected
4435             Condition => '$$self{FocusPointSchema} == 7', #153 focus-point models
4436             Notes => q{
4437             models with 153-point AF -- 9 rows (A-I) and 17 columns (1-17). Center
4438             point is E9
4439             },
4440             Format => 'undef[20]',
4441             ValueConv => 'join(" ", unpack("H2"x20, $val))',
4442             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4443             PrintConv => sub { PrintAFPoints(shift, \%afPoints153) },
4444             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints153) },
4445             },{
4446             Name => 'AFPointsUsed',
4447             Condition => '$$self{FocusPointSchema} == 0', #LiveView or manual focus or no focus (reporting only for purposes of backward compatibility with v13.19 and earlier)
4448             PrintConv => { 0 => '(none)', },
4449             },
4450             ],
4451             0x1c => [
4452             {#PH
4453             Name => 'ContrastDetectAFInFocus',
4454             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4455             PrintConv => { 0 => 'No', 1 => 'Yes' },
4456             },
4457             { #JD/PH
4458             Name => 'AFPointsUsed',
4459             Condition => '$$self{FocusPointSchema} == 1 and
4460             ($$self{AFAreaMode} == 8 or $$self{AFAreaMode} == 9 or $$self{AFAreaMode} == 13 )', #phase detect 51 focus-point models
4461             Format => 'undef[7]',
4462             ValueConv => 'join(" ", unpack("H2"x7, $val))',
4463             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4464             PrintConv => sub { PrintAFPoints(shift, \%afPoints51) },
4465             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints51) },
4466             },{ #PH (D500, see forum11190)
4467             Name => 'AFPointsSelected', # where the viewfinder AF point(s) were positioned when initiating focus in AFAreaMode 3D-tracking Group-area
4468             # will contain a value regardless of whether or not focus was obtained
4469             # reflects the focus points displayed by NXStudio when AFAreaMode is Group-area
4470             Condition => '$$self{FocusPointSchema} == 7 and
4471             ($$self{AFAreaMode} == 8 or $$self{AFAreaMode} == 9 or $$self{AFAreaMode} == 13 )', #phase detect 153 focus-point models in Auto-area/3D-tracking/Group-area
4472             Format => 'undef[20]',
4473             ValueConv => 'join(" ", unpack("H2"x20, $val))',
4474             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4475             PrintConv => sub { PrintAFPoints(shift, \%afPoints153) },
4476             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints153) },
4477             },
4478             ],
4479             0x30 => [
4480             { #PH (D7500) (NC "in focus")
4481             Name => 'AFPointsInFocus', # refelcts the focus point(s) displayed by NXStudio when AFAreaMode is Auto-area or 3D-tracking.
4482             # erroneously named as there is no assurance the reported points are in focus
4483             Condition => '$$self{FocusPointSchema} == 1', #51 focus-point models
4484             Format => 'undef[7]',
4485             ValueConv => 'join(" ", unpack("H2"x7, $val))',
4486             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4487             PrintConv => sub { PrintAFPoints(shift, \%afPoints51) },
4488             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints51) },
4489             },{ #PH (D500, see forum11190)
4490             Name => 'AFPointsInFocus',
4491             Condition => '$$self{FocusPointSchema} == 7', #153 focus-point models
4492             Notes => 'AF points in focus at the time time image was captured',
4493             Format => 'undef[20]',
4494             ValueConv => 'join(" ", unpack("H2"x20, $val))',
4495             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4496             PrintConv => sub { PrintAFPoints(shift, \%afPoints153) },
4497             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints153) },
4498             },
4499             ],
4500             0x44 => [ #AFInfoVersion 0100 use 0x08 for this tag. v0101 could do that as well. The difference is that when Group-area fails to focus..
4501             #...this code (incorrectly) reports a value for PrimaryAFPoint. Moving this code to the 0x08 slot would correctly report '(none)'...
4502             #...leaving it here for now for compatibility purposes
4503             { #PH/JD
4504             Name => 'PrimaryAFPoint',
4505             Condition => '$$self{FocusPointSchema} == 1', #51 focus-point models
4506             Notes => q{
4507             models with 51-point AF -- 5 rows (A-E) and 11 columns (1-11): D7500
4508             },
4509             PrintConvColumns => 5,
4510             PrintConv => {
4511             0 => '(none)',
4512             %afPoints51,
4513             1 => 'C6 (Center)', # (add " (Center)" to central point)
4514             },
4515             },{ #10
4516             Name => 'PrimaryAFPoint',
4517             Notes => 'models with 11-point AF: D3400, D3500',
4518             Condition => '$$self{FocusPointSchema} == 2', #11 focus-point models
4519             PrintConvColumns => 2,
4520             PrintConv => {
4521             0 => '(none)',
4522             1 => 'Center',
4523             2 => 'Top',
4524             3 => 'Bottom',
4525             4 => 'Mid-left',
4526             5 => 'Upper-left',
4527             6 => 'Lower-left',
4528             7 => 'Far Left',
4529             8 => 'Mid-right',
4530             9 => 'Upper-right',
4531             10 => 'Lower-right',
4532             11 => 'Far Right',
4533             },
4534             },{ #PH
4535             Name => 'PrimaryAFPoint',
4536             Condition => '$$self{FocusPointSchema} == 7', #153 focus-point models
4537             Notes => q{
4538             Nikon models with 153-point AF -- 9 rows (A-I) and 17 columns (1-17): D5,
4539             D500 and D850
4540             },
4541             PrintConvColumns => 5,
4542             PrintConv => {
4543             0 => '(none)',
4544             %afPoints153,
4545             1 => 'E9 (Center)',
4546             },
4547             },{
4548             Name => 'PrimaryAFPoint',
4549             Condition => '$$self{FocusPointSchema} == 0', #LiveView or manual focus or no focus (reporting only for purposes of backward compatibility with v13.19 and earlier)
4550             PrintConv => { 0 => '(none)', },
4551             },
4552             ],
4553             0x46 => { #PH
4554             Name => 'AFImageWidth',
4555             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4556             Format => 'int16u',
4557             RawConv => '$val ? $val : undef',
4558             Notes => 'this and the following tags are valid only for contrast-detect AF',
4559             },
4560             0x48 => { #PH
4561             Name => 'AFImageHeight',
4562             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4563             Format => 'int16u',
4564             RawConv => '$val ? $val : undef',
4565             },
4566             0x4a => { #PH
4567             Name => 'AFAreaXPosition',
4568             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4569             Notes => 'center of AF area in AFImage coordinates',
4570             Format => 'int16u',
4571             RawConv => '$val ? $val : undef',
4572             },
4573             0x4c => { #PH
4574             Name => 'AFAreaYPosition',
4575             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4576             Format => 'int16u',
4577             RawConv => '$val ? $val : undef',
4578             },
4579             0x4e => { #PH
4580             Name => 'AFAreaWidth',
4581             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4582             Format => 'int16u',
4583             Notes => 'size of AF area in AFImage coordinates',
4584             RawConv => '$val ? $val : undef',
4585             },
4586             0x50 => { #PH
4587             Name => 'AFAreaHeight',
4588             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4589             Format => 'int16u',
4590             RawConv => '$val ? $val : undef',
4591             },
4592             0x52 => {
4593             Name => 'ContrastDetectAFInFocus',
4594             Condition => '$$self{AFDetectionMethod} == 1', #contrast detect
4595             PrintConv => { 0 => 'No', 1 => 'Yes' },
4596             },
4597             );
4598              
4599             %Image::ExifTool::Nikon::AFInfo2V0200 = (
4600             %binaryDataAttrs,
4601             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4602             DATAMEMBER => [ 0, 6 ],
4603             NOTES => q{
4604             AF information for Nikon 1 series cameras: Nikon 1 V1, V2, V3, J1, J2, J3,
4605             S1, S2 AW1.
4606             },
4607             0 => {
4608             Name => 'AFInfo2Version',
4609             Format => 'undef[4]',
4610             Writable => 0,
4611             RawConv => '$$self{AFInfo2Version} = $val',
4612             },
4613             5 => {
4614             Name => 'AFAreaMode',
4615             PrintConv => {
4616             128 => 'Single', #PH (1J1,1J2,1J3,1J4,1S1,1S2,1V2,1V3)
4617             129 => 'Auto (41 points)', #PH (1J1,1J2,1J3,1J4,1S1,1S2,1V1,1V2,1V3,AW1)
4618             130 => 'Subject Tracking (41 points)', #PH (1J1,1J4,1J3)
4619             131 => 'Face Priority (41 points)', #PH (1J1,1J3,1S1,1V2,AW1)
4620             # 134 - seen for 1V1[PhaseDetectAF=0] (PH)
4621             # 135 - seen for 1J2[PhaseDetectAF=4] (PH)
4622             },
4623             },
4624             6 => {
4625             Name => 'PhaseDetectAF', #JD(AutoFocus), PH(PhaseDetectAF)
4626             Notes => 'PrimaryAFPoint and AFPointsUsed below are only valid when this is On',
4627             RawConv => '$$self{PhaseDetectAF} = $val',
4628             PrintConv => {
4629             # [observed AFAreaMode values in square brackets for each PhaseDetectAF value]
4630             4 => 'On (73-point)', #PH (1J1[128/129],1J2[128/129/135],1J3/1S1/1V2[128/129/131],1V1[129],AW1[129/131])
4631             5 => 'On (5)', #PH (1S2[128/129], 1J4/1V3[129])
4632             6 => 'On (105-point)', #PH (1J4/1V3[128/130])
4633             },
4634             },
4635             7 => [
4636             { #PH
4637             Name => 'PrimaryAFPoint',
4638             Condition => '$$self{PhaseDetectAF} == 4',
4639             Notes => 'Nikon 1 models with older 135-point AF and 73-point phase-detect AF',
4640             PrintConvColumns => 5,
4641             PrintConv => {
4642             0 => '(none)',
4643             %afPoints135,
4644             1 => 'E8 (Center)', # (add " (Center)" to central point)
4645             },
4646             },
4647             { #PH (NC)
4648             Name => 'PrimaryAFPoint',
4649             Condition => '$$self{PhaseDetectAF} == 5',
4650             Notes => q{
4651             Nikon 1 models with newer 135-point AF and 73-point phase-detect AF -- 9
4652             rows (B-J) and 15 columns (1-15), inside a grid of 11 rows by 15 columns.
4653             The points are numbered sequentially, with F8 at the center
4654             },
4655             PrintConv => {
4656             0 => '(none)',
4657             82 => 'F8 (Center)',
4658             OTHER => sub {
4659             my ($val, $inv) = @_;
4660             return GetAFPointGrid($val, 15, $inv);
4661             },
4662             },
4663             },
4664             { #PH
4665             Name => 'PrimaryAFPoint',
4666             Condition => '$$self{PhaseDetectAF} == 6',
4667             Notes => q{
4668             Nikon 1 models with 171-point AF and 105-point phase-detect AF -- 9 rows
4669             (B-J) and 19 columns (2-20), inside a grid of 11 rows by 21 columns. The
4670             points are numbered sequentially, with F11 at the center
4671             },
4672             PrintConv => {
4673             0 => '(none)',
4674             #22 => 'B2 (Top-left)',
4675             #40 => 'B20 (Top-right)',
4676             115 => 'F11 (Center)',
4677             #190 => 'J2 (Bottom-left)',
4678             #208 => 'J20 (Bottom-right)',
4679             OTHER => sub {
4680             my ($val, $inv) = @_;
4681             return GetAFPointGrid($val, 21, $inv);
4682             },
4683             },
4684             },
4685             ],
4686             8 => [
4687             { #PH (1AW1,1J1,1J2,1J3,1S1,1V1,1V2)
4688             Name => 'AFPointsUsed',
4689             Condition => '$$self{PhaseDetectAF} == 4',
4690             Notes => q{
4691             older models with 135-point AF -- 9 rows (A-I) and 15 columns (1-15).
4692             Center point is E8. The odd-numbered columns, columns 2 and 14, and the
4693             remaining corner points are not used for 41-point AF mode
4694             },
4695             Format => 'undef[17]',
4696             ValueConv => 'join(" ", unpack("H2"x17, $val))',
4697             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4698             PrintConv => sub { PrintAFPoints(shift, \%afPoints135) },
4699             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints135) },
4700             },
4701             { #PH (1S2)
4702             Name => 'AFPointsUsed',
4703             Condition => '$$self{PhaseDetectAF} == 5',
4704             Notes => q{
4705             newer models with 135-point AF -- 9 rows (B-J) and 15 columns (1-15). Center
4706             point is F8
4707             },
4708             Format => 'undef[21]',
4709             ValueConv => 'join(" ", unpack("H2"x21, $val))',
4710             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4711             PrintConv => sub { PrintAFPointsGrid(shift, 15) },
4712             PrintConvInv => sub { PrintAFPointsGridInv(shift, 15, 21) },
4713             },
4714             { #PH (1J4,1V3)
4715             Name => 'AFPointsUsed',
4716             Condition => '$$self{PhaseDetectAF} == 6',
4717             Notes => q{
4718             models with 171-point AF -- 9 rows (B-J) and 19 columns (2-20). Center
4719             point is F10
4720             },
4721             Format => 'undef[29]',
4722             ValueConv => 'join(" ", unpack("H2"x29, $val))',
4723             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4724             PrintConv => sub { PrintAFPointsGrid(shift, 21) },
4725             PrintConvInv => sub { PrintAFPointsGridInv(shift, 21, 29) },
4726             },
4727             ],
4728             );
4729              
4730             %Image::ExifTool::Nikon::AFInfo2V0300 = (
4731             %binaryDataAttrs,
4732             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4733             DATAMEMBER => [ 0, 4, 6, 7, 46, 48 ],
4734             NOTES => q{
4735             AF information for Nikon cameras with the Expeed 6 processor: D6, D780, Z5,
4736             Z6, Z6ii, Z7, Z7ii, Z50 and Zfc.
4737             },
4738             0 => {
4739             Name => 'AFInfo2Version',
4740             Format => 'undef[4]',
4741             Writable => 0,
4742             RawConv => '$$self{AFInfo2Version} = $val',
4743             },
4744             4 => {
4745             Name => 'AFDetectionMethod',
4746             RawConv => '$$self{AFDetectionMethod} = $val',
4747             PrintConv => \%aFDetectionMethod ,
4748             },
4749             5 => [
4750             {
4751             Name => 'AFAreaMode',
4752             Condition => '$$self{AFDetectionMethod} == 0',
4753             PrintConv => \%aFAreaModePD, #phase detect
4754             },
4755             {
4756             Name => 'AFAreaMode',
4757             PrintConv => \%aFAreaModeCD, #contrast detect
4758             },
4759             ],
4760             6 => {
4761             Name => 'FocusPointSchema',
4762             RawConv => '$$self{FocusPointSchema} = $val',
4763             #Hidden => 1,
4764             PrintConv => {
4765             0 => 'Off', # LiveView or manual focus or no focus
4766             1 => '51-point', # (D780) 51 points through the viewfinder, 81/273 points in LiveView
4767             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.
4768             9 => '105-point', # (D6) arranged as a 15 column x 9 row grid
4769             },
4770             },
4771             7 => {
4772             Name => 'AFCoordinatesAvailable', #0 => 'AFPointsUsed is populated' 1 => 'AFAreaXPosition & AFAreaYPosition are populated'
4773             RawConv => '$$self{AFCoordinatesAvailable} = $val',
4774             PrintConv => \%noYes ,
4775             },
4776             0x0a => [
4777             { #JD/PH
4778             Name => 'AFPointsUsed',
4779             Condition => '$$self{FocusPointSchema} == 1 and $$self{AFCoordinatesAvailable} == 0', #D780 when AFAreaXYPositions are not populated
4780             Notes => q{
4781             models with 51-point AF -- 5 rows: A1-9, B1-11, C1-11, D1-11, E1-9. Center
4782             point is C6
4783             },
4784             Format => 'undef[7]',
4785             ValueConv => 'join(" ", unpack("H2"x7, $val))',
4786             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4787             PrintConv => sub { PrintAFPoints(shift, \%afPoints51) },
4788             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints51) },
4789             },{
4790             Name => 'AFPointsUsed',
4791             Condition => '$$self{FocusPointSchema} == 8 and $$self{AFCoordinatesAvailable} == 0', # Z6/Z6ii/Z7/Z7ii/Z50/Z50ii/Zfc/D780 when AFAreaXYPositions are not populated
4792             Notes => q{
4793             models with hybrid detect AF have 81 auto-area points -- 9 rows (A-I) and 9 columns (1-9). Center point is E5
4794             },
4795             Format => 'undef[11]',
4796             ValueConv => 'join(" ", unpack("H2"x11, $val))',
4797             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4798             PrintConv => sub { PrintAFPoints(shift, \%afPoints81) },
4799             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints81) },
4800             },{
4801             Name => 'AFPointsUsed',
4802             Condition => '$$self{FocusPointSchema} == 9 and $$self{AFCoordinatesAvailable} == 0', # D6 focus-point model when AFAreaXYPositions are not populated
4803             Format => 'undef[14]',
4804             ValueConv => 'join(" ", unpack("H2"x14, $val))',
4805             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4806             PrintConv => sub { PrintAFPoints(shift, \%afPoints105) },
4807             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints105) },
4808             },
4809             ],
4810             0x2a => { #PH (Z7)
4811             Name => 'AFImageWidth',
4812             Format => 'int16u',
4813             RawConv => '$val ? $val : undef',
4814             },
4815             0x2c => { #PH (Z7)
4816             Name => 'AFImageHeight',
4817             Format => 'int16u',
4818             RawConv => '$val ? $val : undef',
4819             },
4820             0x2e => { #PH (Z7)
4821             Name => 'AFAreaXPosition',
4822             Condition => '$$self{AFCoordinatesAvailable} == 1', # is field populated?
4823             RawConv => '$$self{AFAreaXPosition} = $val',
4824             Format => 'int16u', # (decodes same byte as 0x2f)
4825             },
4826             0x2f => [
4827             {
4828             Name => 'FocusPositionHorizontal', # 209/231 focus point cameras
4829             Condition => '$$self{Model} =~ /^NIKON (Z 30|Z 50|Z fc)\b/i and $$self{AFAreaXPosition}', #models Z30, Z50, Zfc
4830             ValueConv => 'int($$self{AFAreaXPosition} / 260 )', #divisor is an estimate (chosen to cause center point to report 'C')
4831             PrintConv => sub { my ($val) = @_; PrintAFPointsLeftRight($val, 19 ) },
4832             },{
4833             Name => 'FocusPositionHorizontal', #273/299 focus point cameras
4834             Condition => '$$self{Model} =~ /^NIKON (Z 5|Z 6|Z 6_2|D780)\b/i and $$self{AFAreaXPosition}', #models Z5, Z6, Z6ii, D780
4835             ValueConv => 'int($$self{AFAreaXPosition} / 260 )', #divisor is an estimate (chosen to cause center point to report 'C')
4836             PrintConv => sub { my ($val) = @_; PrintAFPointsLeftRight($val, 21 ) },
4837             },{
4838             Name => 'FocusPositionHorizontal', #405/493 focus point cameras
4839             Condition => '$$self{Model} =~ /^NIKON (Z 7|Z 7_2)\b/i and $$self{AFAreaXPosition}', #models Z7/Z7ii
4840             ValueConv => 'int($$self{AFAreaXPosition} / 260 )', #divisor is the measured horizontal pixel separation between adjacent points
4841             PrintConv => sub { my ($val) = @_; PrintAFPointsLeftRight($val, 29 ) },
4842             },
4843             #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
4844             ],
4845             0x30 => { #PH (Z7)
4846             Name => 'AFAreaYPosition',
4847             Condition => '$$self{AFCoordinatesAvailable} == 1', # is field populated?
4848             RawConv => '$$self{AFAreaYPosition} = $val',
4849             Format => 'int16u', # (decodes same byte as 0x31)
4850             },
4851             0x31 => [
4852             {
4853             Name => 'FocusPositionVertical', # 209/233 focus point cameras
4854             Condition => '$$self{Model} =~ /^NIKON (Z 30|Z 50|Z fc)\b/i and $$self{AFAreaYPosition}', #models Z30, Z50, Zfc
4855             ValueConv => 'int($$self{AFAreaYPosition} / 286 )', #divisor is an estimate (chosen to cause center point to report 'C')
4856             PrintConv => sub { my ($val) = @_; PrintAFPointsUpDown($val, 11 ) },
4857             },{
4858             Name => 'FocusPositionVertical', # 273/299 focus point cameras
4859             Condition => '$$self{Model} =~ /^NIKON (Z 5|Z 6|Z 6_2|D780)\b/i and $$self{AFAreaYPosition}', #models Z5, Z6, Z6ii, D780
4860             ValueConv => 'int($$self{AFAreaYPosition} / 286 )', #divisor is an estimate (chosen to cause center point to report 'C')
4861             PrintConv => sub { my ($val) = @_; PrintAFPointsUpDown($val, 13 ) },
4862             },{
4863             Name => 'FocusPositionVertical', # 405/493 focus point cameras
4864             Condition => '$$self{Model} =~ /^NIKON (Z 7|Z 7_2)\b/i and $$self{AFAreaYPosition}', #models Z7/Z7ii
4865             ValueConv => 'int($$self{AFAreaYPosition} / 292 )', #divisor is the measured vertical pixel separation between adjacent points
4866             PrintConv => sub { my ($val) = @_; PrintAFPointsUpDown($val, 17 ) },
4867             },
4868             ],
4869             0x32 => { #PH
4870             Name => 'AFAreaWidth',
4871             Format => 'int16u',
4872             RawConv => '$val ? $val : undef',
4873             },
4874             0x34 => { #PH
4875             Name => 'AFAreaHeight',
4876             Format => 'int16u',
4877             RawConv => '$val ? $val : undef',
4878             },
4879             0x38 =>[
4880             { #PH/JD
4881             Name => 'PrimaryAFPoint',
4882             Condition => '$$self{FocusPointSchema} == 1 and $$self{AFCoordinatesAvailable} == 0', #51 focus-point models when AFAreaXYPositions are not populated
4883             Notes => q{
4884             models with 51-point AF -- 5 rows (A-E) and 11 columns (1-11): D3, D3S, D3X,
4885             D4, D4S, D300, D300S, D700, D750, D800, D800E, D810, D7100 and D7200
4886             },
4887             PrintConvColumns => 5,
4888             PrintConv => {
4889             0 => '(none)',
4890             %afPoints51,
4891             1 => 'C6 (Center)', # (add " (Center)" to central point)
4892             },
4893             },{
4894             Name => 'PrimaryAFPoint',
4895             Condition => '$$self{FocusPointSchema} == 8 and $$self{AFCoordinatesAvailable} == 0', # Z6/Z6ii/Z7/Z7ii/Z50/Z50ii/Zfc/D780 when AFAreaXYPositions are not populated
4896             Notes => q{
4897             models with hybrid detect AF have 81 auto-area points -- 9 rows (A-I) and 9 columns (1-9). Center point is E5
4898             },
4899             PrintConvColumns => 5,
4900             PrintConv => {
4901             0 => '(none)',
4902             %afPoints81,
4903             1 => 'E5 (Center)', # (add " (Center)" to central point)
4904             },
4905             },{ #28
4906             Name => 'PrimaryAFPoint',
4907             Condition => '$$self{FocusPointSchema} == 9 and $$self{AFCoordinatesAvailable} == 0', #153 focus-point models when AFAreaXYPositions are not populated
4908             Notes => q{
4909             Nikon models with 105-point AF -- 7 rows (A-G) and 15 columns (1-15): D6
4910             },
4911             PrintConvColumns => 5,
4912             PrintConv => {
4913             0 => '(none)',
4914             %afPoints105,
4915             1 => 'D8 (Center)',
4916             },
4917             },
4918             ]
4919             );
4920              
4921             %Image::ExifTool::Nikon::AFInfo2V0400 = (
4922             %binaryDataAttrs,
4923             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4924             DATAMEMBER => [ 0, 4, 5, 7, 66, 68 ],
4925             NOTES => q{
4926             AF information for Nikon cameras with the Expeed 7 processor: The Zf, Z6_3,
4927             Z8, Z9, Z50_2 and Z5_2.
4928             },
4929             0 => {
4930             Name => 'AFInfo2Version',
4931             Format => 'undef[4]',
4932             Writable => 0,
4933             RawConv => '$$self{AFInfo2Version} = $val',
4934             },
4935             4 => {
4936             Name => 'AFDetectionMethod',
4937             RawConv => '$$self{AFDetectionMethod} = $val',
4938             PrintConv => \%aFDetectionMethod ,
4939             },
4940             5 => {
4941             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)
4942             RawConv => '$$self{AFAreaModeUsed} = $val',
4943             PrintConv => {
4944             192 => 'Pinpoint',
4945             193 => 'Single',
4946             195 => 'Wide (S)',
4947             196 => 'Wide (L)',
4948             197 => 'Auto',
4949             204 => 'Dynamic Area (S)',
4950             205 => 'Dynamic Area (M)',
4951             206 => 'Dynamic Area (L)',
4952             207 => '3D-tracking',
4953             208 => 'Wide (C1/C2)',
4954             },
4955             },
4956             7 => {
4957             Name => 'AFCoordinatesAvailable', #0 => 'AFPointsUsed is populated' 1 => 'AFAreaXPosition & AFAreaYPosition are populated'
4958             RawConv => '$$self{AFCoordinatesAvailable} = $val',
4959             PrintConv => \%noYes ,
4960             },
4961             10 => [{
4962             # valid only for AFAreaModes where the camera selects the focus point (i.e., AutoArea & 3D-Tracking)
4963             # and the camera has yet to determine a focus target (in these cases tags AFAreaXPosition and AFAreaYPosition will be zeroes)
4964             Name => 'AFPointsUsed', # Z8 and Z9 (AFInfo2Version 0400)
4965             Condition => '$$self{Model} =~ /^NIKON (Z 8|Z 9)\b/i and ($$self{AFAreaModeUsed} == 197 or $$self{AFAreaModeUsed} == 207)',
4966             Format => 'undef[51]',
4967             Notes => 'either AFPointsUsed or AFAreaX/YPosition will be set, but not both',
4968             ValueConv => 'join(" ", unpack("H2"x51, $val))',
4969             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4970             PrintConv => sub { PrintAFPoints(shift, \@afPoints405) }, #full-frame sensor, 45MP, auto-area focus point configuration
4971             PrintConvInv => sub { PrintAFPointsInv(shift, \@afPoints405) },
4972             },{
4973             Name => 'AFPointsUsed', # Z6iii & Zf (AFInfo2Version 0401) and Z5ii (AFInfo2Version 0402)
4974             Condition => '$$self{Model} =~ /^NIKON (Z6_3|Z f|Z5_2)\b/i and ($$self{AFAreaModeUsed} == 197 or $$self{AFAreaModeUsed} == 207)',
4975             Format => 'undef[38]',
4976             ValueConv => 'join(" ", unpack("H2"x38, $val))',
4977             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4978             PrintConv => sub { PrintAFPoints(shift, \@afPoints299) },
4979             PrintConvInv => sub { PrintAFPointsInv(shift, \@afPoints299) }, #full-frame sensor, 24MP, auto-area focus point configuration
4980             },{
4981             Name => 'AFPointsUsed', # Z50ii (AFInfo2Version 0402)
4982             Condition => '$$self{Model} =~ /^NIKON Z50_2\b/i and ($$self{AFAreaModeUsed} == 197 or $$self{AFAreaModeUsed} == 207)',
4983             Format => 'undef[29]',
4984             ValueConv => 'join(" ", unpack("H2"x29, $val))',
4985             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4986             PrintConv => sub { PrintAFPoints(shift, \@afPoints231) },
4987             PrintConvInv => sub { PrintAFPointsInv(shift, \@afPoints231) }, #crop sensor, 21MP, auto-area focus point configuration
4988             }],
4989             0x3e => {
4990             Name => 'AFImageWidth',
4991             Format => 'int16u',
4992             RawConv => '$val ? $val : undef',
4993             },
4994             0x40 => {
4995             Name => 'AFImageHeight',
4996             Format => 'int16u',
4997             RawConv => '$val ? $val : undef',
4998             },
4999             0x42 => { #28
5000             Name => 'AFAreaXPosition', #top left image corner is the origin
5001             Condition => '$$self{AFCoordinatesAvailable} == 1', # is field populated?
5002             RawConv => '$$self{AFAreaXPosition} = $val',
5003             Format => 'int16u', # (decodes same byte as 0x43)
5004             },
5005             0x43 => [
5006             {
5007             Name => 'FocusPositionHorizontal', # 209/231 focus point cameras
5008             Condition => '$$self{Model} =~ /^NIKON Z50_2\b/i and $$self{AFAreaXPosition} and $$self{AFAreaXPosition} != 0', #model Z50ii
5009             ValueConv => 'int($$self{AFAreaXPosition} / 260 )', #divisor is the estimated separation between adjacent points (informed by the measured Z7ii separation)
5010             PrintConv => sub { my ($val) = @_; PrintAFPointsLeftRight($val, 19 ) },
5011             },{
5012             Name => 'FocusPositionHorizontal', #273/299 focus point cameras
5013             Condition => '$$self{Model} =~ /^NIKON (Z6_3|Z f|Z5_2)\b/i and $$self{AFAreaXPosition} and $$self{AFAreaXPosition} != 0', #models Z6iii, Zf & Z5ii
5014             ValueConv => 'int($$self{AFAreaXPosition} / 260 )', #divisor is the estimated separation between adjacent points (informed by the measured Z7ii separation)
5015             PrintConv => sub { my ($val) = @_; PrintAFPointsLeftRight($val, 21 ) },
5016             },{
5017             Name => 'FocusPositionHorizontal', #405/493 focus point cameras
5018             Condition => '$$self{Model} =~ /^NIKON (Z 8|Z 9)\b/i and $$self{AFAreaXPosition} and $$self{AFAreaXPosition} != 0', #models Z8 and Z9
5019             ValueConv => 'int($$self{AFAreaXPosition} / 260 )', #divisor is the measured horizontal pixel separation between adjacent points
5020             PrintConv => sub { my ($val) = @_; PrintAFPointsLeftRight($val, 29 ) },
5021             },
5022             ],
5023             0x44 => { #28
5024             Name => 'AFAreaYPosition',
5025             Condition => '$$self{AFCoordinatesAvailable} == 1', # is field populated?
5026             RawConv => '$$self{AFAreaYPosition} = $val',
5027             Format => 'int16u', # (decodes same byte as 0x45)
5028             },
5029             0x45 => [
5030             {
5031             Name => 'FocusPositionVertical', # 209/233 focus point cameras
5032             Condition => '$$self{Model} =~ /^NIKON Z50_2\b/i and $$self{AFAreaYPosition} and $$self{AFAreaYPosition} != 0', #model Z50ii
5033             ValueConv => 'int($$self{AFAreaYPosition} / 286 )', #divisor chosen to cause center point report 'C'
5034             PrintConv => sub { my ($val) = @_; PrintAFPointsUpDown($val, 11 ) },
5035             },{
5036             Name => 'FocusPositionVertical', #273/299 focus point cameras
5037             Condition => '$$self{Model} =~ /^NIKON (Z6_3|Z f|Z5_2)\b/i and $$self{AFAreaYPosition} and $$self{AFAreaYPosition} != 0', #models Z6iii, Zf & Z5ii
5038             ValueConv => 'int($$self{AFAreaYPosition} / 286 )', #divisor chosen to cause center point report 'C'
5039             PrintConv => sub { my ($val) = @_; PrintAFPointsUpDown($val, 13 ) },
5040             },{
5041             Name => 'FocusPositionVertical', #405/493 focus point cameras
5042             Condition => '$$self{Model} =~ /^NIKON (Z 8|Z 9)\b/i and $$self{AFAreaYPosition} and $$self{AFAreaYPosition} != 0', #models Z8 and Z9
5043             ValueConv => 'int($$self{AFAreaYPosition} / 292 )', #divisor is the measured vertical pixel separation between adjacent points
5044             PrintConv => sub { my ($val) = @_; PrintAFPointsUpDown($val, 17 ) },
5045             },
5046             ],
5047             0x46 => {
5048             Name => 'AFAreaWidth',
5049             Format => 'int16u',
5050             Notes => 'size of AF area in AFImage pixels',
5051             RawConv => '$val ? $val : undef',
5052             },
5053             0x48 => {
5054             Name => 'AFAreaHeight',
5055             Format => 'int16u',
5056             RawConv => '$val ? $val : undef',
5057             },
5058             0x4a => {
5059             Name => 'FocusResult',
5060             # in Manual Foucs mode, reflects the state of viewfinder focus indicator.
5061             # In AF-C or AF-S, reflects the result of the last AF operation.
5062             PrintConv => { 0=> "Out of Focus", 1=>"Focus"},
5063             },
5064             );
5065              
5066             # Nikon AF fine-tune information (ref 28)
5067             %Image::ExifTool::Nikon::AFTune = (
5068             %binaryDataAttrs,
5069             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5070             0 => {
5071             Name => 'AFFineTune',
5072             PrintConv => {
5073             0 => 'Off',
5074             # (don't know what the difference between 1 and 2 is)
5075             1 => 'On (1)',
5076             2 => 'On (2)',
5077             3 => 'On (Zoom)', #28
5078             },
5079             },
5080             1 => {
5081             Name => 'AFFineTuneIndex',
5082             Notes => 'index of saved lens',
5083             PrintConv => '$val == 255 ? "n/a" : $val',
5084             PrintConvInv => '$val eq "n/a" ? 255 : $val',
5085             },
5086             2 => {
5087             # when AFFineTune = 3 (indicating a zoom lens), this Tag stores the tuning adjustment for the wide end of the zoom range (ref 28)
5088             Name => 'AFFineTuneAdj',
5089             Priority => 0, # so other value takes priority if it exists
5090             Notes => 'may only be valid for saved lenses',
5091             Format => 'int8s',
5092             PrintConv => '$val > 0 ? "+$val" : $val',
5093             PrintConvInv => '$val',
5094             },
5095             3 => {
5096             Name => 'AFFineTuneAdjTele',
5097             # should probably insert a Condition that restricts this to AFFineTune = 3 (ref 28)
5098             Notes => 'only valid for zoom lenses (ie, AFTune=3)',
5099             Format => 'int8s',
5100             PrintConv => '$val > 0 ? "+$val" : $val',
5101             PrintConvInv => '$val',
5102             },
5103             );
5104              
5105             # Nikon NEF processing information (ref forum6281)
5106             %Image::ExifTool::Nikon::RetouchInfo = (
5107             %binaryDataAttrs,
5108             FORMAT => 'int8s',
5109             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5110             DATAMEMBER => [ 0 ],
5111             0 => {
5112             Name => 'RetouchInfoVersion',
5113             Format => 'undef[4]',
5114             Writable => 0,
5115             RawConv => '$$self{RetouchInfoVersion} = $val',
5116             },
5117             # 4 - RetouchExposureComp (+$val/6 or -$val/6?)
5118             5 => {
5119             Name => 'RetouchNEFProcessing',
5120             Condition => '$$self{RetouchInfoVersion} ge "0200"',
5121             PrintConv => {
5122             -1 => 'Off',
5123             1 => 'On',
5124             },
5125             },
5126             );
5127              
5128             # Nikon File information - D60, D3 and D300 (ref PH)
5129             %Image::ExifTool::Nikon::FileInfo = (
5130             %binaryDataAttrs,
5131             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
5132             FORMAT => 'int16u',
5133             0 => {
5134             Name => 'FileInfoVersion',
5135             Format => 'undef[4]',
5136             Writable => 0,
5137             },
5138             2 => 'MemoryCardNumber',
5139             3 => {
5140             Name => 'DirectoryNumber',
5141             PrintConv => 'sprintf("%.3d", $val)',
5142             PrintConvInv => '$val',
5143             },
5144             4 => {
5145             Name => 'FileNumber',
5146             PrintConv => 'sprintf("%.4d", $val)',
5147             PrintConvInv => '$val',
5148             },
5149             );
5150              
5151             # ref PH
5152             %Image::ExifTool::Nikon::BarometerInfo = (
5153             %binaryDataAttrs,
5154             GROUPS => { 0 => 'MakerNotes', 2 => 'Location' },
5155             0 => {
5156             Name => 'BarometerInfoVersion',
5157             Format => 'undef[4]',
5158             Writable => 0,
5159             },
5160             6 => {
5161             Name => 'Altitude',
5162             Format => 'int32s',
5163             PrintConv => '"$val m"', # (always stored as metres)
5164             PrintConvInv => '$val=~s/\s*m$//; $val',
5165             },
5166             # 10: int16u - values: 0 (display in metres?), 18 (display in feet?)
5167             );
5168              
5169             # ref PH
5170             %Image::ExifTool::Nikon::CaptureOffsets = (
5171             PROCESS_PROC => \&ProcessNikonCaptureOffsets,
5172             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5173             # (note that these are duplicates of offsets in the normal TIFF structure,
5174             # and that these offsets are not updated when ExifTool rewrites the file)
5175             1 => 'IFD0_Offset',
5176             2 => 'PreviewIFD_Offset',
5177             3 => 'SubIFD_Offset',
5178             );
5179              
5180             # ref PH (Written by capture NX)
5181             %Image::ExifTool::Nikon::CaptureOutput = (
5182             %binaryDataAttrs,
5183             FORMAT => 'int32u',
5184             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
5185             # 1 = 1
5186             2 => 'OutputImageWidth',
5187             3 => 'OutputImageHeight',
5188             4 => 'OutputResolution',
5189             # 5 = 1
5190             );
5191              
5192             # ref IB
5193             %Image::ExifTool::Nikon::ColorBalanceA = (
5194             %binaryDataAttrs,
5195             FORMAT => 'int16u',
5196             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5197             624 => { #4
5198             Name => 'WB_RBLevels',
5199             Notes => 'as shot', #IB
5200             Format => 'int16u[2]',
5201             Protected => 1,
5202             },
5203             626 => {
5204             Name => 'WB_RBLevelsAuto',
5205             Format => 'int16u[2]',
5206             Protected => 1,
5207             },
5208             628 => {
5209             Name => 'WB_RBLevelsDaylight',
5210             Notes => 'red/blue levels for 0,+3,+2,+1,-1,-2,-3',
5211             Format => 'int16u[14]',
5212             Protected => 1,
5213             },
5214             642 => {
5215             Name => 'WB_RBLevelsIncandescent',
5216             Format => 'int16u[14]',
5217             Protected => 1,
5218             },
5219             656 => {
5220             Name => 'WB_RBLevelsFluorescent',
5221             Format => 'int16u[6]',
5222             Notes => 'red/blue levels for fluorescent W,N,D',
5223             Protected => 1,
5224             },
5225             662 => {
5226             Name => 'WB_RBLevelsCloudy',
5227             Format => 'int16u[14]',
5228             Protected => 1,
5229             },
5230             676 => {
5231             Name => 'WB_RBLevelsFlash',
5232             Format => 'int16u[14]',
5233             Protected => 1,
5234             },
5235             690 => {
5236             Name => 'WB_RBLevelsShade',
5237             Condition => '$$self{Model} ne "E8700"',
5238             Notes => 'not valid for E8700',
5239             Format => 'int16u[14]',
5240             Protected => 1,
5241             },
5242             );
5243              
5244             my %nrwLevels = (
5245             Format => 'int32u[4]',
5246             Protected => 1,
5247             ValueConv => 'my @a=split " ",$val;$a[0]*=2;$a[3]*=2;"@a"',
5248             ValueConvInv => 'my @a=split " ",$val;$a[0]/=2;$a[3]/=2;"@a"',
5249             );
5250              
5251             # (ref IB)
5252             %Image::ExifTool::Nikon::ColorBalanceB = (
5253             %binaryDataAttrs,
5254             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5255             NOTES => 'Color balance tags used by the P6000.',
5256             0x0004 => {
5257             Name => 'ColorBalanceVersion',
5258             Format => 'undef[4]',
5259             },
5260             0x13e8 => { Name => 'WB_RGGBLevels', %nrwLevels },
5261             0x13f8 => { Name => 'WB_RGGBLevelsDaylight', %nrwLevels },
5262             0x1408 => { Name => 'WB_RGGBLevelsCloudy', %nrwLevels },
5263             0x1428 => { Name => 'WB_RGGBLevelsTungsten', %nrwLevels },
5264             0x1438 => { Name => 'WB_RGGBLevelsFluorescentW',%nrwLevels },
5265             0x1448 => { Name => 'WB_RGGBLevelsFlash', %nrwLevels },
5266             0x1468 => { Name => 'WB_RGGBLevelsCustom', %nrwLevels, Notes => 'all zero if preset WB not used' },
5267             0x1478 => { Name => 'WB_RGGBLevelsAuto', %nrwLevels },
5268             );
5269              
5270             # (ref IB)
5271             %Image::ExifTool::Nikon::ColorBalanceC = (
5272             %binaryDataAttrs,
5273             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5274             DATAMEMBER => [ 4 ],
5275             NOTES => 'Color balance tags used by the P1000, P7000, P7100 and B700.',
5276             0x0004 => {
5277             Name => 'ColorBalanceVersion',
5278             Format => 'undef[4]',
5279             RawConv => '$$self{ColorBalanceVersion} = $val',
5280             },
5281             0x0020 => { Name => 'BlackLevel', Format => 'int16u' },
5282             0x0038 => { Name => 'WB_RGGBLevels', %nrwLevels },
5283             0x004c => { Name => 'WB_RGGBLevelsDaylight', %nrwLevels },
5284             0x0060 => { Name => 'WB_RGGBLevelsCloudy', %nrwLevels },
5285             0x0074 => {
5286             Name => 'WB_RGGBLevelsShade',
5287             Condition => '$$self{ColorBalanceVersion} ge "0104"',
5288             Notes => 'valid only for some models',
5289             %nrwLevels,
5290             },
5291             0x0088 => { Name => 'WB_RGGBLevelsTungsten', %nrwLevels },
5292             0x009c => { Name => 'WB_RGGBLevelsFluorescentW',%nrwLevels },
5293             0x00b0 => { Name => 'WB_RGGBLevelsFluorescentN',%nrwLevels },
5294             0x00c4 => { Name => 'WB_RGGBLevelsFluorescentD',%nrwLevels },
5295             0x00d8 => { Name => 'WB_RGGBLevelsHTMercury', %nrwLevels },
5296             0x0100 => { Name => 'WB_RGGBLevelsCustom', %nrwLevels, Notes => 'all zero if preset WB not used' },
5297             0x0114 => { Name => 'WB_RGGBLevelsAuto', %nrwLevels },
5298             );
5299              
5300             # ref 4
5301             %Image::ExifTool::Nikon::ColorBalance1 = (
5302             %binaryDataAttrs,
5303             FORMAT => 'int16u',
5304             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5305             0 => {
5306             Name => 'WB_RBGGLevels',
5307             Format => 'int16u[4]',
5308             Protected => 1,
5309             },
5310             );
5311              
5312             # ref 4
5313             %Image::ExifTool::Nikon::ColorBalance2 = (
5314             %binaryDataAttrs,
5315             FORMAT => 'int16u',
5316             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5317             NOTES => 'This information is encrypted for most camera models.',
5318             0 => {
5319             Name => 'WB_RGGBLevels',
5320             Format => 'int16u[4]',
5321             Protected => 1,
5322             },
5323             );
5324              
5325             # ref 4
5326             %Image::ExifTool::Nikon::ColorBalance3 = (
5327             %binaryDataAttrs,
5328             FORMAT => 'int16u',
5329             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5330             0 => {
5331             Name => 'WB_RGBGLevels',
5332             Format => 'int16u[4]',
5333             Protected => 1,
5334             },
5335             );
5336              
5337             # ref 4
5338             %Image::ExifTool::Nikon::ColorBalance4 = (
5339             %binaryDataAttrs,
5340             FORMAT => 'int16u',
5341             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5342             0 => {
5343             Name => 'WB_GRBGLevels',
5344             Format => 'int16u[4]',
5345             Protected => 1,
5346             },
5347             );
5348              
5349             %Image::ExifTool::Nikon::ColorBalanceUnknown = (
5350             %binaryDataAttrs,
5351             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5352             0 => {
5353             Name => 'ColorBalanceVersion',
5354             Format => 'undef[4]',
5355             },
5356             );
5357              
5358             %Image::ExifTool::Nikon::ColorBalanceUnknown2 = (
5359             %binaryDataAttrs,
5360             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5361             FORMAT => 'int16u',
5362             0 => {
5363             Name => 'ColorBalanceVersion',
5364             Format => 'undef[4]',
5365             },
5366             );
5367              
5368             %Image::ExifTool::Nikon::Type2 = (
5369             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
5370             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
5371             WRITABLE => 1,
5372             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5373             0x0003 => 'Quality',
5374             0x0004 => 'ColorMode',
5375             0x0005 => 'ImageAdjustment',
5376             0x0006 => 'CCDSensitivity',
5377             0x0007 => 'WhiteBalance',
5378             0x0008 => 'Focus',
5379             0x000A => 'DigitalZoom',
5380             0x000B => 'Converter',
5381             );
5382              
5383             # these are standard EXIF tags, but they are duplicated here so we can
5384             # set the family 0 group to 'MakerNotes' and set the MINOR_ERRORS flag
5385             %Image::ExifTool::Nikon::PreviewIFD = (
5386             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
5387             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
5388             GROUPS => { 0 => 'MakerNotes', 1 => 'PreviewIFD', 2 => 'Image'},
5389             VARS => { MINOR_ERRORS => 1 }, # this IFD is non-essential and often corrupted
5390             # (these tags are priority 0 by default because PreviewIFD is flagged in LOW_PRIORITY_DIR)
5391             0xfe => { # (not used by Nikon, but SRW images also use this table)
5392             Name => 'SubfileType',
5393             DataMember => 'SubfileType',
5394             RawConv => '$$self{SubfileType} = $val',
5395             PrintConv => \%Image::ExifTool::Exif::subfileType,
5396             },
5397             0x103 => {
5398             Name => 'Compression',
5399             SeparateTable => 'EXIF Compression',
5400             PrintConv => \%Image::ExifTool::Exif::compression,
5401             },
5402             0x11a => 'XResolution',
5403             0x11b => 'YResolution',
5404             0x128 => {
5405             Name => 'ResolutionUnit',
5406             PrintConv => {
5407             1 => 'None',
5408             2 => 'inches',
5409             3 => 'cm',
5410             },
5411             },
5412             0x201 => {
5413             Name => 'PreviewImageStart',
5414             Flags => [ 'IsOffset', 'Permanent' ],
5415             OffsetPair => 0x202,
5416             DataTag => 'PreviewImage',
5417             Writable => 'int32u',
5418             WriteGroup => 'MakerNotes',
5419             Protected => 2,
5420             },
5421             0x202 => {
5422             Name => 'PreviewImageLength',
5423             Flags => 'Permanent' ,
5424             OffsetPair => 0x201,
5425             DataTag => 'PreviewImage',
5426             Writable => 'int32u',
5427             WriteGroup => 'MakerNotes',
5428             Protected => 2,
5429             },
5430             0x213 => {
5431             Name => 'YCbCrPositioning',
5432             PrintConv => {
5433             1 => 'Centered',
5434             2 => 'Co-sited',
5435             },
5436             },
5437             );
5438              
5439             # these are duplicated enough times to make it worthwhile to define them centrally
5440             my %nikonApertureConversions = (
5441             ValueConv => '2**($val/24)',
5442             ValueConvInv => '$val>0 ? 24*log($val)/log(2) : 0',
5443             PrintConv => 'sprintf("%.1f",$val)',
5444             PrintConvInv => '$val',
5445             );
5446              
5447             my %nikonFocalConversions = (
5448             ValueConv => '5 * 2**($val/24)',
5449             ValueConvInv => '$val>0 ? 24*log($val/5)/log(2) : 0',
5450             PrintConv => 'sprintf("%.1f mm",$val)',
5451             PrintConvInv => '$val=~s/\s*mm$//;$val',
5452             );
5453              
5454             # Version 100 Nikon lens data
5455             %Image::ExifTool::Nikon::LensData00 = (
5456             %binaryDataAttrs,
5457             NOTES => 'This structure is used by the D100, and D1X with firmware version 1.1.',
5458             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5459             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
5460             0x00 => {
5461             Name => 'LensDataVersion',
5462             Format => 'undef[4]',
5463             Writable => 0,
5464             },
5465             0x06 => { #8
5466             Name => 'LensIDNumber',
5467             Notes => 'see LensID values below',
5468             },
5469             0x07 => { #8
5470             Name => 'LensFStops',
5471             ValueConv => '$val / 12',
5472             ValueConvInv => '$val * 12',
5473             PrintConv => 'sprintf("%.2f", $val)',
5474             PrintConvInv => '$val',
5475             },
5476             0x08 => { #8/9
5477             Name => 'MinFocalLength',
5478             %nikonFocalConversions,
5479             },
5480             0x09 => { #8/9
5481             Name => 'MaxFocalLength',
5482             %nikonFocalConversions,
5483             },
5484             0x0a => { #8
5485             Name => 'MaxApertureAtMinFocal',
5486             %nikonApertureConversions,
5487             },
5488             0x0b => { #8
5489             Name => 'MaxApertureAtMaxFocal',
5490             %nikonApertureConversions,
5491             },
5492             0x0c => 'MCUVersion', #8 (MCU = Micro Controller Unit)
5493             );
5494              
5495             # Nikon lens data (note: needs decrypting if LensDataVersion is 020x)
5496             %Image::ExifTool::Nikon::LensData01 = (
5497             %binaryDataAttrs,
5498             NOTES => q{
5499             Nikon encrypts the LensData information below if LensDataVersion is 0201 or
5500             higher, but the decryption algorithm is known so the information can be
5501             extracted.
5502             },
5503             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5504             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
5505             0x00 => {
5506             Name => 'LensDataVersion',
5507             Format => 'string[4]',
5508             Writable => 0,
5509             },
5510             0x04 => { #8
5511             Name => 'ExitPupilPosition',
5512             ValueConv => '$val ? 2048 / $val : $val',
5513             ValueConvInv => '$val ? 2048 / $val : $val',
5514             PrintConv => 'sprintf("%.1f mm",$val)',
5515             PrintConvInv => '$val=~s/\s*mm$//; $val',
5516             },
5517             0x05 => { #8
5518             Name => 'AFAperture',
5519             %nikonApertureConversions,
5520             },
5521             0x08 => { #8
5522             # this seems to be 2 values: the upper nibble gives the far focus
5523             # range and the lower nibble gives the near focus range. The values
5524             # are in the range 1-N, where N is lens-dependent. A value of 0 for
5525             # the far focus range indicates infinity. (ref JD)
5526             Name => 'FocusPosition',
5527             PrintConv => 'sprintf("0x%02x", $val)',
5528             PrintConvInv => '$val',
5529             },
5530             0x09 => { #8/9
5531             # With older AF lenses this does not work... (ref 13)
5532             # eg) AF Nikkor 50mm f/1.4 => 48 (0x30)
5533             # AF Zoom-Nikkor 35-105mm f/3.5-4.5 => @35mm => 15 (0x0f), @105mm => 141 (0x8d)
5534             Notes => 'this focus distance is approximate, and not very accurate for some lenses',
5535             Name => 'FocusDistance',
5536             ValueConv => '0.01 * 10**($val/40)', # in m
5537             ValueConvInv => '$val>0 ? 40*log($val*100)/log(10) : 0',
5538             PrintConv => '$val ? sprintf("%.2f m",$val) : "inf"',
5539             PrintConvInv => '$val eq "inf" ? 0 : $val =~ s/\s*m$//, $val',
5540             },
5541             0x0a => { #8/9
5542             Name => 'FocalLength',
5543             Priority => 0,
5544             %nikonFocalConversions,
5545             },
5546             0x0b => { #8
5547             Name => 'LensIDNumber',
5548             Notes => 'see LensID values below',
5549             },
5550             0x0c => { #8
5551             Name => 'LensFStops',
5552             ValueConv => '$val / 12',
5553             ValueConvInv => '$val * 12',
5554             PrintConv => 'sprintf("%.2f", $val)',
5555             PrintConvInv => '$val',
5556             },
5557             0x0d => { #8/9
5558             Name => 'MinFocalLength',
5559             %nikonFocalConversions,
5560             },
5561             0x0e => { #8/9
5562             Name => 'MaxFocalLength',
5563             %nikonFocalConversions,
5564             },
5565             0x0f => { #8
5566             Name => 'MaxApertureAtMinFocal',
5567             %nikonApertureConversions,
5568             },
5569             0x10 => { #8
5570             Name => 'MaxApertureAtMaxFocal',
5571             %nikonApertureConversions,
5572             },
5573             0x11 => 'MCUVersion', #8 (MCU = Micro Controller Unit)
5574             0x12 => { #8
5575             Name => 'EffectiveMaxAperture',
5576             %nikonApertureConversions,
5577             },
5578             );
5579              
5580             # Nikon lens data (note: needs decrypting)
5581             %Image::ExifTool::Nikon::LensData0204 = (
5582             %binaryDataAttrs,
5583             NOTES => q{
5584             Nikon encrypts the LensData information below if LensDataVersion is 0201 or
5585             higher, but the decryption algorithm is known so the information can be
5586             extracted.
5587             },
5588             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5589             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
5590             0x00 => {
5591             Name => 'LensDataVersion',
5592             Format => 'string[4]',
5593             Writable => 0,
5594             },
5595             0x04 => { #8
5596             Name => 'ExitPupilPosition',
5597             ValueConv => '$val ? 2048 / $val : $val',
5598             ValueConvInv => '$val ? 2048 / $val : $val',
5599             PrintConv => 'sprintf("%.1f mm",$val)',
5600             PrintConvInv => '$val=~s/\s*mm$//; $val',
5601             },
5602             0x05 => { #8
5603             Name => 'AFAperture',
5604             %nikonApertureConversions,
5605             },
5606             0x08 => { #8
5607             # this seems to be 2 values: the upper nibble gives the far focus
5608             # range and the lower nibble gives the near focus range. The values
5609             # are in the range 1-N, where N is lens-dependent. A value of 0 for
5610             # the far focus range indicates infinity. (ref JD)
5611             Name => 'FocusPosition',
5612             PrintConv => 'sprintf("0x%02x", $val)',
5613             PrintConvInv => '$val',
5614             },
5615             # --> extra byte at position 0x09 in this version of LensData (PH)
5616             0x0a => { #8/9
5617             # With older AF lenses this does not work... (ref 13)
5618             # eg) AF Nikkor 50mm f/1.4 => 48 (0x30)
5619             # AF Zoom-Nikkor 35-105mm f/3.5-4.5 => @35mm => 15 (0x0f), @105mm => 141 (0x8d)
5620             Notes => 'this focus distance is approximate, and not very accurate for some lenses',
5621             Name => 'FocusDistance',
5622             ValueConv => '0.01 * 10**($val/40)', # in m
5623             ValueConvInv => '$val>0 ? 40*log($val*100)/log(10) : 0',
5624             PrintConv => '$val ? sprintf("%.2f m",$val) : "inf"',
5625             PrintConvInv => '$val eq "inf" ? 0 : $val =~ s/\s*m$//, $val',
5626             },
5627             0x0b => { #8/9
5628             Name => 'FocalLength',
5629             Priority => 0,
5630             %nikonFocalConversions,
5631             },
5632             0x0c => { #8
5633             Name => 'LensIDNumber',
5634             Notes => 'see LensID values below',
5635             },
5636             0x0d => { #8
5637             Name => 'LensFStops',
5638             ValueConv => '$val / 12',
5639             ValueConvInv => '$val * 12',
5640             PrintConv => 'sprintf("%.2f", $val)',
5641             PrintConvInv => '$val',
5642             },
5643             0x0e => { #8/9
5644             Name => 'MinFocalLength',
5645             %nikonFocalConversions,
5646             },
5647             0x0f => { #8/9
5648             Name => 'MaxFocalLength',
5649             %nikonFocalConversions,
5650             },
5651             0x10 => { #8
5652             Name => 'MaxApertureAtMinFocal',
5653             %nikonApertureConversions,
5654             },
5655             0x11 => { #8
5656             Name => 'MaxApertureAtMaxFocal',
5657             %nikonApertureConversions,
5658             },
5659             0x12 => 'MCUVersion', #8 (MCU = Micro Controller Unit)
5660             0x13 => { #8
5661             Name => 'EffectiveMaxAperture',
5662             %nikonApertureConversions,
5663             },
5664             );
5665              
5666             # Nikon lens data version 0400 (note: needs decrypting) (ref PH)
5667             %Image::ExifTool::Nikon::LensData0400 = (
5668             %binaryDataAttrs,
5669             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5670             NOTES => 'Tags extracted from the encrypted lens data of the Nikon 1J1/1V1/1J2.',
5671             0x00 => {
5672             Name => 'LensDataVersion',
5673             Format => 'string[4]',
5674             Writable => 0,
5675             },
5676             0x18a => { #PH
5677             Name => 'LensModel',
5678             Format => 'string[64]',
5679             },
5680             );
5681              
5682             # Nikon lens data version 0402 (note: needs decrypting) (ref PH)
5683             %Image::ExifTool::Nikon::LensData0402 = (
5684             %binaryDataAttrs,
5685             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5686             NOTES => 'Tags extracted from the encrypted lens data of the Nikon 1J3/1S1/1V2.',
5687             0x00 => {
5688             Name => 'LensDataVersion',
5689             Format => 'string[4]',
5690             Writable => 0,
5691             },
5692             0x18b => { #PH
5693             Name => 'LensModel',
5694             Format => 'string[64]',
5695             },
5696             );
5697              
5698             # Nikon lens data version 0403 (note: needs decrypting) (ref PH)
5699             %Image::ExifTool::Nikon::LensData0403 = (
5700             %binaryDataAttrs,
5701             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5702             NOTES => 'Tags extracted from the encrypted lens data of the Nikon 1J4/1J5.',
5703             0x00 => {
5704             Name => 'LensDataVersion',
5705             Format => 'string[4]',
5706             Writable => 0,
5707             },
5708             0x2ac => { #PH
5709             Name => 'LensModel',
5710             Format => 'string[64]',
5711             },
5712             );
5713              
5714             # Nikon Z lens data (note: needs decrypting) (ref PH, based on LensData0204)
5715             %Image::ExifTool::Nikon::LensData0800 = (
5716             %binaryDataAttrs,
5717             NOTES => 'Tags found in the encrypted LensData from cameras such as the Z6 and Z7.',
5718             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5719             DATAMEMBER => [ 0x03, 0x2f, 0x30, 0x4c, 0x56, 0x58 ],
5720             0x00 => {
5721             Name => 'LensDataVersion',
5722             Format => 'string[4]',
5723             Writable => 0,
5724             },
5725             0x03 => { # look forward to see if new old data exists...
5726             Name => 'OldLensData',
5727             Format => 'undef[17]',
5728             RawConv => '$$self{OldLensData} = 1 unless $val =~ /^.\0+$/s; undef',
5729             #Hidden => 1,
5730             },
5731             0x04 => {
5732             Name => 'ExitPupilPosition',
5733             Condition => '$$self{OldLensData}',
5734             ValueConv => '$val ? 2048 / $val : $val',
5735             ValueConvInv => '$val ? 2048 / $val : $val',
5736             PrintConv => 'sprintf("%.1f mm",$val)',
5737             PrintConvInv => '$val=~s/\s*mm$//; $val',
5738             },
5739             0x05 => {
5740             Name => 'AFAperture',
5741             Condition => '$$self{OldLensData}',
5742             %nikonApertureConversions,
5743             },
5744             # --> another extra byte at position 0x08 in this version of LensData (PH)
5745             #0x09 => {
5746             # 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
5747             # Condition => '$$self{OldLensData}',
5748             # PrintConv => 'sprintf("0x%02x", $val)',
5749             # PrintConvInv => '$val',
5750             #},
5751             0x0b => {
5752             Notes => 'this focus distance is approximate, and not very accurate for some lenses',
5753             Name => 'FocusDistance',
5754             Condition => '$$self{OldLensData}',
5755             ValueConv => '0.01 * 10**($val/40)', # in m
5756             ValueConvInv => '$val>0 ? 40*log($val*100)/log(10) : 0',
5757             PrintConv => '$val ? sprintf("%.2f m",$val) : "inf"',
5758             PrintConvInv => '$val eq "inf" ? 0 : $val =~ s/\s*m$//, $val',
5759             },
5760             0x0c => {
5761             Name => 'FocalLength',
5762             Condition => '$$self{OldLensData}',
5763             Priority => 0,
5764             %nikonFocalConversions,
5765             },
5766             0x0d => {
5767             Name => 'LensIDNumber',
5768             Condition => '$$self{OldLensData}',
5769             Notes => 'see LensID values below',
5770             },
5771             0x0e => {
5772             Name => 'LensFStops',
5773             Condition => '$$self{OldLensData}',
5774             ValueConv => '$val / 12',
5775             ValueConvInv => '$val * 12',
5776             PrintConv => 'sprintf("%.2f", $val)',
5777             PrintConvInv => '$val',
5778             },
5779             0x0f => {
5780             Name => 'MinFocalLength',
5781             Condition => '$$self{OldLensData}',
5782             %nikonFocalConversions,
5783             },
5784             0x10 => {
5785             Name => 'MaxFocalLength',
5786             Condition => '$$self{OldLensData}',
5787             %nikonFocalConversions,
5788             },
5789             0x11 => {
5790             Name => 'MaxApertureAtMinFocal',
5791             Condition => '$$self{OldLensData}',
5792             %nikonApertureConversions,
5793             },
5794             0x12 => {
5795             Name => 'MaxApertureAtMaxFocal',
5796             Condition => '$$self{OldLensData}',
5797             %nikonApertureConversions,
5798             },
5799             0x13 => {
5800             Name => 'MCUVersion',
5801             Condition => '$$self{OldLensData}',
5802             },
5803             0x14 => {
5804             Name => 'EffectiveMaxAperture',
5805             Condition => '$$self{OldLensData}',
5806             %nikonApertureConversions,
5807             },
5808             #
5809             # ---- new LensData tags used by Nikkor Z cameras (ref PH/28). ----
5810             # (some fields are strictly for Z-series lenses, others apply to legacy F-mount as well, ref 28)
5811             #
5812             0x2f => { # look forward to see if new lens data exists...
5813             Name => 'NewLensData',
5814             Format => 'undef[17]',
5815             RawConv => '$$self{NewLensData} = 1 unless $val =~ /^.\0+$/s; undef',
5816             ##Hidden => 1,
5817             },
5818             0x30 => { #PH
5819             Name => 'LensID',
5820             Condition => '$$self{NewLensData}',
5821             Notes => 'tags from here onward used for Nikkor Z lenses only',
5822             Format => 'int16u',
5823             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)
5824             PrintConv => {
5825             1 => 'Nikkor Z 24-70mm f/4 S',
5826             2 => 'Nikkor Z 14-30mm f/4 S',
5827             4 => 'Nikkor Z 35mm f/1.8 S',
5828             8 => 'Nikkor Z 58mm f/0.95 S Noct', #IB
5829             9 => 'Nikkor Z 50mm f/1.8 S',
5830             11 => 'Nikkor Z DX 16-50mm f/3.5-6.3 VR',
5831             12 => 'Nikkor Z DX 50-250mm f/4.5-6.3 VR',
5832             13 => 'Nikkor Z 24-70mm f/2.8 S',
5833             14 => 'Nikkor Z 85mm f/1.8 S',
5834             15 => 'Nikkor Z 24mm f/1.8 S', #IB
5835             16 => 'Nikkor Z 70-200mm f/2.8 VR S', #IB
5836             17 => 'Nikkor Z 20mm f/1.8 S', #IB
5837             18 => 'Nikkor Z 24-200mm f/4-6.3 VR', #IB
5838             21 => 'Nikkor Z 50mm f/1.2 S', #IB
5839             22 => 'Nikkor Z 24-50mm f/4-6.3', #IB
5840             23 => 'Nikkor Z 14-24mm f/2.8 S', #IB
5841             24 => 'Nikkor Z MC 105mm f/2.8 VR S', #IB
5842             25 => 'Nikkor Z 40mm f/2', #28
5843             26 => 'Nikkor Z DX 18-140mm f/3.5-6.3 VR', #IB
5844             27 => 'Nikkor Z MC 50mm f/2.8', #IB
5845             28 => 'Nikkor Z 100-400mm f/4.5-5.6 VR S', #28
5846             29 => 'Nikkor Z 28mm f/2.8', #IB
5847             30 => 'Nikkor Z 400mm f/2.8 TC VR S', #28
5848             31 => 'Nikkor Z 24-120mm f/4 S', #github250
5849             32 => 'Nikkor Z 800mm f/6.3 VR S', #28
5850             35 => 'Nikkor Z 28-75mm f/2.8', #IB
5851             36 => 'Nikkor Z 400mm f/4.5 VR S', #IB
5852             37 => 'Nikkor Z 600mm f/4 TC VR S', #28
5853             38 => 'Nikkor Z 85mm f/1.2 S', #28
5854             39 => 'Nikkor Z 17-28mm f/2.8', #IB
5855             40 => 'Nikkor Z 26mm f/2.8', #28
5856             41 => 'Nikkor Z DX 12-28mm f/3.5-5.6 PZ VR', #28
5857             42 => 'Nikkor Z 180-600mm f/5.6-6.3 VR', #30
5858             43 => 'Nikkor Z DX 24mm f/1.7', #28
5859             44 => 'Nikkor Z 70-180mm f/2.8', #28
5860             45 => 'Nikkor Z 600mm f/6.3 VR S', #28
5861             46 => 'Nikkor Z 135mm f/1.8 S Plena', #28
5862             47 => 'Nikkor Z 35mm f/1.2 S', #28
5863             48 => 'Nikkor Z 28-400mm f/4-8 VR', #30
5864             49 => 'Nikkor Z 28-135mm f/4 PZ', #28
5865             51 => 'Nikkor Z 35mm f/1.4', #28
5866             52 => 'Nikkor Z 50mm f/1.4', #28
5867             2305 => 'Laowa FFII 10mm F2.8 C&D Dreamer', #30
5868             32768 => 'Nikkor Z 400mm f/2.8 TC VR S TC-1.4x', #28
5869             32769 => 'Nikkor Z 600mm f/4 TC VR S TC-1.4x', #28
5870             },
5871             },
5872             0x34 => { #28
5873             Name => 'LensFirmwareVersion',
5874             Condition => '$$self{LensID} and $$self{LensID} != 0', #only valid for Z-mount lenses
5875             Format => 'int16u', #4 bits each for version, release amd modification in VRM scheme.
5876             PrintConv => q{
5877             my $version = int($val / 256);
5878             my $release = int(($val - 256 * $version)/16);
5879             my $modification = $val - (256 * $version + 16 * $release);
5880             return sprintf("%.0f.%.0f.%.0f", $version,$release,$modification);
5881             },
5882             },
5883             0x36 => { #PH
5884             Name => 'MaxAperture',
5885             Condition => '$$self{NewLensData}',
5886             Format => 'int16u',
5887             Priority => 0,
5888             ValueConv => '2**($val/384-1)',
5889             ValueConvInv => '384*(log($val)/log(2)+1)',
5890             PrintConv => 'sprintf("%.1f",$val)',
5891             PrintConvInv => '$val',
5892             },
5893             0x38 => { #PH
5894             Name => 'FNumber',
5895             Condition => '$$self{NewLensData}',
5896             Format => 'int16u',
5897             Priority => 0,
5898             ValueConv => '2**($val/384-1)',
5899             ValueConvInv => '384*(log($val)/log(2)+1)',
5900             PrintConv => 'sprintf("%.1f",$val)',
5901             PrintConvInv => '$val',
5902             },
5903             0x3c => { #PH
5904             Name => 'FocalLength',
5905             Condition => '$$self{NewLensData}',
5906             Format => 'int16u',
5907             Priority => 0,
5908             PrintConv => '"$val mm"',
5909             PrintConvInv => '$val=~s/\s*mm$//;$val',
5910             },
5911             0x4c => { #28
5912             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.
5913             Format => 'int8u',
5914             Condition => '$$self{LensID} and $$self{LensID} != 0 and $$self{FocusMode} ne "Manual"',
5915             RawConv => '$$self{FocusDistanceRangeWidth} = $val',
5916             Unknown => 1,
5917             },
5918             0x4e => { #28
5919             Name => 'FocusDistance',
5920             Format => 'int16u',
5921             Condition => '$$self{LensID} and $$self{LensID} != 0', #only valid for Z-mount lenses
5922             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
5923             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
5924             ValueConvInv => '$val>0 ? log(12*($val+80)/log(2) : 0', #was '$val>0 ? 40*log($val*100)/log(10) : 0'
5925             PrintConv => q{
5926             (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),
5927             },
5928             },
5929             0x56 => { #28 #not valid for focus mode M
5930             Name => 'LensDriveEnd', # byte contains: 1 at CFD/MOD; 2 at Infinity; 0 otherwise
5931             Condition => '$$self{LensID} and $$self{LensID} != 0 and $$self{FocusMode} ne "Manual"', #valid for Z-mount lenses in focus modes other than M
5932             Format => 'int8u',
5933             RawConv => 'unless (defined $$self{FocusDistanceRangeWidth} and not $$self{FocusDistanceRangeWidth}) { if ($val == 0 ) {$$self{LensDriveEnd} = "No"} else { $$self{LensDriveEnd} = "CFD"} } else{ $$self{LensDriveEnd} = "Inf"}',
5934             Unknown => 1,
5935             },
5936             0x58 => { #28
5937             Name => 'FocusStepsFromInfinity',
5938             Condition => '$$self{LensID} and $$self{LensID} != 0', #valid for Z-mount lenses in both AF and manual focus modes
5939             Format => 'int8u',
5940             RawConv => '$$self{FocusStepsFromInfinity} = $val', # 0 at Infinity, otherwise a small positive number monotonically increasing towards CFD.
5941             Unknown => 1,
5942             },
5943             0x5a => { #28
5944             Name => 'LensPositionAbsolute', # <=0 at infinity. Typical value at CFD might be 58000. Only valid for Z-mount lenses.
5945             Condition => '$$self{LensID} and $$self{LensID} != 0', # Only valid for Z-mount lenses.
5946             Format => 'int32s',
5947             #Unknown => 1,
5948             },
5949             0x5f => { #28
5950             Name => 'LensMountType',
5951             Format => 'int8u',
5952             Mask => 0x01,
5953             PrintConv => {
5954             0 => 'Z-mount',
5955             1 => 'F-mount',
5956             },
5957             },
5958             );
5959              
5960             # Unknown Nikon lens data (note: data may need decrypting after byte 4)
5961             %Image::ExifTool::Nikon::LensDataUnknown = (
5962             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
5963             FIRST_ENTRY => 0,
5964             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5965             0x00 => {
5966             Name => 'LensDataVersion',
5967             Format => 'string[4]',
5968             },
5969             );
5970              
5971             # shot information (encrypted in some cameras) - ref 18
5972             %Image::ExifTool::Nikon::ShotInfo = (
5973             %binaryDataAttrs,
5974             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5975             DATAMEMBER => [ 0 ],
5976             NOTES => q{
5977             This information is encrypted for ShotInfoVersion 02xx, and some tags are
5978             only valid for specific models.
5979             },
5980             0x00 => {
5981             Name => 'ShotInfoVersion',
5982             Format => 'string[4]',
5983             Writable => 0,
5984             RawConv => '$$self{ShotInfoVersion} = $val; $val =~ /^\d+$/ ? $val : undef',
5985             },
5986             0x04 => {
5987             Name => 'FirmwareVersion',
5988             Format => 'string[5]',
5989             Writable => 0,
5990             RawConv => '$val =~ /^\d\.\d+.$/ ? $val : undef',
5991             },
5992             0x10 => {
5993             Name => 'DistortionControl',
5994             Condition => '$$self{Model} =~ /P6000\b/',
5995             Notes => 'P6000',
5996             PrintConv => \%offOn,
5997             },
5998             0x66 => {
5999             Name => 'VR_0x66',
6000             Condition => '$$self{ShotInfoVersion} eq "0204"',
6001             Format => 'int8u',
6002             Unknown => 1,
6003             Notes => 'D2X, D2Xs (unverified)',
6004             PrintConv => {
6005             0 => 'Off',
6006             1 => 'On (normal)',
6007             2 => 'On (active)',
6008             },
6009             },
6010             # 6a, 6e not correct for 0103 (D70), 0207 (D200)
6011             0x6a => {
6012             Name => 'ShutterCount',
6013             Condition => '$$self{ShotInfoVersion} eq "0204"',
6014             Format => 'int32u',
6015             Priority => 0,
6016             Notes => 'D2X, D2Xs',
6017             },
6018             0x6e => {
6019             Name => 'DeletedImageCount',
6020             Condition => '$$self{ShotInfoVersion} eq "0204"',
6021             Format => 'int32u',
6022             Priority => 0,
6023             Notes => 'D2X, D2Xs',
6024             },
6025             0x75 => { #JD
6026             Name => 'VibrationReduction',
6027             Condition => '$$self{ShotInfoVersion} eq "0207"',
6028             Format => 'int8u',
6029             Notes => 'D200',
6030             PrintConv => {
6031             0 => 'Off',
6032             # (not sure what the different values represent, but values
6033             # of 1 and 2 have even been observed for non-VR lenses!)
6034             1 => 'On (1)', #PH
6035             2 => 'On (2)', #PH
6036             3 => 'On (3)', #PH (rare -- only seen once)
6037             },
6038             },
6039             0x82 => { # educated guess, needs verification
6040             Name => 'VibrationReduction',
6041             Condition => '$$self{ShotInfoVersion} eq "0204"',
6042             Format => 'int8u',
6043             Notes => 'D2X, D2Xs',
6044             PrintConv => {
6045             0 => 'Off',
6046             1 => 'On',
6047             },
6048             },
6049             # 0xac - int16u[600] TiffMeteringImage1: 30x20 image (ShotInfoVersion 0800, ref JR)
6050             0x157 => { #JD
6051             Name => 'ShutterCount',
6052             Condition => '$$self{ShotInfoVersion} eq "0205"',
6053             Format => 'undef[2]',
6054             Priority => 0,
6055             Notes => 'D50',
6056             # treat as a 2-byte big-endian integer
6057             ValueConv => 'unpack("n", $val)',
6058             ValueConvInv => 'pack("n",$val)',
6059             },
6060             0x1ae => { #JD
6061             Name => 'VibrationReduction',
6062             Condition => '$$self{ShotInfoVersion} eq "0205"',
6063             Format => 'int8u',
6064             Notes => 'D50',
6065             PrintHex => 1,
6066             PrintConv => {
6067             0x00 => 'n/a',
6068             0x0c => 'Off',
6069             0x0f => 'On',
6070             },
6071             },
6072             0x24d => { #PH
6073             Name => 'ShutterCount',
6074             Condition => '$$self{ShotInfoVersion} eq "0211"',
6075             Notes => 'D60',
6076             Format => 'int32u',
6077             Priority => 0,
6078             },
6079             # 0x55c - int16u[2400] TiffMeteringImage2: 60x40 image (ShotInfoVersion 0800, ref JR)
6080             # 0x181c - int16u[1200] TiffMeteringImage?: 60x20 image for some NEF's (ShotInfoVersion 0800, ref JR)
6081             # 0x217c - int16u[2400] TiffMeteringImage3: 60x40 image (ShotInfoVersion 0800, ref JR)
6082             # 0x3d9c - int16u[2400] TiffMeteringImage4: 60x40 image (ShotInfoVersion 0800, ref JR)
6083             # 0x59c0 - TiffMeteringImageWidth (ShotInfoVersion 0800, ref JR)
6084             # 0x59c2 - TiffMeteringImageHeight (ShotInfoVersion 0800, ref JR)
6085             # 0x59c4 - int16u[1800] TiffMeteringImage5: 30x20 RGB image (ShotInfoVersion 0800, ref JR)
6086             );
6087              
6088             # shot information for D40 and D40X (encrypted) - ref PH
6089             %Image::ExifTool::Nikon::ShotInfoD40 = (
6090             PROCESS_PROC => \&ProcessNikonEncrypted,
6091             WRITE_PROC => \&ProcessNikonEncrypted,
6092             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6093             VARS => { ID_LABEL => 'Index' },
6094             IS_SUBDIR => [ 729 ],
6095             WRITABLE => 1,
6096             FIRST_ENTRY => 0,
6097             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6098             NOTES => 'These tags are extracted from encrypted data in D40 and D40X images.',
6099             0x00 => {
6100             Name => 'ShotInfoVersion',
6101             Format => 'string[4]',
6102             Writable => 0,
6103             },
6104             582 => {
6105             Name => 'ShutterCount',
6106             Format => 'int32u',
6107             Priority => 0,
6108             },
6109             586.1 => { #JD
6110             Name => 'VibrationReduction',
6111             Mask => 0x08,
6112             PrintConv => { 0 => 'Off', 1 => 'On' },
6113             },
6114             729 => { #JD
6115             Name => 'CustomSettingsD40',
6116             Format => 'undef[12]',
6117             SubDirectory => {
6118             TagTable => 'Image::ExifTool::NikonCustom::SettingsD40',
6119             },
6120             },
6121             );
6122              
6123             # shot information for D80 (encrypted) - ref JD
6124             %Image::ExifTool::Nikon::ShotInfoD80 = (
6125             PROCESS_PROC => \&ProcessNikonEncrypted,
6126             WRITE_PROC => \&ProcessNikonEncrypted,
6127             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6128             VARS => { ID_LABEL => 'Index' },
6129             IS_SUBDIR => [ 748 ],
6130             WRITABLE => 1,
6131             FIRST_ENTRY => 0,
6132             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6133             NOTES => 'These tags are extracted from encrypted data in D80 images.',
6134             0x00 => {
6135             Name => 'ShotInfoVersion',
6136             Format => 'string[4]',
6137             Writable => 0,
6138             },
6139             586 => {
6140             Name => 'ShutterCount',
6141             Format => 'int32u',
6142             Priority => 0,
6143             },
6144             # split 590 into a few different tags
6145             590.1 => {
6146             Name => 'Rotation',
6147             Mask => 0x07,
6148             PrintConv => {
6149             0 => 'Horizontal',
6150             1 => 'Rotate 270 CW',
6151             2 => 'Rotate 90 CW',
6152             3 => 'Rotate 180',
6153             },
6154             },
6155             590.2 => {
6156             Name => 'VibrationReduction',
6157             Mask => 0x18,
6158             PrintConv => {
6159             0 => 'Off',
6160             3 => 'On',
6161             },
6162             },
6163             590.3 => {
6164             Name => 'FlashFired',
6165             Mask => 0xe0,
6166             PrintConv => { BITMASK => {
6167             1 => 'Internal',
6168             2 => 'External',
6169             }},
6170             },
6171             708 => {
6172             Name => 'NikonImageSize',
6173             Mask => 0xf0,
6174             PrintConv => {
6175             0 => 'Large (10.0 M)',
6176             1 => 'Medium (5.6 M)',
6177             2 => 'Small (2.5 M)',
6178             },
6179             },
6180             708.1 => {
6181             Name => 'ImageQuality',
6182             Mask => 0x0f,
6183             PrintConv => {
6184             0 => 'NEF (RAW)',
6185             1 => 'JPEG Fine',
6186             2 => 'JPEG Normal',
6187             3 => 'JPEG Basic',
6188             4 => 'NEF (RAW) + JPEG Fine',
6189             5 => 'NEF (RAW) + JPEG Normal',
6190             6 => 'NEF (RAW) + JPEG Basic',
6191             },
6192             },
6193             748 => { #JD
6194             Name => 'CustomSettingsD80',
6195             Format => 'undef[17]',
6196             SubDirectory => {
6197             TagTable => 'Image::ExifTool::NikonCustom::SettingsD80',
6198             },
6199             },
6200             );
6201              
6202             # shot information for D90 (encrypted) - ref PH
6203             %Image::ExifTool::Nikon::ShotInfoD90 = (
6204             PROCESS_PROC => \&ProcessNikonEncrypted,
6205             WRITE_PROC => \&ProcessNikonEncrypted,
6206             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6207             VARS => { ID_LABEL => 'Index' },
6208             IS_SUBDIR => [ 0x374 ],
6209             WRITABLE => 1,
6210             FIRST_ENTRY => 0,
6211             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6212             NOTES => q{
6213             These tags are extracted from encrypted data in images from the D90 with
6214             firmware 1.00.
6215             },
6216             0x00 => {
6217             Name => 'ShotInfoVersion',
6218             Format => 'string[4]',
6219             Writable => 0,
6220             },
6221             0x04 => {
6222             Name => 'FirmwareVersion',
6223             Format => 'string[5]',
6224             Writable => 0,
6225             },
6226             0x2b5 => { #JD (same value found at offset 0x39, 0x2bf, 0x346)
6227             Name => 'ISO2',
6228             ValueConv => '100*exp(($val/12-5)*log(2))',
6229             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6230             PrintConv => 'int($val + 0.5)',
6231             PrintConvInv => '$val',
6232             },
6233             0x2d5 => {
6234             Name => 'ShutterCount',
6235             Format => 'int32u',
6236             Priority => 0,
6237             },
6238             0x374 => {
6239             Name => 'CustomSettingsD90',
6240             Format => 'undef[36]',
6241             SubDirectory => {
6242             TagTable => 'Image::ExifTool::NikonCustom::SettingsD90',
6243             },
6244             },
6245             );
6246              
6247             # shot information for the D3 firmware 0.37 and 1.00 (encrypted) - ref PH
6248             %Image::ExifTool::Nikon::ShotInfoD3a = (
6249             PROCESS_PROC => \&ProcessNikonEncrypted,
6250             WRITE_PROC => \&ProcessNikonEncrypted,
6251             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6252             VARS => { ID_LABEL => 'Index' },
6253             IS_SUBDIR => [ 0x301 ],
6254             WRITABLE => 1,
6255             FIRST_ENTRY => 0,
6256             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6257             NOTES => q{
6258             These tags are extracted from encrypted data in images from the D3 with
6259             firmware 1.00 and earlier.
6260             },
6261             0x00 => {
6262             Name => 'ShotInfoVersion',
6263             Format => 'string[4]',
6264             Writable => 0,
6265             },
6266             0x256 => { #JD (same value found at offset 0x26b)
6267             Name => 'ISO2',
6268             ValueConv => '100*exp(($val/12-5)*log(2))',
6269             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6270             PrintConv => 'int($val + 0.5)',
6271             PrintConvInv => '$val',
6272             },
6273             0x276 => { #JD
6274             Name => 'ShutterCount',
6275             Format => 'int32u',
6276             Priority => 0,
6277             },
6278             723.1 => {
6279             Name => 'NikonImageSize',
6280             Mask => 0x18,
6281             PrintConv => {
6282             0 => 'Large',
6283             1 => 'Medium',
6284             2 => 'Small',
6285             },
6286             },
6287             723.2 => {
6288             Name => 'ImageQuality',
6289             Mask => 0x07,
6290             PrintConv => {
6291             0 => 'NEF (RAW) + JPEG Fine',
6292             1 => 'NEF (RAW) + JPEG Norm',
6293             2 => 'NEF (RAW) + JPEG Basic',
6294             3 => 'NEF (RAW)',
6295             4 => 'TIF (RGB)',
6296             5 => 'JPEG Fine',
6297             6 => 'JPEG Normal',
6298             7 => 'JPEG Basic',
6299             },
6300             },
6301             0x301 => { #(NC)
6302             Name => 'CustomSettingsD3',
6303             Format => 'undef[24]',
6304             SubDirectory => {
6305             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
6306             },
6307             },
6308             );
6309              
6310             # shot information for the D3 firmware 1.10, 2.00 and 2.01 (encrypted) - ref PH
6311             %Image::ExifTool::Nikon::ShotInfoD3b = (
6312             PROCESS_PROC => \&ProcessNikonEncrypted,
6313             WRITE_PROC => \&ProcessNikonEncrypted,
6314             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6315             VARS => { ID_LABEL => 'Index' },
6316             IS_SUBDIR => [ 0x30a ],
6317             WRITABLE => 1,
6318             FIRST_ENTRY => 0,
6319             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6320             DATAMEMBER => [ 4 ],
6321             NOTES => q{
6322             These tags are extracted from encrypted data in images from the D3 with
6323             firmware 1.10, 2.00, 2.01 and 2.02.
6324             },
6325             0x00 => {
6326             Name => 'ShotInfoVersion',
6327             Format => 'string[4]',
6328             Writable => 0,
6329             },
6330             0x04 => {
6331             Name => 'FirmwareVersion',
6332             Format => 'string[5]',
6333             Writable => 0,
6334             RawConv => '$$self{FirmwareVersion} = $val',
6335             },
6336             0x10 => { #28
6337             Name => 'ImageArea',
6338             PrintConv => {
6339             0 => 'FX (36x24)',
6340             1 => 'DX (24x16)',
6341             2 => '5:4 (30x24)',
6342             },
6343             },
6344             0x25d => {
6345             Name => 'ISO2',
6346             ValueConv => '100*exp(($val/12-5)*log(2))',
6347             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6348             PrintConv => 'int($val + 0.5)',
6349             PrintConvInv => '$val',
6350             },
6351             0x27d => {
6352             Name => 'ShutterCount',
6353             Condition => '$$self{FirmwareVersion} =~ /^1\.01/',
6354             Notes => 'firmware 1.10',
6355             Format => 'int32u',
6356             Priority => 0,
6357             },
6358             0x27f => {
6359             Name => 'ShutterCount',
6360             Condition => '$$self{FirmwareVersion} =~ /^2\.0/',
6361             Notes => 'firmware 2.00, 2.01 and 2.02',
6362             Format => 'int32u',
6363             Priority => 0,
6364             },
6365             732.1 => { #28
6366             Name => 'NikonImageSize',
6367             Mask => 0x18,
6368             PrintConv => {
6369             0 => 'Large',
6370             1 => 'Medium',
6371             2 => 'Small',
6372             },
6373             },
6374             732.2 => { #28
6375             Name => 'ImageQuality',
6376             Mask => 0x07,
6377             PrintConv => {
6378             0 => 'NEF (RAW) + JPEG Fine',
6379             1 => 'NEF (RAW) + JPEG Norm',
6380             2 => 'NEF (RAW) + JPEG Basic',
6381             3 => 'NEF (RAW)',
6382             4 => 'TIF (RGB)',
6383             5 => 'JPEG Fine',
6384             6 => 'JPEG Normal',
6385             7 => 'JPEG Basic',
6386             },
6387             },
6388             0x28a => { #28
6389             Name => 'PreFlashReturnStrength',
6390             Notes => 'valid in TTL and TTL-BL flash control modes',
6391             # this is used to set the flash power using this relationship
6392             # for the SB-800 and SB-900:
6393             # $val < 140 ? 2**(0.08372*$val-12.352) : $val
6394             },
6395             0x30a => { # tested with firmware 2.00
6396             Name => 'CustomSettingsD3',
6397             Format => 'undef[24]',
6398             SubDirectory => {
6399             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
6400             },
6401             },
6402             );
6403              
6404             # shot information for the D3X firmware 1.00 (encrypted) - ref PH
6405             %Image::ExifTool::Nikon::ShotInfoD3X = (
6406             PROCESS_PROC => \&ProcessNikonEncrypted,
6407             WRITE_PROC => \&ProcessNikonEncrypted,
6408             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6409             VARS => { ID_LABEL => 'Index' },
6410             IS_SUBDIR => [ 0x30b ],
6411             WRITABLE => 1,
6412             FIRST_ENTRY => 0,
6413             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6414             NOTES => q{
6415             These tags are extracted from encrypted data in images from the D3X with
6416             firmware 1.00.
6417             },
6418             0x00 => {
6419             Name => 'ShotInfoVersion',
6420             Format => 'string[4]',
6421             Writable => 0,
6422             },
6423             0x04 => {
6424             Name => 'FirmwareVersion',
6425             Format => 'string[5]',
6426             Writable => 0,
6427             },
6428             0x25d => {
6429             Name => 'ISO2',
6430             ValueConv => '100*exp(($val/12-5)*log(2))',
6431             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6432             PrintConv => 'int($val + 0.5)',
6433             PrintConvInv => '$val',
6434             },
6435             0x280 => {
6436             Name => 'ShutterCount',
6437             Format => 'int32u',
6438             Priority => 0,
6439             },
6440             0x30b => { #(NC)
6441             Name => 'CustomSettingsD3X',
6442             Format => 'undef[24]',
6443             SubDirectory => {
6444             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
6445             },
6446             },
6447             );
6448              
6449             # shot information for the D3S firmware 0.16 and 1.00 (encrypted) - ref PH
6450             %Image::ExifTool::Nikon::ShotInfoD3S = (
6451             PROCESS_PROC => \&ProcessNikonEncrypted,
6452             WRITE_PROC => \&ProcessNikonEncrypted,
6453             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6454             VARS => { ID_LABEL => 'Index' },
6455             IS_SUBDIR => [ 0x2ce ],
6456             WRITABLE => 1,
6457             FIRST_ENTRY => 0,
6458             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6459             NOTES => q{
6460             These tags are extracted from encrypted data in images from the D3S with
6461             firmware 1.00 and earlier.
6462             },
6463             0x00 => {
6464             Name => 'ShotInfoVersion',
6465             Format => 'string[4]',
6466             Writable => 0,
6467             },
6468             0x04 => {
6469             Name => 'FirmwareVersion',
6470             Format => 'string[5]',
6471             Writable => 0,
6472             },
6473             0x10 => { #28
6474             Name => 'ImageArea',
6475             PrintConv => {
6476             0 => 'FX (36x24)',
6477             1 => 'DX (24x16)',
6478             2 => '5:4 (30x24)',
6479             3 => '1.2x (30x20)',
6480             },
6481             },
6482             0x221 => {
6483             Name => 'ISO2',
6484             ValueConv => '100*exp(($val/12-5)*log(2))',
6485             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6486             PrintConv => 'int($val + 0.5)',
6487             PrintConvInv => '$val',
6488             },
6489             0x242 => {
6490             Name => 'ShutterCount',
6491             Format => 'int32u',
6492             Priority => 0,
6493             },
6494             671.1 => { # 0x29f
6495             Name => 'JPGCompression',
6496             Mask => 0x40,
6497             PrintConv => {
6498             0 => 'Size Priority',
6499             1 => 'Optimal Quality',
6500             },
6501             },
6502             # this works for one set of D3S samples, but is 0 in some others
6503             #671.2 => { # 0x29f
6504             # Name => 'Quality',
6505             # Mask => 0x03,
6506             # PrintConv => {
6507             # 1 => 'Fine',
6508             # 2 => 'Normal',
6509             # 3 => 'Basic',
6510             # },
6511             #},
6512             0x2ce => { #(NC)
6513             Name => 'CustomSettingsD3S',
6514             Format => 'undef[27]',
6515             SubDirectory => {
6516             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
6517             },
6518             },
6519             );
6520              
6521             # shot information for the D300 firmware 1.00 (encrypted) - ref JD
6522             %Image::ExifTool::Nikon::ShotInfoD300a = (
6523             PROCESS_PROC => \&ProcessNikonEncrypted,
6524             WRITE_PROC => \&ProcessNikonEncrypted,
6525             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6526             VARS => { ID_LABEL => 'Index' },
6527             IS_SUBDIR => [ 790 ],
6528             WRITABLE => 1,
6529             FIRST_ENTRY => 0,
6530             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6531             NOTES => q{
6532             These tags are extracted from encrypted data in images from the D300 with
6533             firmware 1.00 and earlier.
6534             },
6535             0x00 => {
6536             Name => 'ShotInfoVersion',
6537             Format => 'string[4]',
6538             Writable => 0,
6539             },
6540             604 => {
6541             Name => 'ISO2',
6542             ValueConv => '100*exp(($val/12-5)*log(2))',
6543             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6544             PrintConv => 'int($val + 0.5)',
6545             PrintConvInv => '$val',
6546             },
6547             633 => {
6548             Name => 'ShutterCount',
6549             Format => 'int32u',
6550             Priority => 0,
6551             },
6552             721 => { #PH
6553             Name => 'AFFineTuneAdj',
6554             Format => 'int16u',
6555             PrintHex => 1,
6556             PrintConvColumns => 3,
6557             # thanks to Neil Nappe for the samples to decode this!...
6558             # (have seen various unknown values here when flash is enabled, but
6559             # these are yet to be decoded: 0x2e,0x619,0xd0d,0x103a,0x2029 - PH)
6560             PrintConv => {
6561             0x403e => '+20',
6562             0x303e => '+19',
6563             0x203e => '+18',
6564             0x103e => '+17',
6565             0x003e => '+16',
6566             0xe03d => '+15',
6567             0xc03d => '+14',
6568             0xa03d => '+13',
6569             0x803d => '+12',
6570             0x603d => '+11',
6571             0x403d => '+10',
6572             0x203d => '+9',
6573             0x003d => '+8',
6574             0xc03c => '+7',
6575             0x803c => '+6',
6576             0x403c => '+5',
6577             0x003c => '+4',
6578             0x803b => '+3',
6579             0x003b => '+2',
6580             0x003a => '+1',
6581             0x0000 => '0',
6582             0x00c6 => '-1',
6583             0x00c5 => '-2',
6584             0x80c5 => '-3',
6585             0x00c4 => '-4',
6586             0x40c4 => '-5',
6587             0x80c4 => '-6',
6588             0xc0c4 => '-7',
6589             0x00c3 => '-8',
6590             0x20c3 => '-9',
6591             0x40c3 => '-10',
6592             0x60c3 => '-11',
6593             0x80c3 => '-12',
6594             0xa0c3 => '-13',
6595             0xc0c3 => '-14',
6596             0xe0c3 => '-15',
6597             0x00c2 => '-16',
6598             0x10c2 => '-17',
6599             0x20c2 => '-18',
6600             0x30c2 => '-19',
6601             0x40c2 => '-20',
6602             },
6603             },
6604             790 => {
6605             Name => 'CustomSettingsD300',
6606             Format => 'undef[24]',
6607             SubDirectory => {
6608             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
6609             },
6610             },
6611             );
6612              
6613             # shot information for the D300 firmware 1.10 (encrypted) - ref PH
6614             %Image::ExifTool::Nikon::ShotInfoD300b = (
6615             PROCESS_PROC => \&ProcessNikonEncrypted,
6616             WRITE_PROC => \&ProcessNikonEncrypted,
6617             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6618             VARS => { ID_LABEL => 'Index' },
6619             DATAMEMBER => [ 4 ],
6620             IS_SUBDIR => [ 802 ],
6621             WRITABLE => 1,
6622             FIRST_ENTRY => 0,
6623             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6624             NOTES => q{
6625             These tags are extracted from encrypted data in images from the D300 with
6626             firmware 1.10.
6627             },
6628             0x00 => {
6629             Name => 'ShotInfoVersion',
6630             Format => 'string[4]',
6631             Writable => 0,
6632             },
6633             0x04 => { #PH
6634             Name => 'FirmwareVersion',
6635             DataMember => 'FirmwareVersion',
6636             Format => 'string[5]',
6637             Writable => 0,
6638             RawConv => '$$self{FirmwareVersion} = $val',
6639             },
6640             613 => {
6641             Name => 'ISO2',
6642             ValueConv => '100*exp(($val/12-5)*log(2))',
6643             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6644             PrintConv => 'int($val + 0.5)',
6645             PrintConvInv => '$val',
6646             },
6647             644 => {
6648             Name => 'ShutterCount',
6649             Format => 'int32u',
6650             Priority => 0,
6651             },
6652             732 => [{
6653             Name => 'AFFineTuneAdj',
6654             Condition => '$$self{FirmwareVersion} eq "1.10B"',
6655             Notes => 'firmware version 1.10B',
6656             Format => 'int16u',
6657             PrintHex => 1,
6658             PrintConvColumns => 3,
6659             # thanks to Michael Tapes for the samples to decode this!...
6660             PrintConv => {
6661             0xe03e => '+20',
6662             0xc83e => '+19',
6663             0xb03e => '+18',
6664             0x983e => '+17',
6665             0x803e => '+16',
6666             0x683e => '+15',
6667             0x503e => '+14',
6668             0x383e => '+13',
6669             0x203e => '+12',
6670             0x083e => '+11',
6671             0xe03d => '+10',
6672             0xb03d => '+9',
6673             0x803d => '+8',
6674             0x503d => '+7',
6675             0x203d => '+6',
6676             0xe03c => '+5',
6677             0x803c => '+4',
6678             0x203c => '+3',
6679             0x803b => '+2',
6680             0x803a => '+1',
6681             0x0000 => '0',
6682             0x80c6 => '-1',
6683             0x80c5 => '-2',
6684             0x20c4 => '-3',
6685             0x80c4 => '-4',
6686             0xe0c4 => '-5',
6687             0x20c3 => '-6',
6688             0x50c3 => '-7',
6689             0x80c3 => '-8',
6690             0xb0c3 => '-9',
6691             0xe0c3 => '-10',
6692             0x08c2 => '-11',
6693             0x20c2 => '-12',
6694             0x38c2 => '-13',
6695             0x50c2 => '-14',
6696             0x68c2 => '-15',
6697             0x80c2 => '-16',
6698             0x98c2 => '-17',
6699             0xb0c2 => '-18',
6700             0xc8c2 => '-19',
6701             0xe0c2 => '-20',
6702             },
6703             },{
6704             Name => 'AFFineTuneAdj',
6705             Notes => 'other versions',
6706             Format => 'int16u',
6707             PrintHex => 1,
6708             PrintConvColumns => 3,
6709             # thanks to Stuart Solomon for the samples to decode this!...
6710             PrintConv => {
6711             0x903e => '+20',
6712             0x7c3e => '+19',
6713             0x683e => '+18',
6714             0x543e => '+17',
6715             0x403e => '+16',
6716             0x2c3e => '+15',
6717             0x183e => '+14',
6718             0x043e => '+13',
6719             0xe03d => '+12',
6720             0xb83d => '+11',
6721             0x903d => '+10',
6722             0x683d => '+9',
6723             0x403d => '+8',
6724             0x183d => '+7',
6725             0xe03c => '+6',
6726             0x903c => '+5',
6727             0x403c => '+4',
6728             0xe03b => '+3',
6729             0x403b => '+2',
6730             0x403a => '+1',
6731             0x0000 => '0',
6732             0x40c6 => '-1',
6733             0x40c5 => '-2',
6734             0xe0c5 => '-3',
6735             0x40c4 => '-4',
6736             0x90c4 => '-5',
6737             0xe0c4 => '-6',
6738             0x18c3 => '-7',
6739             0x40c3 => '-8',
6740             0x68c3 => '-9',
6741             0x90c3 => '-10',
6742             0xb8c3 => '-11',
6743             0xe0c3 => '-12',
6744             0x04c2 => '-13',
6745             0x18c2 => '-14',
6746             0x2cc2 => '-15',
6747             0x40c2 => '-16',
6748             0x54c2 => '-17',
6749             0x68c2 => '-18',
6750             0x7cc2 => '-19',
6751             0x90c2 => '-20',
6752             },
6753             }],
6754             802 => {
6755             Name => 'CustomSettingsD300',
6756             Format => 'undef[24]',
6757             SubDirectory => {
6758             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
6759             },
6760             },
6761             );
6762              
6763             # shot information for the D300S firmware 1.00 (encrypted) - ref PH
6764             %Image::ExifTool::Nikon::ShotInfoD300S = (
6765             PROCESS_PROC => \&ProcessNikonEncrypted,
6766             WRITE_PROC => \&ProcessNikonEncrypted,
6767             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6768             VARS => { ID_LABEL => 'Index' },
6769             IS_SUBDIR => [ 804 ],
6770             WRITABLE => 1,
6771             FIRST_ENTRY => 0,
6772             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6773             NOTES => q{
6774             These tags are extracted from encrypted data in images from the D300S with
6775             firmware 1.00.
6776             },
6777             0x00 => {
6778             Name => 'ShotInfoVersion',
6779             Format => 'string[4]',
6780             Writable => 0,
6781             },
6782             0x04 => {
6783             Name => 'FirmwareVersion',
6784             Format => 'string[5]',
6785             Writable => 0,
6786             },
6787             613 => {
6788             Name => 'ISO2',
6789             ValueConv => '100*exp(($val/12-5)*log(2))',
6790             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6791             PrintConv => 'int($val + 0.5)',
6792             PrintConvInv => '$val',
6793             },
6794             646 => {
6795             Name => 'ShutterCount',
6796             Format => 'int32u',
6797             Priority => 0,
6798             },
6799             804 => { #(NC)
6800             Name => 'CustomSettingsD300S',
6801             Format => 'undef[24]',
6802             SubDirectory => {
6803             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
6804             },
6805             },
6806             );
6807              
6808             # shot information for the D700 firmware 1.02f (encrypted) - ref 29
6809             %Image::ExifTool::Nikon::ShotInfoD700 = (
6810             PROCESS_PROC => \&ProcessNikonEncrypted,
6811             WRITE_PROC => \&ProcessNikonEncrypted,
6812             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6813             VARS => { ID_LABEL => 'Index' },
6814             IS_SUBDIR => [ 804 ],
6815             WRITABLE => 1,
6816             FIRST_ENTRY => 0,
6817             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6818             NOTES => q{
6819             These tags are extracted from encrypted data in images from the D700 with
6820             firmware 1.02f.
6821             },
6822             0x00 => {
6823             Name => 'ShotInfoVersion',
6824             Format => 'string[4]',
6825             Writable => 0,
6826             },
6827             0x04 => {
6828             Name => 'FirmwareVersion',
6829             Format => 'string[5]',
6830             Writable => 0,
6831             },
6832             613 => { # 0x265
6833             Name => 'ISO2',
6834             ValueConv => '100*exp(($val/12-5)*log(2))',
6835             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6836             PrintConv => 'int($val + 0.5)',
6837             PrintConvInv => '$val',
6838             },
6839             0x287 => {
6840             Name => 'ShutterCount',
6841             Format => 'int32u',
6842             Priority => 0,
6843             },
6844             804 => { # 0x324 (NC)
6845             Name => 'CustomSettingsD700',
6846             Format => 'undef[48]',
6847             SubDirectory => {
6848             TagTable => 'Image::ExifTool::NikonCustom::SettingsD700',
6849             },
6850             },
6851             );
6852              
6853             # shot information for the D780 - ref #28
6854             %Image::ExifTool::Nikon::ShotInfoD780 = (
6855             PROCESS_PROC => \&ProcessNikonEncrypted,
6856             WRITE_PROC => \&ProcessNikonEncrypted,
6857             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6858             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x24 },
6859             DATAMEMBER => [ 0x04 ],
6860             IS_SUBDIR => [ 0x9c ],
6861             WRITABLE => 1,
6862             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6863             NOTES => 'These tags are extracted from encrypted data in images from the D780.',
6864             0x00 => {
6865             Name => 'ShotInfoVersion',
6866             Format => 'string[4]',
6867             Writable => 0,
6868             },
6869             0x04 => {
6870             Name => 'FirmwareVersion',
6871             DataMember => 'FirmwareVersion',
6872             Format => 'string[5]',
6873             Writable => 0,
6874             RawConv => '$$self{FirmwareVersion} = $val',
6875             },
6876             0x9c => {
6877             Name => 'OrientOffset',
6878             Format => 'int32u',
6879             SubDirectory => {
6880             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
6881             Start => '$val',
6882             },
6883             },
6884             );
6885              
6886             # shot information for the D5000 firmware 1.00 (encrypted) - ref PH
6887             %Image::ExifTool::Nikon::ShotInfoD5000 = (
6888             PROCESS_PROC => \&ProcessNikonEncrypted,
6889             WRITE_PROC => \&ProcessNikonEncrypted,
6890             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6891             VARS => { ID_LABEL => 'Index' },
6892             IS_SUBDIR => [ 0x378 ],
6893             WRITABLE => 1,
6894             FIRST_ENTRY => 0,
6895             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6896             NOTES => q{
6897             These tags are extracted from encrypted data in images from the D5000 with
6898             firmware 1.00.
6899             },
6900             0x00 => {
6901             Name => 'ShotInfoVersion',
6902             Format => 'string[4]',
6903             Writable => 0,
6904             },
6905             0x04 => {
6906             Name => 'FirmwareVersion',
6907             Format => 'string[5]',
6908             Writable => 0,
6909             },
6910             0x2b5 => { # (also found at 0x2c0)
6911             Name => 'ISO2',
6912             ValueConv => '100*exp(($val/12-5)*log(2))',
6913             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6914             PrintConv => 'int($val + 0.5)',
6915             PrintConvInv => '$val',
6916             },
6917             0x2d6 => {
6918             Name => 'ShutterCount',
6919             Format => 'int32u',
6920             Priority => 0,
6921             },
6922             0x378 => {
6923             Name => 'CustomSettingsD5000',
6924             Format => 'undef[34]',
6925             SubDirectory => {
6926             TagTable => 'Image::ExifTool::NikonCustom::SettingsD5000',
6927             },
6928             },
6929             );
6930              
6931             # shot information for the D5100 firmware 1.00f (encrypted) - ref PH
6932             %Image::ExifTool::Nikon::ShotInfoD5100 = (
6933             PROCESS_PROC => \&ProcessNikonEncrypted,
6934             WRITE_PROC => \&ProcessNikonEncrypted,
6935             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6936             VARS => { ID_LABEL => 'Index' },
6937             IS_SUBDIR => [ 0x407 ],
6938             WRITABLE => 1,
6939             FIRST_ENTRY => 0,
6940             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6941             0x00 => {
6942             Name => 'ShotInfoVersion',
6943             Format => 'string[4]',
6944             Writable => 0,
6945             },
6946             0x04 => {
6947             Name => 'FirmwareVersion',
6948             Format => 'string[5]',
6949             Writable => 0,
6950             },
6951             0x321 => {
6952             Name => 'ShutterCount',
6953             Format => 'int32u',
6954             Priority => 0,
6955             },
6956             0x407 => {
6957             Name => 'CustomSettingsD5100',
6958             Format => 'undef[34]',
6959             SubDirectory => {
6960             TagTable => 'Image::ExifTool::NikonCustom::SettingsD5100',
6961             },
6962             },
6963             );
6964              
6965             # shot information for the D5200 firmware 1.00 (encrypted) - ref PH
6966             %Image::ExifTool::Nikon::ShotInfoD5200 = (
6967             PROCESS_PROC => \&ProcessNikonEncrypted,
6968             WRITE_PROC => \&ProcessNikonEncrypted,
6969             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6970             VARS => { ID_LABEL => 'Index' },
6971             IS_SUBDIR => [ 0xcd5 ],
6972             WRITABLE => 1,
6973             FIRST_ENTRY => 0,
6974             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6975             0x00 => {
6976             Name => 'ShotInfoVersion',
6977             Format => 'string[4]',
6978             Writable => 0,
6979             },
6980             0x04 => {
6981             Name => 'FirmwareVersion',
6982             Format => 'string[5]',
6983             Writable => 0,
6984             },
6985             # 0x101 - 2=VR Off, 3=VR On
6986             # 0x13d - 0=VR On, 1=VR Off
6987             0xbd8 => {
6988             Name => 'ShutterCount',
6989             Format => 'int32u',
6990             Priority => 0,
6991             },
6992             # 0xcd2 - 12=VR Off, 15=VR On
6993             0xcd5 => {
6994             Name => 'CustomSettingsD5200',
6995             Format => 'undef[34]',
6996             SubDirectory => {
6997             TagTable => 'Image::ExifTool::NikonCustom::SettingsD5200',
6998             },
6999             },
7000             );
7001              
7002             # shot information for the D7000 firmware 1.01d (encrypted) - ref 29
7003             %Image::ExifTool::Nikon::ShotInfoD7000 = (
7004             PROCESS_PROC => \&ProcessNikonEncrypted,
7005             WRITE_PROC => \&ProcessNikonEncrypted,
7006             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7007             VARS => { ID_LABEL => 'Index' },
7008             IS_SUBDIR => [ 1028 ],
7009             WRITABLE => 1,
7010             FIRST_ENTRY => 0,
7011             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7012             NOTES => q{
7013             These tags are extracted from encrypted data in images from the D7000 with
7014             firmware 1.01b.
7015             },
7016             0x00 => {
7017             Name => 'ShotInfoVersion',
7018             Format => 'string[4]',
7019             Writable => 0,
7020             },
7021             0x04 => {
7022             Name => 'FirmwareVersion',
7023             Format => 'string[5]',
7024             Writable => 0,
7025             },
7026             #613 => {
7027             # Name => 'ISO2',
7028             # ValueConv => '100*exp(($val/12-5)*log(2))',
7029             # ValueConvInv => '(log($val/100)/log(2)+5)*12',
7030             # PrintConv => 'int($val + 0.5)',
7031             # PrintConvInv => '$val',
7032             #},
7033             0x320 => { # 800
7034             Name => 'ShutterCount',
7035             Format => 'int32u',
7036             Priority => 0,
7037             },
7038             0x404 => { # 1028 (NC)
7039             Name => 'CustomSettingsD7000',
7040             Format => 'undef[48]',
7041             SubDirectory => {
7042             TagTable => 'Image::ExifTool::NikonCustom::SettingsD7000',
7043             },
7044             },
7045             );
7046              
7047             # shot information for the D7500 - ref #28
7048             %Image::ExifTool::Nikon::ShotInfoD7500 = (
7049             PROCESS_PROC => \&ProcessNikonEncrypted,
7050             WRITE_PROC => \&ProcessNikonEncrypted,
7051             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7052             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x0c },
7053             DATAMEMBER => [ 0x04 ],
7054             IS_SUBDIR => [ 0xa0 ],
7055             WRITABLE => 1,
7056             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7057             NOTES => 'These tags are extracted from encrypted data in images from the D7500.',
7058             0x00 => {
7059             Name => 'ShotInfoVersion',
7060             Format => 'string[4]',
7061             Writable => 0,
7062             },
7063             0x04 => {
7064             Name => 'FirmwareVersion',
7065             DataMember => 'FirmwareVersion',
7066             Format => 'string[5]',
7067             Writable => 0,
7068             RawConv => '$$self{FirmwareVersion} = $val',
7069             },
7070             0xa0 => {
7071             Name => 'OrientOffset',
7072             Format => 'int32u',
7073             SubDirectory => {
7074             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
7075             Start => '$val',
7076             },
7077             },
7078             );
7079              
7080             # shot information for the D800 firmware 1.01a (encrypted) - ref PH
7081             %Image::ExifTool::Nikon::ShotInfoD800 = (
7082             PROCESS_PROC => \&ProcessNikonEncrypted,
7083             WRITE_PROC => \&ProcessNikonEncrypted,
7084             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7085             VARS => { ID_LABEL => 'Index' },
7086             IS_SUBDIR => [ 0x6ec ],
7087             WRITABLE => 1,
7088             FIRST_ENTRY => 0,
7089             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7090             NOTES => 'These tags are extracted from encrypted data in images from the D800.',
7091             0x00 => {
7092             Name => 'ShotInfoVersion',
7093             Format => 'string[4]',
7094             Writable => 0,
7095             },
7096             0x04 => {
7097             Name => 'FirmwareVersion',
7098             Format => 'string[5]',
7099             Writable => 0,
7100             },
7101             0x4c0 => {
7102             Name => 'RepeatingFlashOutputExternal',
7103             ValueConv => '2 ** (-$val/6)',
7104             ValueConvInv => '$val > 0 ? -6*log($val)/log(2) : 0',
7105             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
7106             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
7107             },
7108             0x4c2 => {
7109             Name => 'RepeatingFlashRateExternal',
7110             DelValue => 0,
7111             RawConv => '$val || undef',
7112             PrintConv => '"$val Hz"',
7113             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
7114             },
7115             0x4c3 => {
7116             Name => 'RepeatingFlashCountExternal',
7117             DelValue => 0,
7118             RawConv => '$val || undef',
7119             },
7120             0x4d2 => {
7121             Name => 'FlashExposureComp2',
7122             Notes => 'includes the effect of flash bracketing',
7123             Format => 'int8s',
7124             ValueConv => '-$val/6',
7125             ValueConvInv => '-6 * $val',
7126             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
7127             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
7128             },
7129             # 0x4d4 - FEC again, doesn't include bracketing this time (internal?)
7130             # (not fully decoded, and duplicated in custom settings)
7131             # 0x4d9 => {
7132             # Name => 'FlashControlBuilt-in',
7133             # PrintConv => {
7134             # 1 => 'TTL',
7135             # 6 => 'Manual',
7136             # 7 => 'Repeating Flash',
7137             # },
7138             # },
7139             0x4da => {
7140             Name => 'RepeatingFlashRateBuilt-in',
7141             DelValue => 0,
7142             RawConv => '$val || undef',
7143             PrintConv => '"$val Hz"',
7144             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
7145             },
7146             0x4db => {
7147             Name => 'RepeatingFlashCountBuilt-in',
7148             DelValue => 0,
7149             RawConv => '$val || undef',
7150             },
7151             # 1294.1 => { # (0x4dc)
7152             # Name => 'FlashModeBuilt-in',
7153             # Mask => 0x0f,
7154             # PrintConv => {
7155             # 0 => 'Front-curtain Sync',
7156             # 1 => 'Red-eye Reduction',
7157             # 2 => 'Redy-eye Reduction with Slow Sync',
7158             # 3 => 'Slow Sync',
7159             # 4 => 'Rear-curtain Sync',
7160             # 5 => 'Rear-curtain Sync 2', # got this in P exposure mode
7161             # },
7162             # },
7163             # 1294.2 => { # (0x4dc)
7164             # Name => 'ExposureMode2',
7165             # Mask => 0xf0,
7166             # PrintConv => {
7167             # 0 => 'Program',
7168             # 1 => 'Aperture Priority',
7169             # 3 => 'Manual',
7170             # },
7171             # },
7172             # 0x511 - related to FlashSyncSpeed
7173             0x51c => 'SequenceNumber',
7174             # 0x4ba+0x63 - interesting
7175             # 0x4ba+0x68 - general downward trend
7176             # 0x4ba+0x7b - FlashControlBuilt-in: 8=TTL, 72=Manual
7177             # (not reliable)
7178             # 1346.1 => { # (0x542)
7179             # Name => 'RepeatingFlashOutputBuilt-in',
7180             # DelValue => 112,
7181             # Mask => 0xfc,
7182             # RawConv => '$val == 0x1c ? undef : 2 ** ($val/3-7)',
7183             # ValueConvInv => '$val > 0 ? (log($val)/log(2)+7)*3 : 0',
7184             # PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
7185             # PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
7186             # },
7187             0x5fb => {
7188             Name => 'ShutterCount',
7189             Format => 'int32u',
7190             },
7191             0x6ec => {
7192             Name => 'CustomSettingsD800',
7193             Format => 'undef[48]',
7194             SubDirectory => {
7195             TagTable => 'Image::ExifTool::NikonCustom::SettingsD800',
7196             },
7197             },
7198             );
7199              
7200             # shot information for the D5 firmware 1.10a and D500 firmware 1.01 (encrypted) - ref 28
7201             %Image::ExifTool::Nikon::ShotInfoD500 = (
7202             PROCESS_PROC => \&ProcessNikonEncrypted,
7203             WRITE_PROC => \&ProcessNikonEncrypted,
7204             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7205             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x0c },
7206             DATAMEMBER => [ 0x04 ],
7207             IS_SUBDIR => [ 0x10, 0x14, 0x2c, 0x50, 0x58, 0xa0, 0xa8 ],
7208             WRITABLE => 1,
7209             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7210             NOTES => 'These tags are extracted from encrypted data in images from the D5 and D500.',
7211             0x00 => {
7212             Name => 'ShotInfoVersion',
7213             Format => 'string[4]',
7214             Writable => 0,
7215             },
7216             0x04 => {
7217             Name => 'FirmwareVersion',
7218             DataMember => 'FirmwareVersion',
7219             Format => 'string[5]',
7220             Writable => 0,
7221             RawConv => '$$self{FirmwareVersion} = $val',
7222             },
7223             0x10 => {
7224             Name => 'RotationInfoOffset',
7225             Format => 'int32u',
7226             SubDirectory => {
7227             TagTable => 'Image::ExifTool::Nikon::RotationInfoD500',
7228             Start => '$val',
7229             }
7230             },
7231             0x14 => {
7232             Name => 'JPGInfoOffset',
7233             Format => 'int32u',
7234             SubDirectory => {
7235             TagTable => 'Image::ExifTool::Nikon::JPGInfoD500',
7236             Start => '$val',
7237             }
7238             },
7239             0x2c => {
7240             Name => 'BracketingOffset',
7241             Format => 'int32u',
7242             SubDirectory => {
7243             TagTable => 'Image::ExifTool::Nikon::BracketingInfoD500',
7244             Start => '$val',
7245             }
7246             },
7247             0x50 => {
7248             Name => 'ShootingMenuOffset',
7249             Format => 'int32u',
7250             SubDirectory => {
7251             TagTable => 'Image::ExifTool::Nikon::ShootingMenuD500',
7252             Start => '$val',
7253             }
7254             },
7255             0x58 => {
7256             Name => 'CustomSettingsOffset',
7257             Format => 'int32u',
7258             SubDirectory => {
7259             TagTable => 'Image::ExifTool::Nikon::CustomSettingsD500',
7260             Start => '$val',
7261             }
7262             },
7263             0xa0 => {
7264             Name => 'OrientationOffset',
7265             Format => 'int32u',
7266             SubDirectory => {
7267             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
7268             Start => '$val',
7269             }
7270             },
7271             0xa8 => {
7272             Name => 'OtherOffset',
7273             Format => 'int32u',
7274             SubDirectory => {
7275             TagTable => 'Image::ExifTool::Nikon::OtherInfoD500',
7276             Start => '$val',
7277             }
7278             },
7279             );
7280              
7281             %Image::ExifTool::Nikon::RotationInfoD500 = (
7282             %binaryDataAttrs,
7283             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7284             0x1a => {
7285             Name => 'Rotation',
7286             Mask => 0x03,
7287             PrintConv => {
7288             0 => 'Horizontal',
7289             1 => 'Rotate 270 CW',
7290             2 => 'Rotate 90 CW',
7291             3 => 'Rotate 180',
7292             },
7293             },
7294             0x20 => {
7295             Name => 'Interval',
7296             # prior version of the d% firmware do not support this tag, nor does the D500 (at least thru firmware 1.3)
7297             Condition => '$$self{Model} eq "NIKON D5" and $$self{FirmwareVersion} ge "1.40"',
7298             PrintConv => '$val > 0 ? sprintf("%.0f", $val) : ""',
7299             },
7300             0x24 => {
7301             Name => 'IntervalFrame',
7302             # prior version of the d% firmware do not support this tag, nor does the D500 (at least thru firmware 1.3)
7303             Condition => '$$self{Model} eq "NIKON D5" and $$self{FirmwareVersion} ge "1.40"',
7304             PrintConv => '$val > 0 ? sprintf("%.0f", $val) : ""',
7305             },
7306             0x0532 => {
7307             Name => 'FlickerReductionIndicator',
7308             Mask => 0x01,
7309             PrintConv => { 0 => 'On', 1 => 'Off' },
7310             },
7311             );
7312              
7313             %Image::ExifTool::Nikon::JPGInfoD500 = (
7314             %binaryDataAttrs,
7315             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7316             0x24 => {
7317             Name => 'JPGCompression',
7318             Mask => 0x01,
7319             PrintConv => {
7320             0 => 'Size Priority',
7321             1 => 'Optimal Quality',
7322             },
7323             },
7324             );
7325              
7326             %Image::ExifTool::Nikon::BracketingInfoD500 = (
7327             %binaryDataAttrs,
7328             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7329             0x0f => {
7330             Name => 'AEBracketingSteps',
7331             Condition => '$$self{FILE_TYPE} ne "TIFF"', # (covers NEF and TIFF)
7332             Mask => 0xff,
7333             PrintHex => 1,
7334             PrintConvColumns => 2,
7335             PrintConv => {
7336             0x00 => 'AE Bracketing Disabled',
7337             0x20 => 'AE Bracketing Disabled',
7338             0x30 => 'AE Bracketing Disabled',
7339             0x40 => 'AE Bracketing Disabled',
7340             0x50 => 'AE Bracketing Disabled',
7341             0x81 => '+3F0.3',
7342             0x82 => '-3F0.3',
7343             0x83 => '+2F0.3',
7344             0x84 => '-2F0.3',
7345             0x85 => '3F0.3',
7346             0x86 => '5F0.3',
7347             0x87 => '7F0.3',
7348             0x88 => '9F0.3',
7349             0x91 => '+3F0.5',
7350             0x92 => '-3F0.5',
7351             0x93 => '+2F0.5',
7352             0x94 => '-2F0.5',
7353             0x95 => '3F0.5',
7354             0x96 => '5F0.5',
7355             0x97 => '7F0.5',
7356             0x98 => '9F0.5',
7357             0xa1 => '+3F0.7',
7358             0xa2 => '-3F0.7',
7359             0xa3 => '+2F0.7',
7360             0xa4 => '-2F0.7',
7361             0xa5 => '3F0.7',
7362             0xa6 => '5F0.7',
7363             0xa7 => '7F0.7',
7364             0xa8 => '9F0.7',
7365             0xb1 => '+3F1',
7366             0xb2 => '-3F1',
7367             0xb3 => '+2F1',
7368             0xb4 => '-2F1',
7369             0xb5 => '3F1',
7370             0xb6 => '5F1',
7371             0xb7 => '7F1',
7372             0xb8 => '9F1',
7373             0xc1 => '+3F2',
7374             0xc2 => '-3F2',
7375             0xc3 => '+2F2',
7376             0xc4 => '-2F2',
7377             0xc5 => '3F2',
7378             0xc6 => '5F2',
7379             0xd1 => '+3F3',
7380             0xd2 => '-3F3',
7381             0xd3 => '+2F3',
7382             0xd4 => '-2F3',
7383             0xd5 => '3F3',
7384             0xd6 => '5F3',
7385             },
7386             },
7387             0x10 => {
7388             Name => 'WBBracketingSteps',
7389             Condition => '$$self{FILE_TYPE} ne "TIFF"', # (covers NEF and TIFF)
7390             Mask => 0xff,
7391             PrintHex => 1,
7392             PrintConvColumns => 2,
7393             PrintConv => {
7394             0x00 => 'WB Bracketing Disabled',
7395             0x01 => 'b3F 1',
7396             0x02 => 'A3F 1',
7397             0x03 => 'b2F 1',
7398             0x04 => 'A2F 1',
7399             0x05 => '3F 1',
7400             0x06 => '5F 1',
7401             0x07 => '7F 1',
7402             0x08 => '9F 1',
7403             0x10 => '0F 2',
7404             0x11 => 'b3F 2',
7405             0x12 => 'A3F 2',
7406             0x13 => 'b2F 2',
7407             0x14 => 'A2F 2',
7408             0x15 => '3F 2',
7409             0x16 => '5F 2',
7410             0x17 => '7F 2',
7411             0x18 => '9F 2',
7412             0x20 => '0F 3',
7413             0x21 => 'b3F 3',
7414             0x22 => 'A3F 3',
7415             0x23 => 'b2F 3',
7416             0x24 => 'A2F 3',
7417             0x25 => '3F 3',
7418             0x26 => '5F 3',
7419             0x27 => '7F 3',
7420             0x28 => '9F 3',
7421             0x22 => 'A3F 3',
7422             0x23 => 'b2F 3',
7423             0x24 => 'A2F 3',
7424             0x25 => '3F 3',
7425             0x26 => '5F 3',
7426             0x27 => '7F 3',
7427             0x28 => '9F 3',
7428             },
7429             },
7430             0x17 => {
7431             Name => 'ADLBracketingStep',
7432             Mask => 0xf0,
7433             PrintConv => {
7434             0 => 'Off',
7435             1 => 'Low',
7436             2 => 'Normal',
7437             3 => 'High',
7438             4 => 'Extra High',
7439             8 => 'Auto',
7440             },
7441             },
7442             0x18 => {
7443             Name => 'ADLBracketingType',
7444             Mask => 0x0f,
7445             PrintConv => {
7446             0 => 'Off',
7447             1 => '2 Shots',
7448             2 => '3 Shots',
7449             3 => '4 Shots',
7450             4 => '5 Shots',
7451             },
7452             },
7453             );
7454              
7455             %Image::ExifTool::Nikon::ShootingMenuD500 = (
7456             %binaryDataAttrs,
7457             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7458             0x00 => {
7459             Name => 'PhotoShootingMenuBank',
7460             Mask => 0x03,
7461             PrintConv => {
7462             0 => 'A',
7463             1 => 'B',
7464             2 => 'C',
7465             3 => 'D',
7466             },
7467             },
7468             0x02 => {
7469             Name => 'PrimarySlot',
7470             Condition => '$$self{Model} =~ /\bD500\b/',
7471             Notes => 'D500 only',
7472             Mask => 0x80,
7473             PrintConv => {
7474             0 => 'XQD Card',
7475             1 => 'SD Card',
7476             },
7477             },
7478             0x04 => {
7479             Name => 'ISOAutoShutterTime',
7480             Mask => 0x3f,
7481             PrintConv => {
7482             0 => '1/4000 s',
7483             1 => '1/3200 s',
7484             2 => '1/2500 s',
7485             3 => '1/2000 s',
7486             4 => '1/1600 s',
7487             5 => '1/1250 s',
7488             6 => '1/1000 s',
7489             7 => '1/800 s',
7490             8 => '1/640 s',
7491             9 => '1/500 s',
7492             10 => '1/400 s',
7493             11 => '1/320 s',
7494             12 => '1/250 s',
7495             13 => '1/200 s',
7496             14 => '1/160 s',
7497             15 => '1/125 s',
7498             16 => '1/100 s',
7499             17 => '1/80 s',
7500             18 => '1/60 s',
7501             19 => '1/50 s',
7502             20 => '1/40 s',
7503             21 => '1/30 s',
7504             22 => '1/15 s',
7505             23 => '1/8 s',
7506             24 => '1/4 s',
7507             25 => '1/2 s',
7508             26 => '1 s',
7509             27 => '2 s',
7510             28 => '4 s',
7511             29 => '8 s',
7512             30 => '15 s',
7513             31 => '30 s',
7514             32 => 'Auto (Slowest)',
7515             33 => 'Auto (Slower)',
7516             34 => 'Auto',
7517             35 => 'Auto (Faster)',
7518             36 => 'Auto (Fastest)',
7519             },
7520             },
7521             0x05 => {
7522             Name => 'ISOAutoHiLimit',
7523             Mask => 0xff,
7524             PrintHex => 1,
7525             PrintConv => {
7526             0x24 => 'ISO 200',
7527             0x26 => 'ISO 250',
7528             0x27 => 'ISO 280',
7529             0x28 => 'ISO 320',
7530             0x2a => 'ISO 400',
7531             0x2c => 'ISO 500',
7532             0x2d => 'ISO 560',
7533             0x2e => 'ISO 640',
7534             0x30 => 'ISO 800',
7535             0x32 => 'ISO 1000',
7536             0x33 => 'ISO 1100',
7537             0x34 => 'ISO 1250',
7538             0x36 => 'ISO 1600',
7539             0x38 => 'ISO 2000',
7540             0x39 => 'ISO 2200',
7541             0x3a => 'ISO 2500',
7542             0x3c => 'ISO 3200',
7543             0x3e => 'ISO 4000',
7544             0x3f => 'ISO 4500',
7545             0x40 => 'ISO 5000',
7546             0x42 => 'ISO 6400',
7547             0x44 => 'ISO 8000',
7548             0x45 => 'ISO 9000',
7549             0x46 => 'ISO 10000',
7550             0x48 => 'ISO 12800',
7551             0x4a => 'ISO 16000',
7552             0x4b => 'ISO 18000',
7553             0x4c => 'ISO 20000',
7554             0x4e => 'ISO 25600',
7555             0x50 => 'ISO 32000',
7556             0x51 => 'ISO 36000',
7557             0x52 => 'ISO 40000',
7558             0x54 => 'ISO 51200',
7559             0x56 => 'ISO Hi 0.3',
7560             0x57 => 'ISO Hi 0.5',
7561             0x58 => 'ISO Hi 0.7',
7562             0x5a => 'ISO Hi 1.0',
7563             0x60 => 'ISO Hi 2.0',
7564             0x66 => 'ISO Hi 3.0',
7565             0x6c => 'ISO Hi 4.0',
7566             0x72 => 'ISO Hi 5.0',
7567             },
7568             },
7569             0x07 => {
7570             Name => 'FlickerReduction',
7571             Mask => 0x20,
7572             PrintConv => {
7573             0 => 'Enable',
7574             1 => 'Disable',
7575             },
7576             },
7577             7.1 => {
7578             Name => 'PhotoShootingMenuBankImageArea',
7579             Mask => 0x07,
7580             PrintConv => {
7581             0 => 'FX (36x24)',
7582             1 => 'DX (24x16)',
7583             2 => '5:4 (30x24)',
7584             3 => '1.2x (30x20)',
7585             4 => '1.3x (18x12)',
7586             },
7587             },
7588             );
7589              
7590             %Image::ExifTool::Nikon::CustomSettingsD500 = (
7591             %binaryDataAttrs,
7592             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7593             IS_SUBDIR => [ 0x00 ],
7594             VARS => { ALLOW_REPROCESS => 1 }, # (necessary because subdirectory is at offset 0)
7595             0x00 => [{
7596             Name => 'CustomSettingsD5',
7597             Condition => '$$self{Model} =~ /\bD5\b/',
7598             Format => 'undef[90]',
7599             SubDirectory => {
7600             TagTable => 'Image::ExifTool::NikonCustom::SettingsD5',
7601             },
7602             },{
7603             Name => 'CustomSettingsD500',
7604             Format => 'undef[90]',
7605             SubDirectory => {
7606             TagTable => 'Image::ExifTool::NikonCustom::SettingsD500',
7607             },
7608             }],
7609             # 0x7d => { #this decode works, but involves more bits than should be necessary
7610             # Name => 'ShutterTrigger',
7611             # Mask => 0xff,
7612             # PrintConv => {
7613             # 0 => 'Timer',
7614             # 15 => 'Cable Release/Remote',
7615             # 195 => 'Shutter Button',
7616             # },
7617             # },
7618             );
7619              
7620             %Image::ExifTool::Nikon::OtherInfoD500 = (
7621             %binaryDataAttrs,
7622             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7623             # (needs testing)
7624             #0x22 => {
7625             # Name => 'ExtendedPhotoShootingBanks',
7626             # Mask => 0x01,
7627             # PrintConv => {
7628             # 0 => 'On',
7629             # 1 => 'Off',
7630             # },
7631             #},
7632             # (may not be reliable and is found elsewhere)
7633             #0x212 => {
7634             # Name => 'Rotation',
7635             # Condition => '$$self{Model} =~ /\bD500\b/',
7636             # Notes => 'D500 firmware 1.1x',
7637             # Mask => 0x30,
7638             # PrintConv => {
7639             # 0 => 'Horizontal',
7640             # 1 => 'Rotate 270 CW',
7641             # 2 => 'Rotate 90 CW',
7642             # 3 => 'Rotate 180',
7643             # },
7644             #},
7645             0x214 => { #PH
7646             Name => 'NikonMeteringMode',
7647             Condition => '$$self{Model} =~ /\bD500\b/', # (didn't seem to work for D5, but I need more samples)
7648             Notes => 'D500 only',
7649             Mask => 0x03,
7650             PrintConv => {
7651             0 => 'Matrix',
7652             1 => 'Center',
7653             2 => 'Spot',
7654             3 => 'Highlight'
7655             },
7656             },
7657             );
7658              
7659             # shot information for the D6 firmware 1.00 (encrypted) - ref 28
7660             %Image::ExifTool::Nikon::ShotInfoD6 = (
7661             PROCESS_PROC => \&ProcessNikonEncrypted,
7662             WRITE_PROC => \&ProcessNikonEncrypted,
7663             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7664             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x24 },
7665             IS_SUBDIR => [ 0x30, 0x9c, 0xa4 ],
7666             WRITABLE => 1,
7667             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7668             NOTES => 'These tags are extracted from encrypted data in images from the D6.',
7669             0x00 => {
7670             Name => 'ShotInfoVersion',
7671             Format => 'string[4]',
7672             Writable => 0,
7673             },
7674             0x04 => {
7675             Name => 'FirmwareVersion',
7676             Format => 'string[8]',
7677             Writable => 0,
7678             },
7679             0x24 => {
7680             Name => 'NumberOffsets', # (number of entries in offset table. offsets are from start of ShotInfo data)
7681             Format => 'int32u',
7682             Writable => 0,
7683             #Hidden => 1,
7684             },
7685             0x30 => {
7686             Name => 'SequenceOffset',
7687             Format => 'int32u',
7688             SubDirectory => {
7689             TagTable => 'Image::ExifTool::Nikon::SeqInfoD6',
7690             Start => '$val',
7691             },
7692             },
7693             0x9c => {
7694             Name => 'OrientationOffset',
7695             Format => 'int32u',
7696             SubDirectory => {
7697             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
7698             Start => '$val',
7699             },
7700             },
7701             0xa4 => {
7702             Name => 'IntervalOffset',
7703             Format => 'int32u',
7704             SubDirectory => {
7705             TagTable => 'Image::ExifTool::Nikon::IntervalInfoD6',
7706             Start => '$val',
7707             }
7708             },
7709             );
7710              
7711             %Image::ExifTool::Nikon::SeqInfoD6 = (
7712             %binaryDataAttrs,
7713             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7714             DATAMEMBER => [ 0x24, 0x28 ],
7715             0x24 => {
7716             Name => 'IntervalShooting',
7717             RawConv => '$$self{IntervalShooting} = $val',
7718             Format => 'int16u',
7719             PrintConv => q{
7720             return 'Off' if $val == 0 ;
7721             my $i = sprintf("Interval %.0f of %.0f",$val, $$self{IntervalShootingIntervals}||0); #something like "Interval 1 of 3"
7722             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
7723             return "On: $i$f"
7724             #$val == 0 ? 'Off' : sprintf("On: Interval %.0f of %.0f Frame %.0f of %.0f",$val, $$self{IntervalShootingIntervals}||0, $$self{IntervalFrame}||0, $$self{IntervalShootingShotsPerInterval}||0),
7725             },
7726             },
7727             0x28 => {
7728             Name => 'IntervalFrame',
7729             RawConv => '$$self{IntervalFrame} = $val',
7730             Condition => '$$self{IntervalShooting} > 0',
7731             Format => 'int16u',
7732             #Hidden => 1,
7733             },
7734             0x2b => {
7735             Name => 'ImageArea',
7736             PrintConv => \%imageAreaD6,
7737             },
7738             );
7739              
7740             %Image::ExifTool::Nikon::IntervalInfoD6 = (
7741             %binaryDataAttrs,
7742             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7743             DATAMEMBER => [ 0x17c, 0x180, 0x214, 0x22c ],
7744             0x17c => {
7745             Name => 'Intervals',
7746             Format => 'int32u',
7747             RawConv => '$$self{IntervalShootingIntervals} = $val',
7748             Condition => '$$self{IntervalShooting} > 0',
7749             },
7750             0x180 => {
7751             Name => 'ShotsPerInterval',
7752             Format => 'int32u',
7753             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
7754             Condition => '$$self{IntervalShooting} > 0',
7755             },
7756             0x184 => {
7757             Name => 'IntervalExposureSmoothing',
7758             Condition => '$$self{IntervalShooting} > 0',
7759             Format => 'int8u',
7760             PrintConv => \%offOn,
7761             },
7762             0x186 => {
7763             Name => 'IntervalPriority',
7764             Condition => '$$self{IntervalShooting} > 0',
7765             Format => 'int8u',
7766             PrintConv => \%offOn,
7767             },
7768             0x1a8 => {
7769             Name => 'FocusShiftNumberShots',
7770             },
7771             0x1ac => {
7772             Name => 'FocusShiftStepWidth',
7773             },
7774             0x1b0 => {
7775             Name => 'FocusShiftInterval',
7776             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
7777             },
7778             0x1b4 => {
7779             Name => 'FocusShiftExposureLock',
7780             PrintConv => \%offOn,
7781             },
7782             #0x20a => HighISONoiseReduction
7783             0x20e => {
7784             Name => 'DiffractionCompensation',
7785             Format => 'int8u',
7786             PrintConv => \%offOn,
7787             },
7788             #0x20f => {Name => 'FlickerReductionShooting',}, #redundant with tag in NikonSettings
7789             0x214 => {
7790             Name => 'FlashControlMode', #this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
7791             RawConv => '$$self{FlashControlMode} = $val',
7792             PrintConv => {
7793             0 => 'TTL',
7794             1 => 'Auto External Flash',
7795             2 => 'GN (distance priority)',
7796             3 => 'Manual',
7797             4 => 'Repeating Flash',
7798             },
7799             },
7800             0x21a => {
7801             Name => 'FlashGNDistance',
7802             Condition => '$$self{FlashControlMode} == 2',
7803             Unknown => 1,
7804             ValueConv => '$val + 3',
7805             PrintConv => \%flashGNDistance,
7806             },
7807             0x21e => {
7808             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)
7809             Condition => '$$self{FlashControlMode} >= 3',
7810             Unknown => 1,
7811             ValueConv => '2 ** (-$val/3)',
7812             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
7813             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
7814             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
7815             },
7816             0x228 => {
7817             Name => 'FlashRemoteControl',
7818             Unknown => 1,
7819             PrintConv => {
7820             0 => 'Group',
7821             1 => 'Quick Wireless',
7822             2 => 'Remote Repeating',
7823             },
7824             },
7825             0x22c => {
7826             Name => 'FlashMasterControlMode', #tag name chosen for compatibility with those found in FlashInfo0102 & FlashInfo0103
7827             RawConv => '$$self{FlashGroupOptionsMasterMode} = $val',
7828             PrintConv => \%flashGroupOptionsMode,
7829             },
7830             0x22e => {
7831             Name => 'FlashMasterCompensation',
7832             Unknown => 1,
7833             Format => 'int8s',
7834             Condition => '$$self{FlashGroupOptionsMasterMode} != 3', #other than 'Off'
7835             ValueConv => '$val/6',
7836             ValueConvInv => '6 * $val',
7837             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
7838             PrintConvInv => '$val',
7839             },
7840             0x232 => {
7841             Name => 'FlashMasterOutput',
7842             Unknown => 1,
7843             Condition => '$$self{FlashGroupOptionsMasterMode} == 1', #only for Mode=M
7844             ValueConv => '2 ** (-$val/3)',
7845             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
7846             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
7847             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
7848             },
7849             0x234 => {
7850             Name => 'FlashWirelessOption',
7851             Unknown => 1,
7852             PrintConv => {
7853             0 => 'Optical AWL',
7854             1 => 'Off',
7855             },
7856             },
7857             0x2ca => {
7858             Name => 'MovieType',
7859             Unknown => 1,
7860             PrintConv => {
7861             0 => 'MOV',
7862             1 => 'MP4',
7863             },
7864             },
7865             );
7866              
7867             # shot information for the D610 firmware 1.00 (encrypted) - ref PH
7868             %Image::ExifTool::Nikon::ShotInfoD610 = (
7869             PROCESS_PROC => \&ProcessNikonEncrypted,
7870             WRITE_PROC => \&ProcessNikonEncrypted,
7871             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7872             VARS => { ID_LABEL => 'Index' },
7873             IS_SUBDIR => [ 0x07cf ],
7874             WRITABLE => 1,
7875             FIRST_ENTRY => 0,
7876             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7877             NOTES => 'These tags are extracted from encrypted data in images from the D610.',
7878             0x00 => {
7879             Name => 'ShotInfoVersion',
7880             Format => 'string[4]',
7881             Writable => 0,
7882             },
7883             0x04 => {
7884             Name => 'FirmwareVersion',
7885             Format => 'string[5]',
7886             Writable => 0,
7887             },
7888             0x07cf => {
7889             Name => 'CustomSettingsD610',
7890             Format => 'undef[48]',
7891             SubDirectory => {
7892             TagTable => 'Image::ExifTool::NikonCustom::SettingsD610',
7893             },
7894             },
7895             );
7896              
7897             # shot information for the D810 firmware 1.00(PH)/1.01 (encrypted) - ref 28
7898             %Image::ExifTool::Nikon::ShotInfoD810 = (
7899             PROCESS_PROC => \&ProcessNikonEncrypted,
7900             WRITE_PROC => \&ProcessNikonEncrypted,
7901             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7902             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x0c },
7903             DATAMEMBER => [ 0x04 ],
7904             IS_SUBDIR => [ 0x10, 0x24, 0x38, 0x40, 0x84 ],
7905             WRITABLE => 1,
7906             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7907             NOTES => 'These tags are extracted from encrypted data in images from the D810.',
7908             0x00 => {
7909             Name => 'ShotInfoVersion',
7910             Format => 'string[4]',
7911             Writable => 0,
7912             },
7913             0x04 => {
7914             Name => 'FirmwareVersion',
7915             DataMember => 'FirmwareVersion',
7916             Format => 'string[5]',
7917             Writable => 0,
7918             RawConv => '$$self{FirmwareVersion} = $val',
7919             },
7920             # 0x0c - number of entries in offset table (= 0x21)
7921             # 0x10 - int32u[val 0x0c]: offset table
7922             0x10 => {
7923             Name => 'SettingsOffset',
7924             Format => 'int32u',
7925             SubDirectory => {
7926             TagTable => 'Image::ExifTool::Nikon::SettingsInfoD810',
7927             Start => '$val',
7928             },
7929             },
7930             0x24 => {
7931             Name => 'BracketingOffset',
7932             Format => 'int32u',
7933             SubDirectory => {
7934             TagTable => 'Image::ExifTool::Nikon::BracketingInfoD810',
7935             Start => '$val',
7936             },
7937             },
7938             0x38 => {
7939             Name => 'ISOAutoOffset',
7940             Format => 'int32u',
7941             SubDirectory => {
7942             TagTable => 'Image::ExifTool::Nikon::ISOAutoInfoD810',
7943             Start => '$val',
7944             },
7945             },
7946             0x40 => {
7947             Name => 'CustomSettingsOffset', # (relative offset from start of ShotInfo data)
7948             Format => 'int32u',
7949             SubDirectory => {
7950             TagTable => 'Image::ExifTool::NikonCustom::SettingsD810',
7951             Start => '$val',
7952             },
7953             },
7954             0x84 => {
7955             Name => 'OrientationOffset',
7956             Format => 'int32u',
7957             SubDirectory => {
7958             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
7959             Start => '$val',
7960             }
7961             },
7962             # (moves around too much and doesn't fit cleanly in the offset table)
7963             #0x38be => {
7964             # Name => 'Rotation',
7965             # Condition => '$$self{FirmwareVersion} =~ /^1\.0/',
7966             # Mask => 0x30,
7967             # PrintConv => {
7968             # 0 => 'Horizontal',
7969             # 1 => 'Rotate 270 CW',
7970             # 2 => 'Rotate 90 CW',
7971             # 3 => 'Rotate 180',
7972             # },
7973             #},
7974             );
7975              
7976             %Image::ExifTool::Nikon::SettingsInfoD810 = (
7977             %binaryDataAttrs,
7978             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7979             0x13c => {
7980             Name => 'SecondarySlotFunction',
7981             Mask => 0x03,
7982             PrintConv => {
7983             0 => 'Overflow',
7984             2 => 'Backup',
7985             3 => 'NEF Primary + JPG Secondary',
7986             },
7987             },
7988             );
7989              
7990             %Image::ExifTool::Nikon::BracketingInfoD810 = (
7991             %binaryDataAttrs,
7992             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7993             0x0f => {
7994             Name => 'AEBracketingSteps',
7995             Mask => 0xff,
7996             PrintHex => 1,
7997             PrintConvColumns => 2,
7998             PrintConv => {
7999             0x00 => 'AE Bracketing Disabled',
8000             0x20 => 'AE Bracketing Disabled',
8001             0x30 => 'AE Bracketing Disabled',
8002             0x40 => 'AE Bracketing Disabled',
8003             0x50 => 'AE Bracketing Disabled',
8004             0x81 => '+3F0.3',
8005             0x82 => '-3F0.3',
8006             0x83 => '+2F0.3',
8007             0x84 => '-2F0.3',
8008             0x85 => '3F0.3',
8009             0x86 => '5F0.3',
8010             0x87 => '7F0.3',
8011             0x88 => '9F0.3',
8012             0x91 => '+3F0.5',
8013             0x92 => '-3F0.5',
8014             0x93 => '+2F0.5',
8015             0x94 => '-2F0.5',
8016             0x95 => '3F0.5',
8017             0x96 => '5F0.5',
8018             0x97 => '7F0.5',
8019             0x98 => '9F0.5',
8020             0xa1 => '+3F0.7',
8021             0xa2 => '-3F0.7',
8022             0xa3 => '+2F0.7',
8023             0xa4 => '-2F0.7',
8024             0xa5 => '3F0.7',
8025             0xa6 => '5F0.7',
8026             0xa7 => '7F0.7',
8027             0xa8 => '9F0.7',
8028             0xb1 => '+3F1',
8029             0xb2 => '-3F1',
8030             0xb3 => '+2F1',
8031             0xb4 => '-2F1',
8032             0xb5 => '3F1',
8033             0xb6 => '5F1',
8034             0xb7 => '7F1',
8035             0xb8 => '9F1',
8036             0xc1 => '+3F2',
8037             0xc2 => '-3F2',
8038             0xc3 => '+2F2',
8039             0xc4 => '-2F2',
8040             0xc5 => '3F2',
8041             0xc6 => '5F2',
8042             0xd1 => '+3F3',
8043             0xd2 => '-3F3',
8044             0xd3 => '+2F3',
8045             0xd4 => '-2F3',
8046             0xd5 => '3F3',
8047             0xd6 => '5F3',
8048             },
8049             },
8050             0x10 => {
8051             Name => 'WBBracketingSteps',
8052             Condition => '$$self{FILE_TYPE} ne "TIFF"', # (covers NEF and TIFF)
8053             Mask => 0xff,
8054             PrintHex => 1,
8055             PrintConvColumns => 2,
8056             PrintConv => {
8057             0x00 => 'WB Bracketing Disabled',
8058             0x01 => 'b3F 1',
8059             0x02 => 'A3F 1',
8060             0x03 => 'b2F 1',
8061             0x04 => 'A2F 1',
8062             0x05 => '3F 1',
8063             0x06 => '5F 1',
8064             0x07 => '7F 1',
8065             0x08 => '9F 1',
8066             0x10 => '0F 2',
8067             0x11 => 'b3F 2',
8068             0x12 => 'A3F 2',
8069             0x13 => 'b2F 2',
8070             0x14 => 'A2F 2',
8071             0x15 => '3F 2',
8072             0x16 => '5F 2',
8073             0x17 => '7F 2',
8074             0x18 => '9F 2',
8075             0x20 => '0F 3',
8076             0x21 => 'b3F 3',
8077             0x22 => 'A3F 3',
8078             0x23 => 'b2F 3',
8079             0x24 => 'A2F 3',
8080             0x25 => '3F 3',
8081             0x26 => '5F 3',
8082             0x27 => '7F 3',
8083             0x28 => '9F 3',
8084             0x22 => 'A3F 3',
8085             0x23 => 'b2F 3',
8086             0x24 => 'A2F 3',
8087             0x25 => '3F 3',
8088             0x26 => '5F 3',
8089             0x27 => '7F 3',
8090             0x28 => '9F 3',
8091             },
8092             },
8093             0x17 => {
8094             Name => 'NikonMeteringMode',
8095             Mask => 0x03,
8096             PrintConv => {
8097             0 => 'Matrix',
8098             1 => 'Center',
8099             2 => 'Spot',
8100             3 => 'Highlight'
8101             },
8102             },
8103             );
8104              
8105             %Image::ExifTool::Nikon::ISOAutoInfoD810 = (
8106             %binaryDataAttrs,
8107             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8108             0x04 => {
8109             Name => 'ISOAutoShutterTime',
8110             Mask => 0x3f,
8111             PrintConv => {
8112             0 => '1/4000 s',
8113             1 => '1/3200 s',
8114             2 => '1/2500 s',
8115             3 => '1/2000 s',
8116             4 => '1/1600 s',
8117             5 => '1/1250 s',
8118             6 => '1/1000 s',
8119             7 => '1/800 s',
8120             8 => '1/640 s',
8121             9 => '1/500 s',
8122             10 => '1/400 s',
8123             11 => '1/320 s',
8124             12 => '1/250 s',
8125             13 => '1/200 s',
8126             14 => '1/160 s',
8127             15 => '1/125 s',
8128             16 => '1/100 s',
8129             17 => '1/80 s',
8130             18 => '1/60 s',
8131             19 => '1/50 s',
8132             20 => '1/40 s',
8133             21 => '1/30 s',
8134             22 => '1/15 s',
8135             23 => '1/8 s',
8136             24 => '1/4 s',
8137             25 => '1/2 s',
8138             26 => '1 s',
8139             27 => '2 s',
8140             28 => '4 s',
8141             29 => '8 s',
8142             30 => '15 s',
8143             31 => '30 s',
8144             32 => 'Auto (Slowest)',
8145             33 => 'Auto (Slower)',
8146             34 => 'Auto',
8147             35 => 'Auto (Faster)',
8148             36 => 'Auto (Fastest)',
8149             },
8150             },
8151             0x05 => {
8152             Name => 'ISOAutoHiLimit',
8153             Mask => 0xff,
8154             PrintHex => 1,
8155             PrintConv => {
8156             0x24 => 'ISO 200',
8157             0x26 => 'ISO 250',
8158             0x27 => 'ISO 280',
8159             0x28 => 'ISO 320',
8160             0x2a => 'ISO 400',
8161             0x2c => 'ISO 500',
8162             0x2d => 'ISO 560',
8163             0x2e => 'ISO 640',
8164             0x30 => 'ISO 800',
8165             0x32 => 'ISO 1000',
8166             0x33 => 'ISO 1100',
8167             0x34 => 'ISO 1250',
8168             0x36 => 'ISO 1600',
8169             0x38 => 'ISO 2000',
8170             0x39 => 'ISO 2200',
8171             0x3a => 'ISO 2500',
8172             0x3c => 'ISO 3200',
8173             0x3e => 'ISO 4000',
8174             0x3f => 'ISO 4500',
8175             0x40 => 'ISO 5000',
8176             0x42 => 'ISO 6400',
8177             0x44 => 'ISO 8000',
8178             0x45 => 'ISO 9000',
8179             0x46 => 'ISO 10000',
8180             0x48 => 'ISO 12800',
8181             0x4a => 'ISO 16000',
8182             0x4b => 'ISO 18000',
8183             0x4c => 'ISO 20000',
8184             0x4e => 'ISO 25600',
8185             0x50 => 'ISO 32000',
8186             0x51 => 'ISO 36000',
8187             0x52 => 'ISO 40000',
8188             0x54 => 'ISO 51200',
8189             0x56 => 'ISO Hi 0.3',
8190             0x57 => 'ISO Hi 0.5',
8191             0x58 => 'ISO Hi 0.7',
8192             0x5a => 'ISO Hi 1.0',
8193             0x60 => 'ISO Hi 2.0',
8194             0x66 => 'ISO Hi 3.0',
8195             0x6c => 'ISO Hi 4.0',
8196             0x72 => 'ISO Hi 5.0',
8197             },
8198             },
8199             );
8200              
8201             # shot information for the D850 firmware 1.00b (encrypted) - ref 28
8202             %Image::ExifTool::Nikon::ShotInfoD850 = (
8203             PROCESS_PROC => \&ProcessNikonEncrypted,
8204             WRITE_PROC => \&ProcessNikonEncrypted,
8205             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8206             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x0c },
8207             DATAMEMBER => [ 0x04 ],
8208             IS_SUBDIR => [ 0x10, 0x4c, 0x58, 0xa0 ],
8209             WRITABLE => 1,
8210             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8211             NOTES => 'These tags are extracted from encrypted data in images from the D850.',
8212             0x00 => {
8213             Name => 'ShotInfoVersion',
8214             Format => 'string[4]',
8215             Writable => 0,
8216             },
8217             0x04 => {
8218             Name => 'FirmwareVersion',
8219             DataMember => 'FirmwareVersion',
8220             Format => 'string[5]',
8221             Writable => 0,
8222             RawConv => '$$self{FirmwareVersion} = $val',
8223             },
8224             0x10 => {
8225             Name => 'MenuSettingsOffset',
8226             Format => 'int32u',
8227             SubDirectory => {
8228             TagTable => 'Image::ExifTool::Nikon::MenuSettingsD850',
8229             Start => '$val',
8230             },
8231             },
8232             0x4c => {
8233             Name => 'MoreSettingsOffset',
8234             Format => 'int32u',
8235             SubDirectory => {
8236             TagTable => 'Image::ExifTool::Nikon::MoreSettingsD850',
8237             Start => '$val',
8238             },
8239             },
8240             0x58 => {
8241             Name => 'CustomSettingsOffset',
8242             Format => 'int32u',
8243             SubDirectory => {
8244             TagTable => 'Image::ExifTool::NikonCustom::SettingsD850',
8245             Start => '$val',
8246             },
8247             },
8248             0xa0 => {
8249             Name => 'OrientationOffset',
8250             Format => 'int32u',
8251             SubDirectory => {
8252             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
8253             Start => '$val',
8254             },
8255             },
8256             );
8257              
8258             %Image::ExifTool::Nikon::MenuSettingsD850 = (
8259             %binaryDataAttrs,
8260             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8261             0x06dd => {
8262             Name => 'PhotoShootingMenuBankImageArea',
8263             Mask => 0x07,
8264             PrintConv => {
8265             0 => 'FX (36x24)',
8266             1 => 'DX (24x16)',
8267             2 => '5:4 (30x24)',
8268             3 => '1.2x (30x20)',
8269             4 => '1:1 (24x24)',
8270             },
8271             },
8272             );
8273              
8274             %Image::ExifTool::Nikon::MoreSettingsD850 = (
8275             %binaryDataAttrs,
8276             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8277             0x24 => {
8278             Name => 'PhotoShootingMenuBank',
8279             Condition => '$$self{FILE_TYPE} eq "JPEG"',
8280             Notes => 'valid for JPEG images only',
8281             Mask => 0x03,
8282             PrintConv => {
8283             0 => 'A',
8284             1 => 'B',
8285             2 => 'C',
8286             3 => 'D',
8287             },
8288             },
8289             0x25 => {
8290             Name => 'PrimarySlot',
8291             Mask => 0x80,
8292             PrintConv => {
8293             0 => 'XQD Card',
8294             1 => 'SD Card',
8295             },
8296             },
8297             );
8298              
8299             # shot information for the D4 firmware 1.00g (ref PH)
8300             %Image::ExifTool::Nikon::ShotInfoD4 = (
8301             PROCESS_PROC => \&ProcessNikonEncrypted,
8302             WRITE_PROC => \&ProcessNikonEncrypted,
8303             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8304             VARS => { ID_LABEL => 'Index' },
8305             IS_SUBDIR => [ 0x0751 ],
8306             WRITABLE => 1,
8307             FIRST_ENTRY => 0,
8308             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8309             NOTES => q{
8310             These tags are extracted from encrypted data in images from the D4.
8311             },
8312             0x00 => {
8313             Name => 'ShotInfoVersion',
8314             Format => 'string[4]',
8315             Writable => 0,
8316             },
8317             0x04 => {
8318             Name => 'FirmwareVersion',
8319             Format => 'string[5]',
8320             Writable => 0,
8321             },
8322             0x0751 => { #PH (NC)
8323             Name => 'CustomSettingsD4',
8324             # (seems to work for 1.00g and 1.02b)
8325             Format => 'undef[56]',
8326             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsD4' },
8327             },
8328             );
8329              
8330             # shot information for the D4S firmware 1.01a (ref 28, encrypted)
8331             %Image::ExifTool::Nikon::ShotInfoD4S = (
8332             PROCESS_PROC => \&ProcessNikonEncrypted,
8333             WRITE_PROC => \&ProcessNikonEncrypted,
8334             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8335             VARS => { ID_LABEL => 'Index' },
8336             DATAMEMBER => [ 4 ],
8337             IS_SUBDIR => [ 0x189d, 0x193d, 0x350b ],
8338             WRITABLE => 1,
8339             FIRST_ENTRY => 0,
8340             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8341             NOTES => 'These tags are extracted from encrypted data in images from the D4S.',
8342             0x00 => {
8343             Name => 'ShotInfoVersion',
8344             Format => 'string[4]',
8345             Writable => 0,
8346             },
8347             0x04 => {
8348             Name => 'FirmwareVersion',
8349             DataMember => 'FirmwareVersion',
8350             Format => 'string[5]',
8351             Writable => 0,
8352             RawConv => '$$self{FirmwareVersion} = $val',
8353             },
8354             0x01d0 => {
8355             Name => 'SecondarySlotFunction',
8356             Mask => 0x03,
8357             PrintConv => {
8358             0 => 'Overflow',
8359             2 => 'Backup',
8360             3 => 'NEF Primary + JPG Secondary',
8361             },
8362             },
8363             0x174c => {
8364             Name => 'AEBracketingSteps',
8365             Mask => 0xff,
8366             PrintHex => 1,
8367             PrintConvColumns => 2,
8368             PrintConv => {
8369             0x00 => 'AE Bracketing Disabled',
8370             0x20 => 'AE Bracketing Disabled',
8371             0x30 => 'AE Bracketing Disabled',
8372             0x40 => 'AE Bracketing Disabled',
8373             0x50 => 'AE Bracketing Disabled',
8374             0x81 => '+3F0.3',
8375             0x82 => '-3F0.3',
8376             0x83 => '+2F0.3',
8377             0x84 => '-2F0.3',
8378             0x85 => '3F0.3',
8379             0x86 => '5F0.3',
8380             0x87 => '7F0.3',
8381             0x88 => '9F0.3',
8382             0x91 => '+3F0.5',
8383             0x92 => '-3F0.5',
8384             0x93 => '+2F0.5',
8385             0x94 => '-2F0.5',
8386             0x95 => '3F0.5',
8387             0x96 => '5F0.5',
8388             0x97 => '7F0.5',
8389             0x98 => '9F0.5',
8390             0xa1 => '+3F0.7',
8391             0xa2 => '-3F0.7',
8392             0xa3 => '+2F0.7',
8393             0xa4 => '-2F0.7',
8394             0xa5 => '3F0.7',
8395             0xa6 => '5F0.7',
8396             0xa7 => '7F0.7',
8397             0xa8 => '9F0.7',
8398             0xb1 => '+3F1',
8399             0xb2 => '-3F1',
8400             0xb3 => '+2F1',
8401             0xb4 => '-2F1',
8402             0xb5 => '3F1',
8403             0xb6 => '5F1',
8404             0xb7 => '7F1',
8405             0xb8 => '9F1',
8406             0xc1 => '+3F2',
8407             0xc2 => '-3F2',
8408             0xc3 => '+2F2',
8409             0xc4 => '-2F2',
8410             0xc5 => '3F2',
8411             0xc6 => '5F2',
8412             0xd1 => '+3F3',
8413             0xd2 => '-3F3',
8414             0xd3 => '+2F3',
8415             0xd4 => '-2F3',
8416             0xd5 => '3F3',
8417             0xd6 => '5F3',
8418             },
8419             },
8420             0x174d => {
8421             Name => 'WBBracketingSteps',
8422             Condition => '$$self{FILE_TYPE} ne "TIFF"', # (covers NEF and TIFF)
8423             Mask => 0xff,
8424             PrintHex => 1,
8425             PrintConvColumns => 2,
8426             PrintConv => {
8427             0x00 => 'WB Bracketing Disabled',
8428             0x01 => 'b3F 1',
8429             0x02 => 'A3F 1',
8430             0x03 => 'b2F 1',
8431             0x04 => 'A2F 1',
8432             0x05 => '3F 1',
8433             0x06 => '5F 1',
8434             0x07 => '7F 1',
8435             0x08 => '9F 1',
8436             0x10 => '0F 2',
8437             0x11 => 'b3F 2',
8438             0x12 => 'A3F 2',
8439             0x13 => 'b2F 2',
8440             0x14 => 'A2F 2',
8441             0x15 => '3F 2',
8442             0x16 => '5F 2',
8443             0x17 => '7F 2',
8444             0x18 => '9F 2',
8445             0x20 => '0F 3',
8446             0x21 => 'b3F 3',
8447             0x22 => 'A3F 3',
8448             0x23 => 'b2F 3',
8449             0x24 => 'A2F 3',
8450             0x25 => '3F 3',
8451             0x26 => '5F 3',
8452             0x27 => '7F 3',
8453             0x28 => '9F 3',
8454             0x22 => 'A3F 3',
8455             0x23 => 'b2F 3',
8456             0x24 => 'A2F 3',
8457             0x25 => '3F 3',
8458             0x26 => '5F 3',
8459             0x27 => '7F 3',
8460             0x28 => '9F 3',
8461             },
8462             },
8463             0x184d => {
8464             Name => 'ReleaseMode',
8465             Mask => 0xff,
8466             PrintConv => {
8467             0 => 'Single Frame',
8468             1 => 'Continuous High Speed',
8469             3 => 'Continuous Low Speed',
8470             4 => 'Timer',
8471             32 => 'Mirror-Up',
8472             64 => 'Quiet',
8473             },
8474             },
8475             0x189d => { #PH (NC)
8476             Name => 'CustomSettingsD4S',
8477             Condition => '$$self{FirmwareVersion} =~ /^1\.00/',
8478             Notes => 'firmware version 1.00',
8479             Format => 'undef[56]',
8480             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsD4' },
8481             },
8482             0x18c2 => { # CSf1-c (no idea why it is so far away from the rest of the settings)
8483             Name => 'MultiSelectorLiveViewMode',
8484             Groups => { 1 => 'NikonCustom' },
8485             Condition => '$$self{FirmwareVersion} !~ /^1\.00/',
8486             Mask => 0xc0,
8487             PrintConv => {
8488             0 => 'Reset',
8489             1 => 'Zoom',
8490             3 => 'None',
8491             },
8492             },
8493             0x18ea => {
8494             Name => 'ISOAutoShutterTime',
8495             Mask => 0x3f,
8496             PrintConv => {
8497             0 => '1/4000 s',
8498             1 => '1/3200 s',
8499             2 => '1/2500 s',
8500             3 => '1/2000 s',
8501             4 => '1/1600 s',
8502             5 => '1/1250 s',
8503             6 => '1/1000 s',
8504             7 => '1/800 s',
8505             8 => '1/640 s',
8506             9 => '1/500 s',
8507             10 => '1/400 s',
8508             11 => '1/320 s',
8509             12 => '1/250 s',
8510             13 => '1/200 s',
8511             14 => '1/160 s',
8512             15 => '1/125 s',
8513             16 => '1/100 s',
8514             17 => '1/80 s',
8515             18 => '1/60 s',
8516             19 => '1/50 s',
8517             20 => '1/40 s',
8518             21 => '1/30 s',
8519             22 => '1/15 s',
8520             23 => '1/8 s',
8521             24 => '1/4 s',
8522             25 => '1/2 s',
8523             26 => '1 s',
8524             27 => '2 s',
8525             28 => '4 s',
8526             29 => '8 s',
8527             30 => '15 s',
8528             31 => '30 s',
8529             32 => 'Auto (Slowest)',
8530             33 => 'Auto (Slower)',
8531             34 => 'Auto',
8532             35 => 'Auto (Faster)',
8533             36 => 'Auto (Fastest)',
8534             },
8535             },
8536             0x18eb => {
8537             Name => 'ISOAutoHiLimit',
8538             Mask => 0xff,
8539             PrintHex => 1,
8540             PrintConv => {
8541             0x24 => 'ISO 200',
8542             0x26 => 'ISO 250',
8543             0x27 => 'ISO 280',
8544             0x28 => 'ISO 320',
8545             0x2a => 'ISO 400',
8546             0x2c => 'ISO 500',
8547             0x2d => 'ISO 560',
8548             0x2e => 'ISO 640',
8549             0x30 => 'ISO 800',
8550             0x32 => 'ISO 1000',
8551             0x33 => 'ISO 1100',
8552             0x34 => 'ISO 1250',
8553             0x36 => 'ISO 1600',
8554             0x38 => 'ISO 2000',
8555             0x39 => 'ISO 2200',
8556             0x3a => 'ISO 2500',
8557             0x3c => 'ISO 3200',
8558             0x3e => 'ISO 4000',
8559             0x3f => 'ISO 4500',
8560             0x40 => 'ISO 5000',
8561             0x42 => 'ISO 6400',
8562             0x44 => 'ISO 8000',
8563             0x45 => 'ISO 9000',
8564             0x46 => 'ISO 10000',
8565             0x48 => 'ISO 12800',
8566             0x4a => 'ISO 16000',
8567             0x4b => 'ISO 18000',
8568             0x4c => 'ISO 20000',
8569             0x4e => 'ISO 25600',
8570             0x50 => 'ISO 32000',
8571             0x51 => 'ISO 36000',
8572             0x52 => 'ISO 40000',
8573             0x54 => 'ISO 51200',
8574             0x56 => 'ISO Hi 0.3',
8575             0x57 => 'ISO Hi 0.5',
8576             0x58 => 'ISO Hi 0.7',
8577             0x5a => 'ISO Hi 1.0',
8578             0x60 => 'ISO Hi 2.0',
8579             0x66 => 'ISO Hi 3.0',
8580             0x6c => 'ISO Hi 4.0',
8581             0x72 => 'ISO Hi 5.0',
8582             },
8583             },
8584             0x193d => {
8585             Name => 'CustomSettingsD4S',
8586             Condition => '$$self{FirmwareVersion} !~ /^1\.00/',
8587             Notes => 'firmware version 1.01',
8588             Format => 'undef[56]',
8589             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsD4' },
8590             },
8591             # 0x1978 => { # this decode works, but involves more bits than should be necessary
8592             # Name => 'ShutterTrigger',
8593             # Mask => 0xff,
8594             # PrintConv => {
8595             # 0 => 'Timer',
8596             # 15 => 'Cable Release/Remote',
8597             # 195 => 'Shutter Button',
8598             # },
8599             # },
8600             0x350b => {
8601             Name => 'OrientationInfo',
8602             Format => 'undef[12]',
8603             SubDirectory => {
8604             # Note: pitch angle may be wrong sign for this model?
8605             # (pitch sign was changed without verification to use same decoding as other models)
8606             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
8607             },
8608             },
8609             0x3693 => {
8610             Name => 'Rotation',
8611             Mask => 0x30,
8612             PrintConv => {
8613             0 => 'Horizontal',
8614             1 => 'Rotate 270 CW',
8615             2 => 'Rotate 90 CW',
8616             3 => 'Rotate 180',
8617             },
8618             },
8619             );
8620              
8621             # shot information for the Z6III firmware 1.00 (encrypted) - ref 28
8622             %Image::ExifTool::Nikon::ShotInfoZ6III = (
8623             PROCESS_PROC => \&ProcessNikonEncrypted,
8624             WRITE_PROC => \&ProcessNikonEncrypted,
8625             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8626             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x24 },
8627             DATAMEMBER => [ 0x04 ],
8628             IS_SUBDIR => [ 0x88, 0x90 ],
8629             WRITABLE => 1,
8630             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8631             NOTES => 'These tags are extracted from encrypted data in images from the Z6III.',
8632             0x00 => {
8633             Name => 'ShotInfoVersion',
8634             Format => 'string[4]',
8635             Writable => 0,
8636             },
8637             0x04 => {
8638             Name => 'FirmwareVersion',
8639             DataMember => 'FirmwareVersion',
8640             Format => 'string[8]',
8641             Writable => 0,
8642             RawConv => '$$self{FirmwareVersion} = $val',
8643             },
8644             0x0e => {
8645             Name => 'FirmwareVersion2',
8646             Format => 'string[8]',
8647             Writable => 0,
8648             #Hidden => 1,
8649             },
8650             0x18 => {
8651             Name => 'FirmwareVersion3',
8652             Format => 'string[8]',
8653             Writable => 0,
8654             #Hidden => 1,
8655             },
8656             0x24 => {
8657             Name => 'NumberOffsets', # number of entries in offset table. offsets are from start of ShotInfo data.
8658             Format => 'int32u',
8659             Writable => 0,
8660             #Hidden => 1,
8661             },
8662             #0x28 Offset1 - non-zero for NEF only
8663             #0x2c Offset2 - non-zero for NEF only
8664             #0x38 Offset5 - contains SkinSoftening at 0x2d1 - mapping is %offLowNormalHighZ7
8665             0x88 => {
8666             Name => 'OrientationOffset',
8667             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96', #not valid for C30/C60/C120
8668             Format => 'int32u',
8669             SubDirectory => {
8670             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
8671             Start => '$val',
8672             }
8673             },
8674             0x90 => {
8675             Name => 'MenuOffset',
8676             Condition => '$$self{Model} =~ /^NIKON Z6_3\b/i and $$self{FirmwareVersion} and $$self{FirmwareVersion} lt "02.00"',
8677             Format => 'int32u',
8678             AlwaysDecrypt => 1, # (necessary because FirmwareVersion is extracted after decryption time)
8679             SubDirectory => {
8680             TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ6III',
8681             Start => '$val',
8682             },
8683             },
8684             );
8685              
8686             # shot information for the Z7II firmware 1.00 (encrypted) - ref 28
8687             %Image::ExifTool::Nikon::ShotInfoZ7II = (
8688             PROCESS_PROC => \&ProcessNikonEncrypted,
8689             WRITE_PROC => \&ProcessNikonEncrypted,
8690             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8691             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x24 },
8692             DATAMEMBER => [ 0x04 ],
8693             IS_SUBDIR => [ 0x30, 0x38, 0x88, 0x98, 0xa0 ],
8694             WRITABLE => 1,
8695             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8696             NOTES => 'These tags are extracted from encrypted data in images from the Z7II.',
8697             0x00 => {
8698             Name => 'ShotInfoVersion',
8699             Format => 'string[4]',
8700             Writable => 0,
8701             },
8702             0x04 => {
8703             Name => 'FirmwareVersion',
8704             DataMember => 'FirmwareVersion',
8705             Format => 'string[8]',
8706             Writable => 0,
8707             RawConv => '$$self{FirmwareVersion} = $val',
8708             },
8709             0x0e => {
8710             Name => 'FirmwareVersion2',
8711             Format => 'string[8]',
8712             Writable => 0,
8713             #Hidden => 1,
8714             },
8715             0x18 => {
8716             Name => 'FirmwareVersion3',
8717             Format => 'string[8]',
8718             Writable => 0,
8719             #Hidden => 1,
8720             },
8721             0x24 => {
8722             Name => 'NumberOffsets', # number of entries in offset table. offsets are from start of ShotInfo data.
8723             Format => 'int32u',
8724             Writable => 0,
8725             #Hidden => 1,
8726             },
8727             0x30 => {
8728             Name => 'IntervalOffset',
8729             Format => 'int32u',
8730             SubDirectory => {
8731             TagTable => 'Image::ExifTool::Nikon::IntervalInfoZ7II',
8732             Start => '$val',
8733             }
8734             },
8735             0x38 => {
8736             Name => 'PortraitOffset',
8737             Format => 'int32u',
8738             SubDirectory => {
8739             TagTable => 'Image::ExifTool::Nikon::PortraitInfoZ7II',
8740             Start => '$val',
8741             }
8742             },
8743             0x88 => {
8744             Name => 'OrientationOffset',
8745             Format => 'int32u',
8746             Condition => '$$self{Model} =~ /^NIKON Z f\b/i',
8747             SubDirectory => {
8748             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
8749             Start => '$val',
8750             }
8751             },
8752             0x98 => {
8753             Name => 'OrientationOffset',
8754             Format => 'int32u',
8755             Condition => '$$self{Model} =~ /^NIKON Z (30|5|50|6|6_2|7|7_2|8|fc)\b/i', #models other then the Z f
8756             SubDirectory => {
8757             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
8758             Start => '$val',
8759             }
8760             },
8761             0xa0 => {
8762             Name => 'MenuOffset',
8763             Format => 'int32u',
8764             SubDirectory => {
8765             TagTable => 'Image::ExifTool::Nikon::MenuInfoZ7II',
8766             Start => '$val',
8767             },
8768             },
8769             );
8770              
8771             %Image::ExifTool::Nikon::IntervalInfoZ7II = (
8772             %binaryDataAttrs,
8773             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8774             DATAMEMBER => [ 0x24, 0x28 ],
8775             0x24 => {
8776             Name => 'IntervalShooting',
8777             RawConv => '$$self{IntervalShooting} = $val',
8778             Format => 'int16u',
8779             PrintConv => q{
8780             return 'Off' if $val == 0 ;
8781             my $i = sprintf("Interval %.0f of %.0f",$val, $$self{IntervalShootingIntervals}||0); # something like "Interval 1 of 3"
8782             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
8783             return "On: $i$f"
8784             #$val == 0 ? 'Off' : sprintf("On: Interval %.0f of %.0f Frame %.0f of %.0f",$val, $$self{IntervalShootingIntervals}||0, $$self{IntervalFrame}||0, $$self{IntervalShootingShotsPerInterval}||0),
8785             },
8786             },
8787             0x28 => {
8788             Name => 'IntervalFrame',
8789             RawConv => '$$self{IntervalFrame} = $val',
8790             Condition => '$$self{IntervalShooting} > 0',
8791             Format => 'int16u',
8792             #Hidden => 1,
8793             },
8794             0x2b => {
8795             Name => 'ImageArea',
8796             PrintConv => \%imageAreaD6,
8797             },
8798             );
8799              
8800             %Image::ExifTool::Nikon::PortraitInfoZ7II = (
8801             %binaryDataAttrs,
8802             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8803             0xa0 => { #28
8804             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
8805             # offset5+160; 128 is neutral; >128 increases Yellow; <128 increases Magenta; increments of 4 result from 1 full unit adjustment on the camera
8806             # offset5+161 128 is neutral; >128 increases Brightness; <128 decreases Brightness
8807             # 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]
8808             Format => 'int8u[2]',
8809             Condition => '$$self{FirmwareVersion} ge "01.30"',
8810             PrintConv => q{
8811             return 'Off' if $val eq '0 0' or $val eq '255 255';
8812             my @v = split ' ', $val;
8813             my $brightness = $v[1]==128 ? 'Brightness: Neutral' : sprintf('Brightness: %+.1f',($v[1]-128)/4);
8814             my $color = $v[0]==128 ? 'Color: Neutral' : sprintf('%s: %.1f', $v[0]>128 ? 'Yellow' : 'Magenta', abs($v[0]-128)/4);
8815             # will return something like: 'Magenta: 1.0 Brightness: Neutral'
8816             return "$color $brightness"
8817             },
8818             },
8819             );
8820              
8821             %Image::ExifTool::Nikon::MenuInfoZ7II = (
8822             %binaryDataAttrs,
8823             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8824             IS_SUBDIR => [ 0x10 ],
8825             0x10 => {
8826             Name => 'MenuSettingsOffsetZ7II',
8827             Format => 'int32u',
8828             SubDirectory => {
8829             TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ7II',
8830             Start => '$dirStart + $val',
8831             },
8832             },
8833             );
8834              
8835             # shot information for the Z8 firmware 1.00 (encrypted) - ref 28
8836             %Image::ExifTool::Nikon::ShotInfoZ8 = (
8837             PROCESS_PROC => \&ProcessNikonEncrypted,
8838             WRITE_PROC => \&ProcessNikonEncrypted,
8839             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8840             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x24 },
8841             DATAMEMBER => [ 0x04 ],
8842             IS_SUBDIR => [ 0x30, 0x80, 0x84, 0x8c ],
8843             WRITABLE => 1,
8844             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8845             NOTES => 'These tags are extracted from encrypted data in images from the Z8.',
8846             0x00 => {
8847             Name => 'ShotInfoVersion',
8848             Format => 'string[4]',
8849             Writable => 0,
8850             },
8851             0x04 => {
8852             Name => 'FirmwareVersion',
8853             DataMember => 'FirmwareVersion',
8854             Format => 'string[8]',
8855             Writable => 0,
8856             RawConv => '$$self{FirmwareVersion} = $val',
8857             },
8858             0x0e => {
8859             Name => 'FirmwareVersion2',
8860             Format => 'string[8]',
8861             Writable => 0,
8862             #Hidden => 1,
8863             },
8864             0x18 => {
8865             Name => 'FirmwareVersion3',
8866             Format => 'string[8]',
8867             Writable => 0,
8868             #Hidden => 1,
8869             },
8870             0x24 => {
8871             Name => 'NumberOffsets', # number of entries in offset table. offsets are from start of ShotInfo data.
8872             Format => 'int32u',
8873             Writable => 0,
8874             #Hidden => 1,
8875             },
8876             # subdirectories, referenced by offsets (not processed if offset is zero)
8877             0x30 => {
8878             Name => 'SequenceOffset',
8879             Format => 'int32u',
8880             SubDirectory => {
8881             TagTable => 'Image::ExifTool::Nikon::SeqInfoZ9',
8882             Start => '$val',
8883             },
8884             },
8885             0x80 => {
8886             Name => 'AutoCaptureOffset',
8887             Condition => '$$self{FirmwareVersion} and $$self{FirmwareVersion} ge "02.00"',
8888             Format => 'int32u',
8889             AlwaysDecrypt => 1, # (necessary because FirmwareVersion is extracted after decryption time)
8890             SubDirectory => {
8891             TagTable => 'Image::ExifTool::Nikon::AutoCaptureInfo',
8892             Start => '$val',
8893             },
8894             },
8895             0x84 => {
8896             Name => 'OrientOffset',
8897             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96', #not valid for C30/C60/C120
8898             Format => 'int32u',
8899             SubDirectory => {
8900             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
8901             Start => '$val',
8902             },
8903             },
8904             0x8c => {
8905             Name => 'MenuOffset',
8906             Format => 'int32u',
8907             SubDirectory => {
8908             TagTable => 'Image::ExifTool::Nikon::MenuInfoZ8',
8909             Start => '$val',
8910             },
8911             },
8912             );
8913              
8914             # shot information for the Z9 firmware 1.00 (encrypted) - ref 28
8915             %Image::ExifTool::Nikon::ShotInfoZ9 = (
8916             PROCESS_PROC => \&ProcessNikonEncrypted,
8917             WRITE_PROC => \&ProcessNikonEncrypted,
8918             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8919             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x24 },
8920             DATAMEMBER => [ 0x04 ],
8921             IS_SUBDIR => [ 0x30, 0x58, 0x80, 0x84, 0x8c ],
8922             WRITABLE => 1,
8923             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8924             NOTES => 'These tags are extracted from encrypted data in images from the Z9.',
8925             0x00 => {
8926             Name => 'ShotInfoVersion',
8927             Format => 'string[4]',
8928             Writable => 0,
8929             },
8930             0x04 => {
8931             Name => 'FirmwareVersion',
8932             DataMember => 'FirmwareVersion',
8933             Format => 'string[8]',
8934             Writable => 0,
8935             RawConv => '$$self{FirmwareVersion} = $val',
8936             },
8937             0x0e => {
8938             Name => 'FirmwareVersion2',
8939             Format => 'string[8]',
8940             Writable => 0,
8941             #Hidden => 1,
8942             },
8943             0x18 => {
8944             Name => 'FirmwareVersion3',
8945             Format => 'string[8]',
8946             Writable => 0,
8947             #Hidden => 1,
8948             },
8949             0x24 => {
8950             Name => 'NumberOffsets', # number of entries in offset table. offsets are from start of ShotInfo data.
8951             Format => 'int32u',
8952             Writable => 0,
8953             #Hidden => 1,
8954             },
8955             # subdirectories, referenced by offsets (not processed if offset is zero)
8956             0x30 => {
8957             Name => 'SequenceOffset',
8958             Format => 'int32u',
8959             SubDirectory => {
8960             TagTable => 'Image::ExifTool::Nikon::SeqInfoZ9',
8961             Start => '$val',
8962             },
8963             },
8964             0x58 => {
8965             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.
8966             Condition => '$$self{FirmwareVersion} and $$self{FirmwareVersion} ge "03.01"',
8967             Format => 'int32u',
8968             AlwaysDecrypt => 1, # (necessary because FirmwareVersion is extracted after decryption time)
8969             SubDirectory => {
8970             TagTable => 'Image::ExifTool::Nikon::Offset13InfoZ9',
8971             Start => '$val',
8972             },
8973             },
8974             0x80 => {
8975             Name => 'AutoCaptureOffset',
8976             Condition => '$$self{FirmwareVersion} and $$self{FirmwareVersion} ge "04.00"',
8977             Format => 'int32u',
8978             AlwaysDecrypt => 1, # (necessary because FirmwareVersion is extracted after decryption time)
8979             SubDirectory => {
8980             TagTable => 'Image::ExifTool::Nikon::AutoCaptureInfo',
8981             Start => '$val',
8982             },
8983             },
8984             0x84 => {
8985             Name => 'OrientOffset',
8986             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96', #not valid for C30/C60/C120
8987             Format => 'int32u',
8988             SubDirectory => {
8989             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
8990             Start => '$val',
8991             },
8992             },
8993             0x8c => {
8994             Name => 'MenuOffset',
8995             Format => 'int32u',
8996             SubDirectory => {
8997             TagTable => 'Image::ExifTool::Nikon::MenuInfoZ9',
8998             Start => '$val',
8999             },
9000             },
9001             );
9002              
9003             # ref 28
9004             %Image::ExifTool::Nikon::SeqInfoZ9 = (
9005             %binaryDataAttrs,
9006             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9007             DATAMEMBER => [ 0x20, 0x28, 0x2a ],
9008             #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.
9009             #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.
9010             0x0020 => {
9011             Name => 'FocusShiftShooting',
9012             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96', #not valid for C30/C60/C120
9013             RawConv => '$$self{FocusShiftShooting} = $val',
9014             PrintConv => q{
9015             return 'Off' if $val == 0 ;
9016             my $i = sprintf("Frame %.0f of %.0f",$val, $$self{FocusShiftNumberShots}); # something like Frame 1 of 100"
9017             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)
9018             return "On: $i"
9019             },
9020             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
9021             },
9022             #
9023             # Note: Offsets after this are shifted by +2 for Z8 firmware 3.0 (see Hook above)
9024             #
9025             0x0028 => {
9026             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
9027             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96', #not valid for C30/C60/C120
9028             RawConv => '$$self{IntervalShooting} = $val',
9029             Format => 'int16u',
9030             PrintConv => q{
9031             return 'Off' if $val == 0 ;
9032             my $i = sprintf("Interval %.0f of %.0f",$val, $$self{IntervalShootingIntervals}||0); # something like "Interval 1 of 3"
9033             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
9034             return "On: $i$f"
9035             #$val == 0 ? 'Off' : sprintf("On: Interval %.0f of %.0f Frame %.0f of %.0f",$val, $$self{IntervalShootingIntervals}||0, $$self{IntervalFrame}||0, $$self{IntervalShootingShotsPerInterval}||0),
9036             },
9037             },
9038             0x002a => {
9039             Name => 'IntervalFrame',
9040             RawConv => '$$self{IntervalFrame} = $val',
9041             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0', #not valid for C30/C60/C120
9042             Format => 'int16u',
9043             #Hidden => 1,
9044             },
9045             );
9046              
9047             # ref 28
9048             %Image::ExifTool::Nikon::Offset13InfoZ9 = (
9049             %binaryDataAttrs,
9050             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9051             DATAMEMBER => [ 0x0bea, 0x0beb ],
9052             0x0be8 => {
9053             Name => 'AFAreaInitialXPosition', #the horizontal position of the center the focus box prior to any subject detection or tracking. Origin is Top Left.
9054             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96', #not valid for C30/C60/C120
9055             Format => 'int8s',
9056             PrintConv => q{
9057             my $imageArea = $$self{ImageArea};
9058             my $afAreaMode = $$self{VALUE}{AFAreaMode};
9059             my $dynamicAFAreaSize = ( defined $$self{DynamicAFAreaSize} ? $$self{DynamicAFAreaSize} : 0 );
9060              
9061             my $FX = 0; #image size 8256 x 5504
9062             my $DX = 1; #image size 5392 x 3592
9063             my $WideScreen = 4; #16:9 image area, image size 8256x4640
9064             my $OneToOne = 8; #1:1 image area, image size 5504x5504
9065              
9066             my $Single = 1;
9067             my $Dynamic = 2;
9068             my $WideS = 3;
9069             my $WideL = 4;
9070             my $ThreeD = 5;
9071             my $Auto = 6;
9072             my $WideC1 = 12;
9073              
9074             my $DynamicS = 0;
9075             my $DynamicM = 1;
9076             my $DynamicL = 2;
9077              
9078             my $start = 502; #FX, 16:9 & 1:1 formats
9079             my $increment = 259; #FX & 16:9 formats
9080              
9081             $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)
9082             $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
9083             $start = $start - $increment if $imageArea == $OneToOne and $afAreaMode == $Auto;
9084              
9085             if ($imageArea == $DX) { # DX results are in FX coordinate system to match reporting of ($AFAreaXPosition , $AFAreaYPosition)
9086             $start = 636;
9087             $increment = 388;
9088             if ( $afAreaMode == $WideS ) { #Wide S focus box width is an unusual size
9089             $start = 591;
9090             $increment = 393;
9091             }
9092             $start = $start - $increment if $afAreaMode == $Auto ;
9093             }
9094              
9095             my $divisor = 3.99; #subtract .01 to ensure $val of 2n+2 rounds up
9096             $divisor = 4.01 if $val >= 50; #...but round up on the right side of the frame
9097             $divisor = 6 if $imageArea == $DX or $imageArea == $OneToOne;
9098              
9099             my $roundedValOverDivisor = sprintf("%.0f", $val / $divisor); #round to nearest int
9100              
9101             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
9102             $focusBoxWidth = int($focusBoxWidth * 2 / 3) if $imageArea == $DX or $imageArea == $OneToOne ;
9103              
9104             my $skipPositions = int($focusBoxWidth / 2); #jump over half the width of the focus box
9105              
9106             my $result = $start + $increment * ($roundedValOverDivisor + $skipPositions - 1 ) ;
9107              
9108             return $result;
9109             },
9110             },
9111             0x0be9 => {
9112             Name =>'AFAreaInitialYPosition', #the vertical position of the center the focus box prior to any subject detection or tracking. Origin is Top Left.
9113             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96', #not valid for C30/C60/C120 or for Area Modes 1:1 and 16:9
9114             Format => 'int8s',
9115             PrintConv => q{
9116             my $imageArea = $$self{ImageArea};
9117             my $afAreaMode = $$self{VALUE}{AFAreaMode};
9118              
9119             my $FX = 0; #image size 8256 x 5504
9120             my $DX = 1; #image size 5392 x 3592
9121             my $WideScreen = 4; #16:9 image area, image size 8256x4640
9122             my $OneToOne = 8; #1:1 image area, image size 5504x5504
9123              
9124             my $Single = 1;
9125             my $Dynamic = 2;
9126             my $WideS = 3;
9127             my $WideL = 4;
9128             my $ThreeD = 5;
9129             my $Auto = 6;
9130             my $WideC1 = 12;
9131              
9132             my $DynamicS = 0;
9133             my $DynamicM = 1;
9134             my $DynamicL = 2;
9135              
9136             my $start = 424; #FX, 16:9 & 1:1 formats
9137             my $increment = 291; #FX, & 16:9 formats
9138             $start = $start + $increment if $imageArea == $WideScreen and $val > 0;
9139              
9140             if ($imageArea == $DX) { # DX results are in FX coordinate system to match reporting of ($AFAreaXPosition , $AFAreaYPosition)
9141             $start = 572;
9142             $increment = 436;
9143             if ( $afAreaMode == $WideS ) { #Wide S focus box is a strange size
9144             $start = 542;
9145             $increment = 442;
9146             }
9147             }
9148              
9149             my $divisor = 6.67;
9150             $divisor = 10.01 if $imageArea == $DX ; #extra .01 to ensure $val of 10*n+5 rounds down
9151             $divisor = 8.01 if $imageArea == $WideScreen ;
9152              
9153             my $roundedValOverDivisor = sprintf("%.0f", $val / $divisor); #round to nearest int
9154              
9155             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
9156             $focusBoxHeight = int($focusBoxHeight * 2 / 3) if $imageArea == $DX ;
9157              
9158             my $skipPositions = int($focusBoxHeight / 2); #jump over half the height of the focus box
9159              
9160             my $result = $start + $increment * ($roundedValOverDivisor + $skipPositions - 1 ) ;
9161             return $result;
9162             },
9163             },
9164             0x0bea => {
9165             Name => 'AFAreaInitialWidth',
9166             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96', #not valid for C30/C60/C120
9167             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)
9168             },
9169             0x0beb => {
9170             Name => 'AFAreaInitialHeight',
9171             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96', #not valid for C30/C60/C120
9172             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)
9173             },
9174             );
9175              
9176             %Image::ExifTool::Nikon::MenuInfoZ8 = (
9177             %binaryDataAttrs,
9178             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9179             IS_SUBDIR => [ 0x10 ],
9180             # 0x00 - int32u size of this directory
9181             0x10 => [
9182             {
9183             Name => 'MenuSettingsOffsetZ8v1',
9184             Condition => '$$self{FirmwareVersion} and $$self{FirmwareVersion} lt "02.00"',
9185             Format => 'int32u',
9186             Notes => 'Firmware versions 1.00 and 1.10',
9187             SubDirectory => {
9188             TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ8v1',
9189             Start => '$dirStart + $val',
9190             },
9191             },
9192             {
9193             Name => 'MenuSettingsOffsetZ8v2',
9194             Condition => '$$self{FirmwareVersion} and $$self{FirmwareVersion} ge "02.00"',
9195             Notes => 'Firmware version 2.00 and 2.10',
9196             Format => 'int32u',
9197             SubDirectory => {
9198             TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ8v2',
9199             Start => '$dirStart + $val',
9200             },
9201             },
9202             ],
9203             );
9204              
9205             %Image::ExifTool::Nikon::MenuInfoZ9 = (
9206             %binaryDataAttrs,
9207             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9208             IS_SUBDIR => [ 0x10 ],
9209             # 0x00 - int32u size of this directory
9210             0x10 => [
9211             {
9212             Name => 'MenuSettingsOffsetZ9',
9213             Condition => '$$self{FirmwareVersion} and $$self{FirmwareVersion} lt "03.00"',
9214             Format => 'int32u',
9215             Notes => 'Firmware versions 2.11 and earlier',
9216             SubDirectory => {
9217             TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ9',
9218             Start => '$dirStart + $val',
9219             },
9220             },
9221             {
9222             Name => 'MenuSettingsOffsetZ9v3',
9223             Condition => '$$self{FirmwareVersion} and $$self{FirmwareVersion} lt "04.00"',
9224             Notes => 'Firmware versions 3.00 and v3.10',
9225             Format => 'int32u',
9226             SubDirectory => {
9227             TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ9v3',
9228             Start => '$dirStart + $val',
9229             },
9230             },
9231             {
9232             Name => 'MenuSettingsOffsetZ9v4',
9233             Notes => 'Firmware versions 4.00 and higher',
9234             Format => 'int32u',
9235             SubDirectory => {
9236             TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ9v4',
9237             Start => '$dirStart + $val',
9238             },
9239             },
9240             ],
9241             );
9242              
9243             %Image::ExifTool::Nikon::AutoCaptureInfo = (
9244             %binaryDataAttrs,
9245             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9246             DATAMEMBER => [ 0 ],
9247             0 => {
9248             Name => 'AutoCapturedFrame',
9249             RawConv => '$$self{AutoCapturedFrame} = $val',
9250             PrintConv => {
9251             0 => 'No',
9252             5 => 'Yes',
9253             },
9254             },
9255             1 => {
9256             Name => 'AutoCaptureCriteria',
9257             Condition => '$$self{AutoCapturedFrame} and $$self{AutoCapturedFrame} ne 0',
9258             PrintConv => q[
9259             $_ = '';
9260             return $_ . Image::ExifTool::DecodeBits($val,
9261             {
9262             0 => 'Distance',
9263             1 => 'Motion',
9264             2 => 'Subject Detection',
9265             });
9266             ],
9267             },
9268             # 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.
9269             55 => {
9270             Name => 'AutoCaptureRecordingTime',
9271             Condition => '$$self{AutoCapturedFrame} and $$self{AutoCapturedFrame} ne 0',
9272             PrintConv => {
9273             0 => '1 Sec',
9274             1 => '3 Sec',
9275             2 => '5 Sec',
9276             #3 => '',
9277             4 => '30 Sec',
9278             5 => 'No Limit',
9279             6 => '2 Sec',
9280             7 => '10 Sec',
9281             8 => '20 Sec',
9282             9 => '1 Min',
9283             10 => '3 Min',
9284             11 => '5 Min',
9285             12 => '10 Min',
9286             13 => '30 Min',
9287             },
9288             },
9289             56 => {
9290             Name => 'AutoCaptureWaitTime',
9291             Condition => '$$self{AutoCapturedFrame} and $$self{AutoCapturedFrame} ne 0',
9292             PrintConv => {
9293             0 => 'No Wait',
9294             1 => '10 Sec',
9295             2 => '30 Sec',
9296             3 => '1 Min',
9297             4 => '5 Min',
9298             5 => '10 Min',
9299             6 => '30 Min',
9300             7 => '1 Sec',
9301             8 => '2 Sec',
9302             9 => '3 Sec',
9303             10 => '5 Sec',
9304             11 => '20 Sec',
9305             12 => '3 Min',
9306             },
9307             },
9308             74 => {
9309             Name => 'AutoCaptureDistanceFar',
9310             Condition => '$$self{AutoCapturedFrame} and $$self{AutoCapturedFrame} ne 0',
9311             PrintConv => 'sprintf("%.1f m", $val/10)',
9312             },
9313             78 => {
9314             Name => 'AutoCaptureDistanceNear',
9315             Condition => '$$self{AutoCapturedFrame} and $$self{AutoCapturedFrame} ne 0',
9316             PrintConv => 'sprintf("%.1f m", $val/10)',
9317             },
9318             95 => {
9319             Name => 'AutoCaptureCriteriaMotionDirection',
9320             Condition => '$$self{AutoCapturedFrame} and $$self{AutoCapturedFrame} ne 0',
9321             PrintConv => q[
9322             return 'All' if $val eq 255;
9323             $_ = '';
9324             return $_ . Image::ExifTool::DecodeBits($val,
9325             {
9326             0 => 'Top Left',
9327             1 => 'Top Right',
9328             2 => 'Bottom Left',
9329             3 => 'Bottom Right',
9330             4 => 'Left',
9331             5 => 'Right',
9332             6 => 'Top Center',
9333             7 => 'Bottom Center',
9334             });
9335             ],
9336             },
9337             99 => {
9338             Name => 'AutoCaptureCriteriaMotionSpeed', #1-5
9339             Condition => '$$self{AutoCapturedFrame} and $$self{AutoCapturedFrame} ne 0',
9340             },
9341             100 => {
9342             Name => 'AutoCaptureCriteriaMotionSize', #1-5
9343             Condition => '$$self{AutoCapturedFrame} and $$self{AutoCapturedFrame} ne 0',
9344             },
9345             105 => {
9346             Name => 'AutoCaptureCriteriaSubjectSize', #1-5
9347             Condition => '$$self{AutoCapturedFrame} and $$self{AutoCapturedFrame} ne 0',
9348             },
9349             106 => {
9350             Name => 'AutoCaptureCriteriaSubjectType',
9351             Condition => '$$self{AutoCapturedFrame} and $$self{AutoCapturedFrame} ne 0',
9352             ValueConv => '$val + 1', # change value range to align with %subjectDetectionZ9
9353             ValueConvInv => '$val - 1',
9354             PrintConv => \%subjectDetectionZ9,
9355             },
9356             );
9357              
9358             %Image::ExifTool::Nikon::OrientationInfo = (
9359             %binaryDataAttrs,
9360             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9361             0 => {
9362             Name => 'RollAngle',
9363             Format => 'fixed32u',
9364             Notes => 'converted to degrees of clockwise camera roll',
9365             ValueConv => '$val <= 180 ? $val : $val - 360',
9366             ValueConvInv => '$val >= 0 ? $val : $val + 360',
9367             PrintConv => 'sprintf("%.1f", $val)',
9368             PrintConvInv => '$val',
9369             },
9370             4 => {
9371             Name => 'PitchAngle',
9372             Format => 'fixed32u',
9373             Notes => 'converted to degrees of upward camera tilt',
9374             ValueConv => '$val <= 180 ? $val : $val - 360',
9375             ValueConvInv => '$val >= 0 ? $val : $val + 360',
9376             PrintConv => 'sprintf("%.1f", $val)',
9377             PrintConvInv => '$val',
9378             },
9379             8 => {
9380             Name => 'YawAngle',
9381             Format => 'fixed32u',
9382             Notes => 'the camera yaw angle when shooting in portrait orientation',
9383             ValueConv => '$val <= 180 ? $val : $val - 360',
9384             ValueConvInv => '$val >= 0 ? $val : $val + 360',
9385             PrintConv => 'sprintf("%.1f", $val)',
9386             PrintConvInv => '$val',
9387             },
9388             );
9389              
9390             %Image::ExifTool::Nikon::MenuSettingsZ6III = (
9391             %binaryDataAttrs,
9392             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9393             NOTES => 'These tags are used by the Z6III.',
9394             DATAMEMBER => [ 360, 444, 492, 496, 724, 748, 832, 838, 852, 880, 904, 1050 ],
9395             IS_SUBDIR => [ 1255 ],
9396             360 => {
9397             Name => 'SingleFrame', #0=> Single Frame 1=> one of the continuous modes
9398             #Hidden => 1,
9399             RawConv => '$$self{SingleFrame} = $val',
9400             },
9401             364 => {
9402             Name => 'HighFrameRate', #CH and C30/C60/C120 but not CL
9403             PrintConv => \%highFrameRateZ9,
9404             },
9405             444 => {
9406             Name => 'MultipleExposureMode',
9407             RawConv => '$$self{MultipleExposureMode} = $val',
9408             PrintConv => \%multipleExposureModeZ9,
9409             },
9410             446 => {Name => 'MultiExposureShots', Condition => '$$self{MultipleExposureMode} != 0'}, #range 2-9
9411             476 => {
9412             Name => 'IntervalDurationHours',
9413             Format => 'int32u',
9414             },
9415             480 => {
9416             Name => 'IntervalDurationMinutes',
9417             Format => 'int32u',
9418             },
9419             484 => {
9420             Name => 'IntervalDurationSeconds',
9421             Format => 'int32u',
9422             },
9423             492 => {
9424             Name => 'Intervals',
9425             Format => 'int32u',
9426             RawConv => '$$self{IntervalShootingIntervals} = $val',
9427             },
9428             496 => {
9429             Name => 'ShotsPerInterval',
9430             Format => 'int32u',
9431             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
9432             },
9433             500 => {
9434             Name => 'IntervalExposureSmoothing',
9435             Format => 'int8u',
9436             PrintConv => \%offOn,
9437             },
9438             502 => {
9439             Name => 'IntervalPriority',
9440             Format => 'int8u',
9441             PrintConv => \%offOn,
9442             },
9443             536 => {
9444             Name => 'FocusShiftNumberShots',
9445             },
9446             540 => {
9447             Name => 'FocusShiftStepWidth',
9448             },
9449             544 => {
9450             Name => 'FocusShiftInterval',
9451             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
9452             },
9453             548 => {
9454             Name => 'FocusShiftExposureLock',
9455             PrintConv => \%offOn,
9456             },
9457             648 => { Name => 'AutoISO', PrintConv => \%offOn },
9458             650 => {
9459             Name => 'ISOAutoHiLimit',
9460             Format => 'int16u',
9461             Unknown => 1,
9462             ValueConv => '($val-104)/8',
9463             ValueConvInv => '8 * ($val + 104)',
9464             PrintConv => \%iSOAutoHiLimitZ6III,
9465             },
9466             #652 => ISOAutoFlashLimit # only when ISOAutoFlashLimitSameAsHiLimit == 0
9467             #654 => ISOAutoFlashLimitSameAsHiLimit 1=> Same as ISOAutoHiLimit 0=> Separate (use ISOAutoFlashLimit)
9468             718 => {
9469             Name => 'DiffractionCompensation',
9470             Format => 'int8u',
9471             PrintConv => \%offOn,
9472             },
9473             719 => {
9474             Name => 'AutoDistortionControl',
9475             Format => 'int8u',
9476             PrintConv => \%offOn,
9477             },
9478             720 => { Name => 'FlickerReductionShooting',PrintConv => \%offOn },
9479             722 => { Name => 'NikonMeteringMode', PrintConv => \%meteringModeZ7},
9480             724 => {
9481             Name => 'FlashControlMode',
9482             RawConv => '$$self{FlashControlMode} = $val',
9483             PrintConv => \%flashControlModeZ7,
9484             },
9485             730 => {
9486             Name => 'FlashGNDistance',
9487             Condition => '$$self{FlashControlMode} == 2',
9488             Unknown => 1,
9489             ValueConv => '$val + 3',
9490             PrintConv => \%flashGNDistance,
9491             },
9492             734 => {
9493             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)
9494             Condition => '$$self{FlashControlMode} >= 3',
9495             Unknown => 1,
9496             ValueConv => '2 ** (-$val/3)',
9497             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
9498             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
9499             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9500             },
9501             742 => { Name => 'FlashWirelessOption', PrintConv => \%flashWirelessOptionZ7, Unknown => 1 },
9502             744 => { Name => 'FlashRemoteControl', PrintConv => \%flashRemoteControlZ7, Unknown => 1 },
9503             748 => {
9504             Name => 'FlashMasterControlMode', # tag name chosen for compatibility with those found in FlashInfo0102 & FlashInfo0103
9505             RawConv => '$$self{FlashGroupOptionsMasterMode} = $val',
9506             PrintConv => \%flashGroupOptionsMode,
9507             },
9508             750 => {
9509             Name => 'FlashMasterCompensation',
9510             Format => 'int8s',
9511             Condition => '$$self{FlashGroupOptionsMasterMode} != 3', # other than 'Off'
9512             Unknown => 1,
9513             ValueConv => '$val/6',
9514             ValueConvInv => '6 * $val',
9515             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9516             PrintConvInv => '$val',
9517             },
9518             754 => {
9519             Name => 'FlashMasterOutput',
9520             Unknown => 1,
9521             Condition => '$$self{FlashGroupOptionsMasterMode} == 1', # only for Mode=M
9522             ValueConv => '2 ** (-$val/3)',
9523             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
9524             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
9525             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9526             },
9527             832 => { Name => 'AFAreaMode', RawConv => '$$self{AFAreaMode} = $val', PrintConv => \%aFAreaModeZ9},
9528             834 => { Name => 'VRMode', PrintConv => \%vRModeZ9},
9529             838 => {
9530             Name => 'BracketSet',
9531             RawConv => '$$self{BracketSet} = $val',
9532             PrintConv => \%bracketSetZ9,
9533             },
9534             840 => {
9535             Name => 'BracketProgram',
9536             Condition => '$$self{BracketSet} < 3',
9537             Notes => 'AE and/or Flash Bracketing',
9538             PrintConv => \%bracketProgramZ9,
9539             },
9540             842 => {
9541             Name => 'BracketIncrement',
9542             Condition => '$$self{BracketSet} < 3',
9543             Notes => 'AE and/or Flash Bracketing',
9544             PrintConv => \%bracketIncrementZ9,
9545             },
9546             852 => { Name => 'HDR', RawConv => '$$self{HDR} = $val', PrintConv => \%multipleExposureModeZ9 },
9547             858 => { Name => 'SecondarySlotFunction', PrintConv => \%secondarySlotFunctionZ9 },
9548             864 => { Name => 'HDRLevel', Condition => '$$self{HDR} ne 0', PrintConv => \%hdrLevelZ8 },
9549             868 => { Name => 'Slot2JpgSize', PrintConv => { 0 => 'Large (6048x4032)', 1 => 'Medium (4528x3024)', 2 => 'Small (3024x2016)' }, Unknown => 1},
9550             878 => { Name => 'SubjectDetection', PrintConv => \%subjectDetectionZ9 },
9551             880 => {
9552             Name => 'DynamicAFAreaSize',
9553             Condition => '$$self{AFAreaMode} == 2',
9554             RawConv => '$$self{DynamicAFAreaSize} = $val',
9555             PrintConv => \%dynamicAfAreaModesZ9,
9556             },
9557             884 => { Name => 'ToneMap', PrintConv => { 0 => 'SDR', 1 => 'HLG' }, Unknown => 1 },
9558             888 => { Name => 'PortraitImpressionBalance', PrintConv => \%portraitImpressionBalanceZ8 },
9559             902 => { Name => 'HighFrequencyFlickerReduction', PrintConv => \%offOn, Unknown => 1 },
9560             904 => { Name => 'PixelShiftShooting', RawConv => '$$self{PixelShiftShooting} = $val', PrintConv => \%multipleExposureModeZ9 }, #off/on/on (series)
9561             906 => { Name => 'PixelShiftNumberShots', Condition => '$$self{PixelShiftShooting} > 0', PrintConv => \%pixelShiftNumberShots },
9562             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}
9563             910 => { Name => 'PixelShiftInterval', Condition => '$$self{PixelShiftShooting} > 0', PrintConv => '$val == 0? "No Delay" : sprintf("%.0f sec",$val)' }, #seconds in integer range [0,30]
9564             1002 => { Name => 'SubjectDetectionAreaMF', PrintConv => \%subjectDetectionAreaMZ6III }, #new tag with Z6III
9565             1004 => { Name => 'LinkVRToFocusPoint', PrintConv => \%offOn, Unknown => 1 }, #new tag with Z6III
9566             #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
9567             1046 => { Name => 'MovieSlowMotion', PrintConv => \%movieSlowMotion, Unknown => 1 },
9568             1050 => { Name => 'MovieType', RawConv => '$$self{MovieType} = $val' , PrintConv => \%movieTypeZ9},
9569             1162 => { Name => 'MovieFrameSize', PrintConv => \%movieFrameSizeZ9, Unknown => 1 },
9570             1164 => { Name => 'MovieFrameRate', Condition => '$$self{MovieType} != 1', PrintConv => \%movieFrameRateZ6III, Unknown => 1 },
9571             1255 => {
9572             Name => 'CustomSettingsZ6III',
9573             Format => 'undef[700]',
9574             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsZ6III' },
9575             },
9576             2300 => { Name => 'Language', PrintConv => \%languageZ9, Unknown => 1 },
9577             2302 => { Name => 'TimeZone', PrintConv => \%timeZoneZ9, SeparateTable => 'TimeZone' },
9578             2308 => { Name => 'MonitorBrightness', PrintConv => \%monitorBrightnessZ9, Unknown => 1 }, # settings: -5 to +5 and Lo1, Lo2, Hi1, Hi2
9579             2444 => { Name => 'EmptySlotRelease', PrintConv => { 0 => 'Disable Release', 1 => 'Enable Release' }, Unknown => 1 },
9580             2450 => { Name => 'EnergySavingMode', PrintConv => \%offOn, Unknown => 1 },
9581             2476 => { Name => 'USBPowerDelivery', PrintConv => \%offOn, Unknown => 1 },
9582             2480 => { Name => 'SaveFocusPosition', PrintConv => \%offOn, Unknown => 1 },
9583             2487 => { Name => 'SilentPhotography', PrintConv => \%offOn, Unknown => 1 },
9584             2496 => { Name => 'AirplaneMode', PrintConv => \%offOn, Unknown => 1 },
9585             ),
9586              
9587             %Image::ExifTool::Nikon::MenuSettingsZ7II = (
9588             %binaryDataAttrs,
9589             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9590             DATAMEMBER => [ 90, 176, 180, 328, 352, 858 ],
9591             NOTES => 'These tags are used by the Z5, Z6, Z7, Z6II, Z7II, Z50, Zfc and Zf.',
9592             #48 SelfTimer' #0=> no 1=> yes works for Z7II firmware 1.40, but not 1.30. Follow-up required.
9593             90 => {
9594             Name => 'SingleFrame', #0=> Single Frame 1=> one of the continuous modes
9595             #Hidden => 1,
9596             RawConv => '$$self{SingleFrame} = $val',
9597             },
9598             92 => {
9599             Name => 'ReleaseMode',
9600             #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
9601             ValueConv => '$$self{SingleFrame} == 0 ? 5 : $val', #map single frame to a unique value for PrintConv
9602             PrintConv => \%releaseModeZ7,
9603             },
9604             160 => {
9605             Name => 'IntervalDurationHours',
9606             Format => 'int32u',
9607             #Condition => '$$self{IntervalShooting} > 0',
9608             },
9609             164 => {
9610             Name => 'IntervalDurationMinutes',
9611             Format => 'int32u',
9612             #Condition => '$$self{IntervalShooting} > 0',
9613             },
9614             168 => {
9615             Name => 'IntervalDurationSeconds',
9616             Format => 'int32u',
9617             #Condition => '$$self{IntervalShooting} > 0',
9618             },
9619             176 => {
9620             Name => 'Intervals',
9621             Format => 'int32u',
9622             RawConv => '$$self{IntervalShootingIntervals} = $val',
9623             #Condition => '$$self{IntervalShooting} > 0',
9624             },
9625             180 => {
9626             Name => 'ShotsPerInterval',
9627             Format => 'int32u',
9628             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
9629             #Condition => '$$self{IntervalShooting} > 0',
9630             },
9631             184 => {
9632             Name => 'IntervalExposureSmoothing',
9633             #Condition => '$$self{IntervalShooting} > 0',
9634             Format => 'int8u',
9635             PrintConv => \%offOn,
9636             },
9637             186 => {
9638             Name => 'IntervalPriority',
9639             #Condition => '$$self{IntervalShooting} > 0',
9640             Format => 'int8u',
9641             PrintConv => \%offOn,
9642             },
9643             220 => {
9644             Name => 'FocusShiftNumberShots',
9645             },
9646             224 => {
9647             Name => 'FocusShiftStepWidth',
9648             },
9649             228 => {
9650             Name => 'FocusShiftInterval',
9651             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
9652             },
9653             232 => {
9654             Name => 'FocusShiftExposureLock',
9655             PrintConv => \%offOn,
9656             },
9657             #304 => White Balance - Kelvin Temp
9658             #312 => ColorSpace
9659             #314 => ActiveD-Lighting
9660             #318 => HighISONoiseReduction
9661             322 => {
9662             Name => 'DiffractionCompensation',
9663             Format => 'int8u',
9664             PrintConv => \%offOn,
9665             },
9666             323 => {
9667             Name => 'AutoDistortionControl',
9668             Format => 'int8u',
9669             PrintConv => \%offOn,
9670             },
9671             #324 => {Name => 'FlickerReductionShooting',}, # redundant with tag in NikonSettings
9672             326 => { Name => 'NikonMeteringMode', PrintConv => \%meteringModeZ7 },
9673             328 => {
9674             Name => 'FlashControlMode', # this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
9675             RawConv => '$$self{FlashControlMode} = $val',
9676             PrintConv => \%flashControlModeZ7,
9677             },
9678             334 => {
9679             Name => 'FlashGNDistance',
9680             Condition => '$$self{FlashControlMode} == 2',
9681             Unknown => 1,
9682             ValueConv => '$val + 3',
9683             PrintConv => \%flashGNDistance,
9684             },
9685             338 => {
9686             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)
9687             Condition => '$$self{FlashControlMode} >= 3',
9688             Unknown => 1,
9689             ValueConv => '2 ** (-$val/3)',
9690             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
9691             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
9692             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9693             },
9694             346 => { Name => 'FlashWirelessOption', PrintConv => \%flashWirelessOptionZ7, Unknown => 1 },
9695             348 => { Name => 'FlashRemoteControl', PrintConv => \%flashRemoteControlZ7, Unknown => 1 },
9696             352 => {
9697             Name => 'FlashMasterControlMode', # tag name chosen for compatibility with those found in FlashInfo0102 & FlashInfo0103
9698             RawConv => '$$self{FlashGroupOptionsMasterMode} = $val',
9699             PrintConv => \%flashGroupOptionsMode,
9700             },
9701             354 => {
9702             Name => 'FlashMasterCompensation',
9703             Format => 'int8s',
9704             Condition => '$$self{FlashGroupOptionsMasterMode} != 3', # other than 'Off'
9705             Unknown => 1,
9706             ValueConv => '$val/6',
9707             ValueConvInv => '6 * $val',
9708             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9709             PrintConvInv => '$val',
9710             },
9711             358 => {
9712             Name => 'FlashMasterOutput',
9713             Unknown => 1,
9714             Condition => '$$self{FlashGroupOptionsMasterMode} == 1', # only for Mode=M
9715             ValueConv => '2 ** (-$val/3)',
9716             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
9717             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
9718             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9719             },
9720             #360 => { Name => 'FlashGroupAControlMode' }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupACompensation at 362 and FlashGroupAOutput at 368
9721             #368 => { Name => 'FlashGroupBControlMode' }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupBCompensation at 370 and FlashGroupBOutput at 374
9722             #376 => { Name => 'FlashGroupCControlMode' }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupCCompensation at 378 and FlashGroupCOutput at 382
9723             #384 => { Name => 'FlashGroupDControlMode' }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupDCompensation at 386 and FlashGroupDOutput at 390
9724             #392 => { Name => 'FlashGroupEControlMode' }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupECompensation at 394 and FlashGroupEOutput at 398
9725             #400 => { Name => 'FlashGroupFControlMode' }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupFCompensation at 402 and FlashGroupFOutput at 406
9726             #434 => FocusMode
9727             #436 => AFAreaMode
9728             #438 => VibrationReduction
9729             #442 => BracketSet
9730             #444 => BracketProgram
9731             #446 => BracketIncrement
9732             #463 => SilentPhotography
9733             502 => { Name => 'MovieFrameSize', PrintConv => \%movieFrameSizeZ9, Unknown => 1 },
9734             504 => { Name => 'MovieFrameRate', PrintConv => \%movieFrameRateZ7, Unknown => 1 },
9735             506 => { Name => 'MovieSlowMotion', PrintConv => \%movieSlowMotion, Unknown => 1 },
9736             510 => {
9737             Name => 'MovieType',
9738             Unknown => 1,
9739             PrintConv => {
9740             0 => 'MOV',
9741             1 => 'MP4',
9742             },
9743             },
9744             #512 => MovieISOAutoHiLimit
9745             516 => {
9746             Name => 'MovieISOAutoManualMode',
9747             Condition => '$$self{Model} =~ /^NIKON 7/', #ISO ranges vary by model. These mappings are for the Z7 and Z7II
9748             %isoAutoHiLimitZ7,
9749             },
9750             #520 => MovieWhiteBalanceSameAsPhoto
9751             568 => { Name => 'MovieActiveD-Lighting', PrintConv => \%activeDLightingZ7, Unknown => 1 },
9752             572 => { Name => 'MovieHighISONoiseReduction', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
9753             574 => { Name => 'MovieVignetteControl', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
9754             576 => {
9755             Name => 'MovieVignetteControlSameAsPhoto',
9756             Unknown => 1,
9757             PrintConv => \%noYes
9758             },
9759             577 => {
9760             Name => 'MovieDiffractionCompensation',
9761             Unknown => 1,
9762             PrintConv => \%offOn
9763             },
9764             578 => {
9765             Name => 'MovieAutoDistortionControl',
9766             Unknown => 1,
9767             PrintConv => \%offOn
9768             },
9769             584 => { Name => 'MovieFocusMode', PrintConv => \%focusModeZ7, Unknown => 1 },
9770             #586 => MovieAFAreaMode
9771             590 => {
9772             Name => 'MovieVibrationReduction',
9773             Unknown => 1,
9774             PrintConv => {
9775             0 => 'Off',
9776             1 => 'On (Normal)',
9777             2 => 'On (Sport)',
9778             },
9779             },
9780             591 => {
9781             Name => 'MovieVibrationReductionSameAsPhoto',
9782             Unknown => 1,
9783             PrintConv => \%noYes
9784             },
9785             #848 => HDMIOutputResolution
9786             #850 => HDMIOutputRange
9787             #854 => HDMIExternalRecorder
9788             #856 => HDMIBitDepth
9789             858 => {
9790             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
9791             Condition => '$$self{HDMIBitDepth} and $$self{HDMIBitDepth} == 2', # only for 10 bit
9792             RawConv => '$$self{HDMIOutputNLog} = $val',
9793             Unknown => 1,
9794             PrintConv => \%offOn,
9795             },
9796             #859 => HDMIViewAssist
9797             );
9798              
9799             %Image::ExifTool::Nikon::MenuSettingsZ8 = (
9800             %binaryDataAttrs,
9801             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9802             DATAMEMBER => [ 72, 152, 200, 204, 244, 440, 548, 554, 570, 596, 636 ],
9803             NOTES => 'These tags are common to all Z8 firmware versions.',
9804             72 => {
9805             Name => 'HighFrameRate', #CH and C30/C60/C120 but not CL
9806             PrintConv => \%highFrameRateZ9,
9807             Hook => '$varSize += 4 if $$self{FirmwareVersion} and $$self{FirmwareVersion} ge "02.10"',
9808             },
9809             #
9810             # firmware 2.10 adds 4 bytes somewhere in the range 105-107 (hence the Hook above)
9811             #
9812             152 => {
9813             Name => 'MultipleExposureMode',
9814             RawConv => '$$self{MultipleExposureMode} = $val',
9815             PrintConv => \%multipleExposureModeZ9,
9816             },
9817             154 => {Name => 'MultiExposureShots', Condition => '$$self{MultipleExposureMode} != 0'}, #range 2-9 - not present in a NEF, only in the assembled JPG
9818             184 => {
9819             Name => 'IntervalDurationHours',
9820             Format => 'int32u',
9821             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0',
9822             },
9823             188 => {
9824             Name => 'IntervalDurationMinutes',
9825             Format => 'int32u',
9826             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0',
9827             },
9828             192 => {
9829             Name => 'IntervalDurationSeconds',
9830             Format => 'int32u',
9831             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0',
9832             },
9833             200 => {
9834             Name => 'Intervals',
9835             Format => 'int32u',
9836             RawConv => '$$self{IntervalShootingIntervals} = $val',
9837             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0',
9838             },
9839             204 => {
9840             Name => 'ShotsPerInterval',
9841             Format => 'int32u',
9842             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
9843             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0',
9844             },
9845             208 => {
9846             Name => 'IntervalExposureSmoothing',
9847             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0',
9848             Format => 'int8u',
9849             PrintConv => \%offOn,
9850             },
9851             210 => {
9852             Name => 'IntervalPriority',
9853             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0',
9854             Format => 'int8u',
9855             PrintConv => \%offOn,
9856             },
9857             244 => {
9858             Name => 'FocusShiftNumberShots', #1-300
9859             RawConv => '$$self{FocusShiftNumberShots} = $val',
9860             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
9861             },
9862             248 => {
9863             Name => 'FocusShiftStepWidth', #1(Narrow) to 10 (Wide)
9864             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
9865             },
9866             252 => {
9867             Name => 'FocusShiftInterval',
9868             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
9869             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
9870             },
9871             256 => {
9872             Name => 'FocusShiftExposureLock',
9873             Unknown => 1,
9874             PrintConv => \%offOn,
9875             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
9876             },
9877             286 => { Name => 'PhotoShootingMenuBank', PrintConv => \%banksZ9 },
9878             288 => { Name => 'ExtendedMenuBanks', PrintConv => \%offOn }, # single tag from both Photo & Video menus
9879             324 => { Name => 'PhotoShootingMenuBankImageArea', PrintConv => \%imageAreaZ9 },
9880             338 => { Name => 'AutoISO', PrintConv => \%offOn },
9881             340 => { Name => 'ISOAutoHiLimit', %isoAutoHiLimitZ7 },
9882             342 => { Name => 'ISOAutoFlashLimit', %isoAutoHiLimitZ7 },
9883             350 => {
9884             Name => 'ISOAutoShutterTime', # shutter speed is 2 ** (-$val/24)
9885             ValueConv => '$val / 8',
9886             Format => 'int16s',
9887             PrintConv => \%iSOAutoShutterTimeZ9,
9888             },
9889             432 => { Name => 'MovieVignetteControl', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
9890             434 => { Name => 'DiffractionCompensation', PrintConv => \%offOn }, # value can be set from both the Photo Shoot Menu and the Video Shooting Menu
9891             436 => { Name => 'FlickerReductionShooting',PrintConv => \%offOn },
9892             440 => {
9893             Name => 'FlashControlMode', # this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
9894             RawConv => '$$self{FlashControlMode} = $val',
9895             PrintConv => \%flashControlModeZ7,
9896             },
9897             548 => { Name => 'AFAreaMode', RawConv => '$$self{AFAreaMode} = $val', PrintConv => \%aFAreaModeZ9},
9898             550 => { Name => 'VRMode', PrintConv => \%vRModeZ9},
9899             554 => {
9900             Name => 'BracketSet',
9901             RawConv => '$$self{BracketSet} = $val',
9902             PrintConv => \%bracketSetZ9,
9903             },
9904             556 => {
9905             Name => 'BracketProgram',
9906             Condition => '$$self{BracketSet} < 3',
9907             Notes => 'AE and/or Flash Bracketing',
9908             PrintConv => \%bracketProgramZ9,
9909             },
9910             558 => {
9911             Name => 'BracketIncrement',
9912             Condition => '$$self{BracketSet} < 3',
9913             Notes => 'AE and/or Flash Bracketing',
9914             PrintConv => \%bracketIncrementZ9,
9915             },
9916             570 => { Name => 'HDR', RawConv => '$$self{HDR} = $val', PrintConv => \%multipleExposureModeZ9 }, #will be 'on' for the tone mapped JPGs, off for the source NEF files
9917             #572 HDRSaveRaw 0=> No; 1=> Yes
9918             576 => { Name => 'SecondarySlotFunction', PrintConv => \%secondarySlotFunctionZ9 },
9919             582 => { Name => 'HDRLevel', Condition => '$$self{HDR} ne 0', PrintConv => \%hdrLevelZ8 },
9920             586 => { Name => 'Slot2JpgSize', PrintConv => { 0 => 'Large (8256x5504)', 1 => 'Medium (6192x4128)', 2 => 'Small (4128x2752)' }, Unknown => 1},
9921             592 => { Name => 'DXCropAlert', PrintConv => \%offOn },
9922             594 => { Name => 'SubjectDetection', PrintConv => \%subjectDetectionZ9 },
9923             596 => {
9924             Name => 'DynamicAFAreaSize',
9925             Condition => '$$self{AFAreaMode} == 2',
9926             RawConv => '$$self{DynamicAFAreaSize} = $val',
9927             PrintConv => \%dynamicAfAreaModesZ9,
9928             },
9929             618 => { Name => 'ToneMap', PrintConv => { 0 => 'SDR', 1 => 'HLG' }, Unknown => 1 },
9930             622 => { Name => 'PortraitImpressionBalance', PrintConv => \%portraitImpressionBalanceZ8 },
9931             636 => {
9932             Name => 'HighFrequencyFlickerReduction',
9933             PrintConv => \%offOn,
9934             Unknown => 1,
9935             Hook => '$varSize += 4 if $$self{FirmwareVersion} and $$self{FirmwareVersion} ge "03.00"',
9936             },
9937             #
9938             # firmware 3.00 adds 4 bytes somewhere in the range 638-730 (hence the Hook above)
9939             #
9940             730 => {
9941             Name => 'MovieImageArea',
9942             Unknown => 1,
9943             Mask => 0x01, # without the mask 4 => 'FX' 5 => DX only the 2nd Z-series field encountered with a mask.
9944             PrintConv => \%imageAreaZ9b,
9945             },
9946             740 => { Name => 'MovieType', PrintConv => \%movieTypeZ9, Unknown => 1 },
9947             742 => { Name => 'MovieISOAutoHiLimit', %isoAutoHiLimitZ7 },
9948             744 => { Name => 'MovieISOAutoControlManualMode', PrintConv => \%offOn, Unknown => 1 },
9949             746 => { Name => 'MovieISOAutoManualMode', %isoAutoHiLimitZ7 },
9950             820 => { Name => 'MovieActiveD-Lighting', PrintConv => \%activeDLightingZ7, Unknown => 1 },
9951             822 => { Name => 'MovieHighISONoiseReduction', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
9952             828 => { Name => 'MovieFlickerReduction', PrintConv => \%movieFlickerReductionZ9 },
9953             830 => { Name => 'MovieMeteringMode', PrintConv => \%meteringModeZ7, Unknown => 1 },
9954             832 => { Name => 'MovieFocusMode', PrintConv => \%focusModeZ7, Unknown => 1 },
9955             834 => { Name => 'MovieAFAreaMode', PrintConv => \%aFAreaModeZ9 },
9956             836 => { Name => 'MovieVRMode', PrintConv => \%vRModeZ9, Unknown => 1 },
9957             840 => { Name => 'MovieElectronicVR', PrintConv => \%offOn, Unknown => 1 }, # distinct from MoveieVRMode
9958             842 => { Name => 'MovieSoundRecording', PrintConv => { 0 => 'Off', 1 => 'Auto', 2 => 'Manual' }, Unknown => 1 },
9959             844 => { Name => 'MicrophoneSensitivity', Unknown => 1 }, # 1-20
9960             846 => { Name => 'MicrophoneAttenuator', PrintConv => \%offOn, Unknown => 1 }, # distinct from MoveieVRMode
9961             848 => { Name => 'MicrophoneFrequencyResponse',PrintConv => { 0 => 'Wide Range', 1 => 'Vocal Range' }, Unknown => 1 },
9962             850 => { Name => 'WindNoiseReduction', PrintConv => \%offOn, Unknown => 1 },
9963             882 => { Name => 'MovieFrameSize', PrintConv => \%movieFrameSizeZ9, Unknown => 1 },
9964             884 => { Name => 'MovieFrameRate', PrintConv => \%movieFrameRateZ7, Unknown => 1 },
9965             886 => { Name => 'MicrophoneJackPower', PrintConv => \%offOn, Unknown => 1 },
9966             887 => { Name => 'MovieDXCropAlert', PrintConv => \%offOn, Unknown => 1 },
9967             888 => { Name => 'MovieSubjectDetection', PrintConv => \%subjectDetectionZ9, Unknown => 1 },
9968             896 => { Name => 'MovieHighResZoom', PrintConv => \%offOn, Unknown => 1 },
9969             );
9970              
9971             %Image::ExifTool::Nikon::MenuSettingsZ8v1 = (
9972             %binaryDataAttrs,
9973             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9974             NOTES => 'These tags are used by the Z8 firmware 1.00 and 1.10.',
9975             IS_SUBDIR => [ 0, 943 ],
9976             0 => {
9977             Name => 'MenuSettingsZ8',
9978             Format => 'undef[943]',
9979             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ8' },
9980             },
9981             943 => {
9982             Name => 'CustomSettingsZ8',
9983             Format => 'undef[730]',
9984             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsZ8' },
9985             },
9986             1684 => { Name => 'TimeZone', PrintConv => \%timeZoneZ9, SeparateTable => 'TimeZone' },
9987             1690 => { Name => 'MonitorBrightness', PrintConv => \%monitorBrightnessZ9, Unknown => 1 }, # settings: -5 to +5. Added with firmware 3.0: Lo1, Lo2, Hi1, Hi2
9988             1698 => { Name => 'Language', PrintConv => \%languageZ9, Unknown => 1 },
9989             1712 => { Name => 'AFFineTune', PrintConv => \%offOn, Unknown => 1 },
9990             1716 => { Name => 'NonCPULens1FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1}, #should probably hide altogther if $val is 0
9991             1718 => { Name => 'NonCPULens2FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
9992             1720 => { Name => 'NonCPULens3FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
9993             1722 => { Name => 'NonCPULens4FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
9994             1724 => { Name => 'NonCPULens5FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
9995             1726 => { Name => 'NonCPULens6FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
9996             1728 => { Name => 'NonCPULens7FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
9997             1730 => { Name => 'NonCPULens8FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
9998             1732 => { Name => 'NonCPULens9FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
9999             1734 => { Name => 'NonCPULens10FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10000             1736 => { Name => 'NonCPULens11FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10001             1738 => { Name => 'NonCPULens12FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10002             1740 => { Name => 'NonCPULens13FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10003             1742 => { Name => 'NonCPULens14FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10004             1744 => { Name => 'NonCPULens15FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10005             1746 => { Name => 'NonCPULens16FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10006             1748 => { Name => 'NonCPULens17FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10007             1750 => { Name => 'NonCPULens18FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10008             1752 => { Name => 'NonCPULens19FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10009             1754 => { Name => 'NonCPULens20FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10010             1756 => { Name => 'NonCPULens1MaxAperture', %nonCPULensApertureZ8 },
10011             1758 => { Name => 'NonCPULens2MaxAperture', %nonCPULensApertureZ8},
10012             1760 => { Name => 'NonCPULens3MaxAperture', %nonCPULensApertureZ8},
10013             1762 => { Name => 'NonCPULens4MaxAperture', %nonCPULensApertureZ8},
10014             1764 => { Name => 'NonCPULens5MaxAperture', %nonCPULensApertureZ8},
10015             1766 => { Name => 'NonCPULens6MaxAperture', %nonCPULensApertureZ8},
10016             1768 => { Name => 'NonCPULens7MaxAperture', %nonCPULensApertureZ8},
10017             1770 => { Name => 'NonCPULens8MaxAperture', %nonCPULensApertureZ8},
10018             1772 => { Name => 'NonCPULens9MaxAperture', %nonCPULensApertureZ8},
10019             1774 => { Name => 'NonCPULens10MaxAperture', %nonCPULensApertureZ8},
10020             1776 => { Name => 'NonCPULens11MaxAperture', %nonCPULensApertureZ8},
10021             1778 => { Name => 'NonCPULens12MaxAperture', %nonCPULensApertureZ8},
10022             1780 => { Name => 'NonCPULens13MaxAperture', %nonCPULensApertureZ8},
10023             1782 => { Name => 'NonCPULens14MaxAperture', %nonCPULensApertureZ8},
10024             1784 => { Name => 'NonCPULens15MaxAperture', %nonCPULensApertureZ8},
10025             1786 => { Name => 'NonCPULens16MaxAperture', %nonCPULensApertureZ8},
10026             1788 => { Name => 'NonCPULens17MaxAperture', %nonCPULensApertureZ8},
10027             1790 => { Name => 'NonCPULens18MaxAperture', %nonCPULensApertureZ8},
10028             1792 => { Name => 'NonCPULens19MaxAperture', %nonCPULensApertureZ8},
10029             1794 => { Name => 'NonCPULens20MaxAperture', %nonCPULensApertureZ8},
10030             1808 => { Name => 'HDMIOutputResolution', PrintConv => \%hDMIOutputResolutionZ9 },
10031             1826 => { Name => 'AirplaneMode', PrintConv => \%offOn, Unknown => 1 },
10032             1827 => { Name => 'EmptySlotRelease', PrintConv => { 0 => 'Disable Release', 1 => 'Enable Release' }, Unknown => 1 },
10033             1862 => { Name => 'EnergySavingMode', PrintConv => \%offOn, Unknown => 1 },
10034             1890 => { Name => 'USBPowerDelivery', PrintConv => \%offOn, Unknown => 1 },
10035             1899 => { Name => 'SensorShield', PrintConv => { 0 => 'Stays Open', 1 => 'Closes' }, Unknown => 1 },
10036             );
10037              
10038             %Image::ExifTool::Nikon::MenuSettingsZ8v2 = (
10039             %binaryDataAttrs,
10040             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10041             DATAMEMBER => [ 0, 2046 ],
10042             IS_SUBDIR => [ 0, 943 ],
10043             NOTES => 'These tags are used by the Z8 firmware 2.00 and 2.10.',
10044             0 => {
10045             Name => 'MenuSettingsZ8',
10046             Format => 'undef[943]',
10047             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ8' },
10048             Hook => q{
10049             if ($$self{FirmwareVersion}) {
10050             if ($$self{FirmwareVersion} =~ /^02\.10/) {
10051             $varSize += 4;
10052             } elsif ($$self{FirmwareVersion} ge "03.0") {
10053             $varSize += 8
10054             }
10055             }
10056             },
10057             },
10058             943 => {
10059             Name => 'CustomSettingsZ8',
10060             Format => 'undef[755]',
10061             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsZ8' },
10062             },
10063             1698 => { Name => 'Language', PrintConv => \%languageZ9, Unknown => 1 },
10064             1700 => { Name => 'TimeZone', PrintConv => \%timeZoneZ9, SeparateTable => 'TimeZone' },
10065             1706 => { Name => 'MonitorBrightness', PrintConv => \%monitorBrightnessZ9, Unknown => 1 }, # settings: -5 to +5. Added with firmware 3.0: Lo1, Lo2, Hi1, Hi2
10066             1728 => { Name => 'AFFineTune', PrintConv => \%offOn, Unknown => 1 },
10067             1732 => { Name => 'NonCPULens1FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1}, #should probably hide altogther if $val is 0
10068             1734 => { Name => 'NonCPULens2FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10069             1736 => { Name => 'NonCPULens3FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10070             1738 => { Name => 'NonCPULens4FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10071             1740 => { Name => 'NonCPULens5FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10072             1742 => { Name => 'NonCPULens6FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10073             1744 => { Name => 'NonCPULens7FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10074             1746 => { Name => 'NonCPULens8FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10075             1748 => { Name => 'NonCPULens9FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10076             1750 => { Name => 'NonCPULens10FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10077             1752 => { Name => 'NonCPULens11FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10078             1754 => { Name => 'NonCPULens12FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10079             1756 => { Name => 'NonCPULens13FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10080             1758 => { Name => 'NonCPULens14FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10081             1760 => { Name => 'NonCPULens15FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10082             1762 => { Name => 'NonCPULens16FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10083             1764 => { Name => 'NonCPULens17FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10084             1766 => { Name => 'NonCPULens18FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10085             1768 => { Name => 'NonCPULens19FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10086             1770 => { Name => 'NonCPULens20FocalLength', Format => 'int16u', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10087             1812 => { Name => 'NonCPULens1MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10088             1816 => { Name => 'NonCPULens2MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10089             1820 => { Name => 'NonCPULens3MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10090             1824 => { Name => 'NonCPULens4MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10091             1828 => { Name => 'NonCPULens5MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10092             1832 => { Name => 'NonCPULens6MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10093             1836 => { Name => 'NonCPULens7MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10094             1840 => { Name => 'NonCPULens8MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10095             1844 => { Name => 'NonCPULens9MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10096             1848 => { Name => 'NonCPULens10MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10097             1852 => { Name => 'NonCPULens11MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10098             1856 => { Name => 'NonCPULens12MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10099             1860 => { Name => 'NonCPULens13MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10100             1864 => { Name => 'NonCPULens14MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10101             1868 => { Name => 'NonCPULens15MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10102             1872 => { Name => 'NonCPULens16MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10103             1876 => { Name => 'NonCPULens17MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10104             1880 => { Name => 'NonCPULens18MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10105             1884 => { Name => 'NonCPULens19MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10106             1888 => { Name => 'NonCPULens20MaxAperture', Format => 'int32u', PrintConv => 'sprintf("%.1fmm",$val/100)', Unknown => 1},
10107             1904 => { Name => 'HDMIOutputResolution', PrintConv => \%hDMIOutputResolutionZ9 },
10108             1922 => { Name => 'AirplaneMode', PrintConv => \%offOn, Unknown => 1 },
10109             1923 => { Name => 'EmptySlotRelease', PrintConv => { 0 => 'Disable Release', 1 => 'Enable Release' }, Unknown => 1 },
10110             1958 => { Name => 'EnergySavingMode', PrintConv => \%offOn, Unknown => 1 },
10111             1986 => { Name => 'USBPowerDelivery', PrintConv => \%offOn, Unknown => 1 },
10112             1995 => { Name => 'SensorShield', PrintConv => { 0 => 'Stays Open', 1 => 'Closes' }, Unknown => 1 },
10113             2046 => { Name => 'PixelShiftShooting', RawConv => '$$self{PixelShiftShooting} = $val', PrintConv => \%multipleExposureModeZ9 }, #off/on/on (series)
10114             2048 => { Name => 'PixelShiftNumberShots', Condition => '$$self{PixelShiftShooting} > 0', PrintConv => \%pixelShiftNumberShots },
10115             2050 => { Name => 'PixelShiftDelay', Condition => '$$self{PixelShiftShooting} > 0', PrintConv => \%pixelShiftDelay },
10116             2052 => { Name => 'PlaybackButton', %buttonsZ8 }, #CSf2
10117             2054 => { Name => 'WBButton', %buttonsZ8}, #CSf2
10118             2056 => { Name => 'BracketButton', %buttonsZ8}, #CSf2
10119             2058 => { Name => 'LensFunc1ButtonPlaybackMode', %buttonsZ8}, #CSf3
10120             2060 => { Name => 'LensFunc2ButtonPlaybackMode', %buttonsZ8}, #CSf3
10121             2062 => { Name => 'PlaybackButtonPlaybackMode', %buttonsZ8}, #CSf3
10122             2064 => { Name => 'BracketButtonPlaybackMode', %buttonsZ8}, #CSf3
10123             #2088 FlickerFrequencyPreset #Z8 fw 3.0
10124             2206 => { Name => 'MaximumApertureLV', PrintConv => \%offOn, Unknown => 1 }, #CSa14
10125             2208 => { Name => 'ReleaseModeButton', %buttonsZ8}, #CSf2
10126             2216 => { Name => 'ReleaseModeButtonPlaybackMode', %buttonsZ8}, #CSf3
10127             );
10128              
10129             %Image::ExifTool::Nikon::MenuSettingsZ9 = (
10130             %binaryDataAttrs,
10131             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10132             DATAMEMBER => [ 140, 188, 192, 232, 308, 424, 528, 534, 576 ],
10133             IS_SUBDIR => [ 799 ],
10134             NOTES => 'These tags are used by the Z9.',
10135             #90 ISO
10136             140 => {
10137             Name => 'MultipleExposureMode',
10138             RawConv => '$$self{MultipleExposureMode} = $val',
10139             PrintConv => \%multipleExposureModeZ9,
10140             },
10141             142 => {Name => 'MultiExposureShots', Condition => '$$self{MultipleExposureMode} != 0' }, #range 2-9
10142             188 => {
10143             Name => 'Intervals',
10144             Format => 'int32u',
10145             RawConv => '$$self{IntervalShootingIntervals} = $val',
10146             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0', #not valid for C30/C60/C120
10147             },
10148             192 => {
10149             Name => 'ShotsPerInterval',
10150             Format => 'int32u',
10151             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
10152             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0', #not valid for C30/C60/C120
10153             },
10154             #220 NEFCompression 0=> 'Lossless' 1=> 'High Efficiency*' 4=> 'High Efficientcy'
10155             232 => {
10156             Name => 'FocusShiftNumberShots', #1-300
10157             RawConv => '$$self{FocusShiftNumberShots} = $val',
10158             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10159             },
10160             236 => {
10161             Name => 'FocusShiftStepWidth', #1(Narrow) to 10 (Wide)
10162             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10163             },
10164             240 => {
10165             Name => 'FocusShiftInterval',
10166             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10167             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
10168             },
10169             244 => {
10170             Name => 'FocusShiftExposureLock',
10171             Unknown => 1,
10172             PrintConv => \%offOn,
10173             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10174             },
10175             274 => { Name => 'PhotoShootingMenuBank', PrintConv => \%banksZ9 },
10176             276 => { Name => 'ExtendedMenuBanks', PrintConv => \%offOn }, #single tag from both Photo & Video menus
10177             308 => { Name => 'PhotoShootingMenuBankImageArea', RawConv => '$$self{ImageArea} = $val', PrintConv => \%imageAreaZ9 },
10178             #310 ImageQuality
10179             322 => { Name => 'AutoISO', PrintConv => \%offOn },
10180             324 => { Name => 'ISOAutoHiLimit', %isoAutoHiLimitZ7 },
10181             326 => { Name => 'ISOAutoFlashLimit', %isoAutoHiLimitZ7 },
10182             #332 ISOAutoShutterTime - Auto setting 0=> 'Auto (Slowest)', 1 => 'Auto (Slower)', 2=> 'Auto', 3=> 'Auto (Faster)', 4=> 'Auto (Fastest)'
10183             334 => {
10184             Name => 'ISOAutoShutterTime', #shutter speed is 2 ** (-$val/24)
10185             ValueConv => '$val / 8',
10186             Format => 'int16s',
10187             PrintConv => \%iSOAutoShutterTimeZ9,
10188             },
10189             #336 WhiteBalance
10190             #406 PictureControl
10191             #408 ColorSpace
10192             #410 ActiveD-Lighting
10193             #412 => { Name => 'NoiseReduction', PrintConv => \%offOn }, #Long Exposure Noise Reduction
10194             #414 HighISONoiseReduction
10195             #414 VignetteControl
10196             416 => { Name => 'MovieVignetteControl', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
10197             418 => { Name => 'DiffractionCompensation', PrintConv => \%offOn }, #value can be set from both the Photo Shoot Menu and the Video Shooting Menu
10198             #419 AutoDistortionControl #value can be set from both the Photo Shoot Menu and the Video Shooting Menu
10199             420 => { Name => 'FlickerReductionShooting', PrintConv => \%offOn },
10200             #422 MeteringMode
10201             424 => {
10202             Name => 'FlashControlMode', # this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
10203             RawConv => '$$self{FlashControlMode} = $val',
10204             PrintConv => \%flashControlModeZ7,
10205             },
10206             426 => {
10207             Name => 'FlashMasterCompensation',
10208             Format => 'int8s',
10209             Unknown => 1,
10210             ValueConv => '$val/6',
10211             ValueConvInv => '6 * $val',
10212             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
10213             PrintConvInv => '$val',
10214             },
10215             430 => {
10216             Name => 'FlashGNDistance',
10217             Condition => '$$self{FlashControlMode} == 2',
10218             Unknown => 1,
10219             ValueConv => '$val + 3',
10220             PrintConv => \%flashGNDistance,
10221             },
10222             434 => {
10223             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)
10224             Condition => '$$self{FlashControlMode} >= 3',
10225             Unknown => 1,
10226             ValueConv => '2 ** (-$val/3)',
10227             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
10228             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
10229             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
10230             },
10231             #442 flash wirelss control 0=> 'Off' 1=> 'CMD'
10232             444 => { Name => 'FlashRemoteControl', PrintConv => \%flashRemoteControlZ7, Unknown => 1 },
10233             456 => { Name => 'FlashWirelessOption', PrintConv => \%flashWirelessOptionZ7, Unknown => 1 },
10234             #526 FocusMode
10235             528 => { Name => 'AFAreaMode', RawConv => '$$self{AFAreaMode} = $val', PrintConv => \%aFAreaModeZ9},
10236             530 => { Name => 'VRMode', PrintConv => \%vRModeZ9 },
10237             534 => {
10238             Name => 'BracketSet',
10239             RawConv => '$$self{BracketSet} = $val',
10240             PrintConv => \%bracketSetZ9,
10241             },
10242             536 => {
10243             Name => 'BracketProgram',
10244             Condition => '$$self{BracketSet} < 3',
10245             Notes => 'AE and/or Flash Bracketing',
10246             PrintConv => \%bracketProgramZ9,
10247             },
10248             538 => {
10249             Name => 'BracketIncrement',
10250             Condition => '$$self{BracketSet} < 3',
10251             Notes => 'AE and/or Flash Bracketing',
10252             PrintConv => \%bracketIncrementZ9,
10253             },
10254             #544 BracketProgram for ADL
10255             556 => { Name => 'SecondarySlotFunction', PrintConv => \%secondarySlotFunctionZ9 },
10256             572 => { Name => 'DXCropAlert', PrintConv => \%offOn },
10257             574 => { Name => 'SubjectDetection', PrintConv => \%subjectDetectionZ9 },
10258             576 => {
10259             Name => 'DynamicAFAreaSize',
10260             Condition => '$$self{AFAreaMode} == 2',
10261             RawConv => '$$self{DynamicAFAreaSize} = $val',
10262             PrintConv => \%dynamicAfAreaModesZ9,
10263             },
10264             604 => {
10265             Name => 'MovieImageArea',
10266             Unknown => 1,
10267             Mask => 0x01, # without the mask 4 => 'FX', 5 => DX. only the 2nd Z-series field encountered with a mask
10268             PrintConv => \%imageAreaZ9b,
10269             },
10270             614 => { Name => 'MovieType', PrintConv => \%movieTypeZ9, Unknown => 1 },
10271             616 => { Name => 'MovieISOAutoHiLimit', %isoAutoHiLimitZ7 },
10272             618 => { Name => 'MovieISOAutoControlManualMode', PrintConv => \%offOn, Unknown => 1 },
10273             620 => { Name => 'MovieISOAutoManualMode', %isoAutoHiLimitZ7 },
10274             696 => { Name => 'MovieActiveD-Lighting', PrintConv => \%activeDLightingZ7, Unknown => 1 },
10275             698 => { Name => 'MovieHighISONoiseReduction', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
10276             704 => { Name => 'MovieFlickerReduction', PrintConv => \%movieFlickerReductionZ9 },
10277             706 => { Name => 'MovieMeteringMode', PrintConv => \%meteringModeZ7, Unknown => 1 },
10278             708 => { Name => 'MovieFocusMode', PrintConv => \%focusModeZ7, Unknown => 1 },
10279             710 => { Name => 'MovieAFAreaMode', PrintConv => \%aFAreaModeZ9 },
10280             712 => { Name => 'MovieVRMode', PrintConv => \%vRModeZ9, Unknown => 1 },
10281             716 => { Name => 'MovieElectronicVR', PrintConv => \%offOn, Unknown => 1 }, #distinct from MoveieVRMode
10282             718 => { Name => 'MovieSoundRecording', PrintConv => { 0 => 'Off', 1 => 'Auto', 2 => 'Manual' }, Unknown => 1 },
10283             720 => { Name => 'MicrophoneSensitivity', Unknown => 1 }, #1-20
10284             722 => { Name => 'MicrophoneAttenuator', PrintConv => \%offOn, Unknown => 1 }, #distinct from MoveieVRMode
10285             724 => { Name => 'MicrophoneFrequencyResponse', PrintConv => { 0 => 'Wide Range', 1 => 'Vocal Range' }, Unknown => 1 },
10286             726 => { Name => 'WindNoiseReduction', PrintConv => \%offOn, Unknown => 1 },
10287             748 => { Name => 'MovieToneMap', PrintConv => \%movieToneMapZ9, Unknown => 1 },
10288             754 => { Name => 'MovieFrameSize', PrintConv => \%movieFrameSizeZ9, Unknown => 1 },
10289             756 => { Name => 'MovieFrameRate', PrintConv => \%movieFrameRateZ7, Unknown => 1 },
10290             762 => { Name => 'MicrophoneJackPower', PrintConv => \%offOn, Unknown => 1 },
10291             763 => { Name => 'MovieDXCropAlert', PrintConv => \%offOn, Unknown => 1 },
10292             764 => { Name => 'MovieSubjectDetection', PrintConv => \%subjectDetectionZ9, Unknown => 1 },
10293             799 => {
10294             Name => 'CustomSettingsZ9',
10295             Format => 'undef[608]',
10296             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsZ9' },
10297             },
10298             1426 => { Name => 'Language', PrintConv => \%languageZ9, Unknown => 1 },
10299             1428 => { Name => 'TimeZone', PrintConv => \%timeZoneZ9, SeparateTable => 'TimeZone' },
10300             1434 => { Name => 'MonitorBrightness', ValueConv => '$val - 5', Unknown => 1 }, # settings: -5 to +5
10301             1456 => { Name => 'AFFineTune', PrintConv => \%offOn, Unknown => 1 },
10302             1552 => { Name => 'HDMIOutputResolution', PrintConv => \%hDMIOutputResolutionZ9 },
10303             1565 => { Name => 'SetClockFromLocationData', PrintConv => \%offOn, Unknown => 1 },
10304             1572 => { Name => 'AirplaneMode', PrintConv => \%offOn, Unknown => 1 },
10305             1573 => { Name => 'EmptySlotRelease', PrintConv => { 0 => 'Disable Release', 1 => 'Enable Release' }, Unknown => 1 },
10306             1608 => { Name => 'EnergySavingMode', PrintConv => \%offOn, Unknown => 1 },
10307             1632 => { Name => 'RecordLocationData', PrintConv => \%offOn, Unknown => 1 },
10308             1636 => { Name => 'USBPowerDelivery', PrintConv => \%offOn, Unknown => 1 },
10309             1645 => { Name => 'SensorShield', PrintConv => { 0 => 'Stays Open', 1 => 'Closes' }, Unknown => 1 },
10310             );
10311              
10312             %Image::ExifTool::Nikon::MenuSettingsZ9v3 = (
10313             %binaryDataAttrs,
10314             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10315             DATAMEMBER => [ 154, 204, 208, 248, 328, 444, 548, 554, 596 ],
10316             IS_SUBDIR => [ 847 ],
10317             NOTES => 'These tags are used by the Z9 firmware 3.00.',
10318             72 => {
10319             Name => 'HighFrameRate', #CH and C30/C60/C120 but not CL
10320             PrintConv => \%highFrameRateZ9,
10321             },
10322             154 => {
10323             Name => 'MultipleExposureMode',
10324             RawConv => '$$self{MultipleExposureMode} = $val',
10325             PrintConv => \%multipleExposureModeZ9,
10326             },
10327             156 => {Name => 'MultiExposureShots', Condition => '$$self{MultipleExposureMode} != 0'}, #range 2-9
10328             204 => {
10329             Name => 'Intervals',
10330             Format => 'int32u',
10331             RawConv => '$$self{IntervalShootingIntervals} = $val',
10332             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0', #not valid for C30/C60/C120
10333             },
10334             208 => {
10335             Name => 'ShotsPerInterval',
10336             Format => 'int32u',
10337             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
10338             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0', #not valid for C30/C60/C120
10339             },
10340             248 => {
10341             Name => 'FocusShiftNumberShots', #1-300
10342             RawConv => '$$self{FocusShiftNumberShots} = $val',
10343             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10344             },
10345             252 => {
10346             Name => 'FocusShiftStepWidth', #1(Narrow) to 10 (Wide)
10347             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10348             },
10349             256 => {
10350             Name => 'FocusShiftInterval',
10351             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10352             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
10353             },
10354             260 => {
10355             Name => 'FocusShiftExposureLock',
10356             Unknown => 1,
10357             PrintConv => \%offOn,
10358             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10359             },
10360             290 => { Name => 'PhotoShootingMenuBank', PrintConv => \%banksZ9 },
10361             292 => { Name => 'ExtendedMenuBanks', PrintConv => \%offOn }, # single tag from both Photo & Video menus
10362             328 => { Name => 'PhotoShootingMenuBankImageArea', RawConv => '$$self{ImageArea} = $val', PrintConv => \%imageAreaZ9 },
10363             342 => { Name => 'AutoISO', PrintConv => \%offOn },
10364             344 => { Name => 'ISOAutoHiLimit', %isoAutoHiLimitZ7 },
10365             346 => { Name => 'ISOAutoFlashLimit', %isoAutoHiLimitZ7 },
10366             354 => {
10367             Name => 'ISOAutoShutterTime', # shutter speed is 2 ** (-$val/24)
10368             ValueConv => '$val / 8',
10369             Format => 'int16s',
10370             PrintConv => \%iSOAutoShutterTimeZ9,
10371             },
10372             436 => { Name => 'MovieVignetteControl', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
10373             438 => { Name => 'DiffractionCompensation', PrintConv => \%offOn }, # value can be set from both the Photo Shoot Menu and the Video Shooting Menu
10374             440 => { Name => 'FlickerReductionShooting',PrintConv => \%offOn },
10375             444 => {
10376             Name => 'FlashControlMode', # this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
10377             RawConv => '$$self{FlashControlMode} = $val',
10378             PrintConv => \%flashControlModeZ7,
10379             },
10380             446 => {
10381             Name => 'FlashMasterCompensation',
10382             Format => 'int8s',
10383             Unknown => 1,
10384             ValueConv => '$val/6',
10385             ValueConvInv => '6 * $val',
10386             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
10387             PrintConvInv => '$val',
10388             },
10389             450 => {
10390             Name => 'FlashGNDistance',
10391             Condition => '$$self{FlashControlMode} == 2',
10392             Unknown => 1,
10393             ValueConv => '$val + 3',
10394             PrintConv => \%flashGNDistance,
10395             },
10396             454 => {
10397             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)
10398             Condition => '$$self{FlashControlMode} >= 3',
10399             Unknown => 1,
10400             ValueConv => '2 ** (-$val/3)',
10401             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
10402             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
10403             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
10404             },
10405             #462 flash wireless control 0=> 'Off' 1=> 'Optical AWL'
10406             #464 => { Name => 'FlashRemoteControl', PrintConv => \%flashRemoteControlZ7, Unknown => 1 },
10407             #476 => { Name => 'FlashWirelessOption', PrintConv => \%flashWirelessOptionZ7, Unknown => 1 },
10408             548 => { Name => 'AFAreaMode', RawConv => '$$self{AFAreaMode} = $val', PrintConv => \%aFAreaModeZ9},
10409             550 => { Name => 'VRMode', PrintConv => \%vRModeZ9},
10410             554 => {
10411             Name => 'BracketSet',
10412             RawConv => '$$self{BracketSet} = $val',
10413             PrintConv => \%bracketSetZ9,
10414             },
10415             556 => {
10416             Name => 'BracketProgram',
10417             Condition => '$$self{BracketSet} < 3',
10418             Notes => 'AE and/or Flash Bracketing',
10419             PrintConv => \%bracketProgramZ9,
10420             },
10421             558 => {
10422             Name => 'BracketIncrement',
10423             Condition => '$$self{BracketSet} < 3',
10424             Notes => 'AE and/or Flash Bracketing',
10425             PrintConv => \%bracketIncrementZ9,
10426             },
10427             576 => { Name => 'SecondarySlotFunction', PrintConv => \%secondarySlotFunctionZ9 },
10428             592 => { Name => 'DXCropAlert', PrintConv => \%offOn },
10429             594 => { Name => 'SubjectDetection', PrintConv => \%subjectDetectionZ9 },
10430             596 => {
10431             Name => 'DynamicAFAreaSize',
10432             Condition => '$$self{AFAreaMode} == 2',
10433             RawConv => '$$self{DynamicAFAreaSize} = $val',
10434             PrintConv => \%dynamicAfAreaModesZ9,
10435             },
10436             636 => { Name => 'HighFrequencyFlickerReduction', PrintConv => \%offOn, Unknown => 1 }, # new with firmware 3.0
10437             646 => {
10438             Name => 'MovieImageArea',
10439             Unknown => 1,
10440             Mask => 0x01, # without the mask 4 => 'FX' 5 => DX only the 2nd Z-series field encountered with a mask.
10441             PrintConv => \%imageAreaZ9b,
10442             },
10443             656 => { Name => 'MovieType', PrintConv => \%movieTypeZ9, Unknown => 1 },
10444             658 => { Name => 'MovieISOAutoHiLimit', %isoAutoHiLimitZ7 },
10445             660 => { Name => 'MovieISOAutoControlManualMode', PrintConv => \%offOn, Unknown => 1 },
10446             662 => { Name => 'MovieISOAutoManualMode', %isoAutoHiLimitZ7 },
10447             736 => { Name => 'MovieActiveD-Lighting', PrintConv => \%activeDLightingZ7, Unknown => 1 },
10448             738 => { Name => 'MovieHighISONoiseReduction', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
10449             744 => { Name => 'MovieFlickerReduction', PrintConv => \%movieFlickerReductionZ9 },
10450             746 => { Name => 'MovieMeteringMode', PrintConv => \%meteringModeZ7, Unknown => 1 },
10451             748 => { Name => 'MovieFocusMode', PrintConv => \%focusModeZ7, Unknown => 1 },
10452             750 => { Name => 'MovieAFAreaMode', PrintConv => \%aFAreaModeZ9 },
10453             752 => { Name => 'MovieVRMode', PrintConv => \%vRModeZ9, Unknown => 1 },
10454             756 => { Name => 'MovieElectronicVR', PrintConv => \%offOn, Unknown => 1 }, # distinct from MoveieVRMode
10455             758 => { Name => 'MovieSoundRecording', PrintConv => { 0 => 'Off', 1 => 'Auto', 2 => 'Manual' }, Unknown => 1 },
10456             760 => { Name => 'MicrophoneSensitivity', Unknown => 1 }, # 1-20
10457             762 => { Name => 'MicrophoneAttenuator', PrintConv => \%offOn, Unknown => 1 }, # distinct from MoveieVRMode
10458             764 => { Name => 'MicrophoneFrequencyResponse',PrintConv => { 0 => 'Wide Range', 1 => 'Vocal Range' }, Unknown => 1 },
10459             766 => { Name => 'WindNoiseReduction', PrintConv => \%offOn, Unknown => 1 },
10460             788 => { Name => 'MovieToneMap', PrintConv => \%movieToneMapZ9, Unknown => 1 },
10461             794 => { Name => 'MovieFrameSize', PrintConv => \%movieFrameSizeZ9, Unknown => 1 },
10462             796 => { Name => 'MovieFrameRate', PrintConv => \%movieFrameRateZ7, Unknown => 1 },
10463             802 => { Name => 'MicrophoneJackPower', PrintConv => \%offOn, Unknown => 1 },
10464             803 => { Name => 'MovieDXCropAlert', PrintConv => \%offOn, Unknown => 1 },
10465             804 => { Name => 'MovieSubjectDetection', PrintConv => \%subjectDetectionZ9, Unknown => 1 },
10466             812 => { Name => 'MovieHighResZoom', PrintConv => \%offOn, Unknown => 1 },
10467             847 => {
10468             Name => 'CustomSettingsZ9',
10469             Format => 'undef[608]',
10470             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsZ9' },
10471             },
10472             1474 => { Name => 'Language', PrintConv => \%languageZ9, Unknown => 1 },
10473             1476 => { Name => 'TimeZone', PrintConv => \%timeZoneZ9, SeparateTable => 'TimeZone' },
10474             1482 => { Name => 'MonitorBrightness', PrintConv => \%monitorBrightnessZ9, Unknown => 1 }, # settings: -5 to +5. Added with firmware 3.0: Lo1, Lo2, Hi1, Hi2
10475             1504 => { Name => 'AFFineTune', PrintConv => \%offOn, Unknown => 1 },
10476             1600 => { Name => 'HDMIOutputResolution', PrintConv => \%hDMIOutputResolutionZ9 },
10477             1613 => { Name => 'SetClockFromLocationData', PrintConv => \%offOn, Unknown => 1 },
10478             1620 => { Name => 'AirplaneMode', PrintConv => \%offOn, Unknown => 1 },
10479             1621 => { Name => 'EmptySlotRelease', PrintConv => { 0 => 'Disable Release', 1 => 'Enable Release' }, Unknown => 1 },
10480             1656 => { Name => 'EnergySavingMode', PrintConv => \%offOn, Unknown => 1 },
10481             1680 => { Name => 'RecordLocationData', PrintConv => \%offOn, Unknown => 1 },
10482             1684 => { Name => 'USBPowerDelivery', PrintConv => \%offOn, Unknown => 1 },
10483             1693 => { Name => 'SensorShield', PrintConv => { 0 => 'Stays Open', 1 => 'Closes' }, Unknown => 1 },
10484             1754 => {
10485             Name => 'FocusShiftAutoReset',
10486             Unknown => 1,
10487             PrintConv => \%offOn,
10488             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10489             },
10490             1810 => { #CSd4-a
10491             Name => 'PreReleaseBurstLength',
10492             PrintConv => {
10493             0 => 'None',
10494             1 => '0.3 Sec',
10495             2 => '0.5 Sec',
10496             3 => '1 Sec',
10497             },
10498             },
10499             1812 => { #CSd4-b
10500             Name => 'PostReleaseBurstLength',
10501             PrintConv => {
10502             0 => '1 Sec',
10503             1 => '2 Sec',
10504             2 => '3 Sec',
10505             3 => 'Max',
10506             },
10507             },
10508             #1824 ReleaseTimingIndicatorTypeADelay CSd14-b 0 => '1/200' ... 15 => '1/6'
10509             #1826 VerticalISOButton CSf2
10510             #1828 ExposureCompensationButton CSf2
10511             #1830 ISOButton CSf2
10512             #1890 ViewModeShowEffectsOfSettings CSd9-a 0=>'Always', 1=> 'Only When Flash Not Used'
10513             #1892 DispButton CSf2
10514             #1936 FocusPointDisplayOption3DTrackingColor CSa11-d 0=> 'White', 1= => 'Red'
10515             );
10516              
10517             # firmware version 4.x/5.x menu settings (ref 28)
10518             %Image::ExifTool::Nikon::MenuSettingsZ9v4 = (
10519             %binaryDataAttrs,
10520             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10521             DATAMEMBER => [ 72, 154, 204, 208, 248, 328, 444, 548, 554, 570, 596 ],
10522             IS_SUBDIR => [ 847 ],
10523             NOTES => 'These tags are used by the Z9 firmware 4.00, 4.10, 5.00 and 5.10.',
10524             72 => {
10525             Name => 'HighFrameRate', #CH and C30/C60/C120 but not CL
10526             PrintConv => \%highFrameRateZ9,
10527             Hook => '$varSize += 4 if $$self{FirmwareVersion} and $$self{FirmwareVersion} ge "05.10"',
10528             },
10529             #
10530             # Note: Offsets after this are shifted by +4 for firmware 5.1 (see Hook above)
10531             #
10532             154 => {
10533             Name => 'MultipleExposureMode',
10534             RawConv => '$$self{MultipleExposureMode} = $val',
10535             PrintConv => \%multipleExposureModeZ9,
10536             },
10537             156 => {Name => 'MultiExposureShots', Condition => '$$self{MultipleExposureMode} != 0'}, #range 2-9
10538             204 => {
10539             Name => 'Intervals',
10540             Format => 'int32u',
10541             RawConv => '$$self{IntervalShootingIntervals} = $val',
10542             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0', #not valid for C30/C60/C120
10543             },
10544             208 => {
10545             Name => 'ShotsPerInterval',
10546             Format => 'int32u',
10547             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
10548             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{IntervalShooting} > 0', #not valid for C30/C60/C120
10549             },
10550             248 => {
10551             Name => 'FocusShiftNumberShots', #1-300
10552             RawConv => '$$self{FocusShiftNumberShots} = $val',
10553             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10554             },
10555             252 => {
10556             Name => 'FocusShiftStepWidth', #1(Narrow) to 10 (Wide)
10557             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10558             },
10559             256 => {
10560             Name => 'FocusShiftInterval',
10561             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10562             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
10563             },
10564             260 => {
10565             Name => 'FocusShiftExposureLock',
10566             Unknown => 1,
10567             PrintConv => \%offOn,
10568             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10569             },
10570             290 => { Name => 'PhotoShootingMenuBank', PrintConv => \%banksZ9 },
10571             292 => { Name => 'ExtendedMenuBanks', PrintConv => \%offOn }, # single tag from both Photo & Video menus
10572             328 => { Name => 'PhotoShootingMenuBankImageArea', RawConv => '$$self{ImageArea} = $val', PrintConv => \%imageAreaZ9 },
10573             #334 JPGCompression 0 => 'Size Priority', 1 => 'Optimal Quality',
10574             342 => { Name => 'AutoISO', PrintConv => \%offOn },
10575             344 => { Name => 'ISOAutoHiLimit', %isoAutoHiLimitZ7 },
10576             346 => { Name => 'ISOAutoFlashLimit', %isoAutoHiLimitZ7 },
10577             354 => {
10578             Name => 'ISOAutoShutterTime', # shutter speed is 2 ** (-$val/24)
10579             ValueConv => '$val / 8',
10580             Format => 'int16s',
10581             PrintConv => \%iSOAutoShutterTimeZ9,
10582             },
10583             436 => { Name => 'MovieVignetteControl', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
10584             438 => { Name => 'DiffractionCompensation', PrintConv => \%offOn }, # value can be set from both the Photo Shoot Menu and the Video Shooting Menu
10585             440 => { Name => 'FlickerReductionShooting',PrintConv => \%offOn },
10586             444 => {
10587             Name => 'FlashControlMode', # this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
10588             RawConv => '$$self{FlashControlMode} = $val',
10589             PrintConv => \%flashControlModeZ7,
10590             },
10591             446 => {
10592             Name => 'FlashMasterCompensation',
10593             Format => 'int8s',
10594             Unknown => 1,
10595             ValueConv => '$val/6',
10596             ValueConvInv => '6 * $val',
10597             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
10598             PrintConvInv => '$val',
10599             },
10600             450 => {
10601             Name => 'FlashGNDistance',
10602             Condition => '$$self{FlashControlMode} == 2',
10603             Unknown => 1,
10604             ValueConv => '$val + 3',
10605             PrintConv => \%flashGNDistance,
10606             },
10607             454 => {
10608             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)
10609             Condition => '$$self{FlashControlMode} >= 3',
10610             Unknown => 1,
10611             ValueConv => '2 ** (-$val/3)',
10612             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
10613             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
10614             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
10615             },
10616             #462 flash wireless control 0=> 'Off' 1=> 'Optical AWL'
10617             #464 => { Name => 'FlashRemoteControl', PrintConv => \%flashRemoteControlZ7, Unknown => 1 },
10618             #476 => { Name => 'FlashWirelessOption', PrintConv => \%flashWirelessOptionZ7, Unknown => 1 },
10619             548 => { Name => 'AFAreaMode', RawConv => '$$self{AFAreaMode} = $val', PrintConv => \%aFAreaModeZ9},
10620             550 => { Name => 'VRMode', PrintConv => \%vRModeZ9},
10621             554 => {
10622             Name => 'BracketSet',
10623             RawConv => '$$self{BracketSet} = $val',
10624             PrintConv => \%bracketSetZ9,
10625             },
10626             556 => {
10627             Name => 'BracketProgram',
10628             Condition => '$$self{BracketSet} < 3',
10629             Notes => 'AE and/or Flash Bracketing',
10630             PrintConv => \%bracketProgramZ9,
10631             },
10632             558 => {
10633             Name => 'BracketIncrement',
10634             Condition => '$$self{BracketSet} < 3',
10635             Notes => 'AE and/or Flash Bracketing',
10636             PrintConv => \%bracketIncrementZ9,
10637             },
10638             570 => { Name => 'HDR', RawConv => '$$self{HDR} = $val', PrintConv => \%multipleExposureModeZ9 },
10639             576 => { Name => 'SecondarySlotFunction', PrintConv => \%secondarySlotFunctionZ9 },
10640             582 => { Name => 'HDRLevel', Condition => '$$self{HDR} ne 0', PrintConv => \%hdrLevelZ8 },
10641             586 => { Name => 'Slot2JpgSize', PrintConv => { 0 => 'Large (8256x5504)', 1 => 'Medium (6192x4128)', 2 => 'Small (4128x2752)' }, Unknown => 1},
10642             592 => { Name => 'DXCropAlert', PrintConv => \%offOn },
10643             594 => { Name => 'SubjectDetection', PrintConv => \%subjectDetectionZ9 },
10644             596 => {
10645             Name => 'DynamicAFAreaSize',
10646             Condition => '$$self{AFAreaMode} == 2',
10647             RawConv => '$$self{DynamicAFAreaSize} = $val',
10648             PrintConv => \%dynamicAfAreaModesZ9,
10649             },
10650             636 => { Name => 'HighFrequencyFlickerReduction', PrintConv => \%offOn, Unknown => 1 }, # new with firmware 3.0
10651             646 => {
10652             Name => 'MovieImageArea',
10653             Unknown => 1,
10654             Mask => 0x01, # without the mask 4 => 'FX' 5 => DX only the 2nd Z-series field encountered with a mask.
10655             PrintConv => \%imageAreaZ9b,
10656             },
10657             656 => { Name => 'MovieType', PrintConv => \%movieTypeZ9, Unknown => 1 },
10658             658 => { Name => 'MovieISOAutoHiLimit', %isoAutoHiLimitZ7 },
10659             660 => { Name => 'MovieISOAutoControlManualMode', PrintConv => \%offOn, Unknown => 1 },
10660             662 => { Name => 'MovieISOAutoManualMode', %isoAutoHiLimitZ7 },
10661             736 => { Name => 'MovieActiveD-Lighting', PrintConv => \%activeDLightingZ7, Unknown => 1 },
10662             738 => { Name => 'MovieHighISONoiseReduction', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
10663             744 => { Name => 'MovieFlickerReduction', PrintConv => \%movieFlickerReductionZ9 },
10664             746 => { Name => 'MovieMeteringMode', PrintConv => \%meteringModeZ7, Unknown => 1 },
10665             748 => { Name => 'MovieFocusMode', PrintConv => \%focusModeZ7, Unknown => 1 },
10666             750 => { Name => 'MovieAFAreaMode', PrintConv => \%aFAreaModeZ9 },
10667             752 => { Name => 'MovieVRMode', PrintConv => \%vRModeZ9, Unknown => 1 },
10668             756 => { Name => 'MovieElectronicVR', PrintConv => \%offOn, Unknown => 1 }, # distinct from MoveieVRMode
10669             758 => { Name => 'MovieSoundRecording', PrintConv => { 0 => 'Off', 1 => 'Auto', 2 => 'Manual' }, Unknown => 1 },
10670             760 => { Name => 'MicrophoneSensitivity', Unknown => 1 }, # 1-20
10671             762 => { Name => 'MicrophoneAttenuator', PrintConv => \%offOn, Unknown => 1 }, # distinct from MoveieVRMode
10672             764 => { Name => 'MicrophoneFrequencyResponse',PrintConv => { 0 => 'Wide Range', 1 => 'Vocal Range' }, Unknown => 1 },
10673             766 => { Name => 'WindNoiseReduction', PrintConv => \%offOn, Unknown => 1 },
10674             788 => { Name => 'MovieToneMap', PrintConv => \%movieToneMapZ9, Unknown => 1 },
10675             794 => { Name => 'MovieFrameSize', PrintConv => \%movieFrameSizeZ9, Unknown => 1 },
10676             796 => { Name => 'MovieFrameRate', PrintConv => \%movieFrameRateZ7, Unknown => 1 },
10677             802 => { Name => 'MicrophoneJackPower', PrintConv => \%offOn, Unknown => 1 },
10678             803 => { Name => 'MovieDXCropAlert', PrintConv => \%offOn, Unknown => 1 },
10679             804 => { Name => 'MovieSubjectDetection', PrintConv => \%subjectDetectionZ9, Unknown => 1 },
10680             812 => { Name => 'MovieHighResZoom', PrintConv => \%offOn, Unknown => 1 },
10681             847 => {
10682             Name => 'CustomSettingsZ9v4',
10683             Format => 'undef[632]',
10684             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsZ9v4' },
10685             },
10686             1498 => { Name => 'Language', PrintConv => \%languageZ9, Unknown => 1 },
10687             1500 => { Name => 'TimeZone', PrintConv => \%timeZoneZ9, SeparateTable => 'TimeZone' },
10688             1506 => { Name => 'MonitorBrightness', PrintConv => \%monitorBrightnessZ9, Unknown => 1 }, # settings: -5 to +5. Added with firmware 3.0: Lo1, Lo2, Hi1, Hi2
10689             1528 => { Name => 'AFFineTune', PrintConv => \%offOn, Unknown => 1 },
10690             1532 => { Name => 'NonCPULens1FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1}, #should probably hide altogther if $val is 0
10691             1536 => { Name => 'NonCPULens2FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10692             1540 => { Name => 'NonCPULens3FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10693             1544 => { Name => 'NonCPULens4FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10694             1548 => { Name => 'NonCPULens5FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10695             1552 => { Name => 'NonCPULens6FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10696             1556 => { Name => 'NonCPULens7FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10697             1560 => { Name => 'NonCPULens8FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10698             1564 => { Name => 'NonCPULens9FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10699             1568 => { Name => 'NonCPULens10FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10700             1572 => { Name => 'NonCPULens11FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10701             1576 => { Name => 'NonCPULens12FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10702             1580 => { Name => 'NonCPULens13FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10703             1584 => { Name => 'NonCPULens14FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10704             1588 => { Name => 'NonCPULens15FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10705             1592 => { Name => 'NonCPULens16FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10706             1596 => { Name => 'NonCPULens17FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10707             1600 => { Name => 'NonCPULens18FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10708             1604 => { Name => 'NonCPULens19FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10709             1608 => { Name => 'NonCPULens20FocalLength', Format => 'int16s', PrintConv => 'sprintf("%.1fmm",$val/10)', Unknown => 1},
10710             1612 => { Name => 'NonCPULens1MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1}, #non-CPU aperture interface, values and storage differ from the Z8
10711             1616 => { Name => 'NonCPULens2MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10712             1620 => { Name => 'NonCPULens3MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10713             1624 => { Name => 'NonCPULens4MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10714             1628 => { Name => 'NonCPULens5MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10715             1632 => { Name => 'NonCPULens6MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10716             1636 => { Name => 'NonCPULens7MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10717             1640 => { Name => 'NonCPULens8MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10718             1644 => { Name => 'NonCPULens9MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10719             1648 => { Name => 'NonCPULens10MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10720             1652 => { Name => 'NonCPULens11MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10721             1656 => { Name => 'NonCPULens12MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10722             1660 => { Name => 'NonCPULens13MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10723             1664 => { Name => 'NonCPULens14MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10724             1668 => { Name => 'NonCPULens15MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10725             1672 => { Name => 'NonCPULens16MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10726             1676 => { Name => 'NonCPULens17MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10727             1680 => { Name => 'NonCPULens18MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10728             1684 => { Name => 'NonCPULens19MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10729             1688 => { Name => 'NonCPULens20MaxAperture', Format => 'int16s', PrintConv => 'sprintf("f/%.1f",$val/100)', Unknown => 1},
10730             1704 => { Name => 'HDMIOutputResolution', PrintConv => \%hDMIOutputResolutionZ9 },
10731             1717 => { Name => 'SetClockFromLocationData', PrintConv => \%offOn, Unknown => 1 },
10732             1724 => { Name => 'AirplaneMode', PrintConv => \%offOn, Unknown => 1 },
10733             1725 => { Name => 'EmptySlotRelease', PrintConv => { 0 => 'Disable Release', 1 => 'Enable Release' }, Unknown => 1 },
10734             1760 => { Name => 'EnergySavingMode', PrintConv => \%offOn, Unknown => 1 },
10735             1784 => { Name => 'RecordLocationData', PrintConv => \%offOn, Unknown => 1 },
10736             1788 => { Name => 'USBPowerDelivery', PrintConv => \%offOn, Unknown => 1 },
10737             1797 => { Name => 'SensorShield', PrintConv => { 0 => 'Stays Open', 1 => 'Closes' }, Unknown => 1 },
10738             1862 => {
10739             Name => 'AutoCapturePreset',
10740             PrintConv => {
10741             0 => '1',
10742             1 => '2',
10743             2 => '3',
10744             3 => '4',
10745             4 => '5',
10746             },
10747             },
10748             1864 => {
10749             Name => 'FocusShiftAutoReset',
10750             Unknown => 1,
10751             PrintConv => \%offOn,
10752             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
10753             },
10754             1922 => { #CSd4-a
10755             Name => 'PreReleaseBurstLength',
10756             PrintConv => {
10757             0 => 'None',
10758             1 => '0.3 Sec',
10759             2 => '0.5 Sec',
10760             3 => '1 Sec',
10761             },
10762             },
10763             1924 => { #CSd4-b
10764             Name => 'PostReleaseBurstLength',
10765             PrintConv => {
10766             0 => '1 Sec',
10767             1 => '2 Sec',
10768             2 => '3 Sec',
10769             3 => 'Max',
10770             },
10771             },
10772             1938 => { Name => 'VerticalISOButton', %buttonsZ9}, #CSf2
10773             1940 => { Name => 'ExposureCompensationButton', %buttonsZ9}, #CSf2
10774             1942 => { Name => 'ISOButton', %buttonsZ9}, #CSf2
10775             2002 => { Name => 'ViewModeShowEffectsOfSettings', PrintConv => { 0=>'Always', 1=> 'Only When Flash Not Used'}, Unknown => 1 }, #CSd9-a
10776             2004 => { Name => 'DispButton', %buttonsZ9}, #CSf2
10777             2048 => { #CSd6
10778             Name => 'ExposureDelay',
10779             Format => 'fixed32u',
10780             PrintConv => '$val ? sprintf("%.1f sec",$val/1000) : "Off"',
10781             },
10782             2052 => { #CSf2-m3
10783             Name => 'CommandDialFrameAdvanceZoom',
10784             Condition => '$$self{FirmwareVersion} and $$self{FirmwareVersion} ge "05.00"',
10785             PrintConv => \%dialsFrameAdvanceZoomPositionZ9,
10786             Unknown => 1
10787             },
10788             2054 => { #CSf2-n3
10789             Name => 'SubCommandDialFrameAdvanceZoom',
10790             Condition => '$$self{FirmwareVersion} and $$self{FirmwareVersion} ge "05.00"',
10791             PrintConv => \%dialsFrameAdvanceZoomPositionZ9,
10792             Unknown => 1
10793             },
10794             2056 => { Name => 'PlaybackButton', %buttonsZ9}, #CSf2
10795             2058 => { Name => 'WBButton', %buttonsZ9}, #CSf2
10796             2060 => { Name => 'BracketButton', %buttonsZ9}, #CSf2
10797             2062 => { Name => 'FlashModeButton', %buttonsZ9}, #CSf2
10798             2064 => { Name => 'LensFunc1ButtonPlaybackMode', %buttonsZ9}, #CSf2
10799             2066 => { Name => 'LensFunc2ButtonPlaybackMode', %buttonsZ9}, #CSf2
10800             2068 => { Name => 'PlaybackButtonPlaybackMode', %buttonsZ9}, #CSf2
10801             2070 => { Name => 'BracketButtonPlaybackMode', %buttonsZ9}, #CSf2
10802             2072 => { Name => 'FlashModeButtonPlaybackMode', %buttonsZ9}, #CSf2
10803             );
10804              
10805             # Flash information (ref JD)
10806             %Image::ExifTool::Nikon::FlashInfo0100 = (
10807             %binaryDataAttrs,
10808             DATAMEMBER => [ 9.2, 15, 16 ],
10809             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10810             NOTES => q{
10811             These tags are used by the D2H, D2Hs, D2X, D2Xs, D50, D70, D70s, D80 and
10812             D200.
10813             },
10814             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
10815             0 => {
10816             Name => 'FlashInfoVersion',
10817             Format => 'string[4]',
10818             Writable => 0,
10819             },
10820             4 => { #PH
10821             Name => 'FlashSource',
10822             PrintConv => {
10823             0 => 'None',
10824             1 => 'External',
10825             2 => 'Internal',
10826             },
10827             },
10828             # 5 - values: 46,48,50,54,78
10829             6 => {
10830             Format => 'int8u[2]',
10831             Name => 'ExternalFlashFirmware',
10832             SeparateTable => 'FlashFirmware',
10833             PrintConv => \%flashFirmware,
10834             },
10835             8 => {
10836             Name => 'ExternalFlashFlags',
10837             PrintConv => { 0 => '(none)',
10838             BITMASK => {
10839             0 => 'Fired', #28
10840             2 => 'Bounce Flash', #PH
10841             4 => 'Wide Flash Adapter',
10842             5 => 'Dome Diffuser', #28
10843             },
10844             },
10845             },
10846             9.1 => {
10847             Name => 'FlashCommanderMode',
10848             Mask => 0x80,
10849             PrintConv => { 0 => 'Off', 1 => 'On' },
10850             },
10851             9.2 => {
10852             Name => 'FlashControlMode',
10853             Mask => 0x7f,
10854             DataMember => 'FlashControlMode',
10855             RawConv => '$$self{FlashControlMode} = $val',
10856             PrintConv => \%flashControlMode,
10857             SeparateTable => 'FlashControlMode',
10858             },
10859             10 => [
10860             {
10861             Name => 'FlashOutput',
10862             Condition => '$$self{FlashControlMode} >= 0x06',
10863             ValueConv => '2 ** (-$val/6)',
10864             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
10865             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
10866             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
10867             },
10868             {
10869             Name => 'FlashCompensation',
10870             Format => 'int8s',
10871             Priority => 0,
10872             ValueConv => '-$val/6',
10873             ValueConvInv => '-6 * $val',
10874             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
10875             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
10876             },
10877             ],
10878             11 => {
10879             Name => 'FlashFocalLength',
10880             RawConv => '$val ? $val : undef',
10881             PrintConv => '"$val mm"',
10882             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
10883             },
10884             12 => {
10885             Name => 'RepeatingFlashRate',
10886             RawConv => '$val ? $val : undef',
10887             PrintConv => '"$val Hz"',
10888             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
10889             },
10890             13 => {
10891             Name => 'RepeatingFlashCount',
10892             RawConv => '$val ? $val : undef',
10893             },
10894             14 => { #PH
10895             Name => 'FlashGNDistance',
10896             SeparateTable => 1,
10897             PrintConv => \%flashGNDistance,
10898             },
10899             15 => {
10900             Name => 'FlashGroupAControlMode',
10901             Mask => 0x0f,
10902             DataMember => 'FlashGroupAControlMode',
10903             RawConv => '$$self{FlashGroupAControlMode} = $val',
10904             PrintConv => \%flashControlMode,
10905             SeparateTable => 'FlashControlMode',
10906             },
10907             16 => {
10908             Name => 'FlashGroupBControlMode',
10909             Mask => 0x0f,
10910             DataMember => 'FlashGroupBControlMode',
10911             RawConv => '$$self{FlashGroupBControlMode} = $val',
10912             PrintConv => \%flashControlMode,
10913             SeparateTable => 'FlashControlMode',
10914             },
10915             17 => [
10916             {
10917             Name => 'FlashGroupAOutput',
10918             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
10919             ValueConv => '2 ** (-$val/6)',
10920             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
10921             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
10922             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
10923             },
10924             {
10925             Name => 'FlashGroupACompensation',
10926             Format => 'int8s',
10927             ValueConv => '-$val/6',
10928             ValueConvInv => '-6 * $val',
10929             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
10930             PrintConvInv => '$val',
10931             },
10932             ],
10933             18 => [
10934             {
10935             Name => 'FlashGroupBOutput',
10936             Condition => '$$self{FlashGroupBControlMode} >= 0x06',
10937             ValueConv => '2 ** (-$val/6)',
10938             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
10939             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
10940             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
10941             },
10942             {
10943             Name => 'FlashGroupBCompensation',
10944             Format => 'int8s',
10945             ValueConv => '-$val/6',
10946             ValueConvInv => '-6 * $val',
10947             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
10948             PrintConvInv => '$val',
10949             },
10950             ],
10951             );
10952              
10953             # Flash information for D40, D40x, D3 and D300 (ref JD)
10954             %Image::ExifTool::Nikon::FlashInfo0102 = (
10955             %binaryDataAttrs,
10956             DATAMEMBER => [ 9.2, 16.1, 17.1, 17.2 ],
10957             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10958             NOTES => q{
10959             These tags are used by the D3 (firmware 1.x), D40, D40X, D60 and D300
10960             (firmware 1.00).
10961             },
10962             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
10963             0 => {
10964             Name => 'FlashInfoVersion',
10965             Format => 'string[4]',
10966             Writable => 0,
10967             },
10968             4 => { #PH
10969             Name => 'FlashSource',
10970             PrintConv => {
10971             0 => 'None',
10972             1 => 'External',
10973             2 => 'Internal',
10974             },
10975             },
10976             # 5 - values: 46,48,50,54,78
10977             6 => {
10978             Format => 'int8u[2]',
10979             Name => 'ExternalFlashFirmware',
10980             SeparateTable => 'FlashFirmware',
10981             PrintConv => \%flashFirmware,
10982             },
10983             8 => {
10984             Name => 'ExternalFlashFlags',
10985             PrintConv => { BITMASK => {
10986             0 => 'Fired', #28
10987             2 => 'Bounce Flash', #PH
10988             4 => 'Wide Flash Adapter',
10989             5 => 'Dome Diffuser', #28
10990             }},
10991             },
10992             9.1 => {
10993             Name => 'FlashCommanderMode',
10994             Mask => 0x80,
10995             PrintConv => { 0 => 'Off', 1 => 'On' },
10996             },
10997             9.2 => {
10998             Name => 'FlashControlMode',
10999             Mask => 0x7f,
11000             DataMember => 'FlashControlMode',
11001             RawConv => '$$self{FlashControlMode} = $val',
11002             PrintConv => \%flashControlMode,
11003             SeparateTable => 'FlashControlMode',
11004             },
11005             10 => [
11006             {
11007             Name => 'FlashOutput',
11008             Condition => '$$self{FlashControlMode} >= 0x06',
11009             ValueConv => '2 ** (-$val/6)',
11010             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11011             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11012             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11013             },
11014             {
11015             Name => 'FlashCompensation',
11016             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
11017             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
11018             Format => 'int8s',
11019             Priority => 0,
11020             ValueConv => '-$val/6',
11021             ValueConvInv => '-6 * $val',
11022             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
11023             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
11024             },
11025             ],
11026             12 => {
11027             Name => 'FlashFocalLength',
11028             RawConv => '$val ? $val : undef',
11029             PrintConv => '"$val mm"',
11030             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
11031             },
11032             13 => {
11033             Name => 'RepeatingFlashRate',
11034             RawConv => '$val ? $val : undef',
11035             PrintConv => '"$val Hz"',
11036             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
11037             },
11038             14 => {
11039             Name => 'RepeatingFlashCount',
11040             RawConv => '$val ? $val : undef',
11041             },
11042             15 => { #PH
11043             Name => 'FlashGNDistance',
11044             SeparateTable => 1,
11045             PrintConv => \%flashGNDistance,
11046             },
11047             16.1 => {
11048             Name => 'FlashGroupAControlMode',
11049             Mask => 0x0f,
11050             Notes => 'note: group A tags may apply to the built-in flash settings for some models',
11051             DataMember => 'FlashGroupAControlMode',
11052             RawConv => '$$self{FlashGroupAControlMode} = $val',
11053             PrintConv => \%flashControlMode,
11054             SeparateTable => 'FlashControlMode',
11055             },
11056             17.1 => {
11057             Name => 'FlashGroupBControlMode',
11058             Mask => 0xf0,
11059             Notes => 'note: group B tags may apply to group A settings for some models',
11060             DataMember => 'FlashGroupBControlMode',
11061             RawConv => '$$self{FlashGroupBControlMode} = $val',
11062             PrintConv => \%flashControlMode,
11063             SeparateTable => 'FlashControlMode',
11064             },
11065             17.2 => { #PH
11066             Name => 'FlashGroupCControlMode',
11067             Mask => 0x0f,
11068             Notes => 'note: group C tags may apply to group B settings for some models',
11069             DataMember => 'FlashGroupCControlMode',
11070             RawConv => '$$self{FlashGroupCControlMode} = $val',
11071             PrintConv => \%flashControlMode,
11072             SeparateTable => 'FlashControlMode',
11073             },
11074             18 => [
11075             {
11076             Name => 'FlashGroupAOutput',
11077             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
11078             ValueConv => '2 ** (-$val/6)',
11079             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11080             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11081             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11082             },
11083             {
11084             Name => 'FlashGroupACompensation',
11085             Format => 'int8s',
11086             ValueConv => '-$val/6',
11087             ValueConvInv => '-6 * $val',
11088             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11089             PrintConvInv => '$val',
11090             },
11091             ],
11092             19 => [
11093             {
11094             Name => 'FlashGroupBOutput',
11095             Condition => '$$self{FlashGroupBControlMode} >= 0x60',
11096             ValueConv => '2 ** (-$val/6)',
11097             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11098             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11099             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11100             },
11101             {
11102             Name => 'FlashGroupBCompensation',
11103             Format => 'int8s',
11104             ValueConv => '-$val/6',
11105             ValueConvInv => '-6 * $val',
11106             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11107             PrintConvInv => '$val',
11108             },
11109             ],
11110             20 => [ #PH
11111             {
11112             Name => 'FlashGroupCOutput',
11113             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
11114             ValueConv => '2 ** (-$val/6)',
11115             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11116             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11117             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11118             },
11119             {
11120             Name => 'FlashGroupCCompensation',
11121             Format => 'int8s',
11122             ValueConv => '-$val/6',
11123             ValueConvInv => '-6 * $val',
11124             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11125             PrintConvInv => '$val',
11126             },
11127             ],
11128             );
11129              
11130             # Flash information for D90 and D700 (ref PH)
11131             # - confirmed in detail for D800 (0105) - PH
11132             %Image::ExifTool::Nikon::FlashInfo0103 = (
11133             %binaryDataAttrs,
11134             DATAMEMBER => [ 9.2, 17.1, 18.1, 18.2 ],
11135             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
11136             NOTES => q{
11137             These tags are used by the D3 (firmware 2.x), D3X, D3S, D4, D90, D300
11138             (firmware 1.10), D300S, D600, D700, D800, D3000, D3100, D3200, D5000, D5100,
11139             D5200, D7000.
11140             },
11141             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
11142             0 => {
11143             Name => 'FlashInfoVersion',
11144             Format => 'string[4]',
11145             Writable => 0,
11146             },
11147             4 => { #PH
11148             Name => 'FlashSource',
11149             PrintConv => {
11150             0 => 'None',
11151             1 => 'External',
11152             2 => 'Internal',
11153             },
11154             },
11155             # 5 - values: 46,48,50,54,78
11156             6 => {
11157             Format => 'int8u[2]',
11158             Name => 'ExternalFlashFirmware',
11159             SeparateTable => 'FlashFirmware',
11160             PrintConv => \%flashFirmware,
11161             },
11162             8 => {
11163             Name => 'ExternalFlashFlags',
11164             PrintConv => { BITMASK => {
11165             0 => 'Fired', #28
11166             2 => 'Bounce Flash', #PH
11167             4 => 'Wide Flash Adapter',
11168             5 => 'Dome Diffuser', #28
11169             }},
11170             },
11171             9.1 => {
11172             Name => 'FlashCommanderMode',
11173             Mask => 0x80,
11174             PrintConv => { 0 => 'Off', 1 => 'On' },
11175             },
11176             9.2 => {
11177             Name => 'FlashControlMode',
11178             Mask => 0x7f,
11179             DataMember => 'FlashControlMode',
11180             RawConv => '$$self{FlashControlMode} = $val',
11181             PrintConv => \%flashControlMode,
11182             SeparateTable => 'FlashControlMode',
11183             },
11184             10 => [
11185             {
11186             Name => 'FlashOutput',
11187             Condition => '$$self{FlashControlMode} >= 0x06',
11188             ValueConv => '2 ** (-$val/6)',
11189             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11190             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11191             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11192             },
11193             {
11194             Name => 'FlashCompensation',
11195             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
11196             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
11197             Format => 'int8s',
11198             Priority => 0,
11199             ValueConv => '-$val/6',
11200             ValueConvInv => '-6 * $val',
11201             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
11202             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
11203             },
11204             ],
11205             12 => { #JD
11206             Name => 'FlashFocalLength',
11207             RawConv => '($val and $val != 255) ? $val : undef',
11208             PrintConv => '"$val mm"',
11209             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
11210             },
11211             13 => { #JD
11212             Name => 'RepeatingFlashRate',
11213             RawConv => '($val and $val != 255) ? $val : undef',
11214             PrintConv => '"$val Hz"',
11215             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
11216             },
11217             14 => { #JD
11218             Name => 'RepeatingFlashCount',
11219             RawConv => '($val and $val != 255) ? $val : undef',
11220             },
11221             15 => { #28
11222             Name => 'FlashGNDistance',
11223             SeparateTable => 1,
11224             PrintConv => \%flashGNDistance,
11225             },
11226             16 => { #28
11227             Name => 'FlashColorFilter',
11228             SeparateTable => 1,
11229             PrintConv => \%flashColorFilter,
11230             },
11231             17.1 => {
11232             Name => 'FlashGroupAControlMode',
11233             Mask => 0x0f,
11234             Notes => 'note: group A tags may apply to the built-in flash settings for some models',
11235             DataMember => 'FlashGroupAControlMode',
11236             RawConv => '$$self{FlashGroupAControlMode} = $val',
11237             PrintConv => \%flashControlMode,
11238             SeparateTable => 'FlashControlMode',
11239             },
11240             18.1 => {
11241             Name => 'FlashGroupBControlMode',
11242             Mask => 0xf0,
11243             Notes => 'note: group B tags may apply to group A settings for some models',
11244             DataMember => 'FlashGroupBControlMode',
11245             RawConv => '$$self{FlashGroupBControlMode} = $val',
11246             PrintConv => \%flashControlMode,
11247             SeparateTable => 'FlashControlMode',
11248             },
11249             18.2 => { #PH
11250             Name => 'FlashGroupCControlMode',
11251             Mask => 0x0f,
11252             Notes => 'note: group C tags may apply to group B settings for some models',
11253             DataMember => 'FlashGroupCControlMode',
11254             RawConv => '$$self{FlashGroupCControlMode} = $val',
11255             PrintConv => \%flashControlMode,
11256             SeparateTable => 'FlashControlMode',
11257             },
11258             0x13 => [
11259             {
11260             Name => 'FlashGroupAOutput',
11261             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
11262             ValueConv => '2 ** (-$val/6)',
11263             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11264             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11265             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11266             },
11267             {
11268             Name => 'FlashGroupACompensation',
11269             Format => 'int8s',
11270             ValueConv => '-$val/6',
11271             ValueConvInv => '-6 * $val',
11272             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11273             PrintConvInv => '$val',
11274             },
11275             ],
11276             0x14 => [
11277             {
11278             Name => 'FlashGroupBOutput',
11279             Condition => '$$self{FlashGroupBControlMode} >= 0x60',
11280             ValueConv => '2 ** (-$val/6)',
11281             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11282             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11283             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11284             },
11285             {
11286             Name => 'FlashGroupBCompensation',
11287             Format => 'int8s',
11288             ValueConv => '-$val/6',
11289             ValueConvInv => '-6 * $val',
11290             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11291             PrintConvInv => '$val',
11292             },
11293             ],
11294             0x15 => [ #PH
11295             {
11296             Name => 'FlashGroupCOutput',
11297             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
11298             ValueConv => '2 ** (-$val/6)',
11299             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11300             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11301             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11302             },
11303             {
11304             Name => 'FlashGroupCCompensation',
11305             Format => 'int8s',
11306             ValueConv => '-$val/6',
11307             ValueConvInv => '-6 * $val',
11308             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11309             PrintConvInv => '$val',
11310             },
11311             ],
11312             0x1b => { #PH
11313             Name => 'ExternalFlashCompensation',
11314             Format => 'int8s',
11315             Priority => 0,
11316             ValueConv => '-$val/6',
11317             ValueConvInv => '-6 * $val',
11318             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
11319             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
11320             },
11321             0x1d => { #PH
11322             Name => 'FlashExposureComp3',
11323             Format => 'int8s',
11324             # (does not include the built-in compensation for FlashType "Built-in,TTL&Comdr.")
11325             Notes => 'does not include the effect of flash bracketing',
11326             Priority => 0,
11327             ValueConv => '-$val/6',
11328             ValueConvInv => '-6 * $val',
11329             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
11330             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
11331             },
11332             0x27 => { #PH (same as ShotInfoD800 0x4d2 but also valid for repeating flash)
11333             Name => 'FlashExposureComp4',
11334             Format => 'int8s',
11335             Notes => 'includes the effect of flash bracketing. Valid for repeating flash',
11336             Priority => 0,
11337             ValueConv => '-$val/6',
11338             ValueConvInv => '-6 * $val',
11339             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
11340             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
11341             },
11342             # 0x2b - related to flash power (PH, D800, 96=full,62=1/4,2=1/128)
11343             );
11344              
11345             # Flash information for the D7100 (ref PH)
11346             # (this is VERY similar to FlashInfo0107, but there are a few differences that
11347             # would need to be resolved if these two definitions were to be combined)
11348             %Image::ExifTool::Nikon::FlashInfo0106 = (
11349             %binaryDataAttrs,
11350             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
11351             DATAMEMBER => [ 9.2, 17.1, 18.1, 18.2 ],
11352             NOTES => 'These tags are used by the Df, D610, D3300, D5300, D7100 and Coolpix A.',
11353             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
11354             0 => {
11355             Name => 'FlashInfoVersion',
11356             Format => 'string[4]',
11357             Writable => 0,
11358             },
11359             4 => {
11360             Name => 'FlashSource',
11361             PrintConv => {
11362             0 => 'None',
11363             1 => 'External',
11364             2 => 'Internal',
11365             },
11366             },
11367             6 => {
11368             Format => 'int8u[2]',
11369             Name => 'ExternalFlashFirmware',
11370             SeparateTable => 'FlashFirmware',
11371             PrintConv => \%flashFirmware,
11372             },
11373             8 => {
11374             Name => 'ExternalFlashFlags',
11375             PrintConv => { BITMASK => {
11376             0 => 'Fired',
11377             2 => 'Bounce Flash',
11378             4 => 'Wide Flash Adapter',
11379             5 => 'Dome Diffuser', # (NC, not true for the SB-910 anyway)
11380             # 7 - ? (set for SB-910 when an advanced option is used, eg. diff pattern)
11381             }},
11382             },
11383             9.1 => { # (NC)
11384             Name => 'FlashCommanderMode',
11385             Mask => 0x80,
11386             PrintConv => { 0 => 'Off', 1 => 'On' },
11387             },
11388             9.2 => {
11389             Name => 'FlashControlMode',
11390             Mask => 0x7f,
11391             DataMember => 'FlashControlMode',
11392             RawConv => '$$self{FlashControlMode} = $val',
11393             PrintConv => \%flashControlMode,
11394             SeparateTable => 'FlashControlMode',
11395             },
11396             # 10 - similar to 0x27 but zero sometimes when I don't think it should be
11397             12 => {
11398             Name => 'FlashFocalLength',
11399             Notes => 'only valid if flash pattern is "Standard Illumination"',
11400             RawConv => '($val and $val != 255) ? $val : undef',
11401             PrintConv => '"$val mm"',
11402             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
11403             },
11404             13 => {
11405             Name => 'RepeatingFlashRate',
11406             RawConv => '($val and $val != 255) ? $val : undef',
11407             PrintConv => '"$val Hz"',
11408             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
11409             },
11410             14 => {
11411             Name => 'RepeatingFlashCount',
11412             RawConv => '($val and $val != 255) ? $val : undef',
11413             },
11414             15 => { # (NC)
11415             Name => 'FlashGNDistance',
11416             SeparateTable => 1,
11417             PrintConv => \%flashGNDistance,
11418             },
11419             16 => {
11420             Name => 'FlashColorFilter',
11421             SeparateTable => 1,
11422             PrintConv => \%flashColorFilter,
11423             },
11424             17.1 => {
11425             Name => 'FlashGroupAControlMode',
11426             Mask => 0x0f,
11427             DataMember => 'FlashGroupAControlMode',
11428             RawConv => '$$self{FlashGroupAControlMode} = $val',
11429             PrintConv => \%flashControlMode,
11430             SeparateTable => 'FlashControlMode',
11431             },
11432             18.1 => {
11433             Name => 'FlashGroupBControlMode',
11434             Mask => 0xf0,
11435             DataMember => 'FlashGroupBControlMode',
11436             RawConv => '$$self{FlashGroupBControlMode} = $val',
11437             PrintConv => \%flashControlMode,
11438             SeparateTable => 'FlashControlMode',
11439             },
11440             18.2 => {
11441             Name => 'FlashGroupCControlMode',
11442             Mask => 0x0f,
11443             DataMember => 'FlashGroupCControlMode',
11444             RawConv => '$$self{FlashGroupCControlMode} = $val',
11445             PrintConv => \%flashControlMode,
11446             SeparateTable => 'FlashControlMode',
11447             },
11448             # 0x13 - same as 0x28 but not zero when flash group A is Off
11449             # 0x14 - same as 0x29 but not zero when flash group B is Off
11450             # 0x15 - same as 0x2a but not zero when flash group B is Off
11451             # 0x1a - changes with illumination pattern (0=normal,1=narrow,2=wide), but other values seen
11452             # 0x26 - changes when diffuser is used
11453             0x27 => [
11454             {
11455             Name => 'FlashOutput',
11456             Condition => '$$self{FlashControlMode} >= 0x06',
11457             ValueConv => '2 ** (-$val/6)',
11458             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11459             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11460             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11461             },
11462             {
11463             Name => 'FlashCompensation',
11464             Format => 'int8s',
11465             Priority => 0,
11466             ValueConv => '-$val/6',
11467             ValueConvInv => '-6 * $val',
11468             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
11469             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
11470             },
11471             ],
11472             0x28 => [
11473             {
11474             Name => 'FlashGroupAOutput',
11475             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
11476             ValueConv => '2 ** (-$val/6)',
11477             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11478             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11479             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11480             },
11481             {
11482             Name => 'FlashGroupACompensation',
11483             Format => 'int8s',
11484             ValueConv => '-$val/6',
11485             ValueConvInv => '-6 * $val',
11486             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11487             PrintConvInv => '$val',
11488             },
11489             ],
11490             0x29 => [
11491             {
11492             Name => 'FlashGroupBOutput',
11493             Condition => '$$self{FlashGroupBControlMode} >= 0x60',
11494             ValueConv => '2 ** (-$val/6)',
11495             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11496             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11497             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11498             },
11499             {
11500             Name => 'FlashGroupBCompensation',
11501             Format => 'int8s',
11502             ValueConv => '-$val/6',
11503             ValueConvInv => '-6 * $val',
11504             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11505             PrintConvInv => '$val',
11506             },
11507             ],
11508             0x2a => [
11509             {
11510             Name => 'FlashGroupCOutput',
11511             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
11512             ValueConv => '2 ** (-$val/6)',
11513             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11514             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11515             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11516             },
11517             {
11518             Name => 'FlashGroupCCompensation',
11519             Format => 'int8s',
11520             ValueConv => '-$val/6',
11521             ValueConvInv => '-6 * $val',
11522             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11523             PrintConvInv => '$val',
11524             },
11525             ],
11526             );
11527              
11528             # Flash information for the D4S/D750/D810/D5500/D7200 (0107)
11529             # and D5/D500/D850/D3400 (0108) (ref 28)
11530             %Image::ExifTool::Nikon::FlashInfo0107 = (
11531             %binaryDataAttrs,
11532             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
11533             DATAMEMBER => [ 17.1, 18.1, 18.2 ],
11534             NOTES => q{
11535             These tags are used by the D4S, D750, D810, D5500, D7200 (FlashInfoVersion
11536             0107) and the D5, D500, D850 and D3400 (FlashInfoVersion 0108).
11537             },
11538             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
11539             0 => {
11540             Name => 'FlashInfoVersion',
11541             Format => 'string[4]',
11542             Writable => 0,
11543             },
11544             4 => {
11545             Name => 'FlashSource',
11546             PrintConv => {
11547             0 => 'None',
11548             1 => 'External',
11549             2 => 'Internal',
11550             },
11551             },
11552             6 => {
11553             Format => 'int8u[2]',
11554             Name => 'ExternalFlashFirmware',
11555             SeparateTable => 'FlashFirmware',
11556             PrintConv => \%flashFirmware,
11557             },
11558             8.1 => {
11559             Name => 'ExternalFlashZoomOverride',
11560             Mask => 0x80,
11561             Notes => 'indicates that the user has overridden the flash zoom distance',
11562             PrintConv => { 0 => 'No', 1 => 'Yes' },
11563             },
11564             8.2 => {
11565             Name => 'ExternalFlashStatus',
11566             Mask => 0x01,
11567             PrintConv => {
11568             0 => 'Flash Not Attached',
11569             1 => 'Flash Attached',
11570             },
11571             },
11572             9.1 => {
11573             Name => 'ExternalFlashReadyState',
11574             Mask => 0x07,
11575             PrintConv => {
11576             0 => 'n/a',
11577             1 => 'Ready',
11578             6 => 'Not Ready',
11579             },
11580             },
11581             10 => {
11582             Name => 'FlashCompensation',
11583             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
11584             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
11585             Format => 'int8s',
11586             Priority => 0,
11587             ValueConv => '-$val/6',
11588             ValueConvInv => '-6 * $val',
11589             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
11590             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
11591             },
11592             12 => {
11593             Name => 'FlashFocalLength',
11594             Notes => 'only valid if flash pattern is "Standard Illumination"', #illumination pattern no no supported starting with the SB-910
11595             RawConv => '($val and $val != 255) ? $val : undef',
11596             PrintConv => '"$val mm"',
11597             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
11598             },
11599             13 => {
11600             Name => 'RepeatingFlashRate',
11601             RawConv => '($val and $val != 255) ? $val : undef',
11602             PrintConv => '"$val Hz"',
11603             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
11604             },
11605             14 => {
11606             Name => 'RepeatingFlashCount',
11607             RawConv => '($val and $val != 255) ? $val : undef',
11608             },
11609             15 => {
11610             Name => 'FlashGNDistance',
11611             SeparateTable => 1,
11612             PrintConv => \%flashGNDistance,
11613             },
11614             17.1 => { #PH
11615             Name => 'FlashGroupAControlMode',
11616             Mask => 0x0f,
11617             Notes => 'note: group A tags may apply to the built-in flash settings for some models',
11618             DataMember => 'FlashGroupAControlMode',
11619             RawConv => '$$self{FlashGroupAControlMode} = $val',
11620             PrintConv => \%flashControlMode,
11621             SeparateTable => 'FlashControlMode',
11622             },
11623             18.1 => { #PH
11624             Name => 'FlashGroupBControlMode',
11625             Mask => 0xf0,
11626             Notes => 'note: group B tags may apply to group A settings for some models',
11627             DataMember => 'FlashGroupBControlMode',
11628             RawConv => '$$self{FlashGroupBControlMode} = $val',
11629             PrintConv => \%flashControlMode,
11630             SeparateTable => 'FlashControlMode',
11631             },
11632             18.2 => { #PH
11633             Name => 'FlashGroupCControlMode',
11634             Mask => 0x0f,
11635             Notes => 'note: group C tags may apply to group B settings for some models',
11636             DataMember => 'FlashGroupCControlMode',
11637             RawConv => '$$self{FlashGroupCControlMode} = $val',
11638             PrintConv => \%flashControlMode,
11639             SeparateTable => 'FlashControlMode',
11640             },
11641             # 0x13 - very similar to 0x28
11642             # 0x18 or 0x19 may indicate flash illumination pattern (Standard, Center-weighted, Even)
11643             0x28 => [ #PH
11644             {
11645             Name => 'FlashGroupAOutput',
11646             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
11647             ValueConv => '2 ** (-$val/6)',
11648             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11649             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11650             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11651             },
11652             {
11653             Name => 'FlashGroupACompensation',
11654             Format => 'int8s',
11655             ValueConv => '-$val/6',
11656             ValueConvInv => '-6 * $val',
11657             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11658             PrintConvInv => '$val',
11659             },
11660             ],
11661             0x29 => [ #PH
11662             {
11663             Name => 'FlashGroupBOutput',
11664             Condition => '$$self{FlashGroupBControlMode} >= 0x06',
11665             ValueConv => '2 ** (-$val/6)',
11666             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11667             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11668             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11669             },
11670             {
11671             Name => 'FlashGroupBCompensation',
11672             Format => 'int8s',
11673             ValueConv => '-$val/6',
11674             ValueConvInv => '-6 * $val',
11675             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11676             PrintConvInv => '$val',
11677             },
11678             ],
11679             0x2a => [ #PH
11680             {
11681             Name => 'FlashGroupCOutput',
11682             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
11683             ValueConv => '2 ** (-$val/6)',
11684             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11685             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11686             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11687             },
11688             {
11689             Name => 'FlashGroupCCompensation',
11690             Format => 'int8s',
11691             ValueConv => '-$val/6',
11692             ValueConvInv => '-6 * $val',
11693             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11694             PrintConvInv => '$val',
11695             },
11696             ],
11697             );
11698              
11699             # Flash information for the Z7II (ref 28)
11700             # (likey similar to FlashInfo010 and FlashInfo0108 with addition of support for radio controlled units such as the SB-5000?
11701             %Image::ExifTool::Nikon::FlashInfo0300 = (
11702             %binaryDataAttrs,
11703             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
11704             DATAMEMBER => [ 9.2, 17.1, 18.1, 18.2 ],
11705             0 => {
11706             Name => 'FlashInfoVersion',
11707             Format => 'string[4]',
11708             Writable => 0,
11709             },
11710             4 => {
11711             Name => 'FlashSource',
11712             PrintConv => {
11713             0 => 'None',
11714             1 => 'External',
11715             2 => 'Internal',
11716             },
11717             },
11718             6 => {
11719             Name => 'ExternalFlashFirmware',
11720             Format => 'int8u[2]',
11721             SeparateTable => 'FlashFirmware',
11722             PrintConv => \%flashFirmware,
11723             },
11724             8 => {
11725             Name => 'ExternalFlashFlags',
11726             PrintConv => { BITMASK => {
11727             0 => 'Flash Ready', #flash status is 'Not Ready' when this bit is off and FlashSource is non-zero
11728             # 1 - ? (observed with SB-900)
11729             2 => 'Bounce Flash',
11730             4 => 'Wide Flash Adapter',
11731             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
11732             }},
11733             },
11734             9.1 => {
11735             Name => 'FlashCommanderMode',
11736             Mask => 0x80,
11737             PrintConv => { 0 => 'Off', 1 => 'On' },
11738             },
11739             9.2 => {
11740             Name => 'FlashControlMode',
11741             Mask => 0x7f,
11742             DataMember => 'FlashControlMode',
11743             RawConv => '$$self{FlashControlMode} = $val',
11744             PrintConv => \%flashControlMode,
11745             SeparateTable => 'FlashControlMode',
11746             },
11747             10 => {
11748             Name => 'FlashCompensation',
11749             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
11750             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
11751             Condition => '$$self{FlashControlMode} == 0x01 or $$self{FlashControlMode} == 0x02', #only valid for TTL and TTL-BL modes
11752             Format => 'int8s',
11753             Priority => 0,
11754             ValueConv => '-$val/6',
11755             ValueConvInv => '-6 * $val',
11756             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
11757             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
11758             },
11759             13 => {
11760             Name => 'RepeatingFlashRate',
11761             RawConv => '($val and $val != 255) ? $val : undef',
11762             PrintConv => '"$val Hz"',
11763             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
11764             },
11765             14 => {
11766             Name => 'RepeatingFlashCount',
11767             RawConv => '($val and $val != 255) ? $val : undef',
11768             },
11769             15 => {
11770             Name => 'FlashGNDistance',
11771             SeparateTable => 1,
11772             PrintConv => \%flashGNDistance,
11773             },
11774             16 => {
11775             Name => 'FlashColorFilter',
11776             SeparateTable => 1,
11777             PrintConv => \%flashColorFilter,
11778             },
11779             17.1 => { #PH
11780             Name => 'FlashGroupAControlMode',
11781             Mask => 0x0f,
11782             Notes => 'note: group A tags may apply to the built-in flash settings for some models',
11783             DataMember => 'FlashGroupAControlMode',
11784             RawConv => '$$self{FlashGroupAControlMode} = $val',
11785             PrintConv => \%flashControlMode,
11786             SeparateTable => 'FlashControlMode',
11787             },
11788             18.1 => { #PH
11789             Name => 'FlashGroupBControlMode',
11790             Mask => 0xf0,
11791             Notes => 'note: group B tags may apply to group A settings for some models',
11792             DataMember => 'FlashGroupBControlMode',
11793             RawConv => '$$self{FlashGroupBControlMode} = $val',
11794             PrintConv => \%flashControlMode,
11795             SeparateTable => 'FlashControlMode',
11796             },
11797             18.2 => { #PH
11798             Name => 'FlashGroupCControlMode',
11799             Mask => 0x0f,
11800             Notes => 'note: group C tags may apply to group B settings for some models',
11801             DataMember => 'FlashGroupCControlMode',
11802             RawConv => '$$self{FlashGroupCControlMode} = $val',
11803             PrintConv => \%flashControlMode,
11804             SeparateTable => 'FlashControlMode',
11805             },
11806             33 => {
11807             Name => 'FlashOutput',
11808             Condition => '$$self{FlashControlMode} >= 0x06', #only valid for M mode
11809             ValueConv => '2 ** (-$val/6)',
11810             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11811             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11812             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11813             },
11814             37 => {
11815             Name => 'FlashIlluminationPattern',
11816             PrintConv => {
11817             0 => 'Standard',
11818             1 => 'Center-weighted',
11819             2 => 'Even',
11820             },
11821             },
11822             38 => {
11823             Name => 'FlashFocalLength',
11824             Notes => 'only valid if flash pattern is "Standard Illumination"',
11825             RawConv => '($val and $val != 255) ? $val : undef',
11826             PrintConv => '"$val mm"',
11827             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
11828             },
11829             40 => [ #PH
11830             {
11831             Name => 'FlashGroupAOutput',
11832             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
11833             ValueConv => '2 ** (-$val/6)',
11834             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11835             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11836             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11837             },
11838             {
11839             Name => 'FlashGroupACompensation',
11840             Format => 'int8s',
11841             ValueConv => '-($val-2)/6',
11842             ValueConvInv => '-6 * $val + 2',
11843             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11844             PrintConvInv => '$val',
11845             },
11846             ],
11847             41 => [ #PH
11848             {
11849             Name => 'FlashGroupBOutput',
11850             Condition => '$$self{FlashGroupBControlMode} >= 0x06',
11851             ValueConv => '2 ** (-$val/6)',
11852             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11853             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11854             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11855             },
11856             {
11857             Name => 'FlashGroupBCompensation',
11858             Format => 'int8s',
11859             ValueConv => '-($val-2)/6',
11860             ValueConvInv => '-6 * $val + 2',
11861             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11862             PrintConvInv => '$val',
11863             },
11864             ],
11865             42 => [ #PH
11866             {
11867             Name => 'FlashGroupCOutput',
11868             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
11869             ValueConv => '2 ** (-$val/6)',
11870             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
11871             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
11872             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
11873             },
11874             {
11875             Name => 'FlashGroupCCompensation',
11876             Format => 'int8s',
11877             ValueConv => '-($val-2)/6',
11878             ValueConvInv => '-6 * $val + 2',
11879             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
11880             PrintConvInv => '$val',
11881             },
11882             ],
11883             );
11884             # Unknown Flash information
11885             %Image::ExifTool::Nikon::FlashInfoUnknown = (
11886             %binaryDataAttrs,
11887             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
11888             0 => {
11889             Name => 'FlashInfoVersion',
11890             Format => 'string[4]',
11891             Writable => 0,
11892             },
11893             );
11894              
11895             # Multi exposure / image overlay information (ref PH)
11896             %Image::ExifTool::Nikon::MultiExposure = (
11897             %binaryDataAttrs,
11898             FORMAT => 'int32u',
11899             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
11900             0 => {
11901             Name => 'MultiExposureVersion',
11902             Format => 'string[4]',
11903             Writable => 0,
11904             },
11905             1 => {
11906             Name => 'MultiExposureMode',
11907             PrintConv => {
11908             0 => 'Off',
11909             1 => 'Multiple Exposure',
11910             2 => 'Image Overlay',
11911             3 => 'HDR', #31
11912             },
11913             },
11914             2 => 'MultiExposureShots',
11915             3 => {
11916             Name => 'MultiExposureAutoGain',
11917             PrintConv => \%offOn,
11918             },
11919             );
11920              
11921             # Multi exposure2 / image overlay information (ref 39)
11922             %Image::ExifTool::Nikon::MultiExposure2 = (
11923             %binaryDataAttrs,
11924             FORMAT => 'int32u',
11925             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
11926             0 => {
11927             Name => 'MultiExposureVersion',
11928             Format => 'string[4]',
11929             Writable => 0,
11930             },
11931             1 => {
11932             Name => 'MultiExposureMode',
11933             PrintConv => {
11934             0 => 'Off',
11935             1 => 'Multiple Exposure',
11936             3 => 'HDR',
11937             },
11938             },
11939             2 => 'MultiExposureShots',
11940             3 => {
11941             Name => 'MultiExposureOverlayMode',
11942             PrintConv => {
11943             0 => 'Add',
11944             1 => 'Average',
11945             2 => 'Light',
11946             3 => 'Dark',
11947             },
11948             },
11949             );
11950              
11951             # HDR information (ref 32)
11952             %Image::ExifTool::Nikon::HDRInfo = (
11953             %binaryDataAttrs,
11954             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
11955             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
11956             0 => {
11957             Name => 'HDRInfoVersion',
11958             Format => 'string[4]',
11959             Writable => 0,
11960             },
11961             4 => {
11962             Name => 'HDR',
11963             PrintConv => {
11964             0 => 'Off',
11965             1 => 'On (normal)',
11966             48 => 'Auto', #PH (NC)
11967             },
11968             },
11969             5 => {
11970             Name => 'HDRLevel',
11971             PrintConv => {
11972             0 => 'Auto',
11973             1 => '1 EV',
11974             2 => '2 EV',
11975             3 => '3 EV',
11976             # 5 - seen for 1J4
11977             255 => 'n/a', #PH
11978             },
11979             },
11980             6 => {
11981             Name => 'HDRSmoothing',
11982             PrintConv => {
11983             0 => 'Off',
11984             1 => 'Normal',
11985             2 => 'Low',
11986             3 => 'High',
11987             48 => 'Auto', #PH (NC)
11988             255 => 'n/a', #PH
11989             },
11990             },
11991             7 => { #PH (P330, HDRInfoVersion=0101)
11992             Name => 'HDRLevel2',
11993             PrintConv => {
11994             0 => 'Auto',
11995             1 => '1 EV',
11996             2 => '2 EV',
11997             3 => '3 EV',
11998             255 => 'n/a',
11999             },
12000             },
12001             );
12002              
12003             # ref 39 (Z9)
12004             %Image::ExifTool::Nikon::HDRInfo2 = (
12005             %binaryDataAttrs,
12006             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
12007             0 => {
12008             Name => 'HDRInfoVersion', # 0200
12009             Format => 'string[4]',
12010             Writable => 0,
12011             },
12012             4 => {
12013             Name => 'HDR',
12014             PrintConv => {
12015             0 => 'Off',
12016             1 => 'On (normal)',
12017             },
12018             },
12019             5 => {
12020             Name => 'HDRLevel',
12021             PrintConv => {
12022             0 => 'n/a',
12023             1 => 'Normal',
12024             2 => 'Low',
12025             3 => 'High',
12026             4 => 'High+',
12027             5 => 'Auto',
12028             },
12029             },
12030             );
12031              
12032             # location information (ref PH)
12033             %Image::ExifTool::Nikon::LocationInfo = (
12034             %binaryDataAttrs,
12035             DATAMEMBER => [ 4 ],
12036             GROUPS => { 0 => 'MakerNotes', 2 => 'Location' },
12037             NOTES => 'Tags written by some Nikon GPS-equipped cameras like the AW100.',
12038             0 => {
12039             Name => 'LocationInfoVersion',
12040             Format => 'undef[4]',
12041             },
12042             4 => {
12043             Name => 'TextEncoding',
12044             DataMember => 'TextEncoding',
12045             RawConv => q{
12046             $$self{TextEncoding} = $Image::ExifTool::Nikon::nikonTextEncoding{$val} if $val;
12047             return $val;
12048             },
12049             PrintConv => \%Image::ExifTool::Nikon::nikonTextEncoding,
12050             },
12051             # (the CountryCode and Location tag names chosen to correspond with XMP::iptcCore)
12052             5 => {
12053             Name => 'CountryCode',
12054             Format => 'undef[3]',
12055             ValueConv => '$val=~s/\0.*//s; $val', # truncate at null
12056             ValueConvInv => '$val',
12057             },
12058             8 => 'POILevel', #forum5782
12059             9 => {
12060             Name => 'Location',
12061             Format => 'undef[70]',
12062             RawConv => '$$self{TextEncoding} ? $self->Decode($val,$$self{TextEncoding},"MM") : $val',
12063             RawConvInv => '$$self{TextEncoding} ? $self->Encode($val,$$self{TextEncoding},"MM") : $val',
12064             },
12065             );
12066              
12067             # MakerNotes0x51 - compression info for Z8 and Z9
12068             %Image::ExifTool::Nikon::MakerNotes0x51 = (
12069             %binaryDataAttrs,
12070             GROUPS => { 0 => 'MakerNotes' },
12071             0 => {
12072             Name => 'FirmwareVersion51',
12073             Format => 'string[8]',
12074             Writable => 0,
12075             ValueConv => 'join ".", $val =~ /../g',
12076             },
12077             10 => {
12078             Name => 'NEFCompression',
12079             Format => 'int16u',
12080             SeparateTable => 'NEFCompression',
12081             PrintConv => \%nefCompression,
12082             },
12083             );
12084              
12085             # MakerNotes0x56 - burst info for Z8 and Z9
12086             %Image::ExifTool::Nikon::MakerNotes0x56 = (
12087             %binaryDataAttrs,
12088             GROUPS => { 0 => 'MakerNotes' },
12089             DATAMEMBER => [ 12 ],
12090             0 => {
12091             Name => 'FirmwareVersion56',
12092             Format => 'string[4]',
12093             Writable => 0,
12094             ValueConv => '$val =~ s/(\d{2})/$1./; $val',
12095             },
12096             4 => {
12097             Name => 'BurstGroupID', #all frames shot within a burst (using CL/CH/C30/C60/C120) will share the same BurstGroupID. Value will be > 0 for all images shot in continuous modes (or via Pixel Shift). 0 for single-frame.
12098             Format => 'int16u'
12099             },
12100             12 => {
12101             Name => 'PixelShiftID', # 1 => Pixel shift enabled (either directly or thru Focus Shift Shooting with Z8 fw 3.0)
12102             RawConv => '$$self{PixelShiftActive} = $val',
12103             #Hidden => 1
12104             },
12105             );
12106              
12107             # extra info found in IFD0 of NEF files (ref PH, Z6/Z7)
12108             %Image::ExifTool::Nikon::NEFInfo = (
12109             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
12110             NOTES => q{
12111             As-yet unknown information found in SubIFD1 tag 0xc7d5 of NEF images from
12112             cameras such as the Z6 and Z7, and NRW images from some Coolpix cameras.
12113             },
12114             # 0x01 - undef[12]
12115             # 0x02 - undef[148]
12116             # 0x03 - undef[284]
12117             # 0x04 - undef[148,212]
12118             0x05 => { #28
12119             Name => 'DistortionInfo', # Z-series distortion correction information
12120             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::DistortionInfo' },
12121             },
12122             0x06 => { #28
12123             Name => 'VignetteInfo', # Z-series vignette correction information
12124             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::VignetteInfo' },
12125             },
12126             # 0x07 - undef[104] #possibly Z-series diffration correction information (#28)
12127             # 0x08 - undef[24]
12128             # 0x09 - undef[36]
12129             );
12130              
12131             # Z-series distortion correction information (correction model is appears to be a cubic polynomial) (ref 28)
12132             %Image::ExifTool::Nikon::DistortionInfo = (
12133             %binaryDataAttrs,
12134             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
12135             0 => {
12136             Name => 'DistortionCorrectionVersion',
12137             Format => 'string[4]',
12138             },
12139             4 => {
12140             Name => 'DistortionCorrection', #used by ACR to determine whether the built-in lens profile is applied
12141             Format => 'int8u',
12142             PrintConv => {
12143             0 => 'No Lens Attached', #to prevent reporting 'Unknown'
12144             1 => 'On (Optional)',
12145             2 => 'Off',
12146             3 => 'On (Required)',
12147             },
12148             },
12149             0x14 => {
12150             Name => 'RadialDistortionCoefficient1',
12151             Format => 'rational64s',
12152             PrintConv => 'sprintf("%.5f",$val)',
12153             },
12154             0x1c => {
12155             Name => 'RadialDistortionCoefficient2',
12156             Format => 'rational64s',
12157             PrintConv => 'sprintf("%.5f",$val)',
12158             },
12159             0x24 => {
12160             Name => 'RadialDistortionCoefficient3',
12161             Format => 'rational64s',
12162             PrintConv => 'sprintf("%.5f",$val)',
12163             },
12164             );
12165              
12166             # Z-series vignette correction information (correction model seems to be using a 6th order even polynomial) (ref 28)
12167             %Image::ExifTool::Nikon::VignetteInfo = (
12168             %binaryDataAttrs,
12169             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
12170             0 => {
12171             Name => 'VignetteCorrectionVersion',
12172             Format => 'string[4]',
12173             },
12174             #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)
12175             0x24 => {
12176             Name => 'VignetteCoefficient1',
12177             Format => 'rational64s',
12178             PrintConv => 'sprintf("%.5f",$val)',
12179             },
12180             0x34 => {
12181             Name => 'VignetteCoefficient2',
12182             Format => 'rational64s',
12183             PrintConv => 'sprintf("%.5f",$val)',
12184             },
12185             0x44 => {
12186             Name => 'VignetteCoefficient3',
12187             Format => 'rational64s',
12188             PrintConv => 'sprintf("%.5f",$val)',
12189             },
12190             );
12191              
12192             # tags in Nikon QuickTime videos (PH - observations with Coolpix S3)
12193             # (similar information in Kodak,Minolta,Nikon,Olympus,Pentax and Sanyo videos)
12194             %Image::ExifTool::Nikon::MOV = (
12195             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
12196             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
12197             FIRST_ENTRY => 0,
12198             NOTES => q{
12199             This information is found in MOV and QT videos from some Nikon cameras.
12200             },
12201             0x00 => {
12202             Name => 'Make',
12203             Format => 'string[24]',
12204             },
12205             0x18 => {
12206             Name => 'Model',
12207             Description => 'Camera Model Name',
12208             Format => 'string[8]',
12209             },
12210             # (01 00 at offset 0x20)
12211             0x26 => {
12212             Name => 'ExposureTime',
12213             Format => 'int32u',
12214             ValueConv => '$val ? 10 / $val : 0',
12215             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
12216             },
12217             0x2a => {
12218             Name => 'FNumber',
12219             Format => 'rational64u',
12220             PrintConv => 'sprintf("%.1f",$val)',
12221             },
12222             0x32 => {
12223             Name => 'ExposureCompensation',
12224             Format => 'rational64s',
12225             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
12226             },
12227             0x44 => {
12228             Name => 'WhiteBalance',
12229             Format => 'int16u',
12230             PrintConv => {
12231             0 => 'Auto',
12232             1 => 'Daylight',
12233             2 => 'Shade',
12234             3 => 'Fluorescent', #2
12235             4 => 'Tungsten',
12236             5 => 'Manual',
12237             },
12238             },
12239             0x48 => {
12240             Name => 'FocalLength',
12241             Format => 'rational64u',
12242             PrintConv => 'sprintf("%.1f mm",$val)',
12243             },
12244             0xaf => {
12245             Name => 'Software',
12246             Format => 'string[16]',
12247             },
12248             0xdf => { # (this is a guess ... could also be offset 0xdb)
12249             Name => 'ISO',
12250             Format => 'int16u',
12251             RawConv => '$val < 50 ? undef : $val', # (not valid for Coolpix L10)
12252             },
12253             );
12254              
12255             # Nikon metadata in AVI videos (PH)
12256             %Image::ExifTool::Nikon::AVI = (
12257             NOTES => 'Nikon-specific RIFF tags found in AVI videos.',
12258             GROUPS => { 0 => 'MakerNotes', 2 => 'Video' },
12259             nctg => {
12260             Name => 'NikonTags',
12261             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AVITags' },
12262             },
12263             ncth => {
12264             Name => 'ThumbnailImage',
12265             Groups => { 2 => 'Preview' },
12266             Binary => 1,
12267             },
12268             ncvr => {
12269             Name => 'NikonVers',
12270             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AVIVers' },
12271             },
12272             ncvw => {
12273             Name => 'PreviewImage',
12274             Groups => { 2 => 'Preview' },
12275             RawConv => 'length($val) ? $val : undef',
12276             Binary => 1,
12277             },
12278             );
12279              
12280             # version information in AVI videos (PH)
12281             %Image::ExifTool::Nikon::AVIVers = (
12282             GROUPS => { 0 => 'MakerNotes', 2 => 'Video' },
12283             PROCESS_PROC => \&ProcessNikonAVI,
12284             FORMAT => 'string',
12285             0x01 => 'MakerNoteType',
12286             0x02 => {
12287             Name => 'MakerNoteVersion',
12288             Format => 'int8u',
12289             ValueConv => 'my @a = reverse split " ", $val; join ".", @a;',
12290             },
12291             );
12292              
12293             # tags in AVI videos (PH)
12294             %Image::ExifTool::Nikon::AVITags = (
12295             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
12296             PROCESS_PROC => \&ProcessNikonAVI,
12297             FORMAT => 'string',
12298             NOTES => q{
12299             These tags and the AVIVer tags below are found in proprietary-format records
12300             of Nikon AVI videos.
12301             },
12302             0x03 => 'Make',
12303             0x04 => 'Model',
12304             0x05 => {
12305             Name => 'Software',
12306             Format => 'undef',
12307             ValueConv => '$val =~ tr/\0//d; $val',
12308             },
12309             0x06 => 'Equipment', # "NIKON DIGITAL CAMERA"
12310             0x07 => { # (guess)
12311             Name => 'Orientation',
12312             Format => 'int16u',
12313             Groups => { 2 => 'Image' },
12314             PrintConv => \%Image::ExifTool::Exif::orientation,
12315             },
12316             0x08 => {
12317             Name => 'ExposureTime',
12318             Format => 'rational64u',
12319             Groups => { 2 => 'Image' },
12320             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
12321             },
12322             0x09 => {
12323             Name => 'FNumber',
12324             Format => 'rational64u',
12325             Groups => { 2 => 'Image' },
12326             PrintConv => 'sprintf("%.1f",$val)',
12327             },
12328             0x0a => {
12329             Name => 'ExposureCompensation',
12330             Format => 'rational64s',
12331             Groups => { 2 => 'Image' },
12332             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
12333             },
12334             0x0b => {
12335             Name => 'MaxApertureValue',
12336             Format => 'rational64u',
12337             ValueConv => '2 ** ($val / 2)',
12338             PrintConv => 'sprintf("%.1f",$val)',
12339             },
12340             0x0c => {
12341             Name => 'MeteringMode', # (guess)
12342             Format => 'int16u',
12343             PrintConv => {
12344             0 => 'Unknown',
12345             1 => 'Average',
12346             2 => 'Center-weighted average',
12347             3 => 'Spot',
12348             4 => 'Multi-spot',
12349             5 => 'Multi-segment',
12350             6 => 'Partial',
12351             255 => 'Other',
12352             },
12353             },
12354             0x0d => { # val: 0
12355             Name => 'Nikon_AVITags_0x000d',
12356             Format => 'int16u',
12357             Flags => [ 'Hidden', 'Unknown' ],
12358             },
12359             0x0e => { # val: 0
12360             Name => 'Nikon_AVITags_0x000e',
12361             Format => 'int16u',
12362             Flags => [ 'Hidden', 'Unknown' ],
12363             },
12364             0x0f => {
12365             Name => 'FocalLength',
12366             Format => 'rational64u',
12367             PrintConv => 'sprintf("%.1f mm",$val)',
12368             },
12369             0x10 => {
12370             Name => 'XResolution',
12371             Format => 'rational64u',
12372             Groups => { 2 => 'Image' },
12373             },
12374             0x11 => {
12375             Name => 'YResolution',
12376             Format => 'rational64u',
12377             Groups => { 2 => 'Image' },
12378             },
12379             0x12 => {
12380             Name => 'ResolutionUnit',
12381             Format => 'int16u',
12382             Groups => { 2 => 'Image' },
12383             PrintConv => {
12384             1 => 'None',
12385             2 => 'inches',
12386             3 => 'cm',
12387             },
12388             },
12389             0x13 => {
12390             Name => 'DateTimeOriginal', # (guess)
12391             Description => 'Date/Time Original',
12392             Groups => { 2 => 'Time' },
12393             PrintConv => '$self->ConvertDateTime($val)',
12394             },
12395             0x14 => {
12396             Name => 'CreateDate', # (guess)
12397             Groups => { 2 => 'Time' },
12398             PrintConv => '$self->ConvertDateTime($val)',
12399             },
12400             0x15 => {
12401             Name => 'Nikon_AVITags_0x0015',
12402             Format => 'int16u',
12403             Flags => [ 'Hidden', 'Unknown' ],
12404             },
12405             0x16 => {
12406             Name => 'Duration',
12407             Format => 'rational64u',
12408             PrintConv => '"$val s"',
12409             },
12410             0x17 => { # val: 1
12411             Name => 'Nikon_AVITags_0x0017',
12412             Format => 'int16u',
12413             Flags => [ 'Hidden', 'Unknown' ],
12414             },
12415             0x18 => 'FocusMode',
12416             0x19 => { # vals: -5, -2, 3, 5, 6, 8, 11, 12, 14, 20, 22
12417             Name => 'Nikon_AVITags_0x0019',
12418             Format => 'int32s',
12419             Flags => [ 'Hidden', 'Unknown' ],
12420             },
12421             0x1b => { # vals: 1 (640x480), 1.25 (320x240)
12422             Name => 'DigitalZoom',
12423             Format => 'rational64u',
12424             },
12425             0x1c => { # (same as Nikon_0x000a)
12426             Name => 'Nikon_AVITags_0x001c',
12427             Format => 'rational64u',
12428             Flags => [ 'Hidden', 'Unknown' ],
12429             },
12430             0x1d => 'ColorMode',
12431             0x1e => { # string[8] - val: "AUTO"
12432             Name => 'Sharpness', # (guess, could also be ISOSelection)
12433             },
12434             0x1f => { # string[16] - val: "AUTO"
12435             Name => 'WhiteBalance', # (guess, could also be ImageAdjustment)
12436             },
12437             0x20 => { # string[4] - val: "OFF"
12438             Name => 'NoiseReduction', # (guess)
12439             },
12440             0x801a => { # val: 0 (why is the 0x8000 bit set in the ID?)
12441             Name => 'Nikon_AVITags_0x801a',
12442             Format => 'int32s',
12443             Flags => [ 'Hidden', 'Unknown' ],
12444             }
12445             );
12446              
12447             # Nikon NCDT atoms (ref PH)
12448             %Image::ExifTool::Nikon::NCDT = (
12449             GROUPS => { 0 => 'MakerNotes', 1 => 'Nikon', 2 => 'Video' },
12450             NOTES => q{
12451             Nikon-specific QuickTime tags found in the NCDT atom of MOV videos from
12452             various Nikon models.
12453             },
12454             NCHD => {
12455             Name => 'MakerNoteVersion',
12456             Format => 'undef',
12457             ValueConv => q{
12458             $val =~ s/\0$//; # remove trailing null
12459             $val =~ s/([\0-\x1f])/'.'.ord($1)/ge;
12460             $val =~ s/\./ /; return $val;
12461             },
12462             },
12463             NCTG => {
12464             Name => 'NikonTags',
12465             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::NCTG' },
12466             },
12467             NCTH => {
12468             Name => 'ThumbnailImage',
12469             Groups => { 2 => 'Preview' },
12470             Format => 'undef',
12471             Binary => 1,
12472             },
12473             NCVW => {
12474             Name => 'PreviewImage',
12475             Groups => { 2 => 'Preview' },
12476             Format => 'undef',
12477             Binary => 1,
12478             },
12479             NCDB => { # (often 0 bytes long, or 4 null bytes)
12480             Name => 'NikonNCDB',
12481             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::NCDB' },
12482             },
12483             NCM1 => {
12484             Name => 'PreviewImage1',
12485             Groups => { 2 => 'Preview' },
12486             Format => 'undef',
12487             Binary => 1,
12488             RawConv => 'length $val ? $val : undef',
12489             },
12490             NCM2 => { #PH (guess - have only seen 0 bytes)
12491             Name => 'PreviewImage2',
12492             Groups => { 2 => 'Preview' },
12493             Format => 'undef',
12494             Binary => 1,
12495             RawConv => 'length $val ? $val : undef',
12496             },
12497             );
12498              
12499             # Nikon NCDB tags from MOV videos (ref PH)
12500             %Image::ExifTool::Nikon::NCDB = (
12501             GROUPS => { 0 => 'MakerNotes', 1 => 'Nikon', 2 => 'Video' },
12502             # the following probably contain encrypted data -- look into decryping these!
12503             # OP01 - 320 bytes, starts with "0200" (D600,D610,D810,D3200,D5200)
12504             # - 638 bytes, starts with "0200" (D7100)
12505             # OP02 - 2048 bytes, starts with "0200" (D810)
12506             );
12507              
12508             # Nikon NCTG tags from MOV videos (ref PH)
12509             %Image::ExifTool::Nikon::NCTG = (
12510             PROCESS_PROC => \&ProcessNikonMOV,
12511             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
12512             NOTES => q{
12513             These tags are found in proprietary-format records of the NCTG atom in MOV
12514             videos from some Nikon cameras.
12515             },
12516             0x01 => 'Make',
12517             0x02 => 'Model',
12518             0x03 => 'Software',
12519             0x11 => {
12520             Name => 'CreateDate', #(guess, but matches QuickTime CreateDate)
12521             Groups => { 2 => 'Time' },
12522             PrintConv => '$self->ConvertDateTime($val)',
12523             },
12524             0x12 => {
12525             Name => 'DateTimeOriginal', #(guess, but time is 1 sec before tag 0x11)
12526             Description => 'Date/Time Original',
12527             Groups => { 2 => 'Time' },
12528             PrintConv => '$self->ConvertDateTime($val)',
12529             },
12530             0x13 => {
12531             Name => 'FrameCount',
12532             # int32u[2]: "467 0", "1038 0", "1127 0"
12533             ValueConv => '$val =~ s/ 0$//; $val', # (not sure what the extra "0" is for)
12534             },
12535             # 0x14 - int32u[2]: "0 0"
12536             # 0x15 - int32u[2]: "0 0"
12537             0x16 => {
12538             Name => 'FrameRate',
12539             Groups => { 2 => 'Video' },
12540             PrintConv => 'int($val * 1000 + 0.5) / 1000',
12541             },
12542             # 0x17 - rational62u: same value as FrameRate
12543             # 0x18 - int16u: 1, 2
12544             0x19 => {
12545             Name => 'TimeZone',
12546             Groups => { 2 => 'Time' },
12547             },
12548             # 0x21 - int16u: 1, 2
12549             0x22 => {
12550             Name => 'FrameWidth',
12551             Groups => { 2 => 'Video' },
12552             },
12553             0x23 => {
12554             Name => 'FrameHeight',
12555             Groups => { 2 => 'Video' },
12556             },
12557             # 0x24 - int16u: 1, 2
12558             # 0x31 - int16u: 0, 1, 2
12559             0x32 => { #(guess)
12560             Name => 'AudioChannels',
12561             Groups => { 2 => 'Audio' },
12562             },
12563             0x33 => {
12564             Name => 'AudioBitsPerSample',
12565             Groups => { 2 => 'Audio' },
12566             },
12567             0x34 => {
12568             Name => 'AudioSampleRate',
12569             Groups => { 2 => 'Audio' },
12570             },
12571             # 0x101 - int16u[4]: "160 120 1280 720", "160 120 3840 2160"
12572             # 0x102 - int16u[8]: "640 360 0 0 0 0 0 0", "640 360 1920 1080 0 0 0 0"
12573             # 0x1001 - int16s: 0
12574             0x1002 => {
12575             Name => 'NikonDateTime', #?
12576             Groups => { 2 => 'Time' },
12577             PrintConv => '$self->ConvertDateTime($val)',
12578             },
12579             # 0x1011 - int32u: 0
12580             # 0x1012 - int32u: 0
12581             0x1013 => { #HayoBaan
12582             Name => 'ElectronicVR',
12583             PrintConv => \%offOn,
12584             },
12585             # 0x1014 - int16u: 1
12586             # 0x1021 - int32u[32]: all zeros
12587             #
12588             # 0x110**** tags correspond to 0x**** tags in Exif::Main
12589             #
12590             0x110829a => { #34
12591             Name => 'ExposureTime',
12592             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
12593             },
12594             0x110829d => { #34
12595             Name => 'FNumber',
12596             PrintConv => 'Image::ExifTool::Exif::PrintFNumber($val)',
12597             },
12598             0x1108822 => {
12599             Name => 'ExposureProgram',
12600             PrintConv => {
12601             0 => 'Not Defined',
12602             1 => 'Manual',
12603             2 => 'Program AE',
12604             3 => 'Aperture-priority AE',
12605             4 => 'Shutter speed priority AE',
12606             5 => 'Creative (Slow speed)',
12607             6 => 'Action (High speed)',
12608             7 => 'Portrait',
12609             8 => 'Landscape',
12610             # 9 => 'Bulb', # (non-standard Canon value)
12611             },
12612             },
12613             0x1109204 => {
12614             Name => 'ExposureCompensation',
12615             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
12616             },
12617             0x1109207 => {
12618             Name => 'MeteringMode',
12619             PrintConv => {
12620             0 => 'Unknown',
12621             1 => 'Average',
12622             2 => 'Center-weighted average',
12623             3 => 'Spot',
12624             4 => 'Multi-spot',
12625             5 => 'Multi-segment',
12626             6 => 'Partial',
12627             255 => 'Other',
12628             },
12629             },
12630             0x110920a => { #34
12631             Name => 'FocalLength',
12632             PrintConv => 'sprintf("%.1f mm",$val)',
12633             },
12634             0x110a431 => 'SerialNumber',
12635             0x110a432 => {
12636             Name => 'LensInfo',
12637             PrintConv => \&Image::ExifTool::Exif::PrintLensInfo,
12638             },
12639             0x110a433 => 'LensMake',
12640             0x110a434 => 'LensModel',
12641             0x110a435 => 'LensSerialNumber',
12642             #
12643             # 0x120**** tags correspond to 0x**** tags in GPS::Main
12644             #
12645             0x1200000 => {
12646             Name => 'GPSVersionID',
12647             Groups => { 1 => 'GPS', 2 => 'Location' },
12648             PrintConv => '$val =~ tr/ /./; $val',
12649             },
12650             0x1200001 => {
12651             Name => 'GPSLatitudeRef',
12652             Groups => { 1 => 'GPS', 2 => 'Location' },
12653             PrintConv => {
12654             N => 'North',
12655             S => 'South',
12656             },
12657             },
12658             0x1200002 => {
12659             Name => 'GPSLatitude',
12660             Groups => { 1 => 'GPS', 2 => 'Location' },
12661             ValueConv => q{
12662             require Image::ExifTool::GPS;
12663             Image::ExifTool::GPS::ToDegrees($val);
12664             },
12665             PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1)',
12666             },
12667             0x1200003 => {
12668             Name => 'GPSLongitudeRef',
12669             Groups => { 1 => 'GPS', 2 => 'Location' },
12670             PrintConv => {
12671             E => 'East',
12672             W => 'West',
12673             },
12674             },
12675             0x1200004 => {
12676             Name => 'GPSLongitude',
12677             Groups => { 1 => 'GPS', 2 => 'Location' },
12678             ValueConv => q{
12679             require Image::ExifTool::GPS;
12680             Image::ExifTool::GPS::ToDegrees($val);
12681             },
12682             PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1)',
12683             },
12684             0x1200005 => {
12685             Name => 'GPSAltitudeRef',
12686             Groups => { 1 => 'GPS', 2 => 'Location' },
12687             PrintConv => {
12688             0 => 'Above Sea Level',
12689             1 => 'Below Sea Level',
12690             },
12691             },
12692             0x1200006 => {
12693             Name => 'GPSAltitude',
12694             Groups => { 1 => 'GPS', 2 => 'Location' },
12695             PrintConv => '$val =~ /^(inf|undef)$/ ? $val : "$val m"',
12696             },
12697             0x1200007 => {
12698             Name => 'GPSTimeStamp',
12699             Groups => { 1 => 'GPS', 2 => 'Time' },
12700             ValueConv => q{
12701             require Image::ExifTool::GPS;
12702             Image::ExifTool::GPS::ConvertTimeStamp($val);
12703             },
12704             PrintConv => 'Image::ExifTool::GPS::PrintTimeStamp($val)',
12705             },
12706             0x1200008 => {
12707             Name => 'GPSSatellites',
12708             Groups => { 1 => 'GPS', 2 => 'Location' },
12709             },
12710             0x1200010 => {
12711             Name => 'GPSImgDirectionRef',
12712             Groups => { 1 => 'GPS', 2 => 'Location' },
12713             PrintConv => {
12714             M => 'Magnetic North',
12715             T => 'True North',
12716             },
12717             },
12718             0x1200011 => {
12719             Name => 'GPSImgDirection',
12720             Groups => { 1 => 'GPS', 2 => 'Location' },
12721             },
12722             0x1200012 => {
12723             Name => 'GPSMapDatum',
12724             Groups => { 1 => 'GPS', 2 => 'Location' },
12725             },
12726             0x120001d => {
12727             Name => 'GPSDateStamp',
12728             Groups => { 1 => 'GPS', 2 => 'Time' },
12729             ValueConv => 'Image::ExifTool::Exif::ExifDate($val)',
12730             },
12731             #
12732             # 0x200**** tags correspond to 0x**** tags in Nikon::Main
12733             # (must be duplicated here so tagInfo "Table" entry will point to correct table.
12734             # Also there would be a problem with the PRINT_CONV from the Main table)
12735             #
12736             0x2000001 => {
12737             Name => 'MakerNoteVersion',
12738             PrintConv => '$_=$val;s/^(\d{2})/$1\./;s/^0//;$_',
12739             },
12740             0x2000005 => 'WhiteBalance',
12741             0x2000007 => { Name => 'FocusMode', Writable => 'string' }, #34
12742             0x200000b => 'WhiteBalanceFineTune',
12743             0x200001b => {
12744             Name => 'CropHiSpeed',
12745             Writable => 'int16u',
12746             Count => 7,
12747             PrintConv => \%cropHiSpeed,
12748             },
12749             0x200001e => {
12750             Name => 'ColorSpace',
12751             PrintConv => {
12752             1 => 'sRGB',
12753             2 => 'Adobe RGB',
12754             },
12755             },
12756             0x200001f => {
12757             Name => 'VRInfo',
12758             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::VRInfo' },
12759             },
12760             0x2000022 => {
12761             Name => 'ActiveD-Lighting',
12762             Writable => 'int16u',
12763             PrintConv => {
12764             0 => 'Off',
12765             1 => 'Low',
12766             3 => 'Normal',
12767             5 => 'High',
12768             7 => 'Extra High',
12769             8 => 'Extra High 1',
12770             9 => 'Extra High 2',
12771             10 => 'Extra High 3',
12772             11 => 'Extra High 4',
12773             0xffff => 'Auto',
12774             },
12775             },
12776             0x2000023 => [
12777             { #PH (D300, but also found in D3,D3S,D3X,D90,D300S,D700,D3000,D5000)
12778             Name => 'PictureControlData',
12779             Condition => '$$valPt =~ /^01/',
12780             Writable => 'undef',
12781             Permanent => 0,
12782             Flags => [ 'Binary', 'Protected' ],
12783             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl' },
12784             },{ #28
12785             Name => 'PictureControlData',
12786             Condition => '$$valPt =~ /^02/',
12787             Writable => 'undef',
12788             Permanent => 0,
12789             Flags => [ 'Binary', 'Protected' ],
12790             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl2' },
12791             },{
12792             Name => 'PictureControlData',
12793             Condition => '$$valPt =~ /^03/',
12794             Writable => 'undef',
12795             Permanent => 0,
12796             Flags => [ 'Binary', 'Protected' ],
12797             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl3' },
12798             },{
12799             Name => 'PictureControlData',
12800             Writable => 'undef',
12801             Permanent => 0,
12802             Flags => [ 'Binary', 'Protected' ],
12803             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControlUnknown' },
12804             },
12805             ],
12806             0x2000024 => {
12807             Name => 'WorldTime',
12808             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::WorldTime' },
12809             },
12810             0x2000025 => { #34
12811             Name => 'ISOInfo',
12812             SubDirectory => {
12813             TagTable => 'Image::ExifTool::Nikon::ISOInfo',
12814             ByteOrder => 'BigEndian', # (BigEndian even for D810, which is a little-endian camera)
12815             },
12816             },
12817             0x200002a => { #23 (this tag added with D3 firmware 1.10 -- also written by Nikon utilities)
12818             Name => 'VignetteControl',
12819             Writable => 'int16u',
12820             PrintConv => {
12821             0 => 'Off',
12822             1 => 'Low',
12823             3 => 'Normal',
12824             5 => 'High',
12825             },
12826             },
12827             0x200002c => {
12828             Name => 'UnknownInfo',
12829             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::UnknownInfo' },
12830             },
12831             # 0x200002d - int16u[3]: "512 0 0", "512 1 14", "512 3 10"
12832             0x2000032 => {
12833             Name => 'UnknownInfo2',
12834             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::UnknownInfo2' },
12835             },
12836             0x2000039 => {
12837             Name => 'LocationInfo',
12838             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LocationInfo' },
12839             },
12840             0x200003f => 'WhiteBalanceFineTune',
12841             # 0x200003f - rational64s[2]: "0 0"
12842             # 0x2000042 - undef[6]: "0100\x03\0"
12843             # 0x2000043 - undef[12]: all zeros
12844             # 0x200004d - undef[84]: "0100\0\0\0\0x020100\0\0\0\x010100\0\0\0\x05\0\0\..."
12845             0x200004e => {
12846             Name => 'NikonSettings',
12847             SubDirectory => { TagTable => 'Image::ExifTool::NikonSettings::Main' },
12848             },
12849             # 0x2000055 - undef[8]: "0100\x01\0\0\0"
12850             0x2000083 => {
12851             Name => 'LensType',
12852             # credit to Tom Christiansen (ref 7) for figuring this out...
12853             PrintConv => q[$_ = $val ? Image::ExifTool::DecodeBits($val,
12854             {
12855             0 => 'MF',
12856             1 => 'D',
12857             2 => 'G',
12858             3 => 'VR',
12859             4 => '1', #PH
12860             # bit 5 set for FT-1 adapter? - PH
12861             6 => 'E', #PH (electromagnetic aperture mechanism)
12862             # bit 7 set for AF-P lenses? - PH
12863             }) : 'AF';
12864             # remove commas and change "D G" to just "G"
12865             s/,//g; s/\bD G\b/G/;
12866             s/ E\b// and s/^(G )?/E /; # put "E" at the start instead of "G"
12867             s/ 1// and $_ = "1 $_"; # put "1" at start
12868             return $_;
12869             ],
12870             },
12871             0x2000084 => {
12872             Name => "Lens",
12873             # short focal, long focal, aperture at short focal, aperture at long focal
12874             PrintConv => \&Image::ExifTool::Exif::PrintLensInfo,
12875             },
12876             0x2000087 => {
12877             Name => 'FlashMode',
12878             Writable => 'int8u',
12879             PrintConv => {
12880             0 => 'Did Not Fire',
12881             1 => 'Fired, Manual', #14
12882             3 => 'Not Ready', #28
12883             7 => 'Fired, External', #14
12884             8 => 'Fired, Commander Mode',
12885             9 => 'Fired, TTL Mode',
12886             18 => 'LED Light', #G.F. (movie LED light)
12887             },
12888             },
12889             0x2000098 => [
12890             { #8
12891             Condition => '$$valPt =~ /^0100/', # D100, D1X - PH
12892             Name => 'LensData0100',
12893             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LensData00' },
12894             },
12895             { #8
12896             Condition => '$$valPt =~ /^0101/', # D70, D70s - PH
12897             Name => 'LensData0101',
12898             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LensData01' },
12899             },
12900             # note: this information is encrypted if the version is 02xx
12901             { #8
12902             # 0201 - D200, D2Hs, D2X and D2Xs
12903             # 0202 - D40, D40X and D80
12904             # 0203 - D300
12905             Condition => '$$valPt =~ /^020[1-3]/',
12906             Name => 'LensData0201',
12907             SubDirectory => {
12908             TagTable => 'Image::ExifTool::Nikon::LensData01',
12909             ProcessProc => \&ProcessNikonEncrypted,
12910             WriteProc => \&ProcessNikonEncrypted,
12911             DecryptStart => 4,
12912             },
12913             },
12914             { #PH
12915             Condition => '$$valPt =~ /^0204/', # D90, D7000
12916             Name => 'LensData0204',
12917             SubDirectory => {
12918             TagTable => 'Image::ExifTool::Nikon::LensData0204',
12919             ProcessProc => \&ProcessNikonEncrypted,
12920             WriteProc => \&ProcessNikonEncrypted,
12921             DecryptStart => 4,
12922             },
12923             },
12924             {
12925             Condition => '$$valPt =~ /^040[01]/', # 0=1J1/1V1, 1=1J2
12926             Name => 'LensData0400',
12927             SubDirectory => {
12928             TagTable => 'Image::ExifTool::Nikon::LensData0400',
12929             ProcessProc => \&ProcessNikonEncrypted,
12930             WriteProc => \&ProcessNikonEncrypted,
12931             DecryptStart => 4,
12932             },
12933             },
12934             {
12935             Condition => '$$valPt =~ /^0402/', # 1J3/1S1/1V2
12936             Name => 'LensData0402',
12937             SubDirectory => {
12938             TagTable => 'Image::ExifTool::Nikon::LensData0402',
12939             ProcessProc => \&ProcessNikonEncrypted,
12940             WriteProc => \&ProcessNikonEncrypted,
12941             DecryptStart => 4,
12942             },
12943             },
12944             {
12945             Condition => '$$valPt =~ /^0403/', # 1J4,1J5
12946             Name => 'LensData0403',
12947             SubDirectory => {
12948             TagTable => 'Image::ExifTool::Nikon::LensData0403',
12949             ProcessProc => \&ProcessNikonEncrypted,
12950             WriteProc => \&ProcessNikonEncrypted,
12951             DecryptStart => 4,
12952             },
12953             },
12954             {
12955             Condition => '$$valPt =~ /^080[012]/', # Z6/Z7/Z9
12956             Name => 'LensData0800',
12957             SubDirectory => {
12958             TagTable => 'Image::ExifTool::Nikon::LensData0800',
12959             ProcessProc => \&ProcessNikonEncrypted,
12960             WriteProc => \&ProcessNikonEncrypted,
12961             DecryptStart => 4,
12962             ByteOrder => 'LittleEndian',
12963             # 0x5a0c - NikonMeteringMode for some Z6 ver1.00 samples (ref PH)
12964             },
12965             },
12966             {
12967             Name => 'LensDataUnknown',
12968             SubDirectory => {
12969             TagTable => 'Image::ExifTool::Nikon::LensDataUnknown',
12970             ProcessProc => \&ProcessNikonEncrypted,
12971             WriteProc => \&ProcessNikonEncrypted,
12972             DecryptStart => 4,
12973             },
12974             },
12975             ],
12976             0x20000a7 => { # Number of shots taken by camera so far (ref 2)
12977             Name => 'ShutterCount',
12978             PrintConv => '$val == 4294965247 ? "n/a" : $val',
12979             },
12980             0x20000a8 => [
12981             {
12982             Name => 'FlashInfo0100',
12983             Condition => '$$valPt =~ /^010[01]/',
12984             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0100' },
12985             },
12986             {
12987             Name => 'FlashInfo0102',
12988             Condition => '$$valPt =~ /^0102/',
12989             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0102' },
12990             },
12991             {
12992             Name => 'FlashInfo0103',
12993             # (0104 for D7000, 0105 for D800)
12994             Condition => '$$valPt =~ /^010[345]/',
12995             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0103' },
12996             },
12997             {
12998             Name => 'FlashInfo0106', # (0106 for D7100)
12999             Condition => '$$valPt =~ /^0106/',
13000             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0106' },
13001             },
13002             {
13003             Name => 'FlashInfo0107', # (0107 for D4S/D750/D810/D5500/D7200, 0108 for D5/D500/D3400)
13004             Condition => '$$valPt =~ /^010[78]/',
13005             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0107' },
13006             },
13007             {
13008             Name => 'FlashInfoUnknown',
13009             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfoUnknown' },
13010             },
13011             ],
13012             0x20000ab => { Name => 'VariProgram', Writable => 'string' }, #2 (scene mode for DSLR's - PH)
13013             0x20000b1 => { #34
13014             Name => 'HighISONoiseReduction',
13015             Writable => 'int16u',
13016             PrintConv => {
13017             0 => 'Off',
13018             1 => 'Minimal', # for high ISO (>800) when setting is "Off"
13019             2 => 'Low', # Low,Normal,High take effect for ISO > 400
13020             3 => 'Medium Low',
13021             4 => 'Normal',
13022             5 => 'Medium High',
13023             6 => 'High',
13024             },
13025             },
13026             0x20000b7 => [{
13027             Name => 'AFInfo2',
13028             # LiveView-enabled DSLRs introduced starting in 2007 (D3/D300)
13029             Condition => '$$valPt =~ /^0100/',
13030             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0100' },
13031             },{
13032             Name => 'AFInfo2',
13033             # All Expeed 5 processor and most Expeed 4 processor models from 2016 - D5, D500, D850, D3400, D3500, D7500 (D5600 is v0100)
13034             Condition => '$$valPt =~ /^0101/',
13035             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0101' },
13036             },{
13037             Name => 'AFInfo2',
13038             # Nikon 1 Series cameras
13039             Condition => '$$valPt =~ /^020[01]/',
13040             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0200' },
13041             },{
13042             Name => 'AFInfo2',
13043             # Expeed 6 processor models - D6, D780, Z5, Z6, Z7, Z30, Z50, Z6_2, Z7_2 and Zfc
13044             Condition => '$$valPt =~ /^030[01]/',
13045             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0300' },
13046             },{
13047             Name => 'AFInfo2',
13048             # Expeed 7 processor models - Z8 & Z9 (AFInfo2Version 0400), Z6iii & Zf (AFInfo2Version 0401)
13049             # and Z50ii (AFInfo2Version 0402)
13050             Condition => '$$valPt =~ /^040[012]/',
13051             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0400' },
13052             }],
13053             # 0x20000c0 - undef[8]:
13054             # 34 01 0c 00 90 01 0c 00
13055             # 34 01 0c 00 9c 01 0c 00
13056             # 3c 01 0c 00 9c 01 0c 00
13057             # 3c 01 0c 00 a8 01 0c 00
13058             0x20000c3 => {
13059             Name => 'BarometerInfo',
13060             SubDirectory => {
13061             TagTable => 'Image::ExifTool::Nikon::BarometerInfo',
13062             # (little-endian in II EXIF, big-endian in MOV)
13063             },
13064             },
13065             );
13066              
13067             # Nikon XMP tags written in NKSC metadata
13068             %Image::ExifTool::Nikon::ast = (
13069             GROUPS => { 0 => 'XMP', 1 => 'XMP-ast', 2 => 'Image' },
13070             PROCESS_PROC => \&Image::ExifTool::XMP::ProcessXMP,
13071             NAMESPACE => 'ast',
13072             VARS => { ID_FMT => 'none' },
13073             NOTES => 'Tags used by Nikon NX Studio in Nikon NKSC sidecar files and trailers.',
13074             about => { },
13075             version => { },
13076             XMLPackets => {
13077             SubDirectory => { TagTable => 'Image::ExifTool::XMP::Main' },
13078             Encoding => 'Base64',
13079             Binary => 1,
13080             },
13081             IPTC => {
13082             SubDirectory => { TagTable => 'Image::ExifTool::IPTC::Main' },
13083             Encoding => 'Base64',
13084             Binary => 1,
13085             },
13086             GPSVersionID => { Groups => { 2 => 'Location' }, %base64bytes },
13087             GPSLatitudeRef => {
13088             Groups => { 2 => 'Location' },
13089             %base64int32u,
13090             PrintConv => { 0 => 'North', 1 => 'South' }, #PH (NC)
13091             },
13092             GPSLatitude => { Groups => { 2 => 'Location' }, %base64coord },
13093             GPSLongitudeRef => {
13094             Groups => { 2 => 'Location' },
13095             %base64int32u,
13096             PrintConv => { 2 => 'East', 3 => 'West' }, #PH (NC)
13097             },
13098             GPSLongitude => { Groups => { 2 => 'Location' }, %base64coord },
13099             GPSAltitudeRef => {
13100             Groups => { 2 => 'Location' },
13101             %base64bytes,
13102             PrintConv => {
13103             0 => 'Above Sea Level',
13104             1 => 'Below Sea Level',
13105             },
13106             },
13107             GPSAltitude => {
13108             Groups => { 2 => 'Location' },
13109             %base64double,
13110             PrintConv => '"$val m"',
13111             },
13112             GPSMapDatum => { Groups => { 2 => 'Location' } },
13113             GPSImgDirection => {
13114             Groups => { 2 => 'Location' },
13115             %base64double,
13116             PrintConv => 'sprintf("%.2f", $val)',
13117             },
13118             GPSImgDirectionRef => {
13119             Groups => { 2 => 'Location' },
13120             PrintConv => {
13121             M => 'Magnetic North',
13122             T => 'True North',
13123             },
13124             },
13125             );
13126             %Image::ExifTool::Nikon::sdc = (
13127             GROUPS => { 0 => 'XMP', 1 => 'XMP-sdc', 2 => 'Image' },
13128             PROCESS_PROC => \&Image::ExifTool::XMP::ProcessXMP,
13129             NAMESPACE => 'sdc',
13130             VARS => { ID_FMT => 'none' },
13131             about => { },
13132             version => { },
13133             appversion => { Name => 'AppVersion' },
13134             appname => { Name => 'AppName' },
13135             );
13136             %Image::ExifTool::Nikon::nine = (
13137             GROUPS => { 0 => 'XMP', 1 => 'XMP-nine', 2 => 'Image' },
13138             PROCESS_PROC => \&Image::ExifTool::XMP::ProcessXMP,
13139             NAMESPACE => 'nine',
13140             VARS => { ID_FMT => 'none' },
13141             about => { },
13142             version => { },
13143             Label => { },
13144             Rating => { },
13145             Trim => { %base64bin },
13146             NineEdits => {
13147             SubDirectory => {
13148             TagTable => 'Image::ExifTool::Nikon::NineEdits',
13149             IgnoreProp => { userData => 1 }, # remove "UserData" from already overly long tag names
13150             },
13151             Binary => 1,
13152             },
13153             );
13154             %Image::ExifTool::Nikon::NineEdits = (
13155             GROUPS => { 0 => 'XML', 1 => 'NineEdits', 2 => 'Image' },
13156             PROCESS_PROC => \&Image::ExifTool::XMP::ProcessXMP,
13157             VARS => { ID_FMT => 'none' },
13158             NOTES => 'XML-based tags used to store editing information.',
13159             filterParametersBinary => { %base64bin },
13160             filterParametersExportExportData => { %base64bin },
13161             filterParametersCustomCustomData => { %base64bin },
13162             );
13163              
13164             # Nikon composite tags
13165             %Image::ExifTool::Nikon::Composite = (
13166             GROUPS => { 2 => 'Camera' },
13167             LensSpec => {
13168             Require => {
13169             0 => 'Nikon:Lens',
13170             1 => 'Nikon:LensType',
13171             },
13172             ValueConv => '"$val[0] $val[1]"',
13173             PrintConv => '"$prt[0] $prt[1]"',
13174             },
13175             LensID => {
13176             SeparateTable => 'Nikon LensID', # print values in a separate table
13177             Require => {
13178             0 => 'Nikon:LensIDNumber',
13179             1 => 'LensFStops',
13180             2 => 'MinFocalLength',
13181             3 => 'MaxFocalLength',
13182             4 => 'MaxApertureAtMinFocal',
13183             5 => 'MaxApertureAtMaxFocal',
13184             6 => 'MCUVersion',
13185             7 => 'Nikon:LensType',
13186             },
13187             # construct lens ID string as per ref 11
13188             ValueConv => 'sprintf("%.2X"." %.2X"x7, @raw)',
13189             PrintConv => \%nikonLensIDs,
13190             PrintInt => 1,
13191             },
13192             AutoFocus => {
13193             Require => {
13194             0 => 'Nikon:FocusMode',
13195             },
13196             ValueConv => '($val[0] =~ /^Manual/i) ? 0 : 1',
13197             PrintConv => \%offOn,
13198             },
13199             PhaseDetectAF => {
13200             Require => {
13201             0 => 'Nikon:FocusPointSchema',
13202             1 => 'Nikon:AFDetectionMethod',
13203             },
13204             ValueConv => '(($val[1]) == 0) ? ($val[0]) : 0', # for backward compatibility, report FocusPointSchema when AFDetectionMethod indicates Phase Detect is on
13205             PrintConv => {
13206             0 => 'Off', #contrast detect or hybrid detect
13207             1 => 'On (51-point)', #PH
13208             2 => 'On (11-point)', #PH
13209             3 => 'On (39-point)', #29 (D7000)
13210             7 => 'On (153-point)', #PH (D5/D500/D850)
13211             #8 => 'On (81-point)', #38 will not see this value - only available in hybrid detect
13212             9 => 'On (105-point)', #28 (D6)
13213             },
13214             },
13215             ContrastDetectAF => {
13216             Require => {
13217             0 => 'Nikon:FocusMode',
13218             1 => 'Nikon:AFDetectionMethod',
13219             },
13220             ValueConv => '(($val[0] !~ /^Manual/i) and ($val[1] == 1)) ? 1 : 0',
13221             PrintConv => \%offOn,
13222             },
13223             );
13224              
13225             # add our composite tags
13226             Image::ExifTool::AddCompositeTags('Image::ExifTool::Nikon');
13227              
13228             #------------------------------------------------------------------------------
13229             # Process Nikon AVI tags (D5000 videos)
13230             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
13231             # Returns: 1 on success
13232             sub ProcessNikonAVI($$$)
13233             {
13234 0     0 0 0 my ($et, $dirInfo, $tagTablePtr) = @_;
13235 0         0 my $dataPt = $$dirInfo{DataPt};
13236 0   0     0 my $pos = $$dirInfo{DirStart} || 0;
13237 0         0 my $dirEnd = $pos + $$dirInfo{DirLen};
13238 0         0 $et->VerboseDir($dirInfo, undef, $$dirInfo{DirLen});
13239 0         0 SetByteOrder('II');
13240 0         0 while ($pos + 4 <= $dirEnd) {
13241 0         0 my $tag = Get16u($dataPt, $pos);
13242 0         0 my $size = Get16u($dataPt, $pos + 2);
13243 0         0 $pos += 4;
13244 0 0       0 last if $pos + $size > $dirEnd;
13245 0         0 $et->HandleTag($tagTablePtr, $tag, undef,
13246             DataPt => $dataPt,
13247             Start => $pos,
13248             Size => $size,
13249             );
13250 0         0 $pos += $size;
13251             }
13252 0         0 return 1;
13253             }
13254              
13255             #------------------------------------------------------------------------------
13256             # Print conversion for Nikon AF points
13257             # Inputs: 0) value to convert (as a string of hex bytes),
13258             # 1) lookup for AF point bit number (starting at 1), or array ref
13259             sub PrintAFPoints($$)
13260             {
13261 0     0 0 0 my ($val, $afPoints) = @_;
13262 0         0 my ($i, $j, @points);
13263 0         0 $val =~ tr/ //d; # remove spaces from hex string
13264 0         0 my @dat = unpack 'C*', pack 'H*', $val; # convert to array of bytes
13265             # loop through all bytes to find active AF points
13266 0         0 for ($i=0; $i<=@dat; ++$i) {
13267 0 0       0 next unless $dat[$i];
13268 0         0 for ($j=0; $j<8; ++$j) {
13269 0 0       0 next unless $dat[$i] & (1 << $j);
13270 0 0       0 my $point = ref $afPoints eq 'HASH' ? $$afPoints{$i*8+$j+1} : $$afPoints[$i*8+$j];
13271 0 0       0 push @points, $point if defined $point;
13272             }
13273             }
13274 0 0       0 return '(none)' unless @points;
13275             # sort the points and return as comma-separated string
13276             return join ',', sort {
13277 0 0       0 return $a cmp $b if length($a) == length($b);
  0         0  
13278 0 0       0 return substr($a,0,1).'0'.substr($a,1,1) cmp $b if length($a) == 2;
13279 0         0 return $a cmp substr($b,0,1).'0'.substr($b,1,1);
13280             } @points;
13281             }
13282              
13283             #------------------------------------------------------------------------------
13284             # Inverse print conversion for AF points
13285             # Inputs: 0) AF point string, 1) AF point hash or array ref
13286             # Returns: AF point data as a string of hex bytes
13287             sub PrintAFPointsInv($$)
13288             {
13289 16     16 0 43 my ($val, $afPoints) = @_;
13290 16         75 my @points = ($val =~ /[A-Za-z]\d+/g);
13291 16 50       83 my $size = int((scalar(ref $afPoints eq 'HASH' ? keys %$afPoints : @$afPoints) + 7) / 8);
13292 16         88 my @dat = (0) x $size;
13293 16 50       51 if (@points) {
13294 0         0 my (%bitNum, $point);
13295 0 0       0 if (ref $afPoints eq 'HASH') {
13296 0         0 $bitNum{$$afPoints{$_}} = $_ foreach keys %$afPoints; # build reverse lookup
13297             } else {
13298 0         0 $bitNum{$$afPoints[$_]} = $_ + 1 foreach 0..$#$afPoints;
13299             }
13300 0         0 foreach $point (@points) {
13301 0 0       0 my $bitNum = $bitNum{uc $point} or next;
13302 0         0 my $byte = int(($bitNum - 1) / 8);
13303 0         0 $dat[$byte] |= (1 << (($bitNum - 1) % 8));
13304             }
13305             }
13306 16         256 return join(" ", unpack("H2"x$size, pack('C*', @dat)));
13307             }
13308              
13309             #------------------------------------------------------------------------------
13310             # Get AF point name for grid-type AF
13311             # Inputs: 0) AF point number, 1) number of columns, 2) true for inverse conversion
13312             # Returns: AF point name, or undef
13313             sub GetAFPointGrid($$;$)
13314             {
13315 0     0 0 0 my ($val, $ncol, $inv) = @_;
13316 0 0       0 if ($inv) {
13317 0 0       0 return undef unless $val =~ /^([A-J])(\d+)$/i;
13318 0         0 return (ord(uc($1))-65) * $ncol + $2 - 1;
13319             } else {
13320 0         0 my $row = int(($val + 0.5) / $ncol) & 0xff;
13321 0         0 my $col = $val - $ncol * $row + 1;
13322 0         0 return chr(65+$row) . $col;
13323             }
13324             }
13325              
13326             #------------------------------------------------------------------------------
13327             # Print conversion for grid-type AF points
13328             # Inputs: 0) value to convert (as a string of hex bytes),
13329             # 1) number of columns in grid
13330             sub PrintAFPointsGrid($$)
13331             {
13332 0     0 0 0 my ($val, $ncol) = @_;
13333 0         0 my ($i, $j, @points);
13334 0         0 $val =~ tr/ //d; # remove spaces from hex string
13335 0         0 my @dat = unpack 'C*', pack 'H*', $val; # convert to array of bytes
13336             # loop through all bytes to find active AF points
13337 0         0 for ($i=0; $i<@dat; ++$i) {
13338 0 0       0 next unless $dat[$i];
13339 0         0 for ($j=0; $j<8; ++$j) {
13340 0 0       0 next unless $dat[$i] & (1 << $j);
13341 0         0 my $point = GetAFPointGrid($i*8 + $j, $ncol);
13342 0 0       0 push @points, $point if defined $point;
13343             }
13344             }
13345 0 0       0 return '(none)' unless @points;
13346 0         0 return join ',', @points; # return as comma-separated string
13347             }
13348              
13349             #------------------------------------------------------------------------------
13350             # Inverse print conversion for AF points
13351             # Inputs: 0) AF point string, 1) number of columns, 2) size of data
13352             # Returns: AF point data as a string of hex bytes
13353             sub PrintAFPointsGridInv($$$)
13354             {
13355 0     0 0 0 my ($val, $ncol, $size) = @_;
13356 0         0 my @points = ($val =~ /[A-Za-z]\d+/g);
13357 0         0 my @dat = (0) x $size;
13358 0         0 foreach (@points) {
13359 0         0 my $n = GetAFPointGrid($_, $ncol, 1);
13360 0 0       0 next unless defined $n;
13361 0         0 my $byte = int($n / 8);
13362 0 0       0 next if $byte > $size;
13363 0         0 $dat[$byte] |= (1 << ($n - $byte * 8));
13364             }
13365 0         0 return join(" ", unpack("H2"x$size, pack('C*', @dat)));
13366             }
13367              
13368             #------------------------------------------------------------------------------
13369             # Print conversion for relative Left/Right AF points (ref 28)
13370             # Inputs: 0) column, 1) number of columns
13371             # Returns: AF point data as a string (e.g. '2L of Center' or 'C' or '3R of Center')
13372             sub PrintAFPointsLeftRight($$)
13373             {
13374 0     0 0 0 my ($col, $ncol) = @_;
13375 0         0 my $center = ($ncol + 1) / 2;
13376 0 0       0 return 'n/a' if $col == 0; #out of focus
13377 0 0       0 return 'C' if $col == $center;
13378 0 0       0 return sprintf('%d', $center - $col) . 'L of Center' if $col < $center;
13379 0 0       0 return sprintf('%d', $col - $center) . 'R of Center' if $col > $center;
13380             }
13381              
13382             #------------------------------------------------------------------------------
13383             # Print conversion for relative Up/Down AF points (ref 28)
13384             # Inputs: 0) row, 1) number of rows
13385             # Returns: AF point data as a string (e.g. '2U from Center' or 'C' or '3D from Center')
13386             sub PrintAFPointsUpDown($$)
13387             {
13388 0     0 0 0 my ($row, $nrow) = @_;
13389 0         0 my $center = ($nrow + 1) / 2;
13390 0 0       0 return 'n/a' if $row == 0; #out of focus
13391 0 0       0 return 'C' if $row == $center;
13392 0 0       0 return sprintf('%d', $center - $row) . 'U from Center' if $row < $center;
13393 0 0       0 return sprintf('%d', $row - $center) . 'D from Center' if $row > $center;
13394             }
13395              
13396             #------------------------------------------------------------------------------
13397             # Print PictureControl value
13398             # Inputs: 0) value (with 0x80 subtracted),
13399             # 1) 'Normal' (0 value) string (default 'Normal')
13400             # 2) format string for numbers (default '%+d'), 3) v2 divisor
13401             # Returns: PrintConv value
13402             sub PrintPC($;$$$)
13403             {
13404 0     0 0 0 my ($val, $norm, $fmt, $div) = @_;
13405 0 0 0     0 return $norm || 'Normal' if $val == 0;
13406 0 0       0 return 'n/a' if $val == 0x7f;
13407 0 0       0 return 'Auto' if $val == -128;
13408             # -127 = custom curve created in Camera Control Pro (show as "User" by D3) - ref 28
13409 0 0       0 return 'User' if $val == -127; #28
13410 0   0     0 return sprintf($fmt || '%+d', $val / ($div || 1));
      0        
13411             }
13412              
13413             #------------------------------------------------------------------------------
13414             # Inverse of PrintPC
13415             # Inputs: 0) PrintConv value (after subracting 0x80 from raw value), 1) v2 divisor
13416             # Returns: unconverted value
13417             # Notes: raw values: 0=Auto, 1=User, 0xff=n/a, ... 0x7f=-1, 0x80=0, 0x81=1, ...
13418             sub PrintPCInv($;$)
13419             {
13420 114     114 0 333 my ($val, $div) = @_;
13421 114 100 100     1441 return $val * ($div || 1) if $val =~ /^[-+]?\d+(\.\d+)?$/;
13422 114 50       180 return 0x7f if $val =~ /n\/a/i;
13423 114 100       244 return -128 if $val =~ /auto/i;
13424 111 50       157 return -127 if $val =~ /user/i; #28
13425 111         479 return 0;
13426             }
13427              
13428             #------------------------------------------------------------------------------
13429             # Convert unknown LensID values
13430             # Inputs: 0) value, 1) flag for inverse conversion, 2) PrintConv hash ref
13431             sub LensIDConv($$$)
13432             {
13433 0     0 0 0 my ($val, $inv, $conv) = @_;
13434 0 0       0 return undef if $inv;
13435             # multiple lenses with the same LensID are distinguished by decimal values
13436 0 0       0 if ($$conv{"$val.1"}) {
13437 0         0 my ($i, @vals, @user);
13438 0         0 for ($i=1; ; ++$i) {
13439 0 0       0 my $lens = $$conv{"$val.$i"} or last;
13440 0 0       0 if ($Image::ExifTool::userLens{$lens}) {
13441 0         0 push @user, $lens;
13442             } else {
13443 0         0 push @vals, $lens;
13444             }
13445             }
13446 0 0       0 return join(' or ', @user) if @user;
13447 0         0 return join(' or ', @vals);
13448             }
13449             # Sigma has been changing the LensIDNumber on some new lenses
13450             # and with some Sigma lenses the LensFStops changes! (argh!)
13451             # Also, older cameras my not set bits 4-7 of LensType
13452 0         0 my $pat = $val;
13453 0         0 $pat =~ s/^\w+ \w+/.. ../; # ignore LensIDNumber and LensFStops
13454 0         0 $pat =~ s/\w(\w)$/.$1/; # ignore bits 4-7 of LensType
13455 0         0 my @ids = sort grep /^$pat$/, keys %$conv;
13456 0 0       0 if (@ids) {
13457             # first try different LensFStops (2nd value)
13458 0         0 ($pat = $val) =~ s/ \w+/ ../;
13459 0         0 my @good = grep /^$pat$/, @ids;
13460 0 0       0 return $$conv{$good[0]} if @good;
13461             # then try different LensIDNumber (1st value)
13462 0         0 ($pat = $val) =~ s/^\w+/../;
13463 0         0 @good = grep /^$pat$/, @ids;
13464 0 0       0 return "Unknown ($val) $$conv{$good[0]} ?" if @good;
13465             # older cameras may not set bits 4-7 of LensType
13466 0         0 ($pat = $val) =~ s/\w(\w)$/.$1/;
13467 0         0 @good = grep /^$pat$/, @ids;
13468 0 0       0 return "Unknown ($val) $$conv{$good[0]} ?" if @good;
13469             }
13470 0         0 return undef;
13471             }
13472              
13473             #------------------------------------------------------------------------------
13474             # Clean up formatting of string values
13475             # Inputs: 0) string value, 1) ExifTool ref
13476             # Returns: formatted string value
13477             # - removes trailing spaces and changes case to something more sensible
13478             sub FormatString($$)
13479             {
13480 158     158 0 528 my ($str, $et) = @_;
13481             # limit string length (can be very long for some unknown tags)
13482 158         599 my $lim = $et->Options('LimitLongValues');
13483 158 50 33     564 if (length($str) > $lim and $lim >= 5) {
13484 0         0 $str = substr($str,0,$lim-5) . "[...]";
13485             } else {
13486 158         972 $str =~ s/\s+$//; # remove trailing white space
13487             # Don't change case of non-words (no vowels)
13488 158 100       692 if ($str =~ /[AEIOUY]/) {
13489             # change all letters but the first to lower case,
13490             # but only in words containing a vowel
13491 102 100       801 if ($str =~ s/\b([AEIOUY])([A-Z]+)/$1\L$2/g) {
13492 55         186 $str =~ s/\bAf\b/AF/; # patch for "AF"
13493             # patch for a number of models that write improper string
13494             # terminator for ImageStabilization (VR-OFF, VR-ON)
13495 55         140 $str =~ s/ +.$//s;
13496             }
13497 102 100       729 if ($str =~ s/\b([A-Z])([A-Z]*[AEIOUY][A-Z]*)/$1\L$2/g) {
13498 46         143 $str =~ s/\bRaw\b/RAW/; # patch for "RAW"
13499             }
13500             }
13501             }
13502 158         591 return $str;
13503             }
13504              
13505             #------------------------------------------------------------------------------
13506             # decoding tables from ref 4
13507             my @xlat = (
13508             [ 0xc1,0xbf,0x6d,0x0d,0x59,0xc5,0x13,0x9d,0x83,0x61,0x6b,0x4f,0xc7,0x7f,0x3d,0x3d,
13509             0x53,0x59,0xe3,0xc7,0xe9,0x2f,0x95,0xa7,0x95,0x1f,0xdf,0x7f,0x2b,0x29,0xc7,0x0d,
13510             0xdf,0x07,0xef,0x71,0x89,0x3d,0x13,0x3d,0x3b,0x13,0xfb,0x0d,0x89,0xc1,0x65,0x1f,
13511             0xb3,0x0d,0x6b,0x29,0xe3,0xfb,0xef,0xa3,0x6b,0x47,0x7f,0x95,0x35,0xa7,0x47,0x4f,
13512             0xc7,0xf1,0x59,0x95,0x35,0x11,0x29,0x61,0xf1,0x3d,0xb3,0x2b,0x0d,0x43,0x89,0xc1,
13513             0x9d,0x9d,0x89,0x65,0xf1,0xe9,0xdf,0xbf,0x3d,0x7f,0x53,0x97,0xe5,0xe9,0x95,0x17,
13514             0x1d,0x3d,0x8b,0xfb,0xc7,0xe3,0x67,0xa7,0x07,0xf1,0x71,0xa7,0x53,0xb5,0x29,0x89,
13515             0xe5,0x2b,0xa7,0x17,0x29,0xe9,0x4f,0xc5,0x65,0x6d,0x6b,0xef,0x0d,0x89,0x49,0x2f,
13516             0xb3,0x43,0x53,0x65,0x1d,0x49,0xa3,0x13,0x89,0x59,0xef,0x6b,0xef,0x65,0x1d,0x0b,
13517             0x59,0x13,0xe3,0x4f,0x9d,0xb3,0x29,0x43,0x2b,0x07,0x1d,0x95,0x59,0x59,0x47,0xfb,
13518             0xe5,0xe9,0x61,0x47,0x2f,0x35,0x7f,0x17,0x7f,0xef,0x7f,0x95,0x95,0x71,0xd3,0xa3,
13519             0x0b,0x71,0xa3,0xad,0x0b,0x3b,0xb5,0xfb,0xa3,0xbf,0x4f,0x83,0x1d,0xad,0xe9,0x2f,
13520             0x71,0x65,0xa3,0xe5,0x07,0x35,0x3d,0x0d,0xb5,0xe9,0xe5,0x47,0x3b,0x9d,0xef,0x35,
13521             0xa3,0xbf,0xb3,0xdf,0x53,0xd3,0x97,0x53,0x49,0x71,0x07,0x35,0x61,0x71,0x2f,0x43,
13522             0x2f,0x11,0xdf,0x17,0x97,0xfb,0x95,0x3b,0x7f,0x6b,0xd3,0x25,0xbf,0xad,0xc7,0xc5,
13523             0xc5,0xb5,0x8b,0xef,0x2f,0xd3,0x07,0x6b,0x25,0x49,0x95,0x25,0x49,0x6d,0x71,0xc7 ],
13524             [ 0xa7,0xbc,0xc9,0xad,0x91,0xdf,0x85,0xe5,0xd4,0x78,0xd5,0x17,0x46,0x7c,0x29,0x4c,
13525             0x4d,0x03,0xe9,0x25,0x68,0x11,0x86,0xb3,0xbd,0xf7,0x6f,0x61,0x22,0xa2,0x26,0x34,
13526             0x2a,0xbe,0x1e,0x46,0x14,0x68,0x9d,0x44,0x18,0xc2,0x40,0xf4,0x7e,0x5f,0x1b,0xad,
13527             0x0b,0x94,0xb6,0x67,0xb4,0x0b,0xe1,0xea,0x95,0x9c,0x66,0xdc,0xe7,0x5d,0x6c,0x05,
13528             0xda,0xd5,0xdf,0x7a,0xef,0xf6,0xdb,0x1f,0x82,0x4c,0xc0,0x68,0x47,0xa1,0xbd,0xee,
13529             0x39,0x50,0x56,0x4a,0xdd,0xdf,0xa5,0xf8,0xc6,0xda,0xca,0x90,0xca,0x01,0x42,0x9d,
13530             0x8b,0x0c,0x73,0x43,0x75,0x05,0x94,0xde,0x24,0xb3,0x80,0x34,0xe5,0x2c,0xdc,0x9b,
13531             0x3f,0xca,0x33,0x45,0xd0,0xdb,0x5f,0xf5,0x52,0xc3,0x21,0xda,0xe2,0x22,0x72,0x6b,
13532             0x3e,0xd0,0x5b,0xa8,0x87,0x8c,0x06,0x5d,0x0f,0xdd,0x09,0x19,0x93,0xd0,0xb9,0xfc,
13533             0x8b,0x0f,0x84,0x60,0x33,0x1c,0x9b,0x45,0xf1,0xf0,0xa3,0x94,0x3a,0x12,0x77,0x33,
13534             0x4d,0x44,0x78,0x28,0x3c,0x9e,0xfd,0x65,0x57,0x16,0x94,0x6b,0xfb,0x59,0xd0,0xc8,
13535             0x22,0x36,0xdb,0xd2,0x63,0x98,0x43,0xa1,0x04,0x87,0x86,0xf7,0xa6,0x26,0xbb,0xd6,
13536             0x59,0x4d,0xbf,0x6a,0x2e,0xaa,0x2b,0xef,0xe6,0x78,0xb6,0x4e,0xe0,0x2f,0xdc,0x7c,
13537             0xbe,0x57,0x19,0x32,0x7e,0x2a,0xd0,0xb8,0xba,0x29,0x00,0x3c,0x52,0x7d,0xa8,0x49,
13538             0x3b,0x2d,0xeb,0x25,0x49,0xfa,0xa3,0xaa,0x39,0xa7,0xc5,0xa7,0x50,0x11,0x36,0xfb,
13539             0xc6,0x67,0x4a,0xf5,0xa5,0x12,0x65,0x7e,0xb0,0xdf,0xaf,0x4e,0xb3,0x61,0x7f,0x2f ]
13540             );
13541              
13542             my ($ci0, $cj0, $ck0, $decryptStart); # decryption parameters
13543              
13544             # Decrypt Nikon data block (ref 4)
13545             # Inputs: 0) reference to data block, 1) optional start offset (default 0)
13546             # 2) optional number of bytes to decode (default to the end of the data)
13547             # 3) optional serial number key (undef to continue previous decryption)
13548             # 4) optional shutter count key
13549             # Returns: data block with specified data decrypted
13550             # Notes: The first time this is called for a given encrypted data block the serial/count
13551             # keys must be defined, and $start must be the offset for initialization of the
13552             # decryption parameters (ie. the beginning of the encrypted data, which isn't
13553             # necessarily inside the data block if $len is zero). Subsequent calls for
13554             # the same data block do not specify the serial/count keys, and may be used
13555             # to decrypt data at any start point within the full data block.
13556             sub Decrypt($;$$$$)
13557             {
13558 5     5 0 36 my ($dataPt, $start, $len, $serial, $count) = @_;
13559 5         10 my ($ch, $cj, $ck);
13560              
13561 5 100       13 $start or $start = 0;
13562 5         10 my $maxLen = length($$dataPt) - $start;
13563 5 100 66     22 $len = $maxLen if not defined $len or $len > $maxLen;
13564 5 100 66     23 if (defined $serial and defined $count) {
13565             # initialize decryption parameters
13566 4         9 my $key = 0;
13567 4         25 $key ^= ($count >> ($_*8)) & 0xff foreach 0..3;
13568 4         19 $ci0 = $xlat[0][$serial & 0xff];
13569 4         10 $cj0 = $xlat[1][$key];
13570 4         7 $ck0 = 0x60;
13571 4         7 undef $decryptStart;
13572             }
13573 5 100       14 if (defined $decryptStart) {
13574             # initialize decryption parameters for this start position
13575 1         2 my $n = $start - $decryptStart;
13576 1         4 $cj = ($cj0 + $ci0 * ($n * $ck0 + ($n * ($n - 1))/2)) & 0xff;
13577 1         2 $ck = ($ck0 + $n) & 0xff;
13578             } else {
13579 4         7 $decryptStart = $start;
13580 4         11 ($cj, $ck) = ($cj0, $ck0);
13581             }
13582 5 100       15 return $$dataPt if $len <= 0;
13583 4         72 my @data = unpack('C*', substr($$dataPt, $start, $len));
13584 4         12 foreach $ch (@data) {
13585 616         596 $cj = ($cj + $ci0 * $ck) & 0xff;
13586 616         646 $ck = ($ck + 1) & 0xff;
13587 616         626 $ch ^= $cj;
13588             }
13589 4         54 return substr($$dataPt, 0, $start) . pack('C*', @data) . substr($$dataPt, $start+$len);
13590             }
13591              
13592             #------------------------------------------------------------------------------
13593             # Get serial number for use as a decryption key
13594             # Inputs: 0) ExifTool object ref, 1) serial number string
13595             # Returns: serial key integer or undef if no serial number provided
13596             sub SerialKey($$)
13597             {
13598 32     32 0 92 my ($et, $serial) = @_;
13599             # use serial number as key if integral
13600 32 50 66     401 return $serial if not defined $serial or $serial =~ /^\d+$/;
13601 0 0       0 return 0x22 if $$et{Model} =~ /\bD50$/; # D50 (ref 8)
13602 0         0 return 0x60; # D200 (ref 10), D40X (ref PH), etc
13603             }
13604              
13605             #------------------------------------------------------------------------------
13606             # Extract information from "NIKON APP" trailer (ref PH)
13607             # Inputs: 0) ExifTool ref, 1) Optional dirInfo ref for returning trailer info
13608             # Returns: true on success
13609             sub ProcessNikonApp($;$)
13610             {
13611 0     0 0 0 local $_;
13612 0         0 my ($et, $dirInfo) = @_;
13613 0         0 my $raf = $$et{RAF};
13614 0 0 0     0 my $offset = $dirInfo ? $$dirInfo{Offset} || 0 : 0;
13615 0         0 my $buff;
13616              
13617 0 0 0     0 return 0 unless $raf->Seek(-20-$offset, 2) and $raf->Read($buff, 20) == 20 and
      0        
13618             substr($buff,-16) eq "\0\0\0\0\0\0/NIKON APP"; # check magic number
13619              
13620 0         0 my $verbose = $et->Options('Verbose');
13621 0         0 my $fileEnd = $raf->Tell();
13622 0         0 my $trailerLen = unpack('N', $buff);
13623 0 0       0 $trailerLen > $fileEnd and $et->Warn('Bad NikonApp trailer size'), return 0;
13624 0 0       0 if ($dirInfo) {
13625 0         0 $$dirInfo{DirLen} = $trailerLen;
13626 0         0 $$dirInfo{DataPos} = $fileEnd - $trailerLen;
13627 0 0       0 if ($$dirInfo{OutFile}) {
13628 0 0 0     0 if ($$et{DEL_GROUP}{NikonApp}) {
    0 0        
13629 0         0 $et->VPrint(0, " Deleting NikonApp trailer ($trailerLen bytes)\n");
13630 0         0 ++$$et{CHANGED};
13631             # just copy the trailer when writing (read directly into output buffer)
13632             } elsif ($trailerLen > $fileEnd or not $raf->Seek($$dirInfo{DataPos}, 0) or
13633 0         0 $raf->Read(${$$dirInfo{OutFile}}, $trailerLen) != $trailerLen)
13634             {
13635 0         0 return 0;
13636             }
13637 0         0 return 1;
13638             }
13639 0 0 0     0 $et->DumpTrailer($dirInfo) if $verbose or $$et{HTML_DUMP};
13640             }
13641 0 0 0     0 unless ($trailerLen >= 0x40 and $raf->Seek($fileEnd - $trailerLen, 0) and
      0        
      0        
13642             $raf->Read($buff, 0x40) == 0x40 and $buff =~ m(NIKON APP\0))
13643             {
13644 0         0 $et->Warn('Error reading NikonApp trailer');
13645 0         0 return 0;
13646             }
13647 0         0 $$et{SET_GROUP0} = 'NikonApp';
13648 0         0 while ($raf->Read($buff, 8) == 8) {
13649 0         0 my ($id, $len) = unpack('N2', $buff);
13650 0 0       0 if ($len & 0x80000000) {
13651 0         0 $et->Warn('Invalid NikonApp record length');
13652 0         0 last;
13653             }
13654 0 0 0     0 last if $id == 0 and $len == 0;
13655 0 0       0 unless ($raf->Read($buff, $len) == $len) {
13656 0         0 $et->Warn('Truncated NikonApp record');
13657 0         0 last;
13658             }
13659 0 0       0 if ($id == 1) {
13660 0         0 require Image::ExifTool::XMP;
13661 0         0 Image::ExifTool::XMP::ProcessXMP($et, { DataPt => \$buff });
13662             } else { # (haven't seen any other types of records)
13663 0         0 $et->Warn("Unknown NikonApp record $id");
13664 0         0 last;
13665             }
13666             }
13667 0         0 delete $$et{SET_GROUP0};
13668 0         0 return 1;
13669             }
13670              
13671             #------------------------------------------------------------------------------
13672             # Read Nikon NCTG tags in MOV videos
13673             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
13674             # Returns: 1 on success
13675             sub ProcessNikonMOV($$$)
13676             {
13677 0     0 0 0 my ($et, $dirInfo, $tagTablePtr) = @_;
13678 0         0 my $dataPt = $$dirInfo{DataPt};
13679 0         0 my $dataPos = $$dirInfo{DataPos};
13680 0         0 my %needTags = ( 0x110a431 => 0, 0x20000a7 => undef ); # needed for decryption
13681 0         0 $et->VerboseDir($$dirInfo{DirName}, 0, $$dirInfo{DirLen});
13682 0         0 my $pass;
13683             # do two passes so we can pre-scan for necessary decryption keys
13684 0         0 for ($pass=0; $pass<2; ++$pass) {
13685 0         0 my $pos = $$dirInfo{DirStart};
13686 0         0 my $end = $pos + $$dirInfo{DirLen};
13687 0         0 while ($pos + 8 < $end) {
13688 0         0 my $tag = Get32u($dataPt, $pos);
13689 0         0 my $fmt = Get16u($dataPt, $pos + 4); # (same format code as EXIF)
13690 0         0 my $count = Get16u($dataPt, $pos + 6);
13691 0         0 $pos += 8;
13692 0         0 my $fmtStr = $Image::ExifTool::Exif::formatName[$fmt];
13693 0 0       0 unless ($fmtStr) {
13694 0 0       0 $et->Warn(sprintf("Unknown format ($fmt) for $$dirInfo{DirName} tag 0x%x",$tag)) if $pass;
13695 0         0 last;
13696             }
13697 0         0 my $size = $count * $Image::ExifTool::Exif::formatSize[$fmt];
13698 0 0       0 if ($pos + $size > $end) {
13699 0 0       0 $et->Warn(sprintf("Truncated data for $$dirInfo{DirName} tag 0x%x",$tag)) if $pass;
13700 0         0 last;
13701             }
13702 0 0       0 if ($pass) {
    0          
13703 0         0 my $rational;
13704 0         0 my $val = ReadValue($dataPt, $pos, $fmtStr, $count, $size, \$rational);
13705             my $key = $et->HandleTag($tagTablePtr, $tag, $val,
13706             DataPt => $dataPt,
13707             DataPos => $dataPos,
13708             Format => $fmtStr,
13709             Start => $pos,
13710             Size => $size,
13711             Base => $$dirInfo{Base},
13712 0         0 );
13713 0 0       0 if ($key) {
13714 0 0       0 $$et{TAG_EXTRA}{$key}{Rational} = $rational if $rational;
13715 0 0       0 $$et{TAG_EXTRA}{$key}{BinVal} = substr($$dataPt, $pos, $size) if $$et{OPTIONS}{SaveBin};
13716             }
13717             } elsif (exists $needTags{$tag}) {
13718 0         0 $needTags{$tag} = ReadValue($dataPt, $pos, $fmtStr, $count, $size);
13719 0         0 $$et{NikonSerialKey} = SerialKey($et, $needTags{0x110a431});
13720 0         0 $$et{NikonCountKey} = $needTags{0x20000a7};
13721             }
13722 0         0 $pos += $size; # is this padded to an even offset????
13723             }
13724             }
13725 0         0 return 1;
13726             }
13727              
13728             #------------------------------------------------------------------------------
13729             # Get offset of end-of-data for a tag
13730             # Inputs: 0) tag table ref, 1) tag ID, 2) true to not calculate end for a SubDirectory
13731             # Returns: offset of tag value end, undef if it can't be determined
13732             sub GetTagEnd($$;$)
13733             {
13734 3     3 0 6 my ($tagTablePtr, $tagID, $ignoreSubdir) = @_;
13735 3         4 my $tagInfo = $$tagTablePtr{$tagID};
13736 3 50       7 $tagInfo = $$tagInfo[0] if ref $tagInfo eq 'ARRAY';
13737             # (can't pre-determine position of offset-based subdirectories)
13738 3 0 33     8 return undef if $ignoreSubdir and $$tagInfo{SubDirectory};
13739 3   50     18 my $fmt = $$tagInfo{Format} || $$tagTablePtr{FORMAT} || 'int8u';
13740 3 100       15 my $nm = $fmt =~ s/\[(\d+)\]$// ? $1 : 1;
13741 3 50       9 my $sz = Image::ExifTool::FormatSize($fmt) or return undef;
13742 3         11 return int($tagID) + $sz * $nm;
13743             }
13744              
13745             #------------------------------------------------------------------------------
13746             # Initialize SubDirectory KnownStart/KnownEnd limits of known tags (used in decryption)
13747             # Inputs: 0) tagInfo ref containing this SubDirectory, 2) tag table ref for encrypted subdir
13748             # Notes: KnownStart/KnownEnd are relative to the SubDirectory Start. If KnownStart/KnownEnd
13749             # aren't set then the entire data is decrypted, so all of this effort is just for speed.
13750             sub InitEncryptedSubdir($$)
13751             {
13752 3     3 0 6 my ($tagInfo, $tagTablePtr) = @_;
13753             #
13754             # for encrypted NIKON_OFFSETS tables we loop through all SubDirectory tags in this table
13755             # and set the KnownEnd for each of these according to the last tag in the child tables
13756             #
13757 3         6 my $vars = $$tagTablePtr{VARS};
13758 3 50       12 $vars or $vars = $$tagTablePtr{VARS} = { };
13759 3 50 33     10 if ($$vars{NIKON_OFFSETS} and not $$vars{NIKON_INITIALIZED}) {
13760 0         0 $$vars{NIKON_INITIALIZED} = 1;
13761 0         0 my $tagID;
13762 0         0 foreach $tagID (TagTableKeys($tagTablePtr)) {
13763 0         0 my $tagInfo = $$tagTablePtr{$tagID};
13764 0 0       0 next unless ref $tagInfo eq 'HASH';
13765 0 0       0 my $subdir = $$tagInfo{SubDirectory} or next;
13766 0         0 my $tbl = GetTagTable($$subdir{TagTable});
13767 0         0 my ($last) = sort { $b <=> $a } TagTableKeys($tbl); # (reverse sort)
  0         0  
13768 0         0 $$subdir{KnownEnd} = GetTagEnd($tbl, $last, 1);
13769             }
13770             }
13771             #
13772             # for other encrypted Nikon tables we set the KnownStart/KnownEnd entries in the
13773             # SubDirectory of the parent tag
13774             #
13775 3 50       9 unless ($$tagInfo{NikonInitialized}) {
13776 3         11 $$tagInfo{NikonInitialized} = 1;
13777 3         6 my $subdir = $$tagInfo{SubDirectory};
13778 3   50     9 my $start = $$subdir{DecryptStart} || 0;
13779 3         6 my $off = $$subdir{DirOffset};
13780 3         10 my @tagIDs = sort { $a <=> $b } TagTableKeys($tagTablePtr);
  67         75  
13781 3 100       9 if (defined $off) {
13782 1         3 $off += $start; # (DirOffset, if specified, is relative to DecryptStart)
13783             } else {
13784             # ignore tags that come before the start of encryption
13785 2   66     15 shift @tagIDs while @tagIDs and $tagIDs[0] < $start;
13786 2         3 $off = 0;
13787             }
13788 3 50       6 if (@tagIDs) {
13789 3         9 my ($first, $last) = @tagIDs[0,-1];
13790 3         4 my $lastInfo = $$tagTablePtr{$last};
13791 3 50       9 $lastInfo = $$lastInfo[0] if ref $lastInfo eq 'ARRAY';
13792 3 100       10 $$subdir{KnownStart} = int($first) + $off if $first + $off > $start;
13793 3         10 $$subdir{KnownEnd} = GetTagEnd($tagTablePtr, $last);
13794 3 50       9 if (defined $$subdir{KnownEnd}) {
13795 3         7 $$subdir{KnownEnd} += $off;
13796             } else {
13797 0         0 warn "Internal error setting KnownEnd for $$tagTablePtr{SHORT_NAME}\n";
13798             }
13799             } else {
13800 0         0 $$subdir{KnownStart} = $$subdir{KnownEnd} = $start;
13801             }
13802             }
13803             }
13804              
13805             #------------------------------------------------------------------------------
13806             # Prepare to process NIKON_OFFSETS directory and decrypt necessary data
13807             # Inputs: 0) ExifTool ref, 1) data ref, 2) tag table ref, 3) decrypt start,
13808             # 4) decrypt mode (0=piecewise, 1=continuous to end of last known section, 2=all)
13809             # Returns: end of decrypted data (or undef for piecewise decryption)
13810             sub PrepareNikonOffsets($$$$$)
13811             {
13812 0     0 0 0 my ($et, $dataPt, $tagTablePtr, $start, $decryptMode) = @_;
13813 0         0 my $offset = $$tagTablePtr{VARS}{NIKON_OFFSETS};
13814 0         0 my $dataLen = length $$dataPt;
13815 0 0 0     0 return undef if $offset + 4 > $dataLen or $offset < $start;
13816 0         0 my $serial = $$et{NikonSerialKey};
13817 0         0 my $count = $$et{NikonCountKey};
13818 0         0 my $dpos = $offset + 4; # decrypt up to NumberOffsets
13819 0         0 $$dataPt = Decrypt($dataPt, $start, $dpos - $start, $serial, $count);
13820 0         0 my $numOffsets = Get32u($dataPt, $offset);
13821 0         0 my $more = $numOffsets * 4; # more bytes to decrypt entire offsets table
13822 0 0       0 return undef if $offset + 4 + $more > $dataLen;
13823 0         0 $$dataPt = Decrypt($dataPt, $dpos, $more);
13824 0         0 $dpos += $more;
13825 0         0 my $unknown = $et->Options('Unknown');
13826 0         0 my ($i, @offInfo, $end);
13827             # extract non-zero offsets and create unknown subdirectories if Unknown > 1
13828 0         0 for ($i=0; $i<$numOffsets; ++$i) {
13829 0         0 my $pos = $offset + 4 + 4 * $i;
13830 0 0       0 my $off = Get32u($dataPt, $pos) or next;
13831 0         0 my $tagInfo = $$tagTablePtr{$pos};
13832 0         0 my $known = 0;
13833 0 0       0 if ($tagInfo) {
    0          
13834 0 0 0     0 $known = 1 if ref $tagInfo ne 'HASH' or not $$tagInfo{Unknown};
13835             } elsif ($unknown > 1) {
13836             # create new table for unknown information
13837 0         0 my $tbl = sprintf('Image::ExifTool::Nikon::UnknownInfo%.2x', $pos);
13838 29     29   474 no strict 'refs';
  29         102  
  29         175517  
13839 0 0       0 unless (%$tbl) {
13840 0         0 %$tbl = ( %binaryDataAttrs, GROUPS => { 0=>'MakerNotes', 2=>'Unknown' } );
13841 0         0 GetTagTable($tbl);
13842             }
13843             # add unknown entry in offset table for this subdirectory
13844 0         0 $tagInfo = AddTagToTable($tagTablePtr, $pos, {
13845             Name => sprintf('UnknownOffset%.2x', $pos),
13846             Format => 'int32u',
13847             SubDirectory => { TagTable => $tbl },
13848             Unknown => 2,
13849             });
13850             }
13851 0         0 push @offInfo, [ $pos, $off, $known ]; # save parameters for non-zero offsets
13852             }
13853             # sort offsets in ascending order, and use the differences to calculate
13854             # directory lengths and update the SubDirectory DirLen's accordingly
13855 0 0       0 my @sorted = sort { $$a[1] <=> $$b[1] or $$a[0] <=> $$b[0] } @offInfo;
  0         0  
13856 0         0 push @sorted, [ 0, length($$dataPt), 0 ];
13857 0         0 for ($i=0; $i<@sorted-1; ++$i) {
13858 0         0 my $pos = $sorted[$i][0];
13859 0         0 my $len = $sorted[$i+1][1] - $sorted[$i][1];
13860 0         0 my $tagInfo = $$tagTablePtr{$pos};
13861             $tagInfo = $et->GetTagInfo($tagTablePtr, $pos) if $tagInfo and
13862 0 0 0     0 not (ref $tagInfo eq 'HASH' and $$tagInfo{AlwaysDecrypt});
      0        
13863             # set DirLen in SubDirectory entry
13864 0         0 my $subdir;
13865 0 0 0     0 $$subdir{DirLen} = $len if ref $tagInfo eq 'HASH' and defined($subdir=$$tagInfo{SubDirectory});
13866 0 0 0     0 if ($decryptMode) {
    0 0        
13867             # keep track of end of last known directory
13868 0 0       0 $end = $sorted[$i+1][1] if $sorted[$i][2];
13869             } elsif ($tagInfo and (ref $tagInfo ne 'HASH' or not $$tagInfo{Unknown})) {
13870             # decrypt data piecewise as necessary
13871 0         0 my $n = $len;
13872 0 0 0     0 if ($subdir and $$subdir{KnownEnd}) {
13873 0         0 $n = $$subdir{KnownEnd};
13874 0 0       0 if ($n > $len) {
13875 0 0       0 $et->Warn("Data too short for $$tagInfo{Name}",1) unless $$tagInfo{AlwaysDecrypt};
13876 0         0 $n = $len;
13877             }
13878             }
13879 0         0 $$dataPt = Decrypt($dataPt, $sorted[$i][1], $n);
13880             }
13881             }
13882 0 0       0 if ($decryptMode) {
13883             # decrypt the remaining required data
13884 0 0 0     0 $end = length $$dataPt if $decryptMode == 2 or not $end or $end < $dpos;
      0        
13885 0         0 $$dataPt = Decrypt($dataPt, $dpos, $end - $dpos);
13886             }
13887 0         0 return $end;
13888             }
13889              
13890             #------------------------------------------------------------------------------
13891             # Read/Write Nikon Encrypted data block
13892             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
13893             # Returns: 1 on success when reading, or new directory when writing (IsWriting set)
13894             sub ProcessNikonEncrypted($$$)
13895             {
13896 122     122 0 339 my ($et, $dirInfo, $tagTablePtr) = @_;
13897 122 100       568 $et or return 1; # allow dummy access
13898 3         8 my $serial = $$et{NikonSerialKey};
13899 3         6 my $count = $$et{NikonCountKey};
13900 3 50 33     61 unless (defined $serial and defined $count and $serial =~ /^\d+$/ and $count =~ /^\d+$/) {
      33        
      33        
13901 0 0 0     0 if (defined $serial or defined $count) {
13902 0         0 my $msg;
13903 0 0 0     0 if (defined $serial and defined $count) {
13904 0 0       0 $msg = $serial =~ /^\d+$/ ? 'invalid ShutterCount' : 'invalid SerialNumber';
13905             } else {
13906 0 0       0 $msg = defined $serial ? 'no ShutterCount' : 'no SerialNumber';
13907             }
13908 0         0 $et->Warn("Can't decrypt Nikon information ($msg key)");
13909             }
13910 0         0 delete $$et{NikonSerialKey};
13911 0         0 delete $$et{NikonCountKey};
13912 0         0 return 0;
13913             }
13914 3         7 my $oldOrder = GetByteOrder();
13915 3         7 my $isWriting = $$dirInfo{IsWriting};
13916 3 50       12 my $verbose = $isWriting ? 0 : $et->Options('Verbose');
13917 3         6 my $tagInfo = $$dirInfo{TagInfo};
13918 3         6 my $dirStart = $$dirInfo{DirStart};
13919 3         7 my $data = substr(${$$dirInfo{DataPt}}, $dirStart, $$dirInfo{DirLen});
  3         10  
13920              
13921 3         9 my ($start, $len, $offset, $recrypt, $newSerial, $newCount, $didDecrypt);
13922              
13923             # must re-encrypt when writing if serial number or shutter count changes
13924 3 50       9 if ($isWriting) {
13925 0 0       0 if ($$et{NewNikonSerialKey}) {
13926 0         0 $newSerial = $$et{NewNikonSerialKey};
13927 0         0 $recrypt = 1;
13928             }
13929 0 0       0 if ($$et{NewNikonCountKey}) {
13930 0         0 $newCount = $$et{NewNikonCountKey};
13931 0         0 $recrypt = 1;
13932             }
13933             }
13934 3 50 33     16 if ($tagInfo and $$tagInfo{SubDirectory}) {
13935             # initialize SubDirectory entries used in encryption (KnownStart, KnownEnd)
13936 3         11 InitEncryptedSubdir($tagInfo, $tagTablePtr);
13937 3         6 my $subdir = $$tagInfo{SubDirectory};
13938 3   50     9 $start = $$subdir{DecryptStart} || 0;
13939             # DirOffset, if specified, is the offset to the start of the
13940             # directory relative to start of encrypted data
13941 3 100       9 $offset = defined $$subdir{DirOffset} ? $$subdir{DirOffset} + $start : 0;
13942             # must set byte ordering before calling PrepareNikonOffsets()
13943 3 100       10 SetByteOrder($$subdir{ByteOrder}) if $$subdir{ByteOrder};
13944             # prepare for processing NIKON_OFFSETS directory if necessary
13945 3   33     18 my $unknown = $verbose > 2 || $et->Options('Unknown') > 1;
13946             # decrypt mode: 0=piecewise, 1=continuous to end of last known section, 2=all
13947 3 0       12 my $dMode = $isWriting ? ($recrypt ? 2 : 1) : ($unknown ? 2 : 0);
    50          
    50          
13948 3 50       15 if ($$tagTablePtr{VARS}{NIKON_OFFSETS}) {
    50          
13949 0         0 $len = PrepareNikonOffsets($et, \$data, $tagTablePtr, $start, $dMode);
13950 0         0 $didDecrypt = 1;
13951             } elsif ($dMode < 2) {
13952 3 100 66     16 if ($dMode == 0 and $$subdir{KnownStart}) {
13953             # initialize decryption parameters for address DecryptStart address
13954 1         5 Decrypt(\$data, $start, 0, $serial, $count);
13955             # reset serial/count keys so we don't re-initialize below
13956 1         2 undef $serial;
13957 1         2 undef $count;
13958             # change decryption start to skip unnecessary data
13959 1         4 $start = $$subdir{KnownStart};
13960             }
13961 3 50       13 $len = $$subdir{KnownEnd} - $start if $$subdir{KnownEnd};
13962             }
13963             } else {
13964 0         0 $start = $offset = 0;
13965             }
13966 3         10 my $maxLen = length($data) - $start;
13967             # decrypt all the data unless the length was specified
13968 3 50 33     21 $len = $maxLen unless $len and $len < $maxLen;
13969              
13970 3 50       15 $data = Decrypt(\$data, $start, $len, $serial, $count) unless $didDecrypt;
13971              
13972 3 50       9 if ($verbose > 2) {
13973 0         0 $et->VerboseDir("Decrypted $$tagInfo{Name}");
13974             $et->VerboseDump(\$data,
13975 0         0 Prefix => $$et{INDENT} . ' ',
13976             # (remove this because it is useful to have decrypted offsets start at 0)
13977             #DataPos => $dirStart + $$dirInfo{DataPos} + ($$dirInfo{Base} || 0),
13978             );
13979             }
13980             # process the decrypted information
13981             my %subdirInfo = (
13982             DataPt => \$data,
13983             DirStart => $offset,
13984             DirLen => length($data) - $offset,
13985             DirName => $$dirInfo{DirName},
13986             DataPos => $$dirInfo{DataPos} + $dirStart,
13987             Base => $$dirInfo{Base},
13988 3         23 );
13989 3         4 my $rtnVal;
13990 3 50       9 if ($isWriting) {
13991 0         0 my $changed = $$et{CHANGED};
13992 0         0 $rtnVal = $et->WriteBinaryData(\%subdirInfo, $tagTablePtr);
13993             # must re-encrypt if serial number or shutter count changes
13994 0 0       0 if ($recrypt) {
13995 0 0       0 $serial = $newSerial if defined $newSerial;
13996 0 0       0 $count = $newCount if defined $newCount;
13997 0         0 ++$$et{CHANGED};
13998             }
13999 0 0       0 if ($changed == $$et{CHANGED}) {
14000 0         0 undef $rtnVal; # nothing changed so use original data
14001             } else {
14002             # add back any un-encrypted data at start
14003 0 0       0 $rtnVal = substr($data, 0, $offset) . $rtnVal if $offset;
14004             # re-encrypt data (symmetrical algorithm)
14005 0         0 $rtnVal = Decrypt(\$rtnVal, $start, $len, $serial, $count);
14006 0         0 $et->VPrint(2, $$et{INDENT}, " [recrypted $$tagInfo{Name}]");
14007             }
14008             } else {
14009 3         13 $rtnVal = $et->ProcessBinaryData(\%subdirInfo, $tagTablePtr);
14010             }
14011 3         12 SetByteOrder($oldOrder);
14012 3         15 return $rtnVal;
14013             }
14014              
14015             #------------------------------------------------------------------------------
14016             # Pre-scan EXIF directory to extract specific tags
14017             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) required tagID hash ref
14018             # Returns: 1 if directory was scanned successfully
14019             sub PrescanExif($$$)
14020             {
14021 24     24 0 63 my ($et, $dirInfo, $tagHash) = @_;
14022 24         85 my $dataPt = $$dirInfo{DataPt};
14023 24   100     130 my $dataPos = $$dirInfo{DataPos} || 0;
14024 24         68 my $dataLen = $$dirInfo{DataLen};
14025 24   50     99 my $dirStart = $$dirInfo{DirStart} || 0;
14026 24   50     141 my $base = $$dirInfo{Base} || 0;
14027 24         65 my $raf = $$dirInfo{RAF};
14028 24         60 my ($index, $numEntries, $data, $buff);
14029              
14030             # get number of entries in IFD
14031 24 50 33     154 if ($dirStart >= 0 and $dirStart <= $dataLen-2) {
14032 24         102 $numEntries = Get16u($dataPt, $dirStart);
14033             # reset $numEntries to read from file if necessary
14034 24 50       109 undef $numEntries if $dirStart + 2 + 12 * $numEntries > $dataLen;
14035             }
14036             # read IFD from file if necessary
14037 24 50       92 unless ($numEntries) {
14038 0 0       0 $raf or return 0;
14039 0         0 $dataPos += $dirStart; # read data from the start of the directory
14040 0 0 0     0 $raf->Seek($dataPos + $base, 0) and $raf->Read($data, 2) == 2 or return 0;
14041 0         0 $numEntries = Get16u(\$data, 0);
14042 0         0 my $len = 12 * $numEntries;
14043 0 0       0 $raf->Read($buff, $len) == $len or return 0;
14044 0         0 $data .= $buff;
14045             # update variables for the newly loaded IFD (already updated dataPos)
14046 0         0 $dataPt = \$data;
14047 0         0 $dataLen = length $data;
14048 0         0 $dirStart = 0;
14049             }
14050             # loop through Nikon MakerNote IFD entries
14051 24         100 for ($index=0; $index<$numEntries; ++$index) {
14052 597         858 my $entry = $dirStart + 2 + 12 * $index;
14053 597         1047 my $tagID = Get16u($dataPt, $entry);
14054 597 100       1715 next unless exists $$tagHash{$tagID}; # only extract required tags
14055 8         25 my $format = Get16u($dataPt, $entry+2);
14056 8 50 33     56 next if $format < 1 or $format > 13;
14057 8         30 my $count = Get32u($dataPt, $entry+4);
14058 8         27 my $size = $count * $Image::ExifTool::Exif::formatSize[$format];
14059 8         23 my $formatStr = $Image::ExifTool::Exif::formatName[$format];
14060 8         17 my $valuePtr = $entry + 8; # pointer to value within $$dataPt
14061 8 100       27 if ($size > 4) {
14062 1 50       3 next if $size > 0x1000000; # set a reasonable limit on data size (16MB)
14063 1         3 $valuePtr = Get32u($dataPt, $valuePtr);
14064             # convert offset to pointer in $$dataPt
14065             # (don't yet handle EntryBased or FixOffsets)
14066 1         3 $valuePtr -= $dataPos;
14067 1 50 33     7 if ($valuePtr < 0 or $valuePtr+$size > $dataLen) {
14068 0 0 0     0 next unless $raf and $raf->Seek($base + $valuePtr + $dataPos,0) and
      0        
14069             $raf->Read($buff,$size) == $size;
14070 0         0 $$tagHash{$tagID} = ReadValue(\$buff,0,$formatStr,$count,$size);
14071 0         0 next;
14072             }
14073             }
14074 8         35 $$tagHash{$tagID} = ReadValue($dataPt,$valuePtr,$formatStr,$count,$size);
14075             }
14076 24         86 return 1;
14077             }
14078              
14079             #------------------------------------------------------------------------------
14080             # Process Nikon Capture history data
14081             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
14082             # Returns: 1 on success
14083             sub ProcessNikonCaptureEditVersions($$$)
14084             {
14085 0     0 0 0 my ($et, $dirInfo, $tagTablePtr) = @_;
14086 0         0 require Image::ExifTool::NikonCapture;
14087 0         0 return Image::ExifTool::NikonCapture::ProcessNikonCaptureEditVersions($et, $dirInfo, $tagTablePtr);
14088             }
14089              
14090             #------------------------------------------------------------------------------
14091             # Process Nikon Capture Offsets IFD (ref PH)
14092             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
14093             # Returns: 1 on success
14094             # Notes: This isn't a normal IFD, but is close...
14095             sub ProcessNikonCaptureOffsets($$$)
14096             {
14097 2     2 0 7 my ($et, $dirInfo, $tagTablePtr) = @_;
14098 2         6 my $dataPt = $$dirInfo{DataPt};
14099 2         6 my $dirStart = $$dirInfo{DirStart};
14100 2         5 my $dirLen = $$dirInfo{DirLen};
14101 2         3 my $success = 0;
14102 2 50       10 return 0 unless $dirLen > 2;
14103 2         35 my $count = Get16u($dataPt, $dirStart);
14104 2 50 33     17 return 0 unless $count and $count * 12 + 2 <= $dirLen;
14105 2 50       11 if ($et->Options('Verbose')) {
14106 0         0 $et->VerboseDir('NikonCaptureOffsets', $count);
14107             }
14108 2         5 my $index;
14109 2         11 for ($index=0; $index<$count; ++$index) {
14110 6         13 my $pos = $dirStart + 12 * $index + 2;
14111 6         22 my $tagID = Get32u($dataPt, $pos);
14112 6         31 my $value = Get32u($dataPt, $pos + 4);
14113 6 50       24 $et->HandleTag($tagTablePtr, $tagID, $value,
14114             Index => $index,
14115             DataPt => $dataPt,
14116             Start => $pos,
14117             Size => 12,
14118             ) and $success = 1;
14119             }
14120 2         9 return $success;
14121             }
14122              
14123             #------------------------------------------------------------------------------
14124             # Read Nikon NKA file
14125             # Inputs: 0) ExifTool ref, 1) dirInfo ref
14126             # Returns: 1 on success
14127             sub ProcessNKA($$)
14128             {
14129 0     0 0 0 my ($et, $dirInfo) = @_;
14130 0         0 my $raf = $$et{RAF};
14131 0         0 my $buff;
14132 0 0       0 $raf->Read($buff, 0x35) == 0x35 or return 0;
14133 0         0 my $len = unpack('x49V', $buff);
14134 0 0       0 $raf->Read($buff, $len) == $len or return 0;
14135 0         0 $et->SetFileType('NKA', 'application/x-nikon-nxstudio');
14136 0         0 my %dirInfo = ( DataPt => \$buff, DataPos => 0x35 );
14137 0         0 my $tagTablePtr = GetTagTable('Image::ExifTool::XMP::XML');
14138 0         0 return $et->ProcessDirectory(\%dirInfo, $tagTablePtr);
14139             }
14140              
14141             #------------------------------------------------------------------------------
14142             # Read/write Nikon MakerNotes directory
14143             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
14144             # Returns: 1 on success, otherwise returns 0 and sets a Warning when reading
14145             # or new directory when writing (IsWriting set in dirInfo)
14146             sub ProcessNikon($$$)
14147             {
14148 326     326 0 1037 my ($et, $dirInfo, $tagTablePtr) = @_;
14149 326 100       1717 $et or return 1; # allow dummy access
14150              
14151             # pre-scan IFD to get SerialNumber (0x001d) and ShutterCount (0x00a7) for use in decryption
14152 24         136 my %needTags = ( 0x001d => 0, 0x00a7 => undef );
14153 24         146 PrescanExif($et, $dirInfo, \%needTags);
14154 24         144 $$et{NikonSerialKey} = SerialKey($et, $needTags{0x001d});
14155 24         98 $$et{NikonCountKey} = $needTags{0x00a7};
14156              
14157             # process Nikon makernotes
14158 24         53 my $rtnVal;
14159 24 100       99 if ($$dirInfo{IsWriting}) {
14160             # get new decryptino keys if they are being changed
14161 8         76 my $serial = $et->GetNewValue($Image::ExifTool::Nikon::Main{0x001d});
14162 8         38 my $count = $et->GetNewValue($Image::ExifTool::Nikon::Main{0x00a7});
14163 8         52 $$et{NewNikonSerialKey} = SerialKey($et, $serial);
14164 8         34 $$et{NewNikonCountKey} = $count;
14165 8         229 $rtnVal = Image::ExifTool::Exif::WriteExif($et, $dirInfo, $tagTablePtr);
14166 8         35 delete $$et{NewNikonSerialKey};
14167 8         25 delete $$et{NewNikonCountKey};
14168             } else {
14169 16         202 $rtnVal = Image::ExifTool::Exif::ProcessExif($et, $dirInfo, $tagTablePtr);
14170             }
14171 24         102 delete $$et{NikonSerialKey};
14172 24         92 delete $$et{NikonCountKey};
14173 24         123 return $rtnVal;
14174             }
14175              
14176             1; # end
14177              
14178             __END__