File Coverage

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


line stmt bran cond sub pod time code
1             #------------------------------------------------------------------------------
2             # File: Nikon.pm
3             #
4             # Description: Nikon EXIF maker notes tags
5             #
6             # Revisions: 12/09/2003 - P. Harvey Created
7             # 05/17/2004 - P. Harvey Added information from Joseph Heled
8             # 09/21/2004 - P. Harvey Changed tag 2 to ISOUsed & added PrintConv
9             # 12/01/2004 - P. Harvey Added default PRINT_CONV
10             # 01/01/2005 - P. Harvey Decode preview image and preview IFD
11             # 03/35/2005 - T. Christiansen additions
12             # 05/10/2005 - P. Harvey Decode encrypted lens data
13             # [ongoing] - P. Harvey Constantly decoding new information
14             #
15             # References: 1) http://park2.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html
16             # 2) Joseph Heled private communication (tests with D70)
17             # 3) Thomas Walter private communication (tests with Coolpix 5400)
18             # 4) http://www.cybercom.net/~dcoffin/dcraw/
19             # 5) Brian Ristuccia private communication (tests with D70)
20             # 6) Danek Duvall private communication (tests with D70)
21             # 7) Tom Christiansen private communication (tests with D70)
22             # 8) Robert Rottmerhusen private communication
23             # 9) http://members.aol.com/khancock/pilot/nbuddy/
24             # 10) Werner Kober private communication (D2H, D2X, D100, D70, D200, D90)
25             # 11) http://www.rottmerhusen.com/objektives/lensid/thirdparty.html
26             # 12) http://libexif.sourceforge.net/internals/mnote-olympus-tag_8h-source.html
27             # 13) Roger Larsson private communication (tests with D200)
28             # 14) http://homepage3.nifty.com/kamisaka/makernote/makernote_nikon.htm (2007/09/15)
29             # 15) http://tomtia.plala.jp/DigitalCamera/MakerNote/index.asp
30             # 16) Jeffrey Friedl private communication (D200 with firmware update)
31             # 17) http://www.wohlberg.net/public/software/photo/nstiffexif/
32             # and Brendt Wohlberg private communication
33             # 18) Anonymous user private communication (D70, D200, D2x)
34             # 19) Bruce Stevens private communication
35             # 20) Vladimir Sauta private communication (D80)
36             # 21) Gregor Dorlars private communication (D300)
37             # 22) Tanel Kuusk private communication
38             # 23) Alexandre Naaman private communication (D3)
39             # 24) Geert De Soete private communication
40             # 26) Bozi (http://www.cpanforum.com/posts/8983)
41             # 27) Jens Kriese private communication
42             # 28) Warren Hatch private communication (D3v2.00 with SB-800 and SB-900)
43             # 29) Anonymous contribution 2011/05/25 (D700, D7000)
44             # 30) https://exiftool.org/forum/index.php/topic,3833.30.html
45             # 31) Michael Relt private communication
46             # 32) Stefan https://exiftool.org/forum/index.php/topic,4494.0.html
47             # 34) Stewart Bennett private communication (D4S, D810)
48             # 35) David Puschel private communication
49             # 36) Hayo Baann (forum10207)
50             # 37) Tom Lachecki, private communication
51             # 38) https://github.com/exiftool/exiftool/pull/40 (and forum10893)
52             # IB) Iliah Borg private communication (LibRaw)
53             # JD) Jens Duttke private communication
54             # NJ) Niels Kristian Bech Jensen private communication
55             #------------------------------------------------------------------------------
56              
57             package Image::ExifTool::Nikon;
58              
59 27     27   4861 use strict;
  27         59  
  27         1105  
60 27     27   124 use vars qw($VERSION %nikonLensIDs %nikonTextEncoding);
  27         59  
  27         1444  
61 27     27   146 use Image::ExifTool qw(:DataAccess :Utils);
  27         54  
  27         5280  
62 27     27   1190 use Image::ExifTool::Exif;
  27         96  
  27         575  
63 27     27   637 use Image::ExifTool::GPS;
  27         52  
  27         498  
64 27     27   8574 use Image::ExifTool::XMP;
  27         244  
  27         598663  
65              
66             $VERSION = '4.06';
67              
68             sub LensIDConv($$$);
69             sub ProcessNikonAVI($$$);
70             sub ProcessNikonMOV($$$);
71             sub FormatString($);
72             sub ProcessNikonCaptureEditVersions($$$);
73             sub PrintAFPoints($$);
74             sub PrintAFPointsInv($$);
75             sub PrintAFPointsGrid($$);
76             sub PrintAFPointsGridInv($$$);
77             sub GetAFPointGrid($$;$);
78              
79             # nikon lens ID numbers (ref 8/11)
80             %nikonLensIDs = (
81             Notes => q{
82             The Nikon LensID is constructed as a Composite tag from the raw hex values
83             of 8 other tags: LensIDNumber, LensFStops, MinFocalLength, MaxFocalLength,
84             MaxApertureAtMinFocal, MaxApertureAtMaxFocal, MCUVersion and LensType, in
85             that order. Multiple lenses with the same LensID are differentiated by
86             decimal values in the list below. The user-defined "Lenses" list may be
87             used to specify the lens for ExifTool to choose in these cases (see the
88             L for details).
89             },
90             OTHER => \&LensIDConv,
91             # Note: Sync this list with Robert's Perl version at
92             # http://www.rottmerhusen.com/objektives/lensid/files/exif/fmountlens.p.txt
93             # (hex digits must be uppercase in keys below)
94             '01 58 50 50 14 14 02 00' => 'AF Nikkor 50mm f/1.8',
95             '01 58 50 50 14 14 05 00' => 'AF Nikkor 50mm f/1.8',
96             '02 42 44 5C 2A 34 02 00' => 'AF Zoom-Nikkor 35-70mm f/3.3-4.5',
97             '02 42 44 5C 2A 34 08 00' => 'AF Zoom-Nikkor 35-70mm f/3.3-4.5',
98             '03 48 5C 81 30 30 02 00' => 'AF Zoom-Nikkor 70-210mm f/4',
99             '04 48 3C 3C 24 24 03 00' => 'AF Nikkor 28mm f/2.8',
100             '05 54 50 50 0C 0C 04 00' => 'AF Nikkor 50mm f/1.4',
101             '06 54 53 53 24 24 06 00' => 'AF Micro-Nikkor 55mm f/2.8',
102             '07 40 3C 62 2C 34 03 00' => 'AF Zoom-Nikkor 28-85mm f/3.5-4.5',
103             '08 40 44 6A 2C 34 04 00' => 'AF Zoom-Nikkor 35-105mm f/3.5-4.5',
104             '09 48 37 37 24 24 04 00' => 'AF Nikkor 24mm f/2.8',
105             '0A 48 8E 8E 24 24 03 00' => 'AF Nikkor 300mm f/2.8 IF-ED',
106             '0A 48 8E 8E 24 24 05 00' => 'AF Nikkor 300mm f/2.8 IF-ED N',
107             '0B 48 7C 7C 24 24 05 00' => 'AF Nikkor 180mm f/2.8 IF-ED',
108             '0D 40 44 72 2C 34 07 00' => 'AF Zoom-Nikkor 35-135mm f/3.5-4.5',
109             '0E 48 5C 81 30 30 05 00' => 'AF Zoom-Nikkor 70-210mm f/4',
110             '0F 58 50 50 14 14 05 00' => 'AF Nikkor 50mm f/1.8 N',
111             '10 48 8E 8E 30 30 08 00' => 'AF Nikkor 300mm f/4 IF-ED',
112             '11 48 44 5C 24 24 08 00' => 'AF Zoom-Nikkor 35-70mm f/2.8',
113             '11 48 44 5C 24 24 15 00' => 'AF Zoom-Nikkor 35-70mm f/2.8', #Jakob Dettner
114             '12 48 5C 81 30 3C 09 00' => 'AF Nikkor 70-210mm f/4-5.6',
115             '13 42 37 50 2A 34 0B 00' => 'AF Zoom-Nikkor 24-50mm f/3.3-4.5',
116             '14 48 60 80 24 24 0B 00' => 'AF Zoom-Nikkor 80-200mm f/2.8 ED',
117             '15 4C 62 62 14 14 0C 00' => 'AF Nikkor 85mm f/1.8',
118             '17 3C A0 A0 30 30 0F 00' => 'Nikkor 500mm f/4 P ED IF',
119             '17 3C A0 A0 30 30 11 00' => 'Nikkor 500mm f/4 P ED IF',
120             '18 40 44 72 2C 34 0E 00' => 'AF Zoom-Nikkor 35-135mm f/3.5-4.5 N',
121             '1A 54 44 44 18 18 11 00' => 'AF Nikkor 35mm f/2',
122             '1B 44 5E 8E 34 3C 10 00' => 'AF Zoom-Nikkor 75-300mm f/4.5-5.6',
123             '1C 48 30 30 24 24 12 00' => 'AF Nikkor 20mm f/2.8',
124             '1D 42 44 5C 2A 34 12 00' => 'AF Zoom-Nikkor 35-70mm f/3.3-4.5 N',
125             '1E 54 56 56 24 24 13 00' => 'AF Micro-Nikkor 60mm f/2.8',
126             '1F 54 6A 6A 24 24 14 00' => 'AF Micro-Nikkor 105mm f/2.8',
127             '20 48 60 80 24 24 15 00' => 'AF Zoom-Nikkor 80-200mm f/2.8 ED',
128             '21 40 3C 5C 2C 34 16 00' => 'AF Zoom-Nikkor 28-70mm f/3.5-4.5',
129             '22 48 72 72 18 18 16 00' => 'AF DC-Nikkor 135mm f/2',
130             '23 30 BE CA 3C 48 17 00' => 'Zoom-Nikkor 1200-1700mm f/5.6-8 P ED IF',
131             '24 48 60 80 24 24 1A 02' => 'AF Zoom-Nikkor 80-200mm f/2.8D ED',
132             '25 48 44 5C 24 24 1B 02' => 'AF Zoom-Nikkor 35-70mm f/2.8D',
133             '25 48 44 5C 24 24 3A 02' => 'AF Zoom-Nikkor 35-70mm f/2.8D',
134             '25 48 44 5C 24 24 52 02' => 'AF Zoom-Nikkor 35-70mm f/2.8D',
135             '26 40 3C 5C 2C 34 1C 02' => 'AF Zoom-Nikkor 28-70mm f/3.5-4.5D',
136             '27 48 8E 8E 24 24 1D 02' => 'AF-I Nikkor 300mm f/2.8D IF-ED',
137             '27 48 8E 8E 24 24 F1 02' => 'AF-I Nikkor 300mm f/2.8D IF-ED + TC-14E',
138             '27 48 8E 8E 24 24 E1 02' => 'AF-I Nikkor 300mm f/2.8D IF-ED + TC-17E',
139             '27 48 8E 8E 24 24 F2 02' => 'AF-I Nikkor 300mm f/2.8D IF-ED + TC-20E',
140             '28 3C A6 A6 30 30 1D 02' => 'AF-I Nikkor 600mm f/4D IF-ED',
141             '28 3C A6 A6 30 30 F1 02' => 'AF-I Nikkor 600mm f/4D IF-ED + TC-14E',
142             '28 3C A6 A6 30 30 E1 02' => 'AF-I Nikkor 600mm f/4D IF-ED + TC-17E',
143             '28 3C A6 A6 30 30 F2 02' => 'AF-I Nikkor 600mm f/4D IF-ED + TC-20E',
144             '2A 54 3C 3C 0C 0C 26 02' => 'AF Nikkor 28mm f/1.4D',
145             '2B 3C 44 60 30 3C 1F 02' => 'AF Zoom-Nikkor 35-80mm f/4-5.6D',
146             '2C 48 6A 6A 18 18 27 02' => 'AF DC-Nikkor 105mm f/2D',
147             '2D 48 80 80 30 30 21 02' => 'AF Micro-Nikkor 200mm f/4D IF-ED',
148             '2E 48 5C 82 30 3C 22 02' => 'AF Nikkor 70-210mm f/4-5.6D',
149             '2E 48 5C 82 30 3C 28 02' => 'AF Nikkor 70-210mm f/4-5.6D',
150             '2F 48 30 44 24 24 29 02.1' => 'AF Zoom-Nikkor 20-35mm f/2.8D IF',
151             '30 48 98 98 24 24 24 02' => 'AF-I Nikkor 400mm f/2.8D IF-ED',
152             '30 48 98 98 24 24 F1 02' => 'AF-I Nikkor 400mm f/2.8D IF-ED + TC-14E',
153             '30 48 98 98 24 24 E1 02' => 'AF-I Nikkor 400mm f/2.8D IF-ED + TC-17E',
154             '30 48 98 98 24 24 F2 02' => 'AF-I Nikkor 400mm f/2.8D IF-ED + TC-20E',
155             '31 54 56 56 24 24 25 02' => 'AF Micro-Nikkor 60mm f/2.8D',
156             '32 54 6A 6A 24 24 35 02.1' => 'AF Micro-Nikkor 105mm f/2.8D',
157             '33 48 2D 2D 24 24 31 02' => 'AF Nikkor 18mm f/2.8D',
158             '34 48 29 29 24 24 32 02' => 'AF Fisheye Nikkor 16mm f/2.8D',
159             '35 3C A0 A0 30 30 33 02' => 'AF-I Nikkor 500mm f/4D IF-ED',
160             '35 3C A0 A0 30 30 F1 02' => 'AF-I Nikkor 500mm f/4D IF-ED + TC-14E',
161             '35 3C A0 A0 30 30 E1 02' => 'AF-I Nikkor 500mm f/4D IF-ED + TC-17E',
162             '35 3C A0 A0 30 30 F2 02' => 'AF-I Nikkor 500mm f/4D IF-ED + TC-20E',
163             '36 48 37 37 24 24 34 02' => 'AF Nikkor 24mm f/2.8D',
164             '37 48 30 30 24 24 36 02' => 'AF Nikkor 20mm f/2.8D',
165             '38 4C 62 62 14 14 37 02' => 'AF Nikkor 85mm f/1.8D',
166             '3A 40 3C 5C 2C 34 39 02' => 'AF Zoom-Nikkor 28-70mm f/3.5-4.5D',
167             '3B 48 44 5C 24 24 3A 02' => 'AF Zoom-Nikkor 35-70mm f/2.8D N',
168             '3C 48 60 80 24 24 3B 02' => 'AF Zoom-Nikkor 80-200mm f/2.8D ED', #NJ
169             '3D 3C 44 60 30 3C 3E 02' => 'AF Zoom-Nikkor 35-80mm f/4-5.6D',
170             '3E 48 3C 3C 24 24 3D 02' => 'AF Nikkor 28mm f/2.8D',
171             '3F 40 44 6A 2C 34 45 02' => 'AF Zoom-Nikkor 35-105mm f/3.5-4.5D',
172             '41 48 7C 7C 24 24 43 02' => 'AF Nikkor 180mm f/2.8D IF-ED',
173             '42 54 44 44 18 18 44 02' => 'AF Nikkor 35mm f/2D',
174             '43 54 50 50 0C 0C 46 02' => 'AF Nikkor 50mm f/1.4D',
175             '44 44 60 80 34 3C 47 02' => 'AF Zoom-Nikkor 80-200mm f/4.5-5.6D',
176             '45 40 3C 60 2C 3C 48 02' => 'AF Zoom-Nikkor 28-80mm f/3.5-5.6D',
177             '46 3C 44 60 30 3C 49 02' => 'AF Zoom-Nikkor 35-80mm f/4-5.6D N',
178             '47 42 37 50 2A 34 4A 02' => 'AF Zoom-Nikkor 24-50mm f/3.3-4.5D',
179             '48 48 8E 8E 24 24 4B 02' => 'AF-S Nikkor 300mm f/2.8D IF-ED',
180             '48 48 8E 8E 24 24 F1 02' => 'AF-S Nikkor 300mm f/2.8D IF-ED + TC-14E',
181             '48 48 8E 8E 24 24 E1 02' => 'AF-S Nikkor 300mm f/2.8D IF-ED + TC-17E',
182             '48 48 8E 8E 24 24 F2 02' => 'AF-S Nikkor 300mm f/2.8D IF-ED + TC-20E',
183             '49 3C A6 A6 30 30 4C 02' => 'AF-S Nikkor 600mm f/4D IF-ED',
184             '49 3C A6 A6 30 30 F1 02' => 'AF-S Nikkor 600mm f/4D IF-ED + TC-14E',
185             '49 3C A6 A6 30 30 E1 02' => 'AF-S Nikkor 600mm f/4D IF-ED + TC-17E',
186             '49 3C A6 A6 30 30 F2 02' => 'AF-S Nikkor 600mm f/4D IF-ED + TC-20E',
187             '4A 54 62 62 0C 0C 4D 02' => 'AF Nikkor 85mm f/1.4D IF',
188             '4B 3C A0 A0 30 30 4E 02' => 'AF-S Nikkor 500mm f/4D IF-ED',
189             '4B 3C A0 A0 30 30 F1 02' => 'AF-S Nikkor 500mm f/4D IF-ED + TC-14E',
190             '4B 3C A0 A0 30 30 E1 02' => 'AF-S Nikkor 500mm f/4D IF-ED + TC-17E',
191             '4B 3C A0 A0 30 30 F2 02' => 'AF-S Nikkor 500mm f/4D IF-ED + TC-20E',
192             '4C 40 37 6E 2C 3C 4F 02' => 'AF Zoom-Nikkor 24-120mm f/3.5-5.6D IF',
193             '4D 40 3C 80 2C 3C 62 02' => 'AF Zoom-Nikkor 28-200mm f/3.5-5.6D IF',
194             '4E 48 72 72 18 18 51 02' => 'AF DC-Nikkor 135mm f/2D',
195             '4F 40 37 5C 2C 3C 53 06' => 'IX-Nikkor 24-70mm f/3.5-5.6',
196             '50 48 56 7C 30 3C 54 06' => 'IX-Nikkor 60-180mm f/4-5.6',
197             '53 48 60 80 24 24 57 02' => 'AF Zoom-Nikkor 80-200mm f/2.8D ED',
198             '53 48 60 80 24 24 60 02' => 'AF Zoom-Nikkor 80-200mm f/2.8D ED',
199             '54 44 5C 7C 34 3C 58 02' => 'AF Zoom-Micro Nikkor 70-180mm f/4.5-5.6D ED',
200             '54 44 5C 7C 34 3C 61 02' => 'AF Zoom-Micro Nikkor 70-180mm f/4.5-5.6D ED',
201             '56 48 5C 8E 30 3C 5A 02' => 'AF Zoom-Nikkor 70-300mm f/4-5.6D ED',
202             '59 48 98 98 24 24 5D 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED',
203             '59 48 98 98 24 24 F1 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED + TC-14E',
204             '59 48 98 98 24 24 E1 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED + TC-17E',
205             '59 48 98 98 24 24 F2 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED + TC-20E',
206             '5A 3C 3E 56 30 3C 5E 06' => 'IX-Nikkor 30-60mm f/4-5.6',
207             '5B 44 56 7C 34 3C 5F 06' => 'IX-Nikkor 60-180mm f/4.5-5.6',
208             '5D 48 3C 5C 24 24 63 02' => 'AF-S Zoom-Nikkor 28-70mm f/2.8D IF-ED',
209             '5E 48 60 80 24 24 64 02' => 'AF-S Zoom-Nikkor 80-200mm f/2.8D IF-ED',
210             '5F 40 3C 6A 2C 34 65 02' => 'AF Zoom-Nikkor 28-105mm f/3.5-4.5D IF',
211             '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)
212             '61 44 5E 86 34 3C 67 02' => 'AF Zoom-Nikkor 75-240mm f/4.5-5.6D',
213             '63 48 2B 44 24 24 68 02' => 'AF-S Nikkor 17-35mm f/2.8D IF-ED',
214             '64 00 62 62 24 24 6A 02' => 'PC Micro-Nikkor 85mm f/2.8D',
215             '65 44 60 98 34 3C 6B 0A' => 'AF VR Zoom-Nikkor 80-400mm f/4.5-5.6D ED',
216             '66 40 2D 44 2C 34 6C 02' => 'AF Zoom-Nikkor 18-35mm f/3.5-4.5D IF-ED',
217             '67 48 37 62 24 30 6D 02' => 'AF Zoom-Nikkor 24-85mm f/2.8-4D IF',
218             '68 42 3C 60 2A 3C 6E 06' => 'AF Zoom-Nikkor 28-80mm f/3.3-5.6G',
219             '69 48 5C 8E 30 3C 6F 06' => 'AF Zoom-Nikkor 70-300mm f/4-5.6G',
220             '6A 48 8E 8E 30 30 70 02' => 'AF-S Nikkor 300mm f/4D IF-ED',
221             '6B 48 24 24 24 24 71 02' => 'AF Nikkor ED 14mm f/2.8D',
222             '6D 48 8E 8E 24 24 73 02' => 'AF-S Nikkor 300mm f/2.8D IF-ED II',
223             '6E 48 98 98 24 24 74 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED II',
224             '6F 3C A0 A0 30 30 75 02' => 'AF-S Nikkor 500mm f/4D IF-ED II',
225             '70 3C A6 A6 30 30 76 02' => 'AF-S Nikkor 600mm f/4D IF-ED II',
226             '72 48 4C 4C 24 24 77 00' => 'Nikkor 45mm f/2.8 P',
227             '74 40 37 62 2C 34 78 06' => 'AF-S Zoom-Nikkor 24-85mm f/3.5-4.5G IF-ED',
228             '75 40 3C 68 2C 3C 79 06' => 'AF Zoom-Nikkor 28-100mm f/3.5-5.6G',
229             '76 58 50 50 14 14 7A 02' => 'AF Nikkor 50mm f/1.8D',
230             '77 48 5C 80 24 24 7B 0E' => 'AF-S VR Zoom-Nikkor 70-200mm f/2.8G IF-ED',
231             '78 40 37 6E 2C 3C 7C 0E' => 'AF-S VR Zoom-Nikkor 24-120mm f/3.5-5.6G IF-ED',
232             '79 40 3C 80 2C 3C 7F 06' => 'AF Zoom-Nikkor 28-200mm f/3.5-5.6G IF-ED',
233             '7A 3C 1F 37 30 30 7E 06.1' => 'AF-S DX Zoom-Nikkor 12-24mm f/4G IF-ED',
234             '7B 48 80 98 30 30 80 0E' => 'AF-S VR Zoom-Nikkor 200-400mm f/4G IF-ED',
235             '7D 48 2B 53 24 24 82 06' => 'AF-S DX Zoom-Nikkor 17-55mm f/2.8G IF-ED',
236             '7F 40 2D 5C 2C 34 84 06' => 'AF-S DX Zoom-Nikkor 18-70mm f/3.5-4.5G IF-ED',
237             '80 48 1A 1A 24 24 85 06' => 'AF DX Fisheye-Nikkor 10.5mm f/2.8G ED',
238             '81 54 80 80 18 18 86 0E' => 'AF-S VR Nikkor 200mm f/2G IF-ED',
239             '82 48 8E 8E 24 24 87 0E' => 'AF-S VR Nikkor 300mm f/2.8G IF-ED',
240             '83 00 B0 B0 5A 5A 88 04' => 'FSA-L2, EDG 65, 800mm F13 G',
241             '89 3C 53 80 30 3C 8B 06' => 'AF-S DX Zoom-Nikkor 55-200mm f/4-5.6G ED',
242             '8A 54 6A 6A 24 24 8C 0E' => 'AF-S VR Micro-Nikkor 105mm f/2.8G IF-ED', #10
243             # when the TC-20 III 2x teleconverter is used with the above lens, the following have been observed:
244             # 8A 4D 6A 6A 24 24 8C 0E
245             # 8A 4E 6A 6A 24 24 8C 0E
246             # 8A 50 6A 6A 24 24 8C 0E
247             # 8A 51 6A 6A 24 24 8C 0E
248             # 8A 52 6A 6A 24 24 8C 0E
249             # 8A 53 6A 6A 24 24 8C 0E
250             # 8A 54 6A 6A 24 24 8C 0E (same as without the TC)
251             '8B 40 2D 80 2C 3C 8D 0E' => 'AF-S DX VR Zoom-Nikkor 18-200mm f/3.5-5.6G IF-ED',
252             '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
253             '8C 40 2D 53 2C 3C 8E 06' => 'AF-S DX Zoom-Nikkor 18-55mm f/3.5-5.6G ED',
254             '8D 44 5C 8E 34 3C 8F 0E' => 'AF-S VR Zoom-Nikkor 70-300mm f/4.5-5.6G IF-ED', #10
255             '8F 40 2D 72 2C 3C 91 06' => 'AF-S DX Zoom-Nikkor 18-135mm f/3.5-5.6G IF-ED',
256             '90 3B 53 80 30 3C 92 0E' => 'AF-S DX VR Zoom-Nikkor 55-200mm f/4-5.6G IF-ED',
257             '92 48 24 37 24 24 94 06' => 'AF-S Zoom-Nikkor 14-24mm f/2.8G ED',
258             '93 48 37 5C 24 24 95 06' => 'AF-S Zoom-Nikkor 24-70mm f/2.8G ED',
259             '94 40 2D 53 2C 3C 96 06' => 'AF-S DX Zoom-Nikkor 18-55mm f/3.5-5.6G ED II', #10 (D40)
260             '95 4C 37 37 2C 2C 97 02' => 'PC-E Nikkor 24mm f/3.5D ED',
261             '95 00 37 37 2C 2C 97 06' => 'PC-E Nikkor 24mm f/3.5D ED', #JD
262             '96 48 98 98 24 24 98 0E' => 'AF-S VR Nikkor 400mm f/2.8G ED',
263             '97 3C A0 A0 30 30 99 0E' => 'AF-S VR Nikkor 500mm f/4G ED',
264             '98 3C A6 A6 30 30 9A 0E' => 'AF-S VR Nikkor 600mm f/4G ED',
265             '99 40 29 62 2C 3C 9B 0E' => 'AF-S DX VR Zoom-Nikkor 16-85mm f/3.5-5.6G ED',
266             '9A 40 2D 53 2C 3C 9C 0E' => 'AF-S DX VR Zoom-Nikkor 18-55mm f/3.5-5.6G',
267             '9B 54 4C 4C 24 24 9D 02' => 'PC-E Micro Nikkor 45mm f/2.8D ED',
268             '9B 00 4C 4C 24 24 9D 06' => 'PC-E Micro Nikkor 45mm f/2.8D ED',
269             '9C 54 56 56 24 24 9E 06' => 'AF-S Micro Nikkor 60mm f/2.8G ED',
270             '9D 54 62 62 24 24 9F 02' => 'PC-E Micro Nikkor 85mm f/2.8D',
271             '9D 00 62 62 24 24 9F 06' => 'PC-E Micro Nikkor 85mm f/2.8D',
272             '9E 40 2D 6A 2C 3C A0 0E' => 'AF-S DX VR Zoom-Nikkor 18-105mm f/3.5-5.6G ED', #PH/10
273             '9F 58 44 44 14 14 A1 06' => 'AF-S DX Nikkor 35mm f/1.8G', #27
274             'A0 54 50 50 0C 0C A2 06' => 'AF-S Nikkor 50mm f/1.4G',
275             'A1 40 18 37 2C 34 A3 06' => 'AF-S DX Nikkor 10-24mm f/3.5-4.5G ED',
276             'A1 40 2D 53 2C 3C CB 86' => 'AF-P DX Nikkor 18-55mm f/3.5-5.6G', #30
277             'A2 48 5C 80 24 24 A4 0E' => 'AF-S Nikkor 70-200mm f/2.8G ED VR II',
278             'A3 3C 29 44 30 30 A5 0E' => 'AF-S Nikkor 16-35mm f/4G ED VR',
279             'A4 54 37 37 0C 0C A6 06' => 'AF-S Nikkor 24mm f/1.4G ED',
280             'A5 40 3C 8E 2C 3C A7 0E' => 'AF-S Nikkor 28-300mm f/3.5-5.6G ED VR',
281             'A6 48 8E 8E 24 24 A8 0E' => 'AF-S Nikkor 300mm f/2.8G IF-ED VR II',
282             'A7 4B 62 62 2C 2C A9 0E' => 'AF-S DX Micro Nikkor 85mm f/3.5G ED VR',
283             '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
284             'A9 54 80 80 18 18 AB 0E' => 'AF-S Nikkor 200mm f/2G ED VR II',
285             'AA 3C 37 6E 30 30 AC 0E' => 'AF-S Nikkor 24-120mm f/4G ED VR',
286             'AC 38 53 8E 34 3C AE 0E' => 'AF-S DX Nikkor 55-300mm f/4.5-5.6G ED VR',
287             'AD 3C 2D 8E 2C 3C AF 0E' => 'AF-S DX Nikkor 18-300mm f/3.5-5.6G ED VR',
288             'AE 54 62 62 0C 0C B0 06' => 'AF-S Nikkor 85mm f/1.4G',
289             'AF 54 44 44 0C 0C B1 06' => 'AF-S Nikkor 35mm f/1.4G',
290             'B0 4C 50 50 14 14 B2 06' => 'AF-S Nikkor 50mm f/1.8G',
291             'B1 48 48 48 24 24 B3 06' => 'AF-S DX Micro Nikkor 40mm f/2.8G', #27
292             'B2 48 5C 80 30 30 B4 0E' => 'AF-S Nikkor 70-200mm f/4G ED VR', #35
293             'B3 4C 62 62 14 14 B5 06' => 'AF-S Nikkor 85mm f/1.8G',
294             'B4 40 37 62 2C 34 B6 0E' => 'AF-S Zoom-Nikkor 24-85mm f/3.5-4.5G IF-ED VR', #30
295             'B5 4C 3C 3C 14 14 B7 06' => 'AF-S Nikkor 28mm f/1.8G', #30
296             'B6 3C B0 B0 3C 3C B8 0E' => 'AF-S VR Nikkor 800mm f/5.6E FL ED',
297             'B6 3C B0 B0 3C 3C B8 4E' => 'AF-S VR Nikkor 800mm f/5.6E FL ED', #PH
298             'B7 44 60 98 34 3C B9 0E' => 'AF-S Nikkor 80-400mm f/4.5-5.6G ED VR',
299             'B8 40 2D 44 2C 34 BA 06' => 'AF-S Nikkor 18-35mm f/3.5-4.5G ED',
300             'A0 40 2D 74 2C 3C BB 0E' => 'AF-S DX Nikkor 18-140mm f/3.5-5.6G ED VR', #PH
301             'A1 54 55 55 0C 0C BC 06' => 'AF-S Nikkor 58mm f/1.4G', #IB
302             'A1 48 6E 8E 24 24 DB 4E' => 'AF-S Nikkor 120-300mm f/2.8E FL ED SR VR', #28
303             'A2 40 2D 53 2C 3C BD 0E' => 'AF-S DX Nikkor 18-55mm f/3.5-5.6G VR II',
304             'A4 40 2D 8E 2C 40 BF 0E' => 'AF-S DX Nikkor 18-300mm f/3.5-6.3G ED VR',
305             'A5 4C 44 44 14 14 C0 06' => 'AF-S Nikkor 35mm f/1.8G ED', #35 ("ED" ref 11)
306             'A6 48 98 98 24 24 C1 0E' => 'AF-S Nikkor 400mm f/2.8E FL ED VR',
307             'A7 3C 53 80 30 3C C2 0E' => 'AF-S DX Nikkor 55-200mm f/4-5.6G ED VR II', #IB
308             'A8 48 8E 8E 30 30 C3 4E' => 'AF-S Nikkor 300mm f/4E PF ED VR', #35
309             'A8 48 8E 8E 30 30 C3 0E' => 'AF-S Nikkor 300mm f/4E PF ED VR', #30
310             'A9 4C 31 31 14 14 C4 06' => 'AF-S Nikkor 20mm f/1.8G ED', #30
311             'AA 48 37 5C 24 24 C5 4E' => 'AF-S Nikkor 24-70mm f/2.8E ED VR',
312             'AA 48 37 5C 24 24 C5 0E' => 'AF-S Nikkor 24-70mm f/2.8E ED VR',
313             'AB 3C A0 A0 30 30 C6 4E' => 'AF-S Nikkor 500mm f/4E FL ED VR',
314             'AC 3C A6 A6 30 30 C7 4E' => 'AF-S Nikkor 600mm f/4E FL ED VR', #PH
315             'AD 48 28 60 24 30 C8 4E' => 'AF-S DX Nikkor 16-80mm f/2.8-4E ED VR',
316             'AD 48 28 60 24 30 C8 0E' => 'AF-S DX Nikkor 16-80mm f/2.8-4E ED VR', #PH
317             'AE 3C 80 A0 3C 3C C9 4E' => 'AF-S Nikkor 200-500mm f/5.6E ED VR', #PH
318             'AE 3C 80 A0 3C 3C C9 0E' => 'AF-S Nikkor 200-500mm f/5.6E ED VR',
319             'A0 40 2D 53 2C 3C CA 8E' => 'AF-P DX Nikkor 18-55mm f/3.5-5.6G', #Yang You pvt communication
320             'A0 40 2D 53 2C 3C CA 0E' => 'AF-P DX Nikkor 18-55mm f/3.5-5.6G VR', #PH
321             'AF 4C 37 37 14 14 CC 06' => 'AF-S Nikkor 24mm f/1.8G ED', #IB
322             'A2 38 5C 8E 34 40 CD 86' => 'AF-P DX Nikkor 70-300mm f/4.5-6.3G VR', #PH
323             'A3 38 5C 8E 34 40 CE 8E' => 'AF-P DX Nikkor 70-300mm f/4.5-6.3G ED VR',
324             'A3 38 5C 8E 34 40 CE 0E' => 'AF-P DX Nikkor 70-300mm f/4.5-6.3G ED',
325             'A4 48 5C 80 24 24 CF 4E' => 'AF-S Nikkor 70-200mm f/2.8E FL ED VR',
326             'A4 48 5C 80 24 24 CF 0E' => 'AF-S Nikkor 70-200mm f/2.8E FL ED VR',
327             'A5 54 6A 6A 0C 0C D0 46' => 'AF-S Nikkor 105mm f/1.4E ED', #IB
328             'A5 54 6A 6A 0C 0C D0 06' => 'AF-S Nikkor 105mm f/1.4E ED', #IB
329             'A6 48 2F 2F 30 30 D1 46' => 'PC Nikkor 19mm f/4E ED',
330             'A6 48 2F 2F 30 30 D1 06' => 'PC Nikkor 19mm f/4E ED',
331             'A7 40 11 26 2C 34 D2 46' => 'AF-S Fisheye Nikkor 8-15mm f/3.5-4.5E ED',
332             'A7 40 11 26 2C 34 D2 06' => 'AF-S Fisheye Nikkor 8-15mm f/3.5-4.5E ED',
333             'A8 38 18 30 34 3C D3 8E' => 'AF-P DX Nikkor 10-20mm f/4.5-5.6G VR', #Yang You pvt communication
334             'A8 38 18 30 34 3C D3 0E' => 'AF-P DX Nikkor 10-20mm f/4.5-5.6G VR',
335             'A9 48 7C 98 30 30 D4 4E' => 'AF-S Nikkor 180-400mm f/4E TC1.4 FL ED VR', #IB
336             'A9 48 7C 98 30 30 D4 0E' => 'AF-S Nikkor 180-400mm f/4E TC1.4 FL ED VR',
337             'AA 48 88 A4 3C 3C D5 4E' => 'AF-S Nikkor 180-400mm f/4E TC1.4 FL ED VR + 1.4x TC', #IB
338             'AA 48 88 A4 3C 3C D5 0E' => 'AF-S Nikkor 180-400mm f/4E TC1.4 FL ED VR + 1.4x TC',
339             'AB 44 5C 8E 34 3C D6 CE' => 'AF-P Nikkor 70-300mm f/4.5-5.6E ED VR',
340             'AB 44 5C 8E 34 3C D6 0E' => 'AF-P Nikkor 70-300mm f/4.5-5.6E ED VR',
341             'AB 44 5C 8E 34 3C D6 4E' => 'AF-P Nikkor 70-300mm f/4.5-5.6E ED VR', #IB
342             'AC 54 3C 3C 0C 0C D7 46' => 'AF-S Nikkor 28mm f/1.4E ED',
343             'AC 54 3C 3C 0C 0C D7 06' => 'AF-S Nikkor 28mm f/1.4E ED',
344             'AD 3C A0 A0 3C 3C D8 0E' => 'AF-S Nikkor 500mm f/5.6E PF ED VR',
345             'AD 3C A0 A0 3C 3C D8 4E' => 'AF-S Nikkor 500mm f/5.6E PF ED VR',
346             '01 00 00 00 00 00 02 00' => 'TC-16A',
347             '01 00 00 00 00 00 08 00' => 'TC-16A',
348             '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',
349             '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',
350             '00 00 00 00 00 00 E1 12' => 'TC-17E II',
351             'FE 47 00 00 24 24 4B 06' => 'Sigma 4.5mm F2.8 EX DC HSM Circular Fisheye', #JD
352             '26 48 11 11 30 30 1C 02' => 'Sigma 8mm F4 EX Circular Fisheye',
353             '79 40 11 11 2C 2C 1C 06' => 'Sigma 8mm F3.5 EX Circular Fisheye', #JD
354             'DB 40 11 11 2C 2C 1C 06' => 'Sigma 8mm F3.5 EX DG Circular Fisheye', #30
355             'DC 48 19 19 24 24 4B 06' => 'Sigma 10mm F2.8 EX DC HSM Fisheye',
356             'C2 4C 24 24 14 14 4B 06' => 'Sigma 14mm F1.8 DG HSM | A', #IB
357             '48 48 24 24 24 24 4B 02' => 'Sigma 14mm F2.8 EX Aspherical HSM',
358             '02 3F 24 24 2C 2C 02 00' => 'Sigma 14mm F3.5',
359             '26 48 27 27 24 24 1C 02' => 'Sigma 15mm F2.8 EX Diagonal Fisheye',
360             'EA 48 27 27 24 24 1C 02' => 'Sigma 15mm F2.8 EX Diagonal Fisheye', #30
361             '26 58 31 31 14 14 1C 02' => 'Sigma 20mm F1.8 EX DG Aspherical RF',
362             '79 54 31 31 0C 0C 4B 06' => 'Sigma 20mm F1.4 DG HSM | A', #Rolf Probst
363             '26 58 37 37 14 14 1C 02' => 'Sigma 24mm F1.8 EX DG Aspherical Macro',
364             'E1 58 37 37 14 14 1C 02' => 'Sigma 24mm F1.8 EX DG Aspherical Macro',
365             '02 46 37 37 25 25 02 00' => 'Sigma 24mm F2.8 Super Wide II Macro',
366             '26 58 3C 3C 14 14 1C 02' => 'Sigma 28mm F1.8 EX DG Aspherical Macro',
367             '48 54 3E 3E 0C 0C 4B 06' => 'Sigma 30mm F1.4 EX DC HSM',
368             'F8 54 3E 3E 0C 0C 4B 06' => 'Sigma 30mm F1.4 EX DC HSM', #JD
369             '91 54 44 44 0C 0C 4B 06' => 'Sigma 35mm F1.4 DG HSM', #30
370             'DE 54 50 50 0C 0C 4B 06' => 'Sigma 50mm F1.4 EX DG HSM',
371             '88 54 50 50 0C 0C 4B 06' => 'Sigma 50mm F1.4 DG HSM | A',
372             '02 48 50 50 24 24 02 00' => 'Sigma Macro 50mm F2.8', #https://exiftool.org/forum/index.php/topic,4027.0.html
373             '32 54 50 50 24 24 35 02' => 'Sigma Macro 50mm F2.8 EX DG',
374             '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
375             '79 48 5C 5C 24 24 1C 06' => 'Sigma Macro 70mm F2.8 EX DG', #JD
376             '9B 54 62 62 0C 0C 4B 06' => 'Sigma 85mm F1.4 EX DG HSM',
377             'C8 54 62 62 0C 0C 4B 46' => 'Sigma 85mm F1.4 DG HSM | A', #JamiBradley
378             'C8 54 62 62 0C 0C 4B 06' => 'Sigma 85mm F1.4 DG HSM | A', #KennethCochran
379             '02 48 65 65 24 24 02 00' => 'Sigma Macro 90mm F2.8',
380             '32 54 6A 6A 24 24 35 02.2' => 'Sigma Macro 105mm F2.8 EX DG', #JD
381             'E5 54 6A 6A 24 24 35 02' => 'Sigma Macro 105mm F2.8 EX DG',
382             '97 48 6A 6A 24 24 4B 0E' => 'Sigma Macro 105mm F2.8 EX DG OS HSM',
383             '48 48 76 76 24 24 4B 06' => 'Sigma APO Macro 150mm F2.8 EX DG HSM',
384             'F5 48 76 76 24 24 4B 06' => 'Sigma APO Macro 150mm F2.8 EX DG HSM', #24
385             '99 48 76 76 24 24 4B 0E' => 'Sigma APO Macro 150mm F2.8 EX DG OS HSM', #(Christian Hesse)
386             '48 4C 7C 7C 2C 2C 4B 02' => 'Sigma APO Macro 180mm F3.5 EX DG HSM',
387             '48 4C 7D 7D 2C 2C 4B 02' => 'Sigma APO Macro 180mm F3.5 EX DG HSM',
388             'F4 4C 7C 7C 2C 2C 4B 02' => 'Sigma APO Macro 180mm F3.5 EX DG HSM', #Bruno
389             '94 48 7C 7C 24 24 4B 0E' => 'Sigma APO Macro 180mm F2.8 EX DG OS HSM', #MichaelTapes (HSM from ref 8)
390             '48 54 8E 8E 24 24 4B 02' => 'Sigma APO 300mm F2.8 EX DG HSM',
391             'FB 54 8E 8E 24 24 4B 02' => 'Sigma APO 300mm F2.8 EX DG HSM', #26
392             '26 48 8E 8E 30 30 1C 02' => 'Sigma APO Tele Macro 300mm F4',
393             '02 2F 98 98 3D 3D 02 00' => 'Sigma APO 400mm F5.6',
394             '26 3C 98 98 3C 3C 1C 02' => 'Sigma APO Tele Macro 400mm F5.6',
395             '02 37 A0 A0 34 34 02 00' => 'Sigma APO 500mm F4.5', #19
396             '48 44 A0 A0 34 34 4B 02' => 'Sigma APO 500mm F4.5 EX HSM',
397             'F1 44 A0 A0 34 34 4B 02' => 'Sigma APO 500mm F4.5 EX DG HSM',
398             '02 34 A0 A0 44 44 02 00' => 'Sigma APO 500mm F7.2',
399             '02 3C B0 B0 3C 3C 02 00' => 'Sigma APO 800mm F5.6',
400             '48 3C B0 B0 3C 3C 4B 02' => 'Sigma APO 800mm F5.6 EX HSM',
401             '9E 38 11 29 34 3C 4B 06' => 'Sigma 8-16mm F4.5-5.6 DC HSM',
402             'A1 41 19 31 2C 2C 4B 06' => 'Sigma 10-20mm F3.5 EX DC HSM',
403             '48 3C 19 31 30 3C 4B 06' => 'Sigma 10-20mm F4-5.6 EX DC HSM',
404             'F9 3C 19 31 30 3C 4B 06' => 'Sigma 10-20mm F4-5.6 EX DC HSM', #JD
405             '48 38 1F 37 34 3C 4B 06' => 'Sigma 12-24mm F4.5-5.6 EX DG Aspherical HSM',
406             'F0 38 1F 37 34 3C 4B 06' => 'Sigma 12-24mm F4.5-5.6 EX DG Aspherical HSM',
407             '96 38 1F 37 34 3C 4B 06' => 'Sigma 12-24mm F4.5-5.6 II DG HSM', #Jurgen Sahlberg
408             'CA 3C 1F 37 30 30 4B 46' => 'Sigma 12-24mm F4 DG HSM | A', #github issue#101
409             'C1 48 24 37 24 24 4B 46' => 'Sigma 14-24mm F2.8 DG HSM | A', #30
410             '26 40 27 3F 2C 34 1C 02' => 'Sigma 15-30mm F3.5-4.5 EX DG Aspherical DF',
411             '48 48 2B 44 24 30 4B 06' => 'Sigma 17-35mm F2.8-4 EX DG Aspherical HSM',
412             '26 54 2B 44 24 30 1C 02' => 'Sigma 17-35mm F2.8-4 EX Aspherical',
413             '9D 48 2B 50 24 24 4B 0E' => 'Sigma 17-50mm F2.8 EX DC OS HSM',
414             '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
415             '7A 47 2B 5C 24 34 4B 06' => 'Sigma 17-70mm F2.8-4.5 DC Macro Asp. IF HSM',
416             '7A 48 2B 5C 24 34 4B 06' => 'Sigma 17-70mm F2.8-4.5 DC Macro Asp. IF HSM',
417             '7F 48 2B 5C 24 34 1C 06' => 'Sigma 17-70mm F2.8-4.5 DC Macro Asp. IF',
418             '8E 3C 2B 5C 24 30 4B 0E' => 'Sigma 17-70mm F2.8-4 DC Macro OS HSM | C',
419             '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
420             '8B 4C 2D 44 14 14 4B 06' => 'Sigma 18-35mm F1.8 DC HSM', #30/NJ
421             '26 40 2D 44 2B 34 1C 02' => 'Sigma 18-35mm F3.5-4.5 Aspherical',
422             '26 48 2D 50 24 24 1C 06' => 'Sigma 18-50mm F2.8 EX DC',
423             '7F 48 2D 50 24 24 1C 06' => 'Sigma 18-50mm F2.8 EX DC Macro', #NJ
424             '7A 48 2D 50 24 24 4B 06' => 'Sigma 18-50mm F2.8 EX DC Macro',
425             'F6 48 2D 50 24 24 4B 06' => 'Sigma 18-50mm F2.8 EX DC Macro',
426             'A4 47 2D 50 24 34 4B 0E' => 'Sigma 18-50mm F2.8-4.5 DC OS HSM',
427             '26 40 2D 50 2C 3C 1C 06' => 'Sigma 18-50mm F3.5-5.6 DC',
428             '7A 40 2D 50 2C 3C 4B 06' => 'Sigma 18-50mm F3.5-5.6 DC HSM',
429             '26 40 2D 70 2B 3C 1C 06' => 'Sigma 18-125mm F3.5-5.6 DC',
430             'CD 3D 2D 70 2E 3C 4B 0E' => 'Sigma 18-125mm F3.8-5.6 DC OS HSM',
431             '26 40 2D 80 2C 40 1C 06' => 'Sigma 18-200mm F3.5-6.3 DC',
432             'FF 40 2D 80 2C 40 4B 06' => 'Sigma 18-200mm F3.5-6.3 DC', #30
433             '7A 40 2D 80 2C 40 4B 0E' => 'Sigma 18-200mm F3.5-6.3 DC OS HSM',
434             'ED 40 2D 80 2C 40 4B 0E' => 'Sigma 18-200mm F3.5-6.3 DC OS HSM', #JD
435             '90 40 2D 80 2C 40 4B 0E' => 'Sigma 18-200mm F3.5-6.3 II DC OS HSM', #JohnHelour
436             '89 30 2D 80 2C 40 4B 0E' => 'Sigma 18-200mm F3.5-6.3 DC Macro OS HS | C', #JoeSchonberg
437             'A5 40 2D 88 2C 40 4B 0E' => 'Sigma 18-250mm F3.5-6.3 DC OS HSM',
438             # LensFStops varies with FocalLength for this lens (ref 2):
439             '92 2C 2D 88 2C 40 4B 0E' => 'Sigma 18-250mm F3.5-6.3 DC Macro OS HSM', #2
440             '87 2C 2D 8E 2C 40 4B 0E' => 'Sigma 18-300mm F3.5-6.3 DC Macro HSM', #30
441             # '92 2C 2D 88 2C 40 4B 0E' (250mm)
442             # '92 2B 2D 88 2C 40 4B 0E' (210mm)
443             # '92 2C 2D 88 2C 40 4B 0E' (185mm)
444             # '92 2D 2D 88 2C 40 4B 0E' (155mm)
445             # '92 2E 2D 88 2C 40 4B 0E' (130mm)
446             # '92 2F 2D 88 2C 40 4B 0E' (105mm)
447             # '92 30 2D 88 2C 40 4B 0E' (90mm)
448             # '92 32 2D 88 2C 40 4B 0E' (75mm)
449             # '92 33 2D 88 2C 40 4B 0E' (62mm)
450             # '92 35 2D 88 2C 40 4B 0E' (52mm)
451             # '92 37 2D 88 2C 40 4B 0E' (44mm)
452             # '92 39 2D 88 2C 40 4B 0E' (38mm)
453             # '92 3A 2D 88 2C 40 4B 0E' (32mm)
454             # '92 3E 2D 88 2C 40 4B 0E' (22mm)
455             # '92 40 2D 88 2C 40 4B 0E' (18mm)
456             '26 48 31 49 24 24 1C 02' => 'Sigma 20-40mm F2.8',
457             '7B 48 37 44 18 18 4B 06' => 'Sigma 24-35mm F2.0 DG HSM | A', #30
458             '02 3A 37 50 31 3D 02 00' => 'Sigma 24-50mm F4-5.6 UC',
459             '26 48 37 56 24 24 1C 02' => 'Sigma 24-60mm F2.8 EX DG',
460             'B6 48 37 56 24 24 1C 02' => 'Sigma 24-60mm F2.8 EX DG',
461             'A6 48 37 5C 24 24 4B 06' => 'Sigma 24-70mm F2.8 IF EX DG HSM', #JD
462             'C9 48 37 5C 24 24 4B 4E' => 'Sigma 24-70mm F2.8 DG OS HSM | A', #30
463             '26 54 37 5C 24 24 1C 02' => 'Sigma 24-70mm F2.8 EX DG Macro',
464             '67 54 37 5C 24 24 1C 02' => 'Sigma 24-70mm F2.8 EX DG Macro',
465             'E9 54 37 5C 24 24 1C 02' => 'Sigma 24-70mm F2.8 EX DG Macro',
466             '26 40 37 5C 2C 3C 1C 02' => 'Sigma 24-70mm F3.5-5.6 Aspherical HF',
467             '8A 3C 37 6A 30 30 4B 0E' => 'Sigma 24-105mm F4 DG OS HSM', #IB
468             '26 54 37 73 24 34 1C 02' => 'Sigma 24-135mm F2.8-4.5',
469             '02 46 3C 5C 25 25 02 00' => 'Sigma 28-70mm F2.8',
470             '26 54 3C 5C 24 24 1C 02' => 'Sigma 28-70mm F2.8 EX',
471             '26 48 3C 5C 24 24 1C 06' => 'Sigma 28-70mm F2.8 EX DG',
472             '79 48 3C 5C 24 24 1C 06' => 'Sigma 28-70mm F2.8 EX DG', #30 ("D" removed)
473             '26 48 3C 5C 24 30 1C 02' => 'Sigma 28-70mm F2.8-4 DG',
474             '02 3F 3C 5C 2D 35 02 00' => 'Sigma 28-70mm F3.5-4.5 UC',
475             '26 40 3C 60 2C 3C 1C 02' => 'Sigma 28-80mm F3.5-5.6 Mini Zoom Macro II Aspherical',
476             '26 40 3C 65 2C 3C 1C 02' => 'Sigma 28-90mm F3.5-5.6 Macro',
477             '26 48 3C 6A 24 30 1C 02' => 'Sigma 28-105mm F2.8-4 Aspherical',
478             '26 3E 3C 6A 2E 3C 1C 02' => 'Sigma 28-105mm F3.8-5.6 UC-III Aspherical IF',
479             '26 40 3C 80 2C 3C 1C 02' => 'Sigma 28-200mm F3.5-5.6 Compact Aspherical Hyperzoom Macro',
480             '26 40 3C 80 2B 3C 1C 02' => 'Sigma 28-200mm F3.5-5.6 Compact Aspherical Hyperzoom Macro',
481             '26 3D 3C 80 2F 3D 1C 02' => 'Sigma 28-300mm F3.8-5.6 Aspherical',
482             '26 41 3C 8E 2C 40 1C 02' => 'Sigma 28-300mm F3.5-6.3 DG Macro',
483             '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
484             '26 40 3C 8E 2C 40 1C 02' => 'Sigma 28-300mm F3.5-6.3 Macro',
485             '02 3B 44 61 30 3D 02 00' => 'Sigma 35-80mm F4-5.6',
486             '02 40 44 73 2B 36 02 00' => 'Sigma 35-135mm F3.5-4.5 a',
487             'CC 4C 50 68 14 14 4B 06' => 'Sigma 50-100mm F1.8 DC HSM | A', #30
488             '7A 47 50 76 24 24 4B 06' => 'Sigma 50-150mm F2.8 EX APO DC HSM',
489             'FD 47 50 76 24 24 4B 06' => 'Sigma 50-150mm F2.8 EX APO DC HSM II',
490             '98 48 50 76 24 24 4B 0E' => 'Sigma 50-150mm F2.8 EX APO DC OS HSM', #30
491             '48 3C 50 A0 30 40 4B 02' => 'Sigma 50-500mm F4-6.3 EX APO RF HSM',
492             '9F 37 50 A0 34 40 4B 0E' => 'Sigma 50-500mm F4.5-6.3 DG OS HSM', #16
493             '26 3C 54 80 30 3C 1C 06' => 'Sigma 55-200mm F4-5.6 DC',
494             '7A 3B 53 80 30 3C 4B 06' => 'Sigma 55-200mm F4-5.6 DC HSM',
495             '48 54 5C 80 24 24 4B 02' => 'Sigma 70-200mm F2.8 EX APO IF HSM',
496             '7A 48 5C 80 24 24 4B 06' => 'Sigma 70-200mm F2.8 EX APO DG Macro HSM II',
497             'EE 48 5C 80 24 24 4B 06' => 'Sigma 70-200mm F2.8 EX APO DG Macro HSM II', #JD
498             '9C 48 5C 80 24 24 4B 0E' => 'Sigma 70-200mm F2.8 EX DG OS HSM', #Rolando Ruzic
499             'BB 48 5C 80 24 24 4B 4E' => 'Sigma 70-200mm F2.8 DG OS HSM | S', #forum13207
500             '02 46 5C 82 25 25 02 00' => 'Sigma 70-210mm F2.8 APO', #JD
501             '02 40 5C 82 2C 35 02 00' => 'Sigma APO 70-210mm F3.5-4.5',
502             '26 3C 5C 82 30 3C 1C 02' => 'Sigma 70-210mm F4-5.6 UC-II',
503             '02 3B 5C 82 30 3C 02 00' => 'Sigma Zoom-K 70-210mm F4-5.6', #30
504             '26 3C 5C 8E 30 3C 1C 02' => 'Sigma 70-300mm F4-5.6 DG Macro',
505             '56 3C 5C 8E 30 3C 1C 02' => 'Sigma 70-300mm F4-5.6 APO Macro Super II',
506             'E0 3C 5C 8E 30 3C 4B 06' => 'Sigma 70-300mm F4-5.6 APO DG Macro HSM', #22
507             'A3 3C 5C 8E 30 3C 4B 0E' => 'Sigma 70-300mm F4-5.6 DG OS',
508             '02 37 5E 8E 35 3D 02 00' => 'Sigma 75-300mm F4.5-5.6 APO',
509             '02 3A 5E 8E 32 3D 02 00' => 'Sigma 75-300mm F4.0-5.6',
510             '77 44 61 98 34 3C 7B 0E' => 'Sigma 80-400mm F4.5-5.6 EX OS',
511             '77 44 60 98 34 3C 7B 0E' => 'Sigma 80-400mm F4.5-5.6 APO DG D OS',
512             '48 48 68 8E 30 30 4B 02' => 'Sigma APO 100-300mm F4 EX IF HSM',
513             'F3 48 68 8E 30 30 4B 02' => 'Sigma APO 100-300mm F4 EX IF HSM',
514             '26 45 68 8E 34 42 1C 02' => 'Sigma 100-300mm F4.5-6.7 DL', #30
515             '48 54 6F 8E 24 24 4B 02' => 'Sigma APO 120-300mm F2.8 EX DG HSM',
516             '7A 54 6E 8E 24 24 4B 02' => 'Sigma APO 120-300mm F2.8 EX DG HSM',
517             '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
518             'CF 38 6E 98 34 3C 4B 0E' => 'Sigma APO 120-400mm F4.5-5.6 DG OS HSM',
519             'C3 34 68 98 38 40 4B 4E' => 'Sigma 100-400mm F5-6.3 DG OS HSM | C', #JR (017)
520             '8D 48 6E 8E 24 24 4B 0E' => 'Sigma 120-300mm F2.8 DG OS HSM Sports',
521             '26 44 73 98 34 3C 1C 02' => 'Sigma 135-400mm F4.5-5.6 APO Aspherical',
522             'CE 34 76 A0 38 40 4B 0E' => 'Sigma 150-500mm F5-6.3 DG OS APO HSM', #JD
523             '81 34 76 A6 38 40 4B 0E' => 'Sigma 150-600mm F5-6.3 DG OS HSM | S', #Jaap Voets
524             '82 34 76 A6 38 40 4B 0E' => 'Sigma 150-600mm F5-6.3 DG OS HSM | C',
525             'C4 4C 73 73 14 14 4B 46' => 'Sigma 135mm F1.8 DG HSM | A', #forum3833
526             '26 40 7B A0 34 40 1C 02' => 'Sigma APO 170-500mm F5-6.3 Aspherical RF',
527             'A7 49 80 A0 24 24 4B 06' => 'Sigma APO 200-500mm F2.8 EX DG',
528             '48 3C 8E B0 3C 3C 4B 02' => 'Sigma APO 300-800mm F5.6 EX DG HSM',
529             'D2 3C 8E B0 3C 3C 4B 02' => 'Sigma APO 300-800mm F5.6 EX DG HSM', #forum10942
530             #
531             '00 47 25 25 24 24 00 02' => 'Tamron SP AF 14mm f/2.8 Aspherical (IF) (69E)',
532             'C8 54 44 44 0D 0D DF 46' => 'Tamron SP 35mm f/1.4 Di USD (F045)', #IB
533             'E8 4C 44 44 14 14 DF 0E' => 'Tamron SP 35mm f/1.8 Di VC USD (F012)', #35
534             'E7 4C 4C 4C 14 14 DF 0E' => 'Tamron SP 45mm f/1.8 Di VC USD (F013)',
535             'F4 54 56 56 18 18 84 06' => 'Tamron SP AF 60mm f/2.0 Di II Macro 1:1 (G005)', #24
536             'E5 4C 62 62 14 14 C9 4E' => 'Tamron SP 85mm f/1.8 Di VC USD (F016)', #30
537             '1E 5D 64 64 20 20 13 00' => 'Tamron SP AF 90mm f/2.5 (52E)',
538             '20 5A 64 64 20 20 14 00' => 'Tamron SP AF 90mm f/2.5 Macro (152E)',
539             '22 53 64 64 24 24 E0 02' => 'Tamron SP AF 90mm f/2.8 Macro 1:1 (72E)',
540             '32 53 64 64 24 24 35 02' => 'Tamron SP AF 90mm f/2.8 [Di] Macro 1:1 (172E/272E)',
541             'F8 55 64 64 24 24 84 06' => 'Tamron SP AF 90mm f/2.8 Di Macro 1:1 (272NII)',
542             'F8 54 64 64 24 24 DF 06' => 'Tamron SP AF 90mm f/2.8 Di Macro 1:1 (272NII)',
543             'FE 54 64 64 24 24 DF 0E' => 'Tamron SP 90mm f/2.8 Di VC USD Macro 1:1 (F004)', #Jurgen Sahlberg
544             'E4 54 64 64 24 24 DF 0E' => 'Tamron SP 90mm f/2.8 Di VC USD Macro 1:1 (F017)', #Rolf Probst
545             '00 4C 7C 7C 2C 2C 00 02' => 'Tamron SP AF 180mm f/3.5 Di Model (B01)',
546             '21 56 8E 8E 24 24 14 00' => 'Tamron SP AF 300mm f/2.8 LD-IF (60E)',
547             '27 54 8E 8E 24 24 1D 02' => 'Tamron SP AF 300mm f/2.8 LD-IF (360E)',
548             'E1 40 19 36 2C 35 DF 4E' => 'Tamron 10-24mm f/3.5-4.5 Di II VC HLD (B023)',
549             'F6 3F 18 37 2C 34 84 06' => 'Tamron SP AF 10-24mm f/3.5-4.5 Di II LD Aspherical (IF) (B001)',
550             '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
551             '00 36 1C 2D 34 3C 00 06' => 'Tamron SP AF 11-18mm f/4.5-5.6 Di II LD Aspherical (IF) (A13)',
552             'E9 48 27 3E 24 24 DF 0E' => 'Tamron SP 15-30mm f/2.8 Di VC USD (A012)', #IB
553             'CA 48 27 3E 24 24 DF 4E' => 'Tamron SP 15-30mm f/2.8 Di VC USD G2 (A041)', #IB
554             '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)
555             '07 46 2B 44 24 30 03 02' => 'Tamron SP AF 17-35mm f/2.8-4 Di LD Aspherical (IF) (A05)',
556             'CB 3C 2B 44 24 31 DF 46' => 'Tamron 17-35mm f/2.8-4 Di OSD (A037)', #IB
557             '00 53 2B 50 24 24 00 06' => 'Tamron SP AF 17-50mm f/2.8 XR Di II LD Aspherical (IF) (A16)', #PH
558             '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)
559             '00 54 2B 50 24 24 00 06' => 'Tamron SP AF 17-50mm f/2.8 XR Di II LD Aspherical (IF) (A16NII)',
560             '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
561             'F3 54 2B 50 24 24 84 0E' => 'Tamron SP AF 17-50mm f/2.8 XR Di II VC LD Aspherical (IF) (B005)',
562             '00 3F 2D 80 2B 40 00 06' => 'Tamron AF 18-200mm f/3.5-6.3 XR Di II LD Aspherical (IF) (A14)',
563             '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)',
564             'EC 3E 3C 8E 2C 40 DF 0E' => 'Tamron 28-300mm f/3.5-6.3 Di VC PZD A010', #30
565             '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
566             '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)
567             '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)
568             '00 40 2D 88 2C 40 62 06' => 'Tamron AF 18-250mm f/3.5-6.3 Di II LD Aspherical (IF) Macro (A18)',
569             '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
570             '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)',
571             'F0 3F 2D 8A 2C 40 DF 0E' => 'Tamron AF 18-270mm f/3.5-6.3 Di II VC PZD (B008)',
572             '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)
573             '07 40 2F 44 2C 34 03 02' => 'Tamron AF 19-35mm f/3.5-4.5 (A10)',
574             '07 40 30 45 2D 35 03 02.1' => 'Tamron AF 19-35mm f/3.5-4.5 (A10)',
575             '00 49 30 48 22 2B 00 02' => 'Tamron SP AF 20-40mm f/2.7-3.5 (166D)',
576             '0E 4A 31 48 23 2D 0E 02' => 'Tamron SP AF 20-40mm f/2.7-3.5 (166D)',
577             'FE 48 37 5C 24 24 DF 0E' => 'Tamron SP 24-70mm f/2.8 Di VC USD (A007)', #24
578             'CE 47 37 5C 25 25 DF 4E' => 'Tamron SP 24-70mm f/2.8 Di VC USD G2 (A032)', #forum9110
579             '45 41 37 72 2C 3C 48 02' => 'Tamron SP AF 24-135mm f/3.5-5.6 AD Aspherical (IF) Macro (190D)',
580             '33 54 3C 5E 24 24 62 02' => 'Tamron SP AF 28-75mm f/2.8 XR Di LD Aspherical (IF) Macro (A09)',
581             'FA 54 3C 5E 24 24 84 06' => 'Tamron SP AF 28-75mm f/2.8 XR Di LD Aspherical (IF) Macro (A09NII)', #JD
582             'FA 54 3C 5E 24 24 DF 06' => 'Tamron SP AF 28-75mm f/2.8 XR Di LD Aspherical (IF) Macro (A09NII)',
583             '10 3D 3C 60 2C 3C D2 02' => 'Tamron AF 28-80mm f/3.5-5.6 Aspherical (177D)',
584             '45 3D 3C 60 2C 3C 48 02' => 'Tamron AF 28-80mm f/3.5-5.6 Aspherical (177D)',
585             '00 48 3C 6A 24 24 00 02' => 'Tamron SP AF 28-105mm f/2.8 LD Aspherical IF (176D)',
586             '4D 3E 3C 80 2E 3C 62 02' => 'Tamron AF 28-200mm f/3.8-5.6 XR Aspherical (IF) Macro (A03N)',
587             '0B 3E 3D 7F 2F 3D 0E 00' => 'Tamron AF 28-200mm f/3.8-5.6 (71D)',
588             '0B 3E 3D 7F 2F 3D 0E 02' => 'Tamron AF 28-200mm f/3.8-5.6D (171D)',
589             '12 3D 3C 80 2E 3C DF 02' => 'Tamron AF 28-200mm f/3.8-5.6 AF Aspherical LD (IF) (271D)',
590             '4D 41 3C 8E 2B 40 62 02' => 'Tamron AF 28-300mm f/3.5-6.3 XR Di LD Aspherical (IF) (A061)',
591             '4D 41 3C 8E 2C 40 62 02' => 'Tamron AF 28-300mm f/3.5-6.3 XR LD Aspherical (IF) (185D)',
592             '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)',
593             'C9 3C 44 76 25 31 DF 4E' => 'Tamron 35-150mm f/2.8-4 Di VC OSD (A043)', #30
594             '00 47 53 80 30 3C 00 06' => 'Tamron AF 55-200mm f/4-5.6 Di II LD (A15)',
595             'F7 53 5C 80 24 24 84 06' => 'Tamron SP AF 70-200mm f/2.8 Di LD (IF) Macro (A001)',
596             'FE 53 5C 80 24 24 84 06' => 'Tamron SP AF 70-200mm f/2.8 Di LD (IF) Macro (A001)',
597             'F7 53 5C 80 24 24 40 06' => 'Tamron SP AF 70-200mm f/2.8 Di LD (IF) Macro (A001)',
598             # 'FE 54 5C 80 24 24 DF 0E' => 'Tamron SP AF 70-200mm f/2.8 Di VC USD (A009)',
599             'FE 54 5C 80 24 24 DF 0E' => 'Tamron SP 70-200mm f/2.8 Di VC USD (A009)', #NJ
600             'E2 47 5C 80 24 24 DF 4E' => 'Tamron SP 70-200mm f/2.8 Di VC USD G2 (A025)', #forum9549
601             '69 48 5C 8E 30 3C 6F 02' => 'Tamron AF 70-300mm f/4-5.6 LD Macro 1:2 (572D/772D)',
602             '69 47 5C 8E 30 3C 00 02' => 'Tamron AF 70-300mm f/4-5.6 Di LD Macro 1:2 (A17N)',
603             '00 48 5C 8E 30 3C 00 06' => 'Tamron AF 70-300mm f/4-5.6 Di LD Macro 1:2 (A17NII)', #JD
604             'F1 47 5C 8E 30 3C DF 0E' => 'Tamron SP 70-300mm f/4-5.6 Di VC USD (A005)',
605             'CF 47 5C 8E 31 3D DF 0E' => 'Tamron SP 70-300mm f/4-5.6 Di VC USD (A030)', #forum9773
606             'CC 44 68 98 34 41 DF 0E' => 'Tamron 100-400mm f/4.5-6.3 Di VC USD', #30
607             'EB 40 76 A6 38 40 DF 0E' => 'Tamron SP AF 150-600mm f/5-6.3 VC USD (A011)',
608             'E3 40 76 A6 38 40 DF 4E' => 'Tamron SP 150-600mm f/5-6.3 Di VC USD G2', #30
609             '20 3C 80 98 3D 3D 1E 02' => 'Tamron AF 200-400mm f/5.6 LD IF (75D)',
610             '00 3E 80 A0 38 3F 00 02' => 'Tamron SP AF 200-500mm f/5-6.3 Di LD (IF) (A08)',
611             '00 3F 80 A0 38 3F 00 02' => 'Tamron SP AF 200-500mm f/5-6.3 Di (A08)',
612             #
613             '00 40 2B 2B 2C 2C 00 02' => 'Tokina AT-X 17 AF PRO (AF 17mm f/3.5)',
614             '00 47 44 44 24 24 00 06' => 'Tokina AT-X M35 PRO DX (AF 35mm f/2.8 Macro)',
615             '00 54 68 68 24 24 00 02' => 'Tokina AT-X M100 AF PRO D (AF 100mm f/2.8 Macro)',
616             '27 48 8E 8E 30 30 1D 02' => 'Tokina AT-X 304 AF (AF 300mm f/4.0)',
617             '00 54 8E 8E 24 24 00 02' => 'Tokina AT-X 300 AF PRO (AF 300mm f/2.8)',
618             '12 3B 98 98 3D 3D 09 00' => 'Tokina AT-X 400 AF SD (AF 400mm f/5.6)',
619             '00 40 18 2B 2C 34 00 06' => 'Tokina AT-X 107 AF DX Fisheye (AF 10-17mm f/3.5-4.5)',
620             '00 48 1C 29 24 24 00 06' => 'Tokina AT-X 116 PRO DX (AF 11-16mm f/2.8)',
621             '7A 48 1C 29 24 24 7E 06' => 'Tokina AT-X 116 PRO DX II (AF 11-16mm f/2.8)',
622             '80 48 1C 29 24 24 7A 06' => 'Tokina atx-i 11-16mm F2.8 CF', #exiv2 issue 1078
623             '7A 48 1C 30 24 24 7E 06' => 'Tokina AT-X 11-20 F2.8 PRO DX (AF 11-20mm f/2.8)',
624             '8B 48 1C 30 24 24 85 06' => 'Tokina AT-X 11-20 F2.8 PRO DX (AF 11-20mm f/2.8)', #forum12687
625             '00 3C 1F 37 30 30 00 06' => 'Tokina AT-X 124 AF PRO DX (AF 12-24mm f/4)',
626             '7A 3C 1F 37 30 30 7E 06.2' => 'Tokina AT-X 124 AF PRO DX II (AF 12-24mm f/4)',
627             '7A 3C 1F 3C 30 30 7E 06' => 'Tokina AT-X 12-28 PRO DX (AF 12-28mm f/4)',
628             '00 48 29 3C 24 24 00 06' => 'Tokina AT-X 16-28 AF PRO FX (AF 16-28mm f/2.8)',
629             '00 48 29 50 24 24 00 06' => 'Tokina AT-X 165 PRO DX (AF 16-50mm f/2.8)',
630             '00 40 2A 72 2C 3C 00 06' => 'Tokina AT-X 16.5-135 DX (AF 16.5-135mm F3.5-5.6)',
631             '00 3C 2B 44 30 30 00 06' => 'Tokina AT-X 17-35 F4 PRO FX (AF 17-35mm f/4)',
632             '2F 40 30 44 2C 34 29 02.2' => 'Tokina AF 193 (AF 19-35mm f/3.5-4.5)',
633             '2F 48 30 44 24 24 29 02.2' => 'Tokina AT-X 235 AF PRO (AF 20-35mm f/2.8)',
634             '2F 40 30 44 2C 34 29 02.1' => 'Tokina AF 235 II (AF 20-35mm f/3.5-4.5)',
635             '00 48 37 5C 24 24 00 06' => 'Tokina AT-X 24-70 F2.8 PRO FX (AF 24-70mm f/2.8)',
636             '00 40 37 80 2C 3C 00 02' => 'Tokina AT-X 242 AF (AF 24-200mm f/3.5-5.6)',
637             '25 48 3C 5C 24 24 1B 02.1' => 'Tokina AT-X 270 AF PRO II (AF 28-70mm f/2.6-2.8)',
638             '25 48 3C 5C 24 24 1B 02.2' => 'Tokina AT-X 287 AF PRO SV (AF 28-70mm f/2.8)',
639             '07 48 3C 5C 24 24 03 00' => 'Tokina AT-X 287 AF (AF 28-70mm f/2.8)',
640             '07 47 3C 5C 25 35 03 00' => 'Tokina AF 287 SD (AF 28-70mm f/2.8-4.5)',
641             '07 40 3C 5C 2C 35 03 00' => 'Tokina AF 270 II (AF 28-70mm f/3.5-4.5)',
642             '00 48 3C 60 24 24 00 02' => 'Tokina AT-X 280 AF PRO (AF 28-80mm f/2.8)',
643             '25 44 44 8E 34 42 1B 02' => 'Tokina AF 353 (AF 35-300mm f/4.5-6.7)',
644             '00 48 50 72 24 24 00 06' => 'Tokina AT-X 535 PRO DX (AF 50-135mm f/2.8)',
645             '00 3C 5C 80 30 30 00 0E' => 'Tokina AT-X 70-200 F4 FX VCM-S (AF 70-200mm f/4)',
646             '00 48 5C 80 30 30 00 0E' => 'Tokina AT-X 70-200 F4 FX VCM-S (AF 70-200mm f/4)',
647             '12 44 5E 8E 34 3C 09 00' => 'Tokina AF 730 (AF 75-300mm F4.5-5.6)',
648             '14 54 60 80 24 24 0B 00' => 'Tokina AT-X 828 AF (AF 80-200mm f/2.8)',
649             '24 54 60 80 24 24 1A 02' => 'Tokina AT-X 828 AF PRO (AF 80-200mm f/2.8)',
650             '24 44 60 98 34 3C 1A 02' => 'Tokina AT-X 840 AF-II (AF 80-400mm f/4.5-5.6)',
651             '00 44 60 98 34 3C 00 02' => 'Tokina AT-X 840 D (AF 80-400mm f/4.5-5.6)',
652             '14 48 68 8E 30 30 0B 00' => 'Tokina AT-X 340 AF (AF 100-300mm f/4)',
653             '8C 48 29 3C 24 24 86 06' => 'Tokina opera 16-28mm F2.8 FF', #30
654             #
655             '06 3F 68 68 2C 2C 06 00' => 'Cosina AF 100mm F3.5 Macro',
656             '07 36 3D 5F 2C 3C 03 00' => 'Cosina AF Zoom 28-80mm F3.5-5.6 MC Macro',
657             '07 46 3D 6A 25 2F 03 00' => 'Cosina AF Zoom 28-105mm F2.8-3.8 MC',
658             '12 36 5C 81 35 3D 09 00' => 'Cosina AF Zoom 70-210mm F4.5-5.6 MC Macro',
659             '12 39 5C 8E 34 3D 08 02' => 'Cosina AF Zoom 70-300mm F4.5-5.6 MC Macro',
660             '12 3B 68 8D 3D 43 09 02' => 'Cosina AF Zoom 100-300mm F5.6-6.7 MC Macro',
661             #
662             '12 38 69 97 35 42 09 02' => 'Promaster Spectrum 7 100-400mm F4.5-6.7',
663             #
664             '00 40 31 31 2C 2C 00 00' => 'Voigtlander Color Skopar 20mm F3.5 SLII Aspherical',
665             '00 48 3C 3C 24 24 00 00' => 'Voigtlander Color Skopar 28mm F2.8 SL II',
666             '00 54 48 48 18 18 00 00' => 'Voigtlander Ultron 40mm F2 SLII Aspherical',
667             '00 54 55 55 0C 0C 00 00' => 'Voigtlander Nokton 58mm F1.4 SLII',
668             '00 40 64 64 2C 2C 00 00' => 'Voigtlander APO-Lanthar 90mm F3.5 SLII Close Focus',
669             '07 40 30 45 2D 35 03 02.2' => 'Voigtlander Ultragon 19-35mm F3.5-4.5 VMV', #NJ
670             '71 48 64 64 24 24 00 00' => 'Voigtlander APO-Skopar 90mm F2.8 SL IIs', #30
671             #
672             '00 40 2D 2D 2C 2C 00 00' => 'Carl Zeiss Distagon T* 3.5/18 ZF.2',
673             '00 48 27 27 24 24 00 00' => 'Carl Zeiss Distagon T* 2.8/15 ZF.2', #MykytaKozlov
674             '00 48 32 32 24 24 00 00' => 'Carl Zeiss Distagon T* 2.8/21 ZF.2',
675             '00 54 38 38 18 18 00 00' => 'Carl Zeiss Distagon T* 2/25 ZF.2',
676             '00 54 3C 3C 18 18 00 00' => 'Carl Zeiss Distagon T* 2/28 ZF.2',
677             '00 54 44 44 0C 0C 00 00' => 'Carl Zeiss Distagon T* 1.4/35 ZF.2',
678             '00 54 44 44 18 18 00 00' => 'Carl Zeiss Distagon T* 2/35 ZF.2',
679             '00 54 50 50 0C 0C 00 00' => 'Carl Zeiss Planar T* 1.4/50 ZF.2',
680             '00 54 50 50 18 18 00 00' => 'Carl Zeiss Makro-Planar T* 2/50 ZF.2',
681             '00 54 62 62 0C 0C 00 00' => 'Carl Zeiss Planar T* 1.4/85 ZF.2',
682             '00 54 68 68 18 18 00 00' => 'Carl Zeiss Makro-Planar T* 2/100 ZF.2',
683             '00 54 72 72 18 18 00 00' => 'Carl Zeiss Apo Sonnar T* 2/135 ZF.2',
684             '00 54 53 53 0C 0C 00 00' => 'Zeiss Otus 1.4/55', #IB
685             '01 54 62 62 0C 0C 00 00' => 'Zeiss Otus 1.4/85',
686             '03 54 68 68 0C 0C 00 00' => 'Zeiss Otus 1.4/100', #IB
687             '52 54 44 44 18 18 00 00' => 'Zeiss Milvus 35mm f/2',
688             '53 54 50 50 0C 0C 00 00' => 'Zeiss Milvus 50mm f/1.4', #IB
689             '54 54 50 50 18 18 00 00' => 'Zeiss Milvus 50mm f/2 Macro',
690             '55 54 62 62 0C 0C 00 00' => 'Zeiss Milvus 85mm f/1.4', #IB
691             '56 54 68 68 18 18 00 00' => 'Zeiss Milvus 100mm f/2 Macro',
692             #
693             '00 54 56 56 30 30 00 00' => 'Coastal Optical Systems 60mm 1:4 UV-VIS-IR Macro Apo',
694             #
695             'BF 4E 26 26 1E 1E 01 04' => 'Irix 15mm f/2.4 Firefly', #30
696             'BF 3C 1B 1B 30 30 01 04' => 'Irix 11mm f/4 Firefly', #30
697             #
698             '4A 40 11 11 2C 0C 4D 02' => 'Samyang 8mm f/3.5 Fish-Eye CS',
699             '4A 48 24 24 24 0C 4D 02.1' => 'Samyang 10mm f/2.8 ED AS NCS CS',
700             '4A 48 1E 1E 24 0C 4D 02' => 'Samyang 12mm f/2.8 ED AS NCS Fish-Eye', #Jurgen Sahlberg
701             '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
702             '4A 4C 24 24 1E 6C 4D 06' => 'Samyang 14mm f/2.4 Premium',
703             '4A 54 29 29 18 0C 4D 02' => 'Samyang 16mm f/2.0 ED AS UMC CS', #Jon Bloom (by email)
704             '4A 60 36 36 0C 0C 4D 02' => 'Samyang 24mm f/1.4 ED AS UMC',
705             '4A 60 44 44 0C 0C 4D 02' => 'Samyang 35mm f/1.4 AS UMC',
706             '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
707             #
708             '9A 4C 50 50 14 14 9C 06' => 'Yongnuo YN50mm F1.8N',
709             '9F 48 48 48 24 24 A1 06' => 'Yongnuo YN40mm F2.8N', #30
710             '9F 54 68 68 18 18 A2 06' => 'Yongnuo YN100mm F2N', #30
711             #
712             '02 40 44 5C 2C 34 02 00' => 'Exakta AF 35-70mm 1:3.5-4.5 MC',
713             #
714             '07 3E 30 43 2D 35 03 00' => 'Soligor AF Zoom 19-35mm 1:3.5-4.5 MC',
715             '03 43 5C 81 35 35 02 00' => 'Soligor AF C/D Zoom UMCS 70-210mm 1:4.5',
716             '12 4A 5C 81 31 3D 09 00' => 'Soligor AF C/D Auto Zoom+Macro 70-210mm 1:4-5.6 UMCS',
717             '12 36 69 97 35 42 09 00' => 'Soligor AF Zoom 100-400mm 1:4.5-6.7 MC',
718             #
719             '00 00 00 00 00 00 00 01' => 'Manual Lens No CPU',
720             #
721             '00 00 48 48 53 53 00 01' => 'Loreo 40mm F11-22 3D Lens in a Cap 9005', #PH
722             '00 47 10 10 24 24 00 00' => 'Fisheye Nikkor 8mm f/2.8 AiS',
723             '00 47 3C 3C 24 24 00 00' => 'Nikkor 28mm f/2.8 AiS', #35
724             # '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)
725             '00 57 50 50 14 14 00 00' => 'Nikkor 50mm f/1.8 AI', #35
726             '00 48 50 50 18 18 00 00' => 'Nikkor H 50mm f/2',
727             '00 48 68 68 24 24 00 00' => 'Series E 100mm f/2.8',
728             '00 4C 6A 6A 20 20 00 00' => 'Nikkor 105mm f/2.5 AiS',
729             '00 48 80 80 30 30 00 00' => 'Nikkor 200mm f/4 AiS',
730             '00 40 11 11 2C 2C 00 00' => 'Samyang 8mm f/3.5 Fish-Eye',
731             '00 58 64 64 20 20 00 00' => 'Soligor C/D Macro MC 90mm f/2.5',
732             '4A 58 30 30 14 0C 4D 02' => 'Rokinon 20mm f/1.8 ED AS UMC', #30
733             #
734             'A0 56 44 44 14 14 A2 06' => 'Sony FE 35mm F1.8', #IB (Techart adapter)
735             'A0 37 5C 8E 34 3C A2 06' => 'Sony FE 70-300mm F4.5-5.6 G OSS', #IB (Techart adapter)
736             );
737              
738             # text encoding used in LocationInfo (ref PH)
739             %nikonTextEncoding = (
740             0 => 'n/a',
741             1 => 'UTF8',
742             # UTF16 is a guess here: it could also be Unicode or JIS,
743             # but I chose UTF16 due to the similarity with the QuickTime stringEncoding
744             2 => 'UTF16',
745             );
746              
747             # flash firmware decoding (ref JD)
748             my %flashFirmware = (
749             '0 0' => 'n/a',
750             '1 1' => '1.01 (SB-800 or Metz 58 AF-1)',
751             '1 3' => '1.03 (SB-800)',
752             '2 1' => '2.01 (SB-800)',
753             '2 4' => '2.04 (SB-600)',
754             '2 5' => '2.05 (SB-600)',
755             '3 1' => '3.01 (SU-800 Remote Commander)',
756             '4 1' => '4.01 (SB-400)',
757             '4 2' => '4.02 (SB-400)',
758             '4 4' => '4.04 (SB-400)',
759             '5 1' => '5.01 (SB-900)',
760             '5 2' => '5.02 (SB-900)',
761             '6 1' => '6.01 (SB-700)', #https://exiftool.org/forum/index.php/topic,5034.0.html
762             '7 1' => '7.01 (SB-910)', #PH
763             '14 3' => '14.03 (SB-5000)', #28
764             OTHER => sub {
765             my ($val, $inv) = @_;
766             return sprintf('%d.%.2d (Unknown model)', split(' ', $val)) unless $inv;
767             return "$1 $2" if $val =~ /(\d+)\.(\d+)/;
768             return '0 0';
769             },
770             );
771              
772             # flash Guide Number (GN) distance settings (ref 28)
773             my %flashGNDistance = (
774             0 => 0, 19 => '2.8 m',
775             1 => '0.1 m', 20 => '3.2 m',
776             2 => '0.2 m', 21 => '3.6 m',
777             3 => '0.3 m', 22 => '4.0 m',
778             4 => '0.4 m', 23 => '4.5 m',
779             5 => '0.5 m', 24 => '5.0 m',
780             6 => '0.6 m', 25 => '5.6 m',
781             7 => '0.7 m', 26 => '6.3 m',
782             8 => '0.8 m', 27 => '7.1 m',
783             9 => '0.9 m', 28 => '8.0 m',
784             10 => '1.0 m', 29 => '9.0 m',
785             11 => '1.1 m', 30 => '10.0 m',
786             12 => '1.3 m', 31 => '11.0 m',
787             13 => '1.4 m', 32 => '13.0 m',
788             14 => '1.6 m', 33 => '14.0 m',
789             15 => '1.8 m', 34 => '16.0 m',
790             16 => '2.0 m', 35 => '18.0 m',
791             17 => '2.2 m', 36 => '20.0 m',
792             18 => '2.5 m', 255 => 'n/a',
793             );
794              
795             # flash color filter values (ref 28)
796             my %flashColorFilter = (
797             0x00 => 'None',
798             1 => 'FL-GL1 or SZ-2FL Fluorescent', # (green) (SZ model ref PH)
799             2 => 'FL-GL2',
800             9 => 'TN-A1 or SZ-2TN Incandescent', # (orange) (SZ model ref PH)
801             10 => 'TN-A2',
802             65 => 'Red',
803             66 => 'Blue',
804             67 => 'Yellow',
805             68 => 'Amber',
806             );
807              
808             # flash control mode values (ref JD)
809             my %flashControlMode = (
810             0x00 => 'Off',
811             0x01 => 'iTTL-BL',
812             0x02 => 'iTTL',
813             0x03 => 'Auto Aperture',
814             0x04 => 'Automatic', #28
815             0x05 => 'GN (distance priority)', #28 (Guide Number, but called "GN" in manual)
816             0x06 => 'Manual',
817             0x07 => 'Repeating Flash',
818             );
819              
820             my %activeDLightingZ7 = (
821             0 => 'Off',
822             2 => 'Low',
823             3 => 'Normal',
824             4 => 'High',
825             5 => 'Extra High',
826             );
827              
828             my %flashControlModeZ7 = (
829             0 => 'TTL',
830             1 => 'Auto External Flash',
831             2 => 'GN (distance priority)',
832             3 => 'Manual',
833             4 => 'Repeating Flash',
834             );
835              
836             my %flashRemoteControlZ7 = (
837             0 => 'Group',
838             1 => 'Quick Wireless',
839             2 => 'Remote Repeating',
840             );
841              
842             my %flashWirelessOptionZ7 = (
843             0 => 'Off',
844             1 => 'Optical AWL',
845             2 => 'Optical/Radio AWL',
846             3 => 'Radio AWL',
847             );
848              
849             my %focusModeZ7 = (
850             0 => 'Manual',
851             1 => 'AF-S',
852             2 => 'AF-C',
853             4 => 'AF-F', # full frame
854             );
855              
856             my %infoZSeries = (
857             Condition => '$$self{Model} =~ /^NIKON Z (5|50|6|6_2|7|7_2|fc|9)\b/i',
858             Notes => 'Z Series cameras thru Decemeber 2021',
859             );
860             my %iSOAutoHiLimitZ7 = (
861             0 => 'ISO 64',
862             1 => 'ISO 80',
863             2 => 'ISO 100',
864             3 => 'ISO 125',
865             4 => 'ISO 160',
866             5 => 'ISO 200',
867             6 => 'ISO 250',
868             7 => 'ISO 320',
869             8 => 'ISO 400',
870             9 => 'ISO 500',
871             10 => 'ISO 640',
872             11 => 'ISO 800',
873             12 => 'ISO 1000',
874             13 => 'ISO 1250',
875             14 => 'ISO 1600',
876             15 => 'ISO 2000',
877             16 => 'ISO 2500',
878             17 => 'ISO 3200',
879             18 => 'ISO 4000',
880             19 => 'ISO 5000',
881             20 => 'ISO 6400',
882             21 => 'ISO 8000',
883             22 => 'ISO 10000',
884             23 => 'ISO 12800',
885             24 => 'ISO 16000',
886             25 => 'ISO 20000',
887             26 => 'ISO 25600',
888             27 => 'ISO Hi 0.3',
889             28 => 'ISO Hi 0.7',
890             29 => 'ISO Hi 1.0',
891             32 => 'ISO Hi 2.0',
892             );
893              
894             my %meteringModeZ7 = (
895             0 => 'Matrix',
896             1 => 'Center',
897             2 => 'Spot',
898             3 => 'Highlight'
899             );
900              
901             my %movieFrameRateZ7 = (
902             0 => '120p',
903             1 => '100p',
904             2 => '60p',
905             3 => '50p',
906             4 => '30p',
907             5 => '25p',
908             6 => '24p',
909             );
910              
911             my %offLowNormalHighZ7 = (
912             0 => 'Off',
913             1 => 'Low',
914             2 => 'Normal',
915             3 => 'High',
916             );
917              
918             my %movieFrameSizeZ9 = (
919             1 => '1920x1080',
920             2 => '3840x2160',
921             3 => '7680x4320',
922             );
923              
924             my %subjectDetectionZ9 = (
925             0 => 'Off',
926             1 => 'Auto',
927             2 => 'People',
928             3 => 'Animals',
929             4 => 'Vehicles',
930             );
931              
932             my %vRModeZ9 = (
933             0 => 'Off',
934             1 => 'Normal',
935             2 => 'Sport',
936             );
937              
938             my %retouchValues = ( #PH
939             0 => 'None',
940             3 => 'B & W',
941             4 => 'Sepia',
942             5 => 'Trim',
943             6 => 'Small Picture',
944             7 => 'D-Lighting',
945             8 => 'Red Eye',
946             9 => 'Cyanotype',
947             10 => 'Sky Light',
948             11 => 'Warm Tone',
949             12 => 'Color Custom',
950             13 => 'Image Overlay',
951             14 => 'Red Intensifier',
952             15 => 'Green Intensifier',
953             16 => 'Blue Intensifier',
954             17 => 'Cross Screen',
955             18 => 'Quick Retouch',
956             19 => 'NEF Processing',
957             23 => 'Distortion Control',
958             25 => 'Fisheye',
959             26 => 'Straighten',
960             29 => 'Perspective Control',
961             30 => 'Color Outline',
962             31 => 'Soft Filter',
963             32 => 'Resize', #31
964             33 => 'Miniature Effect',
965             34 => 'Skin Softening', # (S9200)
966             35 => 'Selected Frame', #31 (frame exported from MOV)
967             37 => 'Color Sketch', #31
968             38 => 'Selective Color', # (S9200)
969             39 => 'Glamour', # (S3500)
970             40 => 'Drawing', # (S9200)
971             44 => 'Pop', # (S3500)
972             45 => 'Toy Camera Effect 1', # (S3500)
973             46 => 'Toy Camera Effect 2', # (S3500)
974             47 => 'Cross Process (red)', # (S3500)
975             48 => 'Cross Process (blue)', # (S3500)
976             49 => 'Cross Process (green)', # (S3500)
977             50 => 'Cross Process (yellow)', # (S3500)
978             51 => 'Super Vivid', # (S3500)
979             52 => 'High-contrast Monochrome', # (S3500)
980             53 => 'High Key', # (S3500)
981             54 => 'Low Key', # (S3500)
982             );
983              
984             # AF point indices for models with 51 focus points, eg. D3 (ref JD/PH)
985             # A1 A2 A3 A4 A5 A6 A7 A8 A9
986             # B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11
987             # C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11
988             # D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11
989             # E1 E2 E3 E4 E5 E6 E7 E8 E9
990             my %afPoints51 = (
991             1 => 'C6', 11 => 'C5', 21 => 'C9', 31 => 'C11',41 => 'A2', 51 => 'D1',
992             2 => 'B6', 12 => 'B5', 22 => 'B9', 32 => 'B11',42 => 'D3',
993             3 => 'A5', 13 => 'A4', 23 => 'A8', 33 => 'D11',43 => 'E2',
994             4 => 'D6', 14 => 'D5', 24 => 'D9', 34 => 'C4', 44 => 'C2',
995             5 => 'E5', 15 => 'E4', 25 => 'E8', 35 => 'B4', 45 => 'B2',
996             6 => 'C7', 16 => 'C8', 26 => 'C10',36 => 'A3', 46 => 'A1',
997             7 => 'B7', 17 => 'B8', 27 => 'B10',37 => 'D4', 47 => 'D2',
998             8 => 'A6', 18 => 'A7', 28 => 'A9', 38 => 'E3', 48 => 'E1',
999             9 => 'D7', 19 => 'D8', 29 => 'D10',39 => 'C3', 49 => 'C1',
1000             10 => 'E6', 20 => 'E7', 30 => 'E9', 40 => 'B3', 50 => 'B1',
1001             );
1002              
1003             # AF point indices for models with 39 focus points, eg. D7000 (ref 29)
1004             # A1 A2 A3
1005             # B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11
1006             # C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11
1007             # D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11
1008             # E1 E2 E3
1009             my %afPoints39 = (
1010             1 => 'C6', 11 => 'C5', 21 => 'D9', 31 => 'C3',
1011             2 => 'B6', 12 => 'B5', 22 => 'C10',32 => 'B3',
1012             3 => 'A2', 13 => 'A1', 23 => 'B10',33 => 'D3',
1013             4 => 'D6', 14 => 'D5', 24 => 'D10',34 => 'C2',
1014             5 => 'E2', 15 => 'E1', 25 => 'C11',35 => 'B2',
1015             6 => 'C7', 16 => 'C8', 26 => 'B11',36 => 'D2',
1016             7 => 'B7', 17 => 'B8', 27 => 'D11',37 => 'C1',
1017             8 => 'A3', 18 => 'D8', 28 => 'C4', 38 => 'B1',
1018             9 => 'D7', 19 => 'C9', 29 => 'B4', 39 => 'D1',
1019             10 => 'E3', 20 => 'B9', 30 => 'D4',
1020             );
1021              
1022             # AF point indices for models with 105 focus points, eg. D6 (ref 28)
1023             # - 7 rows (A-G) with 15 columns (1-15), center is D8
1024             my %afPoints105 = (
1025             1 => 'D8', 28 => 'G7', 55 => 'F13', 82 => 'E4',
1026             2 => 'C8', 29 => 'D6', 56 => 'G13', 83 => 'F4',
1027             3 => 'B8', 30 => 'C6', 57 => 'D14', 84 => 'G4',
1028             4 => 'A8', 31 => 'B6', 58 => 'C14', 85 => 'D3',
1029             5 => 'E8', 32 => 'A6', 59 => 'B14', 86 => 'C3',
1030             6 => 'F8', 33 => 'E6', 60 => 'A14', 87 => 'B3',
1031             7 => 'G8', 34 => 'F6', 61 => 'E14', 88 => 'A3',
1032             8 => 'D9', 35 => 'G6', 62 => 'F14', 89 => 'E3',
1033             9 => 'C9', 36 => 'D11', 63 => 'G14', 90 => 'F3',
1034             10 => 'B9', 37 => 'C11', 64 => 'D15', 91 => 'G3',
1035             11 => 'A9', 38 => 'B11', 65 => 'C15', 92 => 'D2',
1036             12 => 'E9', 39 => 'A11', 66 => 'B15', 93 => 'C2',
1037             13 => 'F9', 40 => 'E11', 67 => 'A15', 94 => 'B2',
1038             14 => 'G9', 41 => 'F11', 68 => 'E15', 95 => 'A2',
1039             15 => 'D10', 42 => 'G11', 69 => 'F15', 96 => 'E2',
1040             16 => 'C10', 43 => 'D12', 70 => 'G15', 97 => 'F2',
1041             17 => 'B10', 44 => 'C12', 71 => 'D5', 98 => 'G2',
1042             18 => 'A10', 45 => 'B12', 72 => 'C5', 99 => 'D1',
1043             19 => 'E10', 46 => 'A12', 73 => 'B5', 100 => 'C1',
1044             20 => 'F10', 47 => 'E12', 74 => 'A5', 101 => 'B1',
1045             21 => 'G10', 48 => 'F12', 75 => 'E5', 102 => 'A1',
1046             22 => 'D7', 49 => 'G12', 76 => 'F5', 103 => 'E1',
1047             23 => 'C7', 50 => 'D13', 77 => 'G5', 104 => 'F1',
1048             24 => 'B7', 51 => 'C13', 78 => 'D4', 105 => 'G1',
1049             25 => 'A7', 52 => 'B13', 79 => 'C4',
1050             26 => 'E7', 53 => 'A13', 80 => 'B4',
1051             27 => 'F7', 54 => 'E13', 81 => 'A4',
1052             );
1053              
1054             # AF point indices for models with 135 focus points, eg. 1J1 (ref PH)
1055             # - 9 rows (A-I) with 15 columns (1-15), center is E8
1056             # - odd columns, columns 2 and 14, and the remaining corner points are
1057             # not used in 41-point mode
1058             my %afPoints135 = (
1059             1 => 'E8', 28 => 'E10', 55 => 'E13', 82 => 'E6', 109 => 'E3',
1060             2 => 'D8', 29 => 'D10', 56 => 'D13', 83 => 'D6', 110 => 'D3',
1061             3 => 'C8', 30 => 'C10', 57 => 'C13', 84 => 'C6', 111 => 'C3',
1062             4 => 'B8', 31 => 'B10', 58 => 'B13', 85 => 'B6', 112 => 'B3',
1063             5 => 'A8', 32 => 'A10', 59 => 'A13', 86 => 'A6', 113 => 'A3',
1064             6 => 'F8', 33 => 'F10', 60 => 'F13', 87 => 'F6', 114 => 'F3',
1065             7 => 'G8', 34 => 'G10', 61 => 'G13', 88 => 'G6', 115 => 'G3',
1066             8 => 'H8', 35 => 'H10', 62 => 'H13', 89 => 'H6', 116 => 'H3',
1067             9 => 'I8', 36 => 'I10', 63 => 'I13', 90 => 'I6', 117 => 'I3',
1068             10 => 'E9', 37 => 'E11', 64 => 'E14', 91 => 'E5', 118 => 'E2',
1069             11 => 'D9', 38 => 'D11', 65 => 'D14', 92 => 'D5', 119 => 'D2',
1070             12 => 'C9', 39 => 'C11', 66 => 'C14', 93 => 'C5', 120 => 'C2',
1071             13 => 'B9', 40 => 'B11', 67 => 'B14', 94 => 'B5', 121 => 'B2',
1072             14 => 'A9', 41 => 'A11', 68 => 'A14', 95 => 'A5', 122 => 'A2',
1073             15 => 'F9', 42 => 'F11', 69 => 'F14', 96 => 'F5', 123 => 'F2',
1074             16 => 'G9', 43 => 'G11', 70 => 'G14', 97 => 'G5', 124 => 'G2',
1075             17 => 'H9', 44 => 'H11', 71 => 'H14', 98 => 'H5', 125 => 'H2',
1076             18 => 'I9', 45 => 'I11', 72 => 'I14', 99 => 'I5', 126 => 'I2',
1077             19 => 'E7', 46 => 'E12', 73 => 'E15', 100 => 'E4', 127 => 'E1',
1078             20 => 'D7', 47 => 'D12', 74 => 'D15', 101 => 'D4', 128 => 'D1',
1079             21 => 'C7', 48 => 'C12', 75 => 'C15', 102 => 'C4', 129 => 'C1',
1080             22 => 'B7', 49 => 'B12', 76 => 'B15', 103 => 'B4', 130 => 'B1',
1081             23 => 'A7', 50 => 'A12', 77 => 'A15', 104 => 'A4', 131 => 'A1',
1082             24 => 'F7', 51 => 'F12', 78 => 'F15', 105 => 'F4', 132 => 'F1',
1083             25 => 'G7', 52 => 'G12', 79 => 'G15', 106 => 'G4', 133 => 'G1',
1084             26 => 'H7', 53 => 'H12', 80 => 'H15', 107 => 'H4', 134 => 'H1',
1085             27 => 'I7', 54 => 'I12', 81 => 'I15', 108 => 'I4', 135 => 'I1',
1086             );
1087              
1088             # AF point indices for models with 153 focus points, eg. D5,D500 (ref PH)
1089             # - 9 rows (A-I) with 17 columns (1-17), center is E9
1090             # - 55 of these are selectable cross points (odd rows and columns 1,3,4,6,7,9,11,12,14,15,17)
1091             my %afPoints153 = (
1092             1 => 'E9', 32 => 'A8', 63 => 'I13', 94 => 'B17', 125 => 'H4',
1093             2 => 'D9', 33 => 'F8', 64 => 'E14', 95 => 'A17', 126 => 'I4',
1094             3 => 'C9', 34 => 'G8', 65 => 'D14', 96 => 'F17', 127 => 'E3',
1095             4 => 'B9', 35 => 'H8', 66 => 'C14', 97 => 'G17', 128 => 'D3',
1096             5 => 'A9', 36 => 'I8', 67 => 'B14', 98 => 'H17', 129 => 'C3',
1097             6 => 'F9', 37 => 'E7', 68 => 'A14', 99 => 'I17', 130 => 'B3',
1098             7 => 'G9', 38 => 'D7', 69 => 'F14', 100 => 'E6', 131 => 'A3',
1099             8 => 'H9', 39 => 'C7', 70 => 'G14', 101 => 'D6', 132 => 'F3',
1100             9 => 'I9', 40 => 'B7', 71 => 'H14', 102 => 'C6', 133 => 'G3',
1101             10 => 'E10', 41 => 'A7', 72 => 'I14', 103 => 'B6', 134 => 'H3',
1102             11 => 'D10', 42 => 'F7', 73 => 'E15', 104 => 'A6', 135 => 'I3',
1103             12 => 'C10', 43 => 'G7', 74 => 'D15', 105 => 'F6', 136 => 'E2',
1104             13 => 'B10', 44 => 'H7', 75 => 'C15', 106 => 'G6', 137 => 'D2',
1105             14 => 'A10', 45 => 'I7', 76 => 'B15', 107 => 'H6', 138 => 'C2',
1106             15 => 'F10', 46 => 'E12', 77 => 'A15', 108 => 'I6', 139 => 'B2',
1107             16 => 'G10', 47 => 'D12', 78 => 'F15', 109 => 'E5', 140 => 'A2',
1108             17 => 'H10', 48 => 'C12', 79 => 'G15', 110 => 'D5', 141 => 'F2',
1109             18 => 'I10', 49 => 'B12', 80 => 'H15', 111 => 'C5', 142 => 'G2',
1110             19 => 'E11', 50 => 'A12', 81 => 'I15', 112 => 'B5', 143 => 'H2',
1111             20 => 'D11', 51 => 'F12', 82 => 'E16', 113 => 'A5', 144 => 'I2',
1112             21 => 'C11', 52 => 'G12', 83 => 'D16', 114 => 'F5', 145 => 'E1',
1113             22 => 'B11', 53 => 'H12', 84 => 'C16', 115 => 'G5', 146 => 'D1',
1114             23 => 'A11', 54 => 'I12', 85 => 'B16', 116 => 'H5', 147 => 'C1',
1115             24 => 'F11', 55 => 'E13', 86 => 'A16', 117 => 'I5', 148 => 'B1',
1116             25 => 'G11', 56 => 'D13', 87 => 'F16', 118 => 'E4', 149 => 'A1',
1117             26 => 'H11', 57 => 'C13', 88 => 'G16', 119 => 'D4', 150 => 'F1',
1118             27 => 'I11', 58 => 'B13', 89 => 'H16', 120 => 'C4', 151 => 'G1',
1119             28 => 'E8', 59 => 'A13', 90 => 'I16', 121 => 'B4', 152 => 'H1',
1120             29 => 'D8', 60 => 'F13', 91 => 'E17', 122 => 'A4', 153 => 'I1',
1121             30 => 'C8', 61 => 'G13', 92 => 'D17', 123 => 'F4',
1122             31 => 'B8', 62 => 'H13', 93 => 'C17', 124 => 'G4',
1123             );
1124              
1125             # AF point indices for models with 81 focus points, eg. Z6/Z7/Z50 (ref 38)
1126             # - 9 rows (A-I) with 9 columns (1-9), center is E5
1127             # NOTE: the AF points start 2 bytes into the data, so the map starts
1128             # at 17 instead of 1
1129             #
1130             # 7 6 5 4 3 2 1 0
1131             # 00 : [H5][G5][F5][A5][B5][C5][D5][E5]
1132             # 01 : [G6][F6][A6][B6][C6][D6][E6][I5]
1133             # 02 : [F4][A4][B4][C4][D4][E4][I6][H6]
1134             # 03 : [A7][B7][C7][D7][E7][I4][H4][G4]
1135             # 04 : [B3][C3][D3][E3][I7][H7][G7][F7]
1136             # 05 : [C8][D8][E8][I3][H3][G3][F3][A3]
1137             # 06 : [D2][E2][I8][H8][G8][F8][A8][B8]
1138             # 07 : [E9][I2][H2][G2][F2][A2][B2][C2]
1139             # 08 : [I9][H9][G9][F9][A9][B9][C9][D9]
1140             # 09 : [H1][G1][F1][A1][B1][C1][D1][E1]
1141             # 0a : [ ][ ][ ][ ][ ][ ][ ][I1]
1142             my %afPoints81 = (
1143             17 => 'E5', 34 => 'I6', 51 => 'H7', 68 => 'G8', 85 => 'F9',
1144             18 => 'D5', 35 => 'E4', 52 => 'I7', 69 => 'H8', 86 => 'G9',
1145             19 => 'C5', 36 => 'D4', 53 => 'E3', 70 => 'I8', 87 => 'H9',
1146             20 => 'B5', 37 => 'C4', 54 => 'D3', 71 => 'E2', 88 => 'I9',
1147             21 => 'A5', 38 => 'B4', 55 => 'C3', 72 => 'D2', 89 => 'E1',
1148             22 => 'F5', 39 => 'A4', 56 => 'B3', 73 => 'C2', 90 => 'D1',
1149             23 => 'G5', 40 => 'F4', 57 => 'A3', 74 => 'B2', 91 => 'C1',
1150             24 => 'H5', 41 => 'G4', 58 => 'F3', 75 => 'A2', 92 => 'B1',
1151             25 => 'I5', 42 => 'H4', 59 => 'G3', 76 => 'F2', 93 => 'A1',
1152             26 => 'E6', 43 => 'I4', 60 => 'H3', 77 => 'G2', 94 => 'F1',
1153             27 => 'D6', 44 => 'E7', 61 => 'I3', 78 => 'H2', 95 => 'G1',
1154             28 => 'C6', 45 => 'D7', 62 => 'E8', 79 => 'I2', 96 => 'H1',
1155             29 => 'B6', 46 => 'C7', 63 => 'D8', 80 => 'E9', 97 => 'I1',
1156             30 => 'A6', 47 => 'B7', 64 => 'C8', 81 => 'D9',
1157             31 => 'F6', 48 => 'A7', 65 => 'B8', 82 => 'C9',
1158             32 => 'G6', 49 => 'F7', 66 => 'A8', 83 => 'B9',
1159             33 => 'H6', 50 => 'G7', 67 => 'F8', 84 => 'A9',
1160             );
1161              
1162             my %cropHiSpeed = ( #IB
1163             0 => 'Off',
1164             1 => '1.3x Crop', # (1.3x Crop, Large)
1165             2 => 'DX Crop', # (1.5x)
1166             3 => '5:4 Crop',
1167             4 => '3:2 Crop', # (1.2x, ref 36)
1168             6 => '16:9 Crop',
1169             8 => '2.7x Crop', #36 (D4/D500)
1170             9 => 'DX Movie Crop', # (DX during movie recording, Large)
1171             10 => '1.3x Movie Crop', #36 (D4/D500)
1172             11 => 'FX Uncropped',
1173             12 => 'DX Uncropped',
1174             13 => '2.8x Movie Crop', #28 (D5/D6) 5584/1936
1175             14 => '1.4x Movie Crop', #28 (D5/D6) 5584/3856
1176             15 => '1.5x Movie Crop', #36 (D4/D500) 5600/3872
1177             17 => '1:1 Crop',
1178             OTHER => sub {
1179             my ($val, $inv, $conv) = @_;
1180             return undef if $inv;
1181             my @a = split ' ', $val;
1182             return "Unknown ($val)" unless @a == 7;
1183             $a[0] = $$conv{$a[0]} || "Unknown ($a[0])";
1184             return "$a[0] ($a[1]x$a[2] cropped to $a[3]x$a[4] at pixel $a[5],$a[6])";
1185             },
1186             );
1187              
1188             my %flashGroupOptionsMode = (
1189             0 => 'TTL',
1190             1 => 'Manual',
1191             2 => 'Auto',
1192             3 => 'Off',
1193             );
1194              
1195             my %nefCompression = ( #28 relocated to MakerNotes_0x51 at offset x'0a (Z9)
1196             1 => 'Lossy (type 1)', # (older models)
1197             2 => 'Uncompressed', #JD - D100 (even though TIFF compression is set!)
1198             3 => 'Lossless',
1199             4 => 'Lossy (type 2)',
1200             5 => 'Striped packed 12 bits', #IB
1201             6 => 'Uncompressed (reduced to 12 bit)', #IB
1202             7 => 'Unpacked 12 bits', #IB (padded to 16)
1203             8 => 'Small', #IB
1204             9 => 'Packed 12 bits', #IB (2 pixels in 3 bytes)
1205             10 => 'Packed 14 bits', #28 (4 pixels in 7 bytes, eg. D6 uncompressed 14 bit)
1206             13 => 'High Efficiency', #28
1207             14 => 'High Efficiency*', #28
1208             );
1209              
1210             my %noYes = ( 0 => 'No' , 1 => 'Yes', );
1211             my %offOn = ( 0 => 'Off', 1 => 'On' );
1212             my %onOff = ( 0 => 'On', 1 => 'Off' );
1213              
1214             # common attributes for writable BinaryData directories
1215             my %binaryDataAttrs = (
1216             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
1217             WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
1218             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
1219             WRITABLE => 1,
1220             FIRST_ENTRY => 0,
1221             );
1222              
1223             my %base64bin = ( ValueConv => 'Image::ExifTool::XMP::DecodeBase64($val)' );
1224             my %base64int32u = ( ValueConv => 'my $val=Image::ExifTool::XMP::DecodeBase64($val); unpack("V",$$val)' );
1225             my %base64bytes = ( ValueConv => 'my $val=Image::ExifTool::XMP::DecodeBase64($val); join(".",unpack("C*",$$val))' );
1226             my %base64double = (
1227             ValueConv => q{
1228             my $val=Image::ExifTool::XMP::DecodeBase64($val);
1229             my $saveOrder = GetByteOrder();
1230             SetByteOrder('II');
1231             $val = GetDouble($val,0);
1232             SetByteOrder($saveOrder);
1233             return $val;
1234             },
1235             );
1236             my %base64coord = (
1237             ValueConv => q{
1238             my $val=Image::ExifTool::XMP::DecodeBase64($val);
1239             my $saveOrder = GetByteOrder();
1240             SetByteOrder('II');
1241             $val = GetDouble($val,0) + GetDouble($val,8)/60 + GetDouble($val,16)/3600;
1242             SetByteOrder($saveOrder);
1243             return $val;
1244             },
1245             PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1)',
1246             );
1247             # Nikon maker note tags
1248             %Image::ExifTool::Nikon::Main = (
1249             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikon,
1250             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikon,
1251             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
1252             WRITABLE => 1,
1253             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
1254             PRINT_CONV => \&FormatString,
1255             0x0001 => { #2
1256             # the format differs for different models. for D70, this is a string '0210',
1257             # but for the E775 it is binary: "\x00\x01\x00\x00"
1258             Name => 'MakerNoteVersion',
1259             Writable => 'undef',
1260             Count => 4,
1261             # convert to string if binary
1262             ValueConv => '$_=$val; /^[\x00-\x09]/ and $_=join("",unpack("CCCC",$_)); $_',
1263             ValueConvInv => '$val',
1264             PrintConv => '$_=$val;s/^(\d{2})/$1\./;s/^0//;$_',
1265             PrintConvInv => '$_=$val;s/\.//;"0$_"',
1266             },
1267             0x0002 => {
1268             # this is the ISO actually used by the camera
1269             # (may be different than ISO setting if auto)
1270             Name => 'ISO',
1271             Writable => 'int16u',
1272             Count => 2,
1273             Priority => 0, # the EXIF ISO is more reliable
1274             Groups => { 2 => 'Image' },
1275             # D300 sets this to undef with 4 zero bytes when LO ISO is used - PH
1276             RawConv => '$val eq "\0\0\0\0" ? undef : $val',
1277             # first number is 1 for "Hi ISO" modes (H0.3, H0.7 and H1.0 on D80) - PH
1278             PrintConv => '$_=$val;s/^0 //;s/^1 (\d+)/Hi $1/;$_',
1279             PrintConvInv => '$_=$val;/^\d+/ ? "0 $_" : (s/Hi ?//i ? "1 $_" : $_)',
1280             },
1281             # Note: we attempt to fix the case of these string values (typically written in all caps)
1282             0x0003 => { Name => 'ColorMode', Writable => 'string' },
1283             0x0004 => { Name => 'Quality', Writable => 'string' },
1284             0x0005 => { Name => 'WhiteBalance', Writable => 'string' },
1285             0x0006 => { Name => 'Sharpness', Writable => 'string' },
1286             0x0007 => {
1287             Name => 'FocusMode',
1288             DataMember => 'FocusMode',
1289             Writable => 'string',
1290             RawConv => '$$self{FocusMode} = $val',
1291             },
1292             # FlashSetting (better named FlashSyncMode, ref 28) values:
1293             # "Normal", "Slow", "Rear Slow", "RED-EYE", "RED-EYE SLOW"
1294             0x0008 => { Name => 'FlashSetting', Writable => 'string' },
1295             # FlashType observed values:
1296             # internal: "Built-in,TTL", "Built-in,RPT", "Comdr.", "NEW_TTL"
1297             # external: "Optional,TTL", "Optional,RPT", "Optional,M", "Comdr."
1298             # both: "Built-in,TTL&Comdr."
1299             # no flash: ""
1300             0x0009 => { Name => 'FlashType', Writable => 'string' }, #2 (count varies by model - PH)
1301             # 0x000a - rational values: 5.6 to 9.33 - found in Coolpix models - PH
1302             # (seems constant for a given camera model, but not correlated with scale factor)
1303             0x000b => { #2
1304             Name => 'WhiteBalanceFineTune',
1305             Writable => 'int16s',
1306             Count => -1, # older models write 1 value, newer DSLR's write 2 - PH
1307             },
1308             0x000c => { # (D1X)
1309             Name => 'WB_RBLevels',
1310             Writable => 'rational64u',
1311             Count => 4, # (not sure what the last 2 values are for)
1312             },
1313             0x000d => { #15
1314             Name => 'ProgramShift',
1315             Writable => 'undef',
1316             Count => 4,
1317             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1318             ValueConvInv => q{
1319             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1320             $a<-128 or $a>127 ? undef : pack("c4",$a,1,6,0);
1321             },
1322             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1323             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1324             },
1325             0x000e => {
1326             Name => 'ExposureDifference',
1327             Writable => 'undef',
1328             Count => 4,
1329             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1330             ValueConvInv => q{
1331             my $a = int($val*12 + ($val>0 ? 0.5 : -0.5));
1332             $a<-128 or $a>127 ? undef : pack("c4",$a,1,12,0);
1333             },
1334             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
1335             PrintConvInv => '$val',
1336             },
1337             0x000f => { Name => 'ISOSelection', Writable => 'string' }, #2
1338             0x0010 => {
1339             Name => 'DataDump',
1340             Writable => 0,
1341             Binary => 1,
1342             },
1343             0x0011 => {
1344             Name => 'PreviewIFD',
1345             Groups => { 1 => 'PreviewIFD', 2 => 'Image' },
1346             Flags => 'SubIFD',
1347             SubDirectory => {
1348             TagTable => 'Image::ExifTool::Nikon::PreviewIFD',
1349             Start => '$val',
1350             },
1351             },
1352             0x0012 => { #2 (camera setting: combination of command dial and menus - PH)
1353             Name => 'FlashExposureComp',
1354             Description => 'Flash Exposure Compensation',
1355             Writable => 'undef',
1356             Count => 4,
1357             # (includes the built-in compensation for FlashType "Built-in,TTL&Comdr.")
1358             Notes => q{
1359             may be set even if flash does not fire. Does not include the effect of
1360             flash bracketing.
1361             },
1362             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1363             ValueConvInv => q{
1364             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1365             $a<-128 or $a>127 ? undef : pack("c4",$a,1,6,0);
1366             },
1367             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1368             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1369             },
1370             # D70 - another ISO tag
1371             0x0013 => { #2
1372             Name => 'ISOSetting',
1373             Writable => 'int16u',
1374             Count => 2,
1375             PrintConv => '$_=$val;s/^0 //;$_',
1376             PrintConvInv => '"0 $val"',
1377             },
1378             0x0014 => [
1379             { #4
1380             Name => 'ColorBalanceA',
1381             Condition => '$format eq "undef" and $count == 2560',
1382             SubDirectory => {
1383             TagTable => 'Image::ExifTool::Nikon::ColorBalanceA',
1384             ByteOrder => 'BigEndian',
1385             },
1386             },
1387             { #IB
1388             Name => 'NRWData',
1389             Condition => '$$valPt =~ /^NRW 0100/',
1390             Drop => 1, # 'Drop' because it is large and not found in JPEG images
1391             SubDirectory => {
1392             TagTable => 'Image::ExifTool::Nikon::ColorBalanceB',
1393             },
1394             },
1395             { #IB
1396             Name => 'NRWData',
1397             Condition => '$$valPt =~ /^NRW /',
1398             Drop => 1, # 'Drop' because it is large and not found in JPEG images
1399             SubDirectory => {
1400             TagTable => 'Image::ExifTool::Nikon::ColorBalanceC',
1401             },
1402             },
1403             ],
1404             # 0x0015 - string[8]: "AUTO "
1405             # D70 Image boundary?? top x,y bot-right x,y
1406             0x0016 => { #2
1407             Name => 'ImageBoundary',
1408             Writable => 'int16u',
1409             Count => 4,
1410             },
1411             0x0017 => { #28
1412             Name => 'ExternalFlashExposureComp', #PH (setting from external flash unit)
1413             Writable => 'undef',
1414             Count => 4,
1415             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1416             ValueConvInv => q{
1417             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1418             $a<-128 or $a>127 ? undef : pack("c4",$a,1,6,0);
1419             },
1420             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1421             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1422             },
1423             0x0018 => { #5
1424             Name => 'FlashExposureBracketValue',
1425             Writable => 'undef',
1426             Count => 4,
1427             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1428             ValueConvInv => q{
1429             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1430             $a<-128 or $a>127 ? undef : pack("c4",$a,1,6,0);
1431             },
1432             PrintConv => 'sprintf("%.1f",$val)',
1433             PrintConvInv => '$val',
1434             },
1435             0x0019 => { #5
1436             Name => 'ExposureBracketValue',
1437             Writable => 'rational64s',
1438             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1439             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1440             },
1441             0x001a => { #PH
1442             Name => 'ImageProcessing',
1443             Writable => 'string',
1444             },
1445             0x001b => { #15
1446             Name => 'CropHiSpeed',
1447             Writable => 'int16u',
1448             Count => 7,
1449             PrintConv => \%cropHiSpeed,
1450             },
1451             0x001c => { #28 (D3 "the application of CSb6 to the selected metering mode")
1452             Name => 'ExposureTuning',
1453             Writable => 'undef',
1454             Count => 3,
1455             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1456             ValueConvInv => q{
1457             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1458             $a<-128 or $a>127 ? undef : pack("c3",$a,1,6);
1459             },
1460             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1461             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1462             },
1463             0x001d => { #4
1464             Name => 'SerialNumber',
1465             # Note: this has been known to change even if the serial number on the body
1466             # stays the same if some parts of the camera were replaced by Nikon service
1467             Writable => 'string',
1468             Protected => 1,
1469             Notes => q{
1470             this value is used as a key to decrypt other information -- writing this tag
1471             causes the other information to be re-encrypted with the new key
1472             },
1473             PrintConv => undef, # disable default PRINT_CONV
1474             },
1475             0x001e => { #14
1476             Name => 'ColorSpace',
1477             Writable => 'int16u',
1478             PrintConv => {
1479             1 => 'sRGB',
1480             2 => 'Adobe RGB',
1481             },
1482             },
1483             0x001f => { #PH
1484             Name => 'VRInfo',
1485             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::VRInfo' },
1486             },
1487             0x0020 => { #16
1488             Name => 'ImageAuthentication',
1489             Writable => 'int8u',
1490             PrintConv => \%offOn,
1491             },
1492             0x0021 => { #PH
1493             Name => 'FaceDetect',
1494             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FaceDetect' },
1495             },
1496             0x0022 => { #21
1497             Name => 'ActiveD-Lighting',
1498             Writable => 'int16u',
1499             PrintConv => {
1500             0 => 'Off',
1501             1 => 'Low',
1502             3 => 'Normal',
1503             5 => 'High',
1504             7 => 'Extra High', #10
1505             8 => 'Extra High 1', #PH
1506             9 => 'Extra High 2', #PH
1507             10 => 'Extra High 3', #PH
1508             11 => 'Extra High 4', #PH
1509             0xffff => 'Auto', #10
1510             },
1511             },
1512             0x0023 => [
1513             { #PH (D300, but also found in D3,D3S,D3X,D90,D300S,D700,D3000,D5000)
1514             Name => 'PictureControlData',
1515             Condition => '$$valPt =~ /^01/',
1516             Writable => 'undef',
1517             Permanent => 0,
1518             Flags => [ 'Binary', 'Protected' ],
1519             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl' },
1520             },{ #28
1521             Name => 'PictureControlData',
1522             Condition => '$$valPt =~ /^02/',
1523             Writable => 'undef',
1524             Permanent => 0,
1525             Flags => [ 'Binary', 'Protected' ],
1526             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl2' },
1527             },{
1528             Name => 'PictureControlData',
1529             Condition => '$$valPt =~ /^03/',
1530             Writable => 'undef',
1531             Permanent => 0,
1532             Flags => [ 'Binary', 'Protected' ],
1533             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl3' },
1534             },{
1535             Name => 'PictureControlData',
1536             Writable => 'undef',
1537             Permanent => 0,
1538             Flags => [ 'Binary', 'Protected' ],
1539             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControlUnknown' },
1540             },
1541             ],
1542             0x0024 => { #JD
1543             Name => 'WorldTime',
1544             SubDirectory => {
1545             TagTable => 'Image::ExifTool::Nikon::WorldTime',
1546             # (CaptureNX does flip the byte order of this record)
1547             },
1548             },
1549             0x0025 => { #PH
1550             Name => 'ISOInfo',
1551             SubDirectory => {
1552             TagTable => 'Image::ExifTool::Nikon::ISOInfo',
1553             ByteOrder => 'BigEndian',
1554             },
1555             },
1556             0x002a => { #23 (this tag added with D3 firmware 1.10 -- also written by Nikon utilities)
1557             Name => 'VignetteControl',
1558             Writable => 'int16u',
1559             PrintConv => {
1560             0 => 'Off',
1561             1 => 'Low',
1562             3 => 'Normal',
1563             5 => 'High',
1564             },
1565             },
1566             0x002b => { #PH
1567             Name => 'DistortInfo',
1568             SubDirectory => {
1569             TagTable => 'Image::ExifTool::Nikon::DistortInfo',
1570             },
1571             },
1572             0x002c => { #29 (D7000)
1573             Name => 'UnknownInfo',
1574             SubDirectory => {
1575             TagTable => 'Image::ExifTool::Nikon::UnknownInfo',
1576             ByteOrder => 'BigEndian', #(NC)
1577             },
1578             },
1579             # 0x2d - "512 0 0","512 3 10","512 1 14",...
1580             0x0032 => { #PH
1581             Name => 'UnknownInfo2',
1582             SubDirectory => {
1583             TagTable => 'Image::ExifTool::Nikon::UnknownInfo2',
1584             ByteOrder => 'BigEndian', #(NC)
1585             },
1586             },
1587             0x0034 => { #forum9646
1588             Name => 'ShutterMode',
1589             Writable => 'int16u',
1590             PrintConv => {
1591             0 => 'Mechanical',
1592             16 => 'Electronic',
1593             # 33 => ? seen for 1J2
1594             48 => 'Electronic Front Curtain',
1595             64 => 'Electronic (Movie)', #JanSkoda (Z6II)
1596             80 => 'Auto (Mechanical)', #JanSkoda (Z6II)
1597             81 => 'Auto (Electronic Front Curtain)', #JanSkoda (Z6II)
1598             },
1599             },
1600             0x0035 => { #32
1601             Name => 'HDRInfo',
1602             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::HDRInfo' },
1603             },
1604             0x0037 => { #XavierJubier
1605             Name => 'MechanicalShutterCount',
1606             Writable => 'int32u',
1607             },
1608             0x0039 => {
1609             Name => 'LocationInfo',
1610             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LocationInfo' },
1611             },
1612             0x003d => { #IB
1613             Name => 'BlackLevel',
1614             Writable => 'int16u',
1615             Count => 4,
1616             # (may need to divide by 4 for some images, eg. D3300/D5300, 12 bit - ref IB)
1617             },
1618             0x003e => { #28
1619             Name => 'ImageSizeRAW',
1620             PrintConv => {
1621             1 => 'Large',
1622             2 => 'Medium',
1623             3 => 'Small',
1624             },
1625             },
1626             0x0045 => { #IB
1627             Name => 'CropArea',
1628             Notes => 'left, top, width, height',
1629             Writable => 'int16u',
1630             Count => 4,
1631             },
1632             0x004e => { #28
1633             Name => 'NikonSettings',
1634             Writable => 'undef',
1635             Permanent => 0,
1636             Flags => [ 'Binary', 'Protected' ],
1637             SubDirectory => { TagTable => 'Image::ExifTool::NikonSettings::Main' },
1638             },
1639             0x004f => { #IB (D850)
1640             Name => 'ColorTemperatureAuto',
1641             Writable => 'int16u',
1642             },
1643             0x0051 => { #28 (Z9)
1644             Name => 'MakerNotes0x51',
1645             Writable => 'undef',
1646             Hidden => 1,
1647             Permanent => 0,
1648             Flags => [ 'Binary', 'Protected' ],
1649             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::MakerNotes0x51' },
1650             },
1651             #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)
1652             #0x005e #28 possibly DiffractionCompensation block? Certainly offset 0x04 within block contains tag DiffractionCompensation
1653             0x0080 => { Name => 'ImageAdjustment', Writable => 'string' },
1654             0x0081 => { Name => 'ToneComp', Writable => 'string' }, #2
1655             0x0082 => { Name => 'AuxiliaryLens', Writable => 'string' },
1656             0x0083 => {
1657             Name => 'LensType',
1658             Writable => 'int8u',
1659             # credit to Tom Christiansen (ref 7) for figuring this out...
1660             # (note that older models don't seem to set bits 4-7 (0xf0), so the
1661             # LensType may be different with different models, ref Kenneth Cochran)
1662             PrintConv => q[$_ = $val ? Image::ExifTool::DecodeBits($val,
1663             {
1664             0 => 'MF',
1665             1 => 'D',
1666             2 => 'G',
1667             3 => 'VR',
1668             4 => '1', #PH
1669             5 => 'FT-1', #PH/IB
1670             6 => 'E', #PH (electromagnetic aperture mechanism)
1671             7 => 'AF-P', #PH/IB
1672             }) : 'AF';
1673             # remove commas and change "D G" to just "G"
1674             s/,//g; s/\bD G\b/G/;
1675             s/ E\b// and s/^(G )?/E /; # put "E" at the start instead of "G"
1676             s/ 1// and $_ = "1 $_"; # put "1" at start
1677             s/FT-1 // and $_ .= ' FT-1'; # put "FT-1" at end
1678             return $_;
1679             ],
1680             PrintConvInv => q[
1681             my $bits = 0;
1682             $bits |= 0x01 if $val =~ /\bMF\b/i; # bit 0
1683             $bits |= 0x02 if $val =~ /\bD\b/i; # bit 1
1684             $bits |= 0x06 if $val =~ /\bG\b/i; # bits 1 and 2
1685             $bits |= 0x08 if $val =~ /\bVR\b/i; # bit 3
1686             $bits |= 0x10 if $val =~ /\b1\b/; # bit 4
1687             $bits |= 0x20 if $val =~ /\bFT-1/i; # bit 5
1688             $bits |= 0x80 if $val =~ /\bAF-P/i; # bit 7 (not used by all models)
1689             $bits |= 0x46 if $val =~ /\bE\b/i; # bits 1, 2 and 6
1690             return $bits;
1691             ],
1692             },
1693             0x0084 => { #2
1694             Name => "Lens",
1695             Writable => 'rational64u',
1696             Count => 4,
1697             # short focal, long focal, aperture at short focal, aperture at long focal
1698             PrintConv => \&Image::ExifTool::Exif::PrintLensInfo,
1699             PrintConvInv => \&Image::ExifTool::Exif::ConvertLensInfo,
1700             },
1701             0x0085 => {
1702             Name => 'ManualFocusDistance',
1703             Writable => 'rational64u',
1704             },
1705             0x0086 => {
1706             Name => 'DigitalZoom',
1707             Writable => 'rational64u',
1708             },
1709             0x0087 => { #5
1710             Name => 'FlashMode',
1711             Writable => 'int8u',
1712             PrintConv => {
1713             0 => 'Did Not Fire',
1714             1 => 'Fired, Manual', #14
1715             3 => 'Not Ready', #28
1716             7 => 'Fired, External', #14
1717             8 => 'Fired, Commander Mode',
1718             9 => 'Fired, TTL Mode',
1719             18 => 'LED Light', #G.F. (movie LED light)
1720             },
1721             },
1722             0x0088 => [
1723             {
1724             Name => 'AFInfo',
1725             Condition => '$$self{Model} =~ /^NIKON D/i',
1726             SubDirectory => {
1727             TagTable => 'Image::ExifTool::Nikon::AFInfo',
1728             ByteOrder => 'BigEndian',
1729             },
1730             },
1731             {
1732             Name => 'AFInfo',
1733             SubDirectory => {
1734             TagTable => 'Image::ExifTool::Nikon::AFInfo',
1735             ByteOrder => 'LittleEndian',
1736             },
1737             },
1738             ],
1739             0x0089 => { #5
1740             Name => 'ShootingMode',
1741             Writable => 'int16u',
1742             # the meaning of bit 5 seems to change: For the D200 it indicates "Auto ISO" - PH
1743             Notes => 'for the D70, Bit 5 = Unused LE-NR Slowdown',
1744             # credit to Tom Christiansen (ref 7) for figuring this out...
1745             # The (new?) bit 5 seriously complicates our life here: after firmwareB's
1746             # 1.03, bit 5 turns on when you ask for BUT DO NOT USE the long-range
1747             # noise reduction feature, probably because even not using it, it still
1748             # slows down your drive operation to 50% (1.5fps max not 3fps). But no
1749             # longer does !$val alone indicate single-frame operation. - TC, D70
1750             # The following comments are from Warren Hatch:
1751             # Bits 4,6,8 indicate bracketing mode.
1752             # - all 0's => Bracketing Off
1753             # - bit 4 on with bits 6,8 off => Exposure Bracketing On
1754             # - bits 4,6 on => WB bracketing On
1755             # - 4,8 on => ADL Bracketing On
1756             # Bit 2 gives tethered status: Off=>Not Tethered; On=Tethered.
1757             # - that this simply indicates a camera is connected via a cord to a PC
1758             # (doesn't necessarily mean that the shutter was tripped by the computer)
1759             # Bits 0,1,3,7,9 relate to how the shutter is tripped in concert with the
1760             # Release Mode dial [although I cannot cause bit 7 to flip with any of my gear and
1761             # I suspect it is no longer used for the D500]. Regardless, the ReleaseMode tag
1762             # offers a superior decoding of this information for the D4s, D810 and D500.
1763             # Bit 5 indicates whether or not AutoISO is enabled.
1764             PrintConv => q[
1765             $_ = '';
1766             unless ($val & 0x87) {
1767             return 'Single-Frame' unless $val;
1768             $_ = 'Single-Frame, ';
1769             }
1770             return $_ . Image::ExifTool::DecodeBits($val,
1771             {
1772             0 => 'Continuous',
1773             1 => 'Delay',
1774             2 => 'PC Control',
1775             3 => 'Self-timer', #forum6281 (NC)
1776             4 => 'Exposure Bracketing',
1777             5 => $$self{Model}=~/D70\b/ ? 'Unused LE-NR Slowdown' : 'Auto ISO',
1778             6 => 'White-Balance Bracketing',
1779             7 => 'IR Control',
1780             8 => 'D-Lighting Bracketing', #forum6281 (NC)
1781             });
1782             ],
1783             },
1784             # 0x008a - called "AutoBracketRelease" by ref 15 [but this seems wrong]
1785             # values: 0,255 (when writing NEF only), or 1,2 (when writing JPEG or JPEG+NEF)
1786             # --> makes odd, repeating pattern in sequential NEF images (ref 28)
1787             0x008b => { #8
1788             Name => 'LensFStops',
1789             ValueConv => 'my ($a,$b,$c)=unpack("C3",$val); $c ? $a*($b/$c) : 0',
1790             ValueConvInv => 'my $a=int($val*12+0.5);$a<256 ? pack("C4",$a,1,12,0) : undef',
1791             PrintConv => 'sprintf("%.2f", $val)',
1792             PrintConvInv => '$val',
1793             Writable => 'undef',
1794             Count => 4,
1795             },
1796             0x008c => {
1797             Name => 'ContrastCurve', #JD
1798             Writable => 'undef',
1799             Flags => [ 'Binary', 'Protected', 'Drop' ], # (drop because not found in Nikon JPEG's)
1800             },
1801             # ColorHue: MODE1/MODE1a=sRGB, MODE2=Adobe RGB, MODE3a=more saturated sRGB
1802             # --> should really be called ColorSpace or ColorMode, but that would conflict with other tags
1803             0x008d => { Name => 'ColorHue' , Writable => 'string' }, #2
1804             # SceneMode takes on the following values: PORTRAIT, PARTY/INDOOR, NIGHT PORTRAIT,
1805             # BEACH/SNOW, LANDSCAPE, SUNSET, NIGHT SCENE, MUSEUM, FIREWORKS, CLOSE UP, COPY,
1806             # BACK LIGHT, PANORAMA ASSIST, SPORT, DAWN/DUSK
1807             0x008f => { Name => 'SceneMode', Writable => 'string' }, #2
1808             # LightSource shows 3 values COLORED SPEEDLIGHT NATURAL.
1809             # (SPEEDLIGHT when flash goes. Have no idea about difference between other two.)
1810             0x0090 => { Name => 'LightSource', Writable => 'string' }, #2
1811             0x0091 => [ #18
1812             { #PH
1813             Condition => '$$valPt =~ /^0209/',
1814             Name => 'ShotInfoD40',
1815             SubDirectory => {
1816             TagTable => 'Image::ExifTool::Nikon::ShotInfoD40',
1817             DecryptStart => 4,
1818             DecryptLen => 748,
1819             ByteOrder => 'BigEndian',
1820             },
1821             },
1822             {
1823             Condition => '$$valPt =~ /^0208/',
1824             Name => 'ShotInfoD80',
1825             SubDirectory => {
1826             TagTable => 'Image::ExifTool::Nikon::ShotInfoD80',
1827             DecryptStart => 4,
1828             DecryptLen => 765,
1829             # (Capture NX can change the makernote byte order, but this stays big-endian)
1830             ByteOrder => 'BigEndian',
1831             },
1832             },
1833             { #PH (D90, firmware 1.00)
1834             Condition => '$$valPt =~ /^0213/',
1835             Name => 'ShotInfoD90',
1836             SubDirectory => {
1837             TagTable => 'Image::ExifTool::Nikon::ShotInfoD90',
1838             DecryptStart => 4,
1839             DecryptLen => 0x398,
1840             ByteOrder => 'BigEndian',
1841             },
1842             },
1843             { #PH (D3, firmware 0.37 and 1.00)
1844             Condition => '$$valPt =~ /^0210/ and $count == 5399',
1845             Name => 'ShotInfoD3a',
1846             SubDirectory => {
1847             TagTable => 'Image::ExifTool::Nikon::ShotInfoD3a',
1848             DecryptStart => 4,
1849             DecryptLen => 0x318,
1850             ByteOrder => 'BigEndian',
1851             },
1852             },
1853             { #PH (D3, firmware 1.10, 2.00 and 2.01 [count 5408], and 2.02 [count 5412])
1854             Condition => '$$valPt =~ /^0210/ and ($count == 5408 or $count == 5412)',
1855             Name => 'ShotInfoD3b',
1856             SubDirectory => {
1857             TagTable => 'Image::ExifTool::Nikon::ShotInfoD3b',
1858             DecryptStart => 4,
1859             DecryptLen => 0x321,
1860             ByteOrder => 'BigEndian',
1861             },
1862             },
1863             { #PH (D3X, firmware 1.00)
1864             Condition => '$$valPt =~ /^0214/ and $count == 5409',
1865             Name => 'ShotInfoD3X',
1866             SubDirectory => {
1867             TagTable => 'Image::ExifTool::Nikon::ShotInfoD3X',
1868             DecryptStart => 4,
1869             DecryptLen => 0x323,
1870             ByteOrder => 'BigEndian',
1871             },
1872             },
1873             { #PH (D3S, firmware 0.16 and 1.00)
1874             Condition => '$$valPt =~ /^0218/ and ($count == 5356 or $count == 5388)',
1875             Name => 'ShotInfoD3S',
1876             SubDirectory => {
1877             TagTable => 'Image::ExifTool::Nikon::ShotInfoD3S',
1878             DecryptStart => 4,
1879             DecryptLen => 0x2e9,
1880             ByteOrder => 'BigEndian',
1881             },
1882             },
1883             { #JD (D300, firmware 0.25 and 1.00)
1884             # D3 and D300 use the same version number, but the length is different
1885             Condition => '$$valPt =~ /^0210/ and $count == 5291',
1886             Name => 'ShotInfoD300a',
1887             SubDirectory => {
1888             TagTable => 'Image::ExifTool::Nikon::ShotInfoD300a',
1889             DecryptStart => 4,
1890             DecryptLen => 813,
1891             ByteOrder => 'BigEndian',
1892             },
1893             },
1894             { #PH (D300, firmware version 1.10)
1895             # yet again the same ShotInfoVersion for different data
1896             Condition => '$$valPt =~ /^0210/ and $count == 5303',
1897             Name => 'ShotInfoD300b',
1898             SubDirectory => {
1899             TagTable => 'Image::ExifTool::Nikon::ShotInfoD300b',
1900             DecryptStart => 4,
1901             DecryptLen => 825,
1902             ByteOrder => 'BigEndian',
1903             },
1904             },
1905             { #PH (D300S, firmware version 1.00)
1906             # yet again the same ShotInfoVersion for different data
1907             Condition => '$$valPt =~ /^0216/ and $count == 5311',
1908             Name => 'ShotInfoD300S',
1909             SubDirectory => {
1910             TagTable => 'Image::ExifTool::Nikon::ShotInfoD300S',
1911             DecryptStart => 4,
1912             DecryptLen => 827,
1913             ByteOrder => 'BigEndian',
1914             },
1915             },
1916             # 0225 - D600
1917             { #29 (D700 firmware version 1.02f)
1918             Condition => '$$valPt =~ /^0212/ and $count == 5312',
1919             Name => 'ShotInfoD700',
1920             SubDirectory => {
1921             TagTable => 'Image::ExifTool::Nikon::ShotInfoD700',
1922             DecryptStart => 4,
1923             DecryptLen => 0x358,
1924             ByteOrder => 'BigEndian',
1925             },
1926             },
1927             { #PH (D800 firmware 1.01a)
1928             Condition => '$$valPt =~ /^0222/',
1929             Name => 'ShotInfoD800',
1930             SubDirectory => {
1931             TagTable => 'Image::ExifTool::Nikon::ShotInfoD800',
1932             DecryptStart => 4,
1933             DecryptLen => 0x720,
1934             ByteOrder => 'BigEndian',
1935             },
1936             },
1937             { #28 (D810 firmware 1.01)
1938             Condition => '$$valPt =~ /^0233/',
1939             Name => 'ShotInfoD810',
1940             SubDirectory => {
1941             TagTable => 'Image::ExifTool::Nikon::ShotInfoD810',
1942             DecryptStart => 4,
1943             DecryptLen => 0x36f4 + 12,
1944             DecryptMore => 'Get32u(\$data, 0x84) + 12',
1945             ByteOrder => 'LittleEndian',
1946             },
1947             },
1948             { #28 (D850 firmware 1.00b)
1949             Condition => '$$valPt =~ /^0243/',
1950             Name => 'ShotInfoD850',
1951             SubDirectory => {
1952             TagTable => 'Image::ExifTool::Nikon::ShotInfoD850',
1953             DecryptStart => 4,
1954             DecryptLen => 0x2efb + 12,
1955             DecryptMore => 'Get32u(\$data, 0xa0) + 12',
1956             ByteOrder => 'LittleEndian',
1957             },
1958             },
1959             # 0217 - D3000
1960             # 0219 - D3100
1961             # 0224 - D3200
1962             { #PH
1963             Condition => '$$valPt =~ /^0215/ and $count == 6745',
1964             Name => 'ShotInfoD5000',
1965             SubDirectory => {
1966             TagTable => 'Image::ExifTool::Nikon::ShotInfoD5000',
1967             DecryptStart => 4,
1968             DecryptLen => 0x39a,
1969             ByteOrder => 'BigEndian',
1970             },
1971             },
1972             { #PH
1973             Condition => '$$valPt =~ /^0221/ and $count == 8902',
1974             Name => 'ShotInfoD5100',
1975             SubDirectory => {
1976             TagTable => 'Image::ExifTool::Nikon::ShotInfoD5100',
1977             DecryptStart => 4,
1978             DecryptLen => 0x430,
1979             ByteOrder => 'BigEndian',
1980             },
1981             },
1982             { #PH
1983             Condition => '$$valPt =~ /^0226/ and $count == 11587',
1984             Name => 'ShotInfoD5200',
1985             SubDirectory => {
1986             TagTable => 'Image::ExifTool::Nikon::ShotInfoD5200',
1987             DecryptStart => 4,
1988             DecryptLen => 0xd00,
1989             ByteOrder => 'BigEndian',
1990             },
1991             },
1992             { #29 (D7000 firmware version 1.01b)
1993             Condition => '$$valPt =~ /^0220/',
1994             Name => 'ShotInfoD7000',
1995             SubDirectory => {
1996             TagTable => 'Image::ExifTool::Nikon::ShotInfoD7000',
1997             DecryptStart => 4,
1998             DecryptLen => 0x448,
1999             ByteOrder => 'BigEndian',
2000             },
2001             },
2002             { # (D4 firmware version 1.00g)
2003             Condition => '$$valPt =~ /^0223/',
2004             Name => 'ShotInfoD4',
2005             SubDirectory => {
2006             TagTable => 'Image::ExifTool::Nikon::ShotInfoD4',
2007             DecryptStart => 4,
2008             DecryptLen => 0x789,
2009             ByteOrder => 'BigEndian',
2010             },
2011             },
2012             { # (D4S firmware version 1.00d and 1.01a)
2013             Condition => '$$valPt =~ /^0231/',
2014             Name => 'ShotInfoD4S',
2015             SubDirectory => {
2016             TagTable => 'Image::ExifTool::Nikon::ShotInfoD4S',
2017             DecryptStart => 4,
2018             DecryptLen => 0x3697,
2019             ByteOrder => 'LittleEndian',
2020             },
2021             },
2022             { #28 (D5 firmware version 1.10a)
2023             Condition => '$$valPt =~ /^0238/',
2024             Name => 'ShotInfoD5',
2025             SubDirectory => {
2026             TagTable => 'Image::ExifTool::Nikon::ShotInfoD500',
2027             DecryptStart => 4,
2028             DecryptLen => 0x2c24 + 12,
2029             DecryptMore => 'Get32u(\$data, 0xa8) + 0x2ea5 - 0x2c90',
2030             ByteOrder => 'LittleEndian',
2031             },
2032             },
2033             { # (D500 firmware version 1.00)
2034             Condition => '$$valPt =~ /^0239/',
2035             Name => 'ShotInfoD500',
2036             SubDirectory => {
2037             TagTable => 'Image::ExifTool::Nikon::ShotInfoD500',
2038             DecryptStart => 4,
2039             DecryptLen => 0x2cb2 + 4,
2040             DecryptMore => 'Get32u(\$data, 0xa8) + 0x2ea5 - 0x2c90',
2041             ByteOrder => 'LittleEndian',
2042             },
2043             },
2044             { # (D6 firmware version 1.00, ref 28)
2045             Condition => '$$valPt =~ /^0246/',
2046             Name => 'ShotInfoD6',
2047             SubDirectory => {
2048             TagTable => 'Image::ExifTool::Nikon::ShotInfoD6',
2049             DecryptStart => 4,
2050             DecryptLen => 0xc292 + 720, # thru decoded parts of Offset 32
2051             ByteOrder => 'LittleEndian',
2052             },
2053             },
2054             { # (D610 firmware version 1.00)
2055             Condition => '$$valPt =~ /^0232/',
2056             Name => 'ShotInfoD610',
2057             SubDirectory => {
2058             TagTable => 'Image::ExifTool::Nikon::ShotInfoD610',
2059             DecryptStart => 4,
2060             DecryptLen => 0x7ff,
2061             ByteOrder => 'BigEndian',
2062             },
2063             },
2064             { # (Z6_2 firmware version 1.00 and Z7II firmware versions 1.00 & 1.01, ref 28)
2065             # 0800=Z6/Z7 0801=Z50 0802=Z5 0803=Z6II/Z7II 0804=Zfc
2066             Condition => '$$valPt =~ /^080[01234]/',
2067             Name => 'ShotInfoZ7II',
2068             SubDirectory => {
2069             TagTable => 'Image::ExifTool::Nikon::ShotInfoZ7II',
2070             DecryptStart => 4,
2071             # TODO: eventually set the length dynamically according to actual offsets!
2072             DecryptLen => 0xd04e + 860, # thru decoded MenuSettingsZ7II
2073             ByteOrder => 'LittleEndian',
2074             },
2075             },
2076             { # (Z9 firmware version 1.00 ref 28)
2077             Condition => '$$valPt =~ /^0805/',
2078             Name => 'ShotInfoZ9',
2079             SubDirectory => {
2080             TagTable => 'Image::ExifTool::Nikon::ShotInfoZ9',
2081             DecryptStart => 4,
2082             # TODO: eventually set the length dynamically according to actual offsets!
2083             DecryptLen => 0xec4b + 1646, # decoded thru end of CustomSettingZ9 in Offset26 (+MenuSettingsZ9Offset)
2084             ByteOrder => 'LittleEndian',
2085             },
2086             },
2087             { # D7100=0227
2088             Condition => '$$valPt =~ /^0[28]/',
2089             Name => 'ShotInfo02xx',
2090             SubDirectory => {
2091             TagTable => 'Image::ExifTool::Nikon::ShotInfo',
2092             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2093             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2094             DecryptStart => 4,
2095             DecryptLen => 0x251,
2096             ByteOrder => 'BigEndian',
2097             },
2098             },
2099             {
2100             Name => 'ShotInfoUnknown',
2101             Writable => 0,
2102             SubDirectory => {
2103             TagTable => 'Image::ExifTool::Nikon::ShotInfo',
2104             ByteOrder => 'BigEndian',
2105             },
2106             },
2107             ],
2108             0x0092 => { #2
2109             Name => 'HueAdjustment',
2110             Writable => 'int16s',
2111             },
2112             # 0x0093 - ref 15 calls this Saturation, but this is wrong - PH
2113             0x0093 => { #21
2114             Name => 'NEFCompression',
2115             Writable => 'int16u',
2116             SeparateTable => 'NEFCompression',
2117             PrintConv => \%nefCompression,
2118             },
2119             0x0094 => { Name => 'SaturationAdj', Writable => 'int16s' },
2120             0x0095 => { Name => 'NoiseReduction', Writable => 'string' }, # ("Off" or "FPNR"=long exposure NR)
2121             0x0096 => {
2122             Name => 'NEFLinearizationTable', # same table as DNG LinearizationTable (ref JD)
2123             Writable => 'undef',
2124             Flags => [ 'Binary', 'Protected' ],
2125             },
2126             0x0097 => [ #4
2127             # (NOTE: these are byte-swapped by NX when byte order changes)
2128             {
2129             Condition => '$$valPt =~ /^0100/', # (D100 and Coolpix models)
2130             Name => 'ColorBalance0100',
2131             SubDirectory => {
2132             Start => '$valuePtr + 72',
2133             TagTable => 'Image::ExifTool::Nikon::ColorBalance1',
2134             },
2135             },
2136             {
2137             Condition => '$$valPt =~ /^0102/', # (D2H)
2138             Name => 'ColorBalance0102',
2139             SubDirectory => {
2140             Start => '$valuePtr + 10',
2141             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2142             },
2143             },
2144             {
2145             Condition => '$$valPt =~ /^0103/', # (D70/D70s)
2146             Name => 'ColorBalance0103',
2147             # D70: at file offset 'tag-value + base + 20', 4 16 bits numbers,
2148             # v[0]/v[1] , v[2]/v[3] are the red/blue multipliers.
2149             SubDirectory => {
2150             Start => '$valuePtr + 20',
2151             TagTable => 'Image::ExifTool::Nikon::ColorBalance3',
2152             },
2153             },
2154             {
2155             Condition => '$$valPt =~ /^0205/', # (D50)
2156             Name => 'ColorBalance0205',
2157             SubDirectory => {
2158             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2159             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2160             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2161             DecryptStart => 4,
2162             DecryptLen => 22, # 284 bytes encrypted, but don't need to decrypt it all
2163             DirOffset => 14,
2164             },
2165             },
2166             { # (D3/D3X/D300/D700=0209,D300S=0212,D3S=0214)
2167             Condition => '$$valPt =~ /^02(09|12|14)/',
2168             Name => 'ColorBalance0209',
2169             SubDirectory => {
2170             TagTable => 'Image::ExifTool::Nikon::ColorBalance4',
2171             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2172             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2173             DecryptStart => 284,
2174             DecryptLen => 18, # 324 bytes encrypted, but don't need to decrypt it all
2175             DirOffset => 10,
2176             },
2177             },
2178             { # (D2X/D2Xs=0204,D2Hs=0206,D200=0207,D40/D40X/D80=0208,D60=0210)
2179             Condition => '$$valPt =~ /^02(\d{2})/ and $1 < 11',
2180             Name => 'ColorBalance02',
2181             SubDirectory => {
2182             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2183             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2184             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2185             DecryptStart => 284,
2186             DecryptLen => 14, # don't need to decrypt it all
2187             DirOffset => 6,
2188             },
2189             },
2190             {
2191             Condition => '$$valPt =~ /^0211/', # (D90/D5000)
2192             Name => 'ColorBalance0211',
2193             SubDirectory => {
2194             TagTable => 'Image::ExifTool::Nikon::ColorBalance4',
2195             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2196             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2197             DecryptStart => 284,
2198             DecryptLen => 24, # don't need to decrypt it all
2199             DirOffset => 16,
2200             },
2201             },
2202             {
2203             Condition => '$$valPt =~ /^0213/', # (D3000)
2204             Name => 'ColorBalance0213',
2205             SubDirectory => {
2206             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2207             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2208             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2209             DecryptStart => 284,
2210             DecryptLen => 18, # don't need to decrypt it all
2211             DirOffset => 10,
2212             },
2213             },
2214             { # (D3100=0215,D7000/D5100=0216,D4/D600/D800/D800E/D3200=0217)
2215             Condition => '$$valPt =~ /^021[567]/',
2216             Name => 'ColorBalance0215',
2217             SubDirectory => {
2218             TagTable => 'Image::ExifTool::Nikon::ColorBalance4',
2219             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2220             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2221             DecryptStart => 284,
2222             DecryptLen => 12, # don't need to decrypt it all
2223             DirOffset => 4,
2224             },
2225             },
2226             { # (D5200/D7100=0218, D5300=0219, D610/Df=0220, D3300=0221, CoolpixA=0601)
2227             Name => 'ColorBalanceUnknown02',
2228             Condition => '$$valPt =~ /^0[26]/',
2229             SubDirectory => {
2230             TagTable => 'Image::ExifTool::Nikon::ColorBalanceUnknown',
2231             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2232             DecryptStart => 284,
2233             DecryptLen => 10, # (arbitrary)
2234             },
2235             },
2236             { # (1J1/1J2/1V1=0400, 1V2=0401, 1J3/1S1=0402, 1AW1=0403, Z6/Z7=0800)
2237             Name => 'ColorBalanceUnknown04',
2238             Condition => '$$valPt =~ /^0[48]/',
2239             SubDirectory => {
2240             TagTable => 'Image::ExifTool::Nikon::ColorBalanceUnknown',
2241             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2242             DecryptStart => 4,
2243             DecryptLen => 10, # (arbitrary)
2244             },
2245             },
2246             {
2247             # (CoolpixP7700/P7800=0500, CoolpixP330/P520=0502)
2248             Name => 'ColorBalanceUnknown',
2249             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::ColorBalanceUnknown' },
2250             },
2251             ],
2252             0x0098 => [
2253             { #8
2254             Condition => '$$valPt =~ /^0100/', # D100, D1X - PH
2255             Name => 'LensData0100',
2256             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LensData00' },
2257             },
2258             { #8
2259             Condition => '$$valPt =~ /^0101/', # D70, D70s - PH
2260             Name => 'LensData0101',
2261             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LensData01' },
2262             },
2263             # note: this information is encrypted if the version is 02xx
2264             { #8
2265             # 0201 - D200, D2Hs, D2X and D2Xs
2266             # 0202 - D40, D40X and D80
2267             # 0203 - D300
2268             Condition => '$$valPt =~ /^020[1-3]/',
2269             Name => 'LensData0201',
2270             SubDirectory => {
2271             TagTable => 'Image::ExifTool::Nikon::LensData01',
2272             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2273             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2274             DecryptStart => 4,
2275             },
2276             },
2277             { #PH
2278             Condition => '$$valPt =~ /^0204/', # D90, D7000
2279             Name => 'LensData0204',
2280             SubDirectory => {
2281             TagTable => 'Image::ExifTool::Nikon::LensData0204',
2282             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2283             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2284             DecryptStart => 4,
2285             },
2286             },
2287             {
2288             Condition => '$$valPt =~ /^040[01]/', # 0=1J1/1V1, 1=1J2
2289             Name => 'LensData0400',
2290             SubDirectory => {
2291             TagTable => 'Image::ExifTool::Nikon::LensData0400',
2292             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2293             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2294             DecryptStart => 4,
2295             },
2296             },
2297             {
2298             Condition => '$$valPt =~ /^0402/', # 1J3/1S1/1V2
2299             Name => 'LensData0402',
2300             SubDirectory => {
2301             TagTable => 'Image::ExifTool::Nikon::LensData0402',
2302             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2303             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2304             DecryptStart => 4,
2305             },
2306             },
2307             {
2308             Condition => '$$valPt =~ /^0403/', # 1J4,1J5
2309             Name => 'LensData0403',
2310             SubDirectory => {
2311             TagTable => 'Image::ExifTool::Nikon::LensData0403',
2312             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2313             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2314             DecryptStart => 4,
2315             },
2316             },
2317             {
2318             Condition => '$$valPt =~ /^080[012]/', # Z6/Z7/Z9
2319             Name => 'LensData0800',
2320             SubDirectory => {
2321             TagTable => 'Image::ExifTool::Nikon::LensData0800',
2322             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2323             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2324             DecryptStart => 4,
2325             ByteOrder => 'LittleEndian',
2326             },
2327             },
2328             {
2329             Name => 'LensDataUnknown',
2330             SubDirectory => {
2331             TagTable => 'Image::ExifTool::Nikon::LensDataUnknown',
2332             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2333             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
2334             DecryptStart => 4,
2335             },
2336             },
2337             ],
2338             0x0099 => { #2/15
2339             Name => 'RawImageCenter',
2340             Writable => 'int16u',
2341             Count => 2,
2342             },
2343             0x009a => { #10
2344             Name => 'SensorPixelSize',
2345             Writable => 'rational64u',
2346             Count => 2,
2347             PrintConv => '$val=~s/ / x /;"$val um"',
2348             PrintConvInv => '$val=~tr/a-zA-Z/ /;$val',
2349             },
2350             0x009c => { #14
2351             # L2/L3 has these modes (from owner's manual): - PH
2352             # Portrait Assist: FACE-PRIORITY AF,PORTRAIT,PORTRAIT LEFT,PORTRAIT RIGHT,
2353             # PORTRAIT CLOSE-UP,PORTRAIT COUPLE,PORTRAIT-FIGURE
2354             # Landscape Assist:LANDSCAPE,SCENIC VIEW,ARCHITECTURE,GROUP RIGHT,GROUP LEFT
2355             # Sports Assist: SPORTS,SPORT SPECTATOR,SPORT COMPOSITE
2356             # P7100 has test modes: - PH
2357             # CREATIVE MONOCHROME,PAINTING,CROSS PROCESS,SOFT,NOSTALGIC SEPIA,
2358             # HIGH KEY,LOW KEY,SELECTIVE COLOR,ZOOM EXPOSURE EXP.,DEFOCUS DURING
2359             Name => 'SceneAssist',
2360             Writable => 'string',
2361             },
2362             0x009d => { #NealKrawetz
2363             Name => 'DateStampMode',
2364             Writable => 'int16u',
2365             Notes => 'feature to imprint date/time on image',
2366             PrintConv => { #PH
2367             0 => 'Off',
2368             1 => 'Date & Time',
2369             2 => 'Date',
2370             3 => 'Date Counter', # (NC) (D3500)
2371             },
2372             },
2373             0x009e => { #JD
2374             Name => 'RetouchHistory',
2375             Writable => 'int16u',
2376             Count => 10,
2377             # trim off extra "None" values
2378             ValueConv => '$val=~s/( 0)+$//; $val',
2379             ValueConvInv => 'my $n=($val=~/ \d+/g);$n < 9 ? $val . " 0" x (9-$n) : $val',
2380             PrintConvColumns => 2,
2381             PrintConv => [
2382             \%retouchValues,
2383             \%retouchValues,
2384             \%retouchValues,
2385             \%retouchValues,
2386             \%retouchValues,
2387             \%retouchValues,
2388             \%retouchValues,
2389             \%retouchValues,
2390             \%retouchValues,
2391             \%retouchValues,
2392             ],
2393             },
2394             0x00a0 => { Name => 'SerialNumber', Writable => 'string' }, #2
2395             0x00a2 => { # size of compressed image data plus EOI segment (ref 10)
2396             Name => 'ImageDataSize',
2397             Writable => 'int32u',
2398             },
2399             # 0x00a3 - int8u: 0 (All DSLR's but D1,D1H,D1X,D100)
2400             # 0x00a4 - version number found only in NEF images from DSLR models except the
2401             # D1,D1X,D2H and D100. Value is "0200" for all available samples except images
2402             # edited by Nikon Capture Editor 4.3.1 W and 4.4.2 which have "0100" - PH
2403             0x00a5 => { #15
2404             Name => 'ImageCount',
2405             Writable => 'int32u',
2406             },
2407             0x00a6 => { #15
2408             Name => 'DeletedImageCount',
2409             Writable => 'int32u',
2410             },
2411             # the sum of 0xa5 and 0xa6 is equal to 0xa7 ShutterCount (D2X,D2Hs,D2H,D200, ref 10)
2412             0x00a7 => { # Number of shots taken by camera so far (ref 2)
2413             Name => 'ShutterCount',
2414             Writable => 'int32u',
2415             Protected => 1,
2416             PrintConv => '$val == 4294965247 ? "n/a" : $val',
2417             PrintConvInv => '$val eq "n/a" ? 4294965247 : $val',
2418             Notes => q{
2419             includes both mechanical and electronic shutter activations for models with
2420             this feature. This value is used as a key to decrypt other information, and
2421             writing this tag causes the other information to be re-encrypted with the
2422             new key
2423             },
2424             },
2425             0x00a8 => [#JD
2426             {
2427             Name => 'FlashInfo0100',
2428             Condition => '$$valPt =~ /^010[01]/',
2429             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0100' },
2430             },
2431             {
2432             Name => 'FlashInfo0102',
2433             Condition => '$$valPt =~ /^0102/',
2434             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0102' },
2435             },
2436             {
2437             Name => 'FlashInfo0103',
2438             # (0104 for D7000, 0105 for D800)
2439             Condition => '$$valPt =~ /^010[345]/',
2440             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0103' },
2441             },
2442             {
2443             Name => 'FlashInfo0106', # (Df, D610, D3300, D5300, D7100, Coolpix A)
2444             Condition => '$$valPt =~ /^0106/',
2445             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0106' },
2446             },
2447             {
2448             Name => 'FlashInfo0107', # (0107 for D4S/D750/D810/D5500/D7200, 0108 for D5/D500/D3400)
2449             Condition => '$$valPt =~ /^010[78]/',
2450             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0107' },
2451             },
2452             {
2453             Name => 'FlashInfo0300', # (Z7II)
2454             Condition => '$$valPt =~ /^030[01]/',
2455             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0300' },
2456             },
2457             {
2458             Name => 'FlashInfoUnknown',
2459             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfoUnknown' },
2460             },
2461             ],
2462             0x00a9 => { Name => 'ImageOptimization',Writable => 'string' },#2
2463             0x00aa => { Name => 'Saturation', Writable => 'string' }, #2
2464             0x00ab => { Name => 'VariProgram', Writable => 'string' }, #2 (scene mode for DSLR's - PH)
2465             0x00ac => { Name => 'ImageStabilization',Writable=> 'string' }, #14
2466             0x00ad => { Name => 'AFResponse', Writable => 'string' }, #14
2467             0x00b0 => [{ #PH
2468             Name => 'MultiExposure',
2469             Condition => '$$valPt =~ /^0100/',
2470             SubDirectory => {
2471             TagTable => 'Image::ExifTool::Nikon::MultiExposure',
2472             # Note: this endianness varies with model, but Nikon software may change
2473             # metadata endianness (although it is unknown how it affects this record),
2474             # so for now don't specify ByteOrder although it may be wrong if the
2475             # file is rewritten by Nikon software --> see comments for FileInfo
2476             },
2477             },{
2478             Name => 'MultiExposure',
2479             Condition => '$$valPt =~ /^0101/',
2480             SubDirectory => {
2481             TagTable => 'Image::ExifTool::Nikon::MultiExposure',
2482             ByteOrder => 'LittleEndian',
2483             },
2484             }],
2485             0x00b1 => { #14/PH/JD (D80)
2486             Name => 'HighISONoiseReduction',
2487             Writable => 'int16u',
2488             PrintConv => {
2489             0 => 'Off',
2490             1 => 'Minimal', # for high ISO (>800) when setting is "Off"
2491             2 => 'Low', # Low,Normal,High take effect for ISO > 400
2492             3 => 'Medium Low',
2493             4 => 'Normal',
2494             5 => 'Medium High',
2495             6 => 'High',
2496             },
2497             },
2498             # 0x00b2 (string: "NORMAL ", 0xc3's, 0xff's or 0x20's)
2499             0x00b3 => { #14
2500             Name => 'ToningEffect',
2501             Writable => 'string',
2502             },
2503             0x00b6 => { #PH
2504             Name => 'PowerUpTime',
2505             Groups => { 2 => 'Time' },
2506             Shift => 'Time',
2507             # not clear whether "powered up" means "turned on" or "power applied" - PH
2508             Notes => 'date/time when camera was last powered up',
2509             Writable => 'undef',
2510             # must use RawConv so byte order is correct
2511             RawConv => sub {
2512             my $val = shift;
2513             return $val if length $val < 7;
2514             my $shrt = GetByteOrder() eq 'II' ? 'v' : 'n';
2515             my @date = unpack("${shrt}C5", $val);
2516             return sprintf('%.4d:%.2d:%.2d %.2d:%.2d:%.2d', @date);
2517             },
2518             RawConvInv => sub {
2519             my $val = shift;
2520             my $shrt = GetByteOrder() eq 'II' ? 'v' : 'n';
2521             my @date = ($val =~ /\d+/g);
2522             return pack("${shrt}C6", @date, 0);
2523             },
2524             PrintConv => '$self->ConvertDateTime($val)',
2525             PrintConvInv => '$self->InverseDateTime($val,0)',
2526             },
2527             0x00b7 => [{
2528             Name => 'AFInfo2',
2529             Condition => '$$self{Model} =~ /^NIKON Z 9\b/i', #AFInfo2Version 0400
2530             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0400' },
2531             },{ #JD
2532             Name => 'AFInfo2',
2533             # (this structure may be byte swapped when rewritten by CaptureNX)
2534             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2' },
2535             }],
2536             0x00b8 => [{ #PH
2537             Name => 'FileInfo',
2538             # unfortunately, some newer models write this as little-endian
2539             # (and CaptureNX can change the byte order of the maker notes,
2540             # but leaves this structure unchanged)
2541             # - it will be an ongoing pain to keep this list of models up-to-date,
2542             # so if only one ordering yields valid DirectoryNumber and FileNumber values,
2543             # use it, otherwise default to a-priori knowledge of the camera model
2544             # (assume that a valid DirectoryNumber is 100-999, and a valid FileNumber
2545             # is 0000-9999, although I have some samples with a DirectoryNumber of 99)
2546             Condition => q{
2547             if (length($$valPt) >= 0) {
2548             my ($dir, $file) = unpack('x6vv', $$valPt);
2549             my $littleEndian = ($dir >= 100 and $dir <= 999 and $file <= 9999);
2550             ($dir, $file) = unpack('x6nn', $$valPt);
2551             my $bigEndian = ($dir >= 100 and $dir <= 999 and $file <= 9999);
2552             return $littleEndian if $littleEndian xor $bigEndian;
2553             }
2554             return $$self{Model} =~ /^NIKON (D4S|D750|D810|D3300|D5200|D5300|D5500|D7100)$/;
2555             },
2556             SubDirectory => {
2557             TagTable => 'Image::ExifTool::Nikon::FileInfo',
2558             ByteOrder => 'LittleEndian',
2559             },
2560             },{
2561             Name => 'FileInfo',
2562             SubDirectory => {
2563             TagTable => 'Image::ExifTool::Nikon::FileInfo',
2564             ByteOrder => 'BigEndian',
2565             },
2566             }],
2567             0x00b9 => { #28
2568             Name => 'AFTune',
2569             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFTune' },
2570             },
2571             # 0x00ba - custom curve data? (ref 28?) (only in NEF images)
2572             0x00bb => { #forum6281
2573             Name => 'RetouchInfo',
2574             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::RetouchInfo' },
2575             },
2576             # 0x00bc - NEFThumbnail? (forum6281)
2577             0x00bd => { #PH (P6000)
2578             Name => 'PictureControlData',
2579             Writable => 'undef',
2580             Permanent => 0,
2581             Flags => [ 'Binary', 'Protected' ],
2582             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl' },
2583             },
2584             0x00bf => {
2585             Name => 'SilentPhotography',
2586             PrintConv => \%offOn,
2587             },
2588             0x00c3 => {
2589             Name => 'BarometerInfo',
2590             SubDirectory => {
2591             TagTable => 'Image::ExifTool::Nikon::BarometerInfo',
2592             # (little-endian in II EXIF, big-endian in MOV)
2593             },
2594             },
2595             0x0e00 => {
2596             Name => 'PrintIM',
2597             Description => 'Print Image Matching',
2598             Writable => 0,
2599             SubDirectory => {
2600             TagTable => 'Image::ExifTool::PrintIM::Main',
2601             },
2602             },
2603             # 0x0e01 - In D70 NEF files produced by Nikon Capture, the data for this tag extends 4 bytes
2604             # past the end of the maker notes. Very odd. I hope these 4 bytes aren't useful because
2605             # they will get lost by any utility that blindly copies the maker notes (not ExifTool) - PH
2606             0x0e01 => {
2607             Name => 'NikonCaptureData',
2608             Writable => 'undef',
2609             Permanent => 0,
2610             # (Drop because may be too large for JPEG images)
2611             Flags => [ 'Binary', 'Protected', 'Drop' ],
2612             Notes => q{
2613             this data is dropped when copying Nikon MakerNotes since it may be too large
2614             to fit in the EXIF segment of a JPEG image, but it may be copied as a block
2615             into existing Nikon MakerNotes later if desired
2616             },
2617             SubDirectory => {
2618             DirName => 'NikonCapture',
2619             TagTable => 'Image::ExifTool::NikonCapture::Main',
2620             },
2621             },
2622             # 0x0e05 written by Nikon Capture to NEF files, values of 1 and 2 - PH
2623             0x0e09 => { #12
2624             Name => 'NikonCaptureVersion',
2625             Writable => 'string',
2626             Permanent => 0,
2627             PrintConv => undef, # (avoid applying default print conversion to string)
2628             },
2629             # 0x0e0e is in D70 Nikon Capture files (not out-of-the-camera D70 files) - PH
2630             0x0e0e => { #PH
2631             Name => 'NikonCaptureOffsets',
2632             Writable => 'undef',
2633             Permanent => 0,
2634             SubDirectory => {
2635             TagTable => 'Image::ExifTool::Nikon::CaptureOffsets',
2636             Validate => '$val =~ /^0100/',
2637             Start => '$valuePtr + 4',
2638             },
2639             },
2640             0x0e10 => { #17
2641             Name => 'NikonScanIFD',
2642             Groups => { 1 => 'NikonScan', 2 => 'Image' },
2643             Flags => 'SubIFD',
2644             SubDirectory => {
2645             TagTable => 'Image::ExifTool::Nikon::Scan',
2646             Start => '$val',
2647             },
2648             },
2649             0x0e13 => [{ # PH/https://exiftool.org/forum/index.php/topic,2737.0.html
2650             Name => 'NikonCaptureEditVersions',
2651             Condition => '$self->Options("ExtractEmbedded")',
2652             Notes => q{
2653             the L option may be used to decode settings from the stored
2654             edit versions, otherwise this is extracted as a binary data block
2655             },
2656             Writable => 'undef',
2657             Permanent => 0,
2658             Drop => 1, # (may be too large for JPEG images)
2659             SubDirectory => {
2660             DirName => 'NikonCaptureEditVersions',
2661             TagTable => 'Image::ExifTool::NikonCapture::Main',
2662             ProcessProc => \&ProcessNikonCaptureEditVersions,
2663             WriteProc => sub { return undef }, # (writing not yet supported)
2664             },
2665             },{
2666             Name => 'NikonCaptureEditVersions',
2667             Writable => 'undef',
2668             Permanent => 0,
2669             Flags => [ 'Binary', 'Protected', 'Drop' ],
2670             }],
2671             0x0e1d => { #JD
2672             Name => 'NikonICCProfile',
2673             Flags => [ 'Binary', 'Protected' ],
2674             Writable => 'undef', # must be defined here so tag will be extracted if specified
2675             WriteCheck => q{
2676             require Image::ExifTool::ICC_Profile;
2677             return Image::ExifTool::ICC_Profile::ValidateICC(\$val);
2678             },
2679             SubDirectory => {
2680             DirName => 'NikonICCProfile',
2681             TagTable => 'Image::ExifTool::ICC_Profile::Main',
2682             },
2683             },
2684             0x0e1e => { #PH
2685             Name => 'NikonCaptureOutput',
2686             Writable => 'undef',
2687             Permanent => 0,
2688             Flags => [ 'Binary', 'Protected' ],
2689             SubDirectory => {
2690             TagTable => 'Image::ExifTool::Nikon::CaptureOutput',
2691             Validate => '$val =~ /^0100/',
2692             },
2693             },
2694             0x0e22 => { #28
2695             Name => 'NEFBitDepth',
2696             Writable => 'int16u',
2697             Count => 4,
2698             Protected => 1,
2699             PrintConv => {
2700             '0 0 0 0' => 'n/a (JPEG)',
2701             '8 8 8 0' => '8 x 3', # TIFF RGB
2702             '16 16 16 0' => '16 x 3', # TIFF 16-bit RGB
2703             '12 0 0 0' => 12,
2704             '14 0 0 0' => 14,
2705             },
2706             },
2707             );
2708              
2709             # NikonScan IFD entries (ref 17)
2710             %Image::ExifTool::Nikon::Scan = (
2711             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
2712             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
2713             WRITE_GROUP => 'NikonScan',
2714             WRITABLE => 1,
2715             GROUPS => { 0 => 'MakerNotes', 1 => 'NikonScan', 2 => 'Image' },
2716             VARS => { MINOR_ERRORS => 1 }, # this IFD is non-essential and often corrupted
2717             NOTES => 'This information is written by the Nikon Scan software.',
2718             0x02 => { Name => 'FilmType', Writable => 'string', },
2719             0x40 => { Name => 'MultiSample', Writable => 'string' },
2720             0x41 => { Name => 'BitDepth', Writable => 'int16u' },
2721             0x50 => {
2722             Name => 'MasterGain',
2723             Writable => 'rational64s',
2724             PrintConv => 'sprintf("%.2f",$val)',
2725             PrintConvInv => '$val',
2726             },
2727             0x51 => {
2728             Name => 'ColorGain',
2729             Writable => 'rational64s',
2730             Count => 3,
2731             PrintConv => 'sprintf("%.2f %.2f %.2f",split(" ",$val))',
2732             PrintConvInv => '$val',
2733             },
2734             0x60 => {
2735             Name => 'ScanImageEnhancer',
2736             Writable => 'int32u',
2737             PrintConv => \%offOn,
2738             },
2739             0x100 => { Name => 'DigitalICE', Writable => 'string' },
2740             0x110 => {
2741             Name => 'ROCInfo',
2742             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::ROC' },
2743             },
2744             0x120 => {
2745             Name => 'GEMInfo',
2746             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::GEM' },
2747             },
2748             0x200 => { Name => 'DigitalDEEShadowAdj', Writable => 'int32u' },
2749             0x201 => { Name => 'DigitalDEEThreshold', Writable => 'int32u' },
2750             0x202 => { Name => 'DigitalDEEHighlightAdj',Writable => 'int32u' },
2751             );
2752              
2753             # ref 17
2754             %Image::ExifTool::Nikon::ROC = (
2755             %binaryDataAttrs,
2756             FORMAT => 'int32u',
2757             GROUPS => { 0 => 'MakerNotes', 1 => 'NikonScan', 2 => 'Image' },
2758             0 => {
2759             Name => 'DigitalROC',
2760             ValueConv => '$val / 10',
2761             ValueConvInv => 'int($val * 10)',
2762             },
2763             );
2764              
2765             # ref 17
2766             %Image::ExifTool::Nikon::GEM = (
2767             %binaryDataAttrs,
2768             FORMAT => 'int32u',
2769             GROUPS => { 0 => 'MakerNotes', 1 => 'NikonScan', 2 => 'Image' },
2770             0 => {
2771             Name => 'DigitalGEM',
2772             ValueConv => '$val<95 ? $val/20-1 : 4',
2773             ValueConvInv => '$val == 4 ? 95 : int(($val + 1) * 20)',
2774             },
2775             );
2776              
2777             # Vibration Reduction information - PH (D300)
2778             %Image::ExifTool::Nikon::VRInfo = (
2779             %binaryDataAttrs,
2780             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
2781             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
2782             0 => {
2783             Name => 'VRInfoVersion',
2784             Format => 'undef[4]',
2785             Writable => 0,
2786             },
2787             4 => {
2788             Name => 'VibrationReduction',
2789             PrintConv => {
2790             0 => 'n/a', # (1V1 with a non-VR lens)
2791             1 => 'On',
2792             2 => 'Off',
2793             },
2794             },
2795             # 5 - values: 0, 1 (VR On), 2 (VR Off)
2796             6 => [{
2797             Name => 'VRMode',
2798             PrintConv => {
2799             0 => 'Off',
2800             1 => 'Sport',
2801             3 => 'Normal',
2802             },
2803             %infoZSeries
2804             },{
2805             Name => 'VRMode',
2806             PrintConv => {
2807             0 => 'Normal',
2808             1 => 'On (1)', #PH (NC)
2809             2 => 'Active', # (1J1)
2810             3 => 'Sport', #PH (Z7)
2811             },
2812             }],
2813             # 7 - values: 0, 1
2814             );
2815              
2816             # Face detection information - PH (S8100)
2817             %Image::ExifTool::Nikon::FaceDetect = (
2818             %binaryDataAttrs,
2819             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
2820             FORMAT => 'int16u',
2821             DATAMEMBER => [ 0x03 ],
2822             0x01 => {
2823             Name => 'FaceDetectFrameSize',
2824             Format => 'int16u[2]',
2825             },
2826             0x03 => {
2827             Name => 'FacesDetected',
2828             DataMember => 'FacesDetected',
2829             RawConv => '$$self{FacesDetected} = $val',
2830             },
2831             0x04 => {
2832             Name => 'Face1Position',
2833             Format => 'int16u[4]',
2834             RawConv => '$$self{FacesDetected} < 1 ? undef : $val',
2835             Notes => q{
2836             top, left, width and height of face detect area in coordinates of
2837             FaceDetectFrameSize
2838             },
2839             },
2840             0x08 => {
2841             Name => 'Face2Position',
2842             Format => 'int16u[4]',
2843             RawConv => '$$self{FacesDetected} < 2 ? undef : $val',
2844             },
2845             0x0c => {
2846             Name => 'Face3Position',
2847             Format => 'int16u[4]',
2848             RawConv => '$$self{FacesDetected} < 3 ? undef : $val',
2849             },
2850             0x10 => {
2851             Name => 'Face4Position',
2852             Format => 'int16u[4]',
2853             RawConv => '$$self{FacesDetected} < 4 ? undef : $val',
2854             },
2855             0x14 => {
2856             Name => 'Face5Position',
2857             Format => 'int16u[4]',
2858             RawConv => '$$self{FacesDetected} < 5 ? undef : $val',
2859             },
2860             0x18 => {
2861             Name => 'Face6Position',
2862             Format => 'int16u[4]',
2863             RawConv => '$$self{FacesDetected} < 6 ? undef : $val',
2864             },
2865             0x1c => {
2866             Name => 'Face7Position',
2867             Format => 'int16u[4]',
2868             RawConv => '$$self{FacesDetected} < 7 ? undef : $val',
2869             },
2870             0x20 => {
2871             Name => 'Face8Position',
2872             Format => 'int16u[4]',
2873             RawConv => '$$self{FacesDetected} < 8 ? undef : $val',
2874             },
2875             0x24 => {
2876             Name => 'Face9Position',
2877             Format => 'int16u[4]',
2878             RawConv => '$$self{FacesDetected} < 9 ? undef : $val',
2879             },
2880             0x28 => {
2881             Name => 'Face10Position',
2882             Format => 'int16u[4]',
2883             RawConv => '$$self{FacesDetected} < 10 ? undef : $val',
2884             },
2885             0x2c => {
2886             Name => 'Face11Position',
2887             Format => 'int16u[4]',
2888             RawConv => '$$self{FacesDetected} < 11 ? undef : $val',
2889             },
2890             0x30 => {
2891             Name => 'Face12Position',
2892             Format => 'int16u[4]',
2893             RawConv => '$$self{FacesDetected} < 12 ? undef : $val',
2894             },
2895             );
2896              
2897             # Picture Control information - PH (D300,P6000)
2898             %Image::ExifTool::Nikon::PictureControl = (
2899             %binaryDataAttrs,
2900             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
2901             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
2902             0 => {
2903             Name => 'PictureControlVersion',
2904             Format => 'undef[4]',
2905             Writable => 0,
2906             },
2907             4 => {
2908             Name => 'PictureControlName',
2909             Format => 'string[20]',
2910             # make lower case with a leading capital for each word
2911             PrintConv => \&FormatString,
2912             PrintConvInv => 'uc($val)',
2913             },
2914             24 => {
2915             Name => 'PictureControlBase',
2916             Format => 'string[20]',
2917             PrintConv => \&FormatString,
2918             PrintConvInv => 'uc($val)',
2919             },
2920             # beginning at byte 44, there is some interesting information.
2921             # here are the observed bytes for each PictureControlMode:
2922             # 44 45 46 47 48 49 50 51 52 53 54 55 56 57
2923             # STANDARD 00 01 00 00 00 80 83 80 80 80 80 ff ff ff
2924             # NEUTRAL 03 c2 00 00 00 ff 82 80 80 80 80 ff ff ff
2925             # VIVID 00 c3 00 00 00 80 84 80 80 80 80 ff ff ff
2926             # MONOCHROME 06 4d 00 01 02 ff 82 80 80 ff ff 80 80 ff
2927             # Neutral2 03 c2 01 00 02 ff 80 7f 81 00 7f ff ff ff (custom)
2928             # (note that up to 9 different custom picture controls can be stored)
2929             # --> bytes 44 and 45 are swapped if CaptureNX changes the byte order
2930             #
2931             48 => { #21
2932             Name => 'PictureControlAdjust',
2933             PrintConv => {
2934             0 => 'Default Settings',
2935             1 => 'Quick Adjust',
2936             2 => 'Full Control',
2937             },
2938             },
2939             49 => {
2940             Name => 'PictureControlQuickAdjust',
2941             # settings: -2 to +2 (n/a for Neutral and Monochrome modes)
2942             DelValue => 0xff,
2943             ValueConv => '$val - 0x80',
2944             ValueConvInv => '$val + 0x80',
2945             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
2946             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
2947             },
2948             50 => {
2949             Name => 'Sharpness',
2950             # settings: 0 to 9, Auto
2951             ValueConv => '$val - 0x80',
2952             ValueConvInv => '$val + 0x80',
2953             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"No Sharpening","%d")',
2954             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
2955             },
2956             51 => {
2957             Name => 'Contrast',
2958             # settings: -3 to +3, Auto
2959             ValueConv => '$val - 0x80',
2960             ValueConvInv => '$val + 0x80',
2961             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
2962             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
2963             },
2964             52 => {
2965             Name => 'Brightness',
2966             # settings: -1 to +1
2967             ValueConv => '$val - 0x80',
2968             ValueConvInv => '$val + 0x80',
2969             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
2970             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
2971             },
2972             53 => {
2973             Name => 'Saturation',
2974             # settings: -3 to +3, Auto (n/a for Monochrome mode)
2975             DelValue => 0xff,
2976             ValueConv => '$val - 0x80',
2977             ValueConvInv => '$val + 0x80',
2978             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
2979             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
2980             },
2981             54 => {
2982             Name => 'HueAdjustment',
2983             # settings: -3 to +3 (n/a for Monochrome mode)
2984             DelValue => 0xff,
2985             ValueConv => '$val - 0x80',
2986             ValueConvInv => '$val + 0x80',
2987             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None")',
2988             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
2989             },
2990             55 => {
2991             Name => 'FilterEffect',
2992             # settings: Off,Yellow,Orange,Red,Green (n/a for color modes)
2993             DelValue => 0xff,
2994             PrintHex => 1,
2995             PrintConv => {
2996             0x80 => 'Off',
2997             0x81 => 'Yellow',
2998             0x82 => 'Orange',
2999             0x83 => 'Red',
3000             0x84 => 'Green',
3001             0xff => 'n/a',
3002             },
3003             },
3004             56 => {
3005             Name => 'ToningEffect',
3006             # settings: B&W,Sepia,Cyanotype,Red,Yellow,Green,Blue-Green,Blue,
3007             # Purple-Blue,Red-Purple (n/a for color modes)
3008             DelValue => 0xff,
3009             PrintHex => 1,
3010             PrintConvColumns => 2,
3011             PrintConv => {
3012             0x80 => 'B&W',
3013             0x81 => 'Sepia',
3014             0x82 => 'Cyanotype',
3015             0x83 => 'Red',
3016             0x84 => 'Yellow',
3017             0x85 => 'Green',
3018             0x86 => 'Blue-green',
3019             0x87 => 'Blue',
3020             0x88 => 'Purple-blue',
3021             0x89 => 'Red-purple',
3022             0xff => 'n/a',
3023             # 0x04 - seen for D810 (PH)
3024             },
3025             },
3026             57 => { #21
3027             Name => 'ToningSaturation',
3028             # settings: B&W,Sepia,Cyanotype,Red,Yellow,Green,Blue-Green,Blue,
3029             # Purple-Blue,Red-Purple (n/a unless ToningEffect is used)
3030             DelValue => 0xff,
3031             ValueConv => '$val - 0x80',
3032             ValueConvInv => '$val + 0x80',
3033             PrintConv => '$val==0x7f ? "n/a" : $val',
3034             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3035             },
3036             );
3037              
3038             # Picture Control information V2 (ref 28)
3039             %Image::ExifTool::Nikon::PictureControl2 = (
3040             %binaryDataAttrs,
3041             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3042             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3043             0 => {
3044             Name => 'PictureControlVersion',
3045             Format => 'undef[4]',
3046             Writable => 0,
3047             },
3048             4 => {
3049             Name => 'PictureControlName',
3050             Format => 'string[20]',
3051             # make lower case with a leading capital for each word
3052             PrintConv => \&FormatString,
3053             PrintConvInv => 'uc($val)',
3054             },
3055             24 => {
3056             Name => 'PictureControlBase',
3057             Format => 'string[20]',
3058             PrintConv => \&FormatString,
3059             PrintConvInv => 'uc($val)',
3060             },
3061             # beginning at byte 44, there is some interesting information.
3062             # here are the observed bytes for each PictureControlMode:
3063             # 44 45 46 47 48 49 50 51 52 53 54 55 56 57
3064             # STANDARD 00 01 00 00 00 80 83 80 80 80 80 ff ff ff
3065             # NEUTRAL 03 c2 00 00 00 ff 82 80 80 80 80 ff ff ff
3066             # VIVID 00 c3 00 00 00 80 84 80 80 80 80 ff ff ff
3067             # MONOCHROME 06 4d 00 01 02 ff 82 80 80 ff ff 80 80 ff
3068             # Neutral2 03 c2 01 00 02 ff 80 7f 81 00 7f ff ff ff (custom)
3069             # (note that up to 9 different custom picture controls can be stored)
3070             # --> bytes 44 and 45 are swapped if CaptureNX changes the byte order
3071             #
3072             48 => { #21
3073             Name => 'PictureControlAdjust',
3074             PrintConv => {
3075             0 => 'Default Settings',
3076             1 => 'Quick Adjust',
3077             2 => 'Full Control',
3078             },
3079             },
3080             49 => {
3081             Name => 'PictureControlQuickAdjust',
3082             # settings: -2 to +2 (n/a for Neutral and Monochrome modes)
3083             DelValue => 0xff,
3084             ValueConv => '$val - 0x80',
3085             ValueConvInv => '$val + 0x80',
3086             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3087             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3088             },
3089             51 => {
3090             Name => 'Sharpness',
3091             DelValue => 0xff,
3092             ValueConv => '$val - 0x80',
3093             ValueConvInv => '$val + 0x80',
3094             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3095             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3096             },
3097             53 => {
3098             Name => 'Clarity',
3099             DelValue => 0xff,
3100             ValueConv => '$val - 0x80',
3101             ValueConvInv => '$val + 0x80',
3102             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3103             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv2($val,4)',
3104             },
3105             55 => {
3106             Name => 'Contrast',
3107             DelValue => 0xff,
3108             ValueConv => '$val - 0x80',
3109             ValueConvInv => '$val + 0x80',
3110             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3111             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3112             },
3113             57 => { #21
3114             Name => 'Brightness',
3115             # settings: -1 to +1
3116             ValueConv => '$val - 0x80',
3117             ValueConvInv => '$val + 0x80',
3118             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,undef,"%.2f",4)',
3119             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3120             },
3121             59 => {
3122             Name => 'Saturation',
3123             DelValue => 0xff,
3124             ValueConv => '$val - 0x80',
3125             ValueConvInv => '$val + 0x80',
3126             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3127             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3128             },
3129             61 => {
3130             Name => 'Hue',
3131             DelValue => 0xff,
3132             ValueConv => '$val - 0x80',
3133             ValueConvInv => '$val + 0x80',
3134             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3135             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3136             },
3137             63 => {
3138             Name => 'FilterEffect',
3139             # settings: Off,Yellow,Orange,Red,Green (n/a for color modes)
3140             DelValue => 0xff,
3141             PrintHex => 1,
3142             PrintConv => {
3143             0x80 => 'Off',
3144             0x81 => 'Yellow',
3145             0x82 => 'Orange',
3146             0x83 => 'Red',
3147             0x84 => 'Green',
3148             0xff => 'n/a',
3149             },
3150             },
3151             64 => {
3152             Name => 'ToningEffect',
3153             # settings: B&W,Sepia,Cyanotype,Red,Yellow,Green,Blue-Green,Blue,
3154             # Purple-Blue,Red-Purple (n/a for color modes)
3155             DelValue => 0xff,
3156             PrintHex => 1,
3157             PrintConvColumns => 2,
3158             PrintConv => {
3159             0x80 => 'B&W',
3160             0x81 => 'Sepia',
3161             0x82 => 'Cyanotype',
3162             0x83 => 'Red',
3163             0x84 => 'Yellow',
3164             0x85 => 'Green',
3165             0x86 => 'Blue-green',
3166             0x87 => 'Blue',
3167             0x88 => 'Purple-blue',
3168             0x89 => 'Red-purple',
3169             0xff => 'n/a',
3170             },
3171             },
3172             65 => {
3173             Name => 'ToningSaturation',
3174             DelValue => 0xff,
3175             ValueConv => '$val - 0x80', #$val == 0x7f (n/a) for "B&W"
3176             ValueConvInv => '$val + 0x80',
3177             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3178             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3179              
3180             },
3181             );
3182              
3183             # Picture Control information V3 (ref PH, Z7)
3184             %Image::ExifTool::Nikon::PictureControl3 = (
3185             %binaryDataAttrs,
3186             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3187             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3188             0 => {
3189             Name => 'PictureControlVersion',
3190             Format => 'undef[4]',
3191             Writable => 0,
3192             },
3193             8 => {
3194             Name => 'PictureControlName',
3195             Format => 'string[20]',
3196             # make lower case with a leading capital for each word
3197             PrintConv => \&FormatString,
3198             PrintConvInv => 'uc($val)',
3199             },
3200             # 48 - looks like PictureControl2 byte 45
3201             28 => {
3202             Name => 'PictureControlBase',
3203             Format => 'string[20]',
3204             PrintConv => \&FormatString,
3205             PrintConvInv => 'uc($val)',
3206             },
3207             54 => { # (NC)
3208             Name => 'PictureControlAdjust',
3209             PrintConv => {
3210             0 => 'Default Settings',
3211             1 => 'Quick Adjust',
3212             2 => 'Full Control',
3213             },
3214             },
3215             55 => { # (NC)
3216             Name => 'PictureControlQuickAdjust',
3217             DelValue => 0xff,
3218             ValueConv => '$val - 0x80',
3219             ValueConvInv => '$val + 0x80',
3220             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3221             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3222             },
3223             57 => {
3224             Name => 'Sharpness',
3225             DelValue => 0xff,
3226             ValueConv => '$val - 0x80',
3227             ValueConvInv => '$val + 0x80',
3228             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3229             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3230             },
3231             59 => {
3232             Name => 'MidRangeSharpness',
3233             DelValue => 0xff,
3234             ValueConv => '$val - 0x80',
3235             ValueConvInv => '$val + 0x80',
3236             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3237             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3238             },
3239             61 => {
3240             Name => 'Clarity',
3241             DelValue => 0xff,
3242             ValueConv => '$val - 0x80',
3243             ValueConvInv => '$val + 0x80',
3244             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3245             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv2($val,4)',
3246             },
3247             63 => {
3248             Name => 'Contrast',
3249             DelValue => 0xff,
3250             ValueConv => '$val - 0x80',
3251             ValueConvInv => '$val + 0x80',
3252             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3253             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3254             },
3255             65 => { #21
3256             Name => 'Brightness',
3257             ValueConv => '$val - 0x80',
3258             ValueConvInv => '$val + 0x80',
3259             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,undef,"%.2f",4)',
3260             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3261             },
3262             67 => {
3263             Name => 'Saturation',
3264             DelValue => 0xff,
3265             ValueConv => '$val - 0x80',
3266             ValueConvInv => '$val + 0x80',
3267             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3268             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3269             },
3270             69 => {
3271             Name => 'Hue',
3272             DelValue => 0xff,
3273             ValueConv => '$val - 0x80',
3274             ValueConvInv => '$val + 0x80',
3275             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3276             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3277             },
3278             71 => { # (NC)
3279             Name => 'FilterEffect',
3280             DelValue => 0xff,
3281             PrintHex => 1,
3282             PrintConv => {
3283             0x80 => 'Off',
3284             0x81 => 'Yellow',
3285             0x82 => 'Orange',
3286             0x83 => 'Red',
3287             0x84 => 'Green',
3288             0xff => 'n/a',
3289             },
3290             },
3291             72 => { # (NC)
3292             Name => 'ToningEffect',
3293             DelValue => 0xff,
3294             PrintHex => 1,
3295             PrintConvColumns => 2,
3296             PrintConv => {
3297             0x80 => 'B&W',
3298             0x81 => 'Sepia',
3299             0x82 => 'Cyanotype',
3300             0x83 => 'Red',
3301             0x84 => 'Yellow',
3302             0x85 => 'Green',
3303             0x86 => 'Blue-green',
3304             0x87 => 'Blue',
3305             0x88 => 'Purple-blue',
3306             0x89 => 'Red-purple',
3307             0xff => 'n/a',
3308             },
3309             },
3310             73 => { # (NC)
3311             Name => 'ToningSaturation',
3312             DelValue => 0xff,
3313             ValueConv => '$val - 0x80',
3314             ValueConvInv => '$val + 0x80',
3315             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3316             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3317              
3318             },
3319             );
3320              
3321             # Unknown Picture Control information
3322             %Image::ExifTool::Nikon::PictureControlUnknown = (
3323             %binaryDataAttrs,
3324             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3325             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3326             0 => {
3327             Name => 'PictureControlVersion',
3328             Format => 'undef[4]',
3329             Writable => 0,
3330             },
3331             );
3332              
3333             # World Time information - JD (D300)
3334             %Image::ExifTool::Nikon::WorldTime = (
3335             %binaryDataAttrs,
3336             GROUPS => { 0 => 'MakerNotes', 2 => 'Time' },
3337             0 => {
3338             Name => 'TimeZone',
3339             Format => 'int16s',
3340             PrintConv => q{
3341             my $sign = $val < 0 ? '-' : '+';
3342             my $h = int(abs($val) / 60);
3343             sprintf("%s%.2d:%.2d", $sign, $h, abs($val)-60*$h);
3344             },
3345             PrintConvInv => q{
3346             $val =~ /([-+]?)(\d+):(\d+)/ or return undef;
3347             return $1 . ($2 * 60 + $3);
3348             },
3349             },
3350             2 => {
3351             Name => 'DaylightSavings',
3352             PrintConv => { 0 => 'No', 1 => 'Yes' },
3353             },
3354             3 => {
3355             Name => 'DateDisplayFormat',
3356             PrintConv => {
3357             0 => 'Y/M/D',
3358             1 => 'M/D/Y',
3359             2 => 'D/M/Y',
3360             },
3361             },
3362             );
3363              
3364             # ISO information - PH (D300)
3365             %Image::ExifTool::Nikon::ISOInfo = (
3366             %binaryDataAttrs,
3367             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3368             0 => {
3369             Name => 'ISO',
3370             Notes => 'val = 100 * 2**(raw/12-5)',
3371             Priority => 0, # because people like to see rounded-off values if they exist
3372             ValueConv => '100*exp(($val/12-5)*log(2))',
3373             ValueConvInv => '(log($val/100)/log(2)+5)*12',
3374             PrintConv => 'int($val + 0.5)',
3375             PrintConvInv => '$val',
3376             },
3377             # 1 - 0x01
3378             # 2 - 0x0c (probably the ISO divisor above)
3379             # 3 - 0x00
3380             4 => {
3381             Name => 'ISOExpansion',
3382             Format => 'int16u',
3383             PrintHex => 1,
3384             PrintConvColumns => 2,
3385             PrintConv => {
3386             0x000 => 'Off',
3387             0x101 => 'Hi 0.3',
3388             0x102 => 'Hi 0.5',
3389             0x103 => 'Hi 0.7',
3390             0x104 => 'Hi 1.0',
3391             0x105 => 'Hi 1.3', # (Hi 1.3-1.7 may be possible with future models)
3392             0x106 => 'Hi 1.5',
3393             0x107 => 'Hi 1.7',
3394             0x108 => 'Hi 2.0', #(NC) - D3 should have this mode
3395             0x109 => 'Hi 2.3', #IB
3396             0x10a => 'Hi 2.5', #IB
3397             0x10b => 'Hi 2.7', #IB
3398             0x10c => 'Hi 3.0', #IB
3399             0x10d => 'Hi 3.3', #IB
3400             0x10e => 'Hi 3.5', #IB
3401             0x10f => 'Hi 3.7', #IB
3402             0x110 => 'Hi 4.0', #IB
3403             0x111 => 'Hi 4.3', #IB
3404             0x112 => 'Hi 4.5', #IB
3405             0x113 => 'Hi 4.7', #IB
3406             0x114 => 'Hi 5.0', #IB
3407             0x201 => 'Lo 0.3',
3408             0x202 => 'Lo 0.5',
3409             0x203 => 'Lo 0.7',
3410             0x204 => 'Lo 1.0',
3411             },
3412             },
3413             # bytes 6-11 same as 0-4 in my samples (why is this duplicated?)
3414             6 => {
3415             Name => 'ISO2',
3416             Notes => 'val = 100 * 2**(raw/12-5)',
3417             ValueConv => '100*exp(($val/12-5)*log(2))',
3418             ValueConvInv => '(log($val/100)/log(2)+5)*12',
3419             PrintConv => 'int($val + 0.5)',
3420             PrintConvInv => '$val',
3421             },
3422             # 7 - 0x01
3423             # 8 - 0x0c (probably the ISO divisor above)
3424             # 9 - 0x00
3425             10 => {
3426             Name => 'ISOExpansion2',
3427             Format => 'int16u',
3428             PrintHex => 1,
3429             PrintConvColumns => 2,
3430             PrintConv => {
3431             0x000 => 'Off',
3432             0x101 => 'Hi 0.3',
3433             0x102 => 'Hi 0.5',
3434             0x103 => 'Hi 0.7',
3435             0x104 => 'Hi 1.0',
3436             0x105 => 'Hi 1.3', # (Hi 1.3-1.7 may be possible with future models)
3437             0x106 => 'Hi 1.5',
3438             0x107 => 'Hi 1.7',
3439             0x108 => 'Hi 2.0', #(NC) - D3 should have this mode
3440             0x201 => 'Lo 0.3',
3441             0x202 => 'Lo 0.5',
3442             0x203 => 'Lo 0.7',
3443             0x204 => 'Lo 1.0',
3444             },
3445             },
3446             # bytes 12-13: 00 00
3447             );
3448              
3449             # distortion information - PH (D5000)
3450             %Image::ExifTool::Nikon::DistortInfo = (
3451             %binaryDataAttrs,
3452             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3453             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3454             0 => {
3455             Name => 'DistortionVersion',
3456             Format => 'undef[4]',
3457             Writable => 0,
3458             Unknown => 1,
3459             },
3460             4 => {
3461             Name => 'AutoDistortionControl',
3462             PrintConv => {
3463             0 => 'Off',
3464             1 => 'On',
3465             2 => 'On (underwater)', # (1AW1)
3466             },
3467             },
3468             );
3469              
3470             # unknown information - PH (D7000)
3471             %Image::ExifTool::Nikon::UnknownInfo = (
3472             %binaryDataAttrs,
3473             FORMAT => 'int32u',
3474             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3475             0 => {
3476             Name => 'UnknownInfoVersion',
3477             Condition => '$$valPt =~ /^\d{4}/',
3478             Format => 'undef[4]',
3479             Writable => 0,
3480             Unknown => 1,
3481             },
3482             # (bytes 6/7 and 8/9 are swapped if CaptureNX changes the byte order)
3483             );
3484              
3485             # more unknown information - PH (D7000)
3486             %Image::ExifTool::Nikon::UnknownInfo2 = (
3487             %binaryDataAttrs,
3488             FORMAT => 'int32u',
3489             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3490             0 => {
3491             Name => 'UnknownInfo2Version',
3492             Condition => '$$valPt =~ /^\d{4}/',
3493             Format => 'undef[4]',
3494             Writable => 0,
3495             Unknown => 1,
3496             },
3497             # (byte 4 may be changed from 1 to 0 when rewritten by CaptureNX)
3498             );
3499              
3500             # Nikon AF information (ref 13)
3501             %Image::ExifTool::Nikon::AFInfo = (
3502             %binaryDataAttrs,
3503             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3504             0 => {
3505             Name => 'AFAreaMode',
3506             PrintConv => {
3507             0 => 'Single Area',
3508             1 => 'Dynamic Area',
3509             2 => 'Dynamic Area (closest subject)',
3510             3 => 'Group Dynamic',
3511             4 => 'Single Area (wide)',
3512             5 => 'Dynamic Area (wide)',
3513             },
3514             },
3515             1 => {
3516             Name => 'AFPoint',
3517             Notes => 'in some focus modes this value is not meaningful',
3518             PrintConvColumns => 2,
3519             PrintConv => {
3520             0 => 'Center',
3521             1 => 'Top',
3522             2 => 'Bottom',
3523             3 => 'Mid-left',
3524             4 => 'Mid-right',
3525             5 => 'Upper-left',
3526             6 => 'Upper-right',
3527             7 => 'Lower-left',
3528             8 => 'Lower-right',
3529             9 => 'Far Left',
3530             10 => 'Far Right',
3531             # (have also seen values of 11 and 12 when AFPointsInFocus is "(none)" - PH S3500)
3532             },
3533             },
3534             2 => {
3535             Name => 'AFPointsInFocus',
3536             Format => 'int16u',
3537             PrintConvColumns => 2,
3538             PrintConv => {
3539             0 => '(none)',
3540             0x7ff => 'All 11 Points',
3541             BITMASK => {
3542             0 => 'Center',
3543             1 => 'Top',
3544             2 => 'Bottom',
3545             3 => 'Mid-left',
3546             4 => 'Mid-right',
3547             5 => 'Upper-left',
3548             6 => 'Upper-right',
3549             7 => 'Lower-left',
3550             8 => 'Lower-right',
3551             9 => 'Far Left',
3552             10 => 'Far Right',
3553             },
3554             },
3555             },
3556             );
3557              
3558             # Nikon AF information for D3 and D300 (ref JD)
3559             %Image::ExifTool::Nikon::AFInfo2 = (
3560             %binaryDataAttrs,
3561             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3562             DATAMEMBER => [ 0, 4, 6 ],
3563             NOTES => "These tags are written by Nikon DSLR's which have the live view feature.",
3564             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3565             0 => {
3566             Name => 'AFInfo2Version',
3567             Format => 'undef[4]',
3568             Writable => 0,
3569             RawConv => '$$self{AFInfo2Version} = $val',
3570             },
3571             4 => { #PH
3572             Name => 'ContrastDetectAF',
3573             RawConv => '$$self{ContrastDetectAF} = $val',
3574             PrintConv => {
3575             %offOn,
3576             2 => 'On (2)', #PH (Z7)
3577             },
3578             Notes => 'this is Off for the hybrid AF used in Nikon 1 models',
3579             },
3580             5 => [
3581             {
3582             Name => 'AFAreaMode',
3583             Condition => 'not $$self{ContrastDetectAF}',
3584             Notes => 'ContrastDetectAF Off',
3585             PrintConv => {
3586             0 => 'Single Area', # (called "Single Point" in manual - PH)
3587             1 => 'Dynamic Area', #PH
3588             2 => 'Dynamic Area (closest subject)', #PH
3589             3 => 'Group Dynamic', #PH
3590             4 => 'Dynamic Area (9 points)', #JD/28
3591             5 => 'Dynamic Area (21 points)', #28
3592             6 => 'Dynamic Area (51 points)', #28
3593             7 => 'Dynamic Area (51 points, 3D-tracking)', #PH/28
3594             8 => 'Auto-area',
3595             9 => 'Dynamic Area (3D-tracking)', #PH (D5000 "3D-tracking (11 points)")
3596             10 => 'Single Area (wide)', #PH
3597             11 => 'Dynamic Area (wide)', #PH
3598             12 => 'Dynamic Area (wide, 3D-tracking)', #PH
3599             13 => 'Group Area', #PH
3600             14 => 'Dynamic Area (25 points)', #PH
3601             15 => 'Dynamic Area (72 points)', #PH
3602             16 => 'Group Area (HL)', #28
3603             17 => 'Group Area (VL)', #28
3604             18 => 'Dynamic Area (49 points)', #28
3605             128 => 'Single', #PH (1J1,1J2,1J3,1J4,1S1,1S2,1V2,1V3)
3606             129 => 'Auto (41 points)', #PH (1J1,1J2,1J3,1J4,1S1,1S2,1V1,1V2,1V3,AW1)
3607             130 => 'Subject Tracking (41 points)', #PH (1J1,1J4,1J3)
3608             131 => 'Face Priority (41 points)', #PH (1J1,1J3,1S1,1V2,AW1)
3609             # 134 - seen for 1V1[PhaseDetectAF=0] (PH)
3610             # 135 - seen for 1J2[PhaseDetectAF=4] (PH)
3611             192 => 'Pinpoint', #PH (NC)
3612             193 => 'Single', #PH (NC)
3613             195 => 'Wide (S)', #PH (NC)
3614             196 => 'Wide (L)', #PH (NC)
3615             197 => 'Auto', #PH (NC)
3616             },
3617             },
3618             { #PH (D3/D90/D5000)
3619             Name => 'AFAreaMode',
3620             Notes => 'ContrastDetectAF On',
3621             PrintConv => {
3622             0 => 'Contrast-detect', # (D3)
3623             1 => 'Contrast-detect (normal area)', # (D90/D5000)
3624             # (D90 and D5000 give value of 2 when set to 'Face Priority' and
3625             # 'Subject Tracking', but I didn't have a face to shoot at or a
3626             # moving subject to track so perhaps this value changes dynamically)
3627             2 => 'Contrast-detect (wide area)', # (D90/D5000)
3628             3 => 'Contrast-detect (face priority)', # (ViewNX)
3629             4 => 'Contrast-detect (subject tracking)', # (ViewNX)
3630             128 => 'Single', #PH (1V3)
3631             129 => 'Auto (41 points)', #PH (NC)
3632             130 => 'Subject Tracking (41 points)', #PH (NC)
3633             131 => 'Face Priority (41 points)', #PH (NC)
3634             192 => 'Pinpoint', #PH (Z7)
3635             193 => 'Single', #PH (Z7)
3636             194 => 'Dynamic', #PH (Z7)
3637             195 => 'Wide (S)', #PH (Z7)
3638             196 => 'Wide (L)', #PH (Z7)
3639             197 => 'Auto', #PH (Z7)
3640             198 => 'Auto (People)', #28 (Z7) #if no faces are detected, will record as 'Auto'. Camera setting recorded in AFAreaMode field in the MakerNotes area
3641             199 => 'Auto (Animal)', #28 (Z7) #if no animals are detected, will record as 'Auto'. Camera setting recorded in AFAreaMode field in the MakerNotes area
3642             200 => 'Normal-area AF', #28 (D6)
3643             201 => 'Wide-area AF', #28 (D6)
3644             202 => 'Face-priority AF', #28 (D6)
3645             203 => 'Subject-tracking AF', #28 (D6)
3646             204 => 'Dynamic Area (S)', #28 (Z9)
3647             205 => 'Dynamic Area (M)', #28 (Z9)
3648             206 => 'Dynamic Area (L)', #28 (Z9)
3649             207 => '3D-tracking', #28 (Z9)
3650             },
3651             },
3652             ],
3653             6 => {
3654             Name => 'PhaseDetectAF', #JD(AutoFocus), PH(PhaseDetectAF)
3655             Notes => 'PrimaryAFPoint and AFPointsUsed below are only valid when this is On',
3656             RawConv => '$$self{PhaseDetectAF} = $val',
3657             PrintConv => {
3658             # [observed AFAreaMode values in square brackets for each PhaseDetectAF value]
3659             0 => 'Off',
3660             1 => 'On (51-point)', #PH
3661             2 => 'On (11-point)', #PH
3662             3 => 'On (39-point)', #29 (D7000)
3663             4 => 'On (73-point)', #PH (1J1[128/129],1J2[128/129/135],1J3/1S1/1V2[128/129/131],1V1[129],AW1[129/131])
3664             5 => 'On (5)', #PH (1S2[128/129], 1J4/1V3[129])
3665             6 => 'On (105-point)', #PH (1J4/1V3[128/130])
3666             7 => 'On (153-point)', #PH (D5/D500/D850)
3667             8 => 'On (81-point)', #38
3668             9 => 'On (105-point)', #28 (D6)
3669             },
3670             },
3671             7 => [
3672             { #PH/JD
3673             Name => 'PrimaryAFPoint',
3674             # PrimaryAFPoint may only be valid for PhaseDetect - certainly true on the D6, possibly other bodies? (ref 28)
3675             Condition => '$$self{PhaseDetectAF} < 2 and $$self{AFInfo2Version} ne "0301"',
3676             Notes => q{
3677             models with 51-point AF -- 5 rows (A-E) and 11 columns (1-11): D3, D3S, D3X,
3678             D4, D4S, D300, D300S, D700, D800, D800e and D810
3679             },
3680             PrintConvColumns => 5,
3681             PrintConv => {
3682             0 => '(none)',
3683             %afPoints51,
3684             1 => 'C6 (Center)', # (add " (Center)" to central point)
3685             },
3686             },
3687             { #10
3688             Name => 'PrimaryAFPoint',
3689             Notes => 'models with 11-point AF: D90, D3000, D3100, D5000 and D5100',
3690             Condition => '$$self{PhaseDetectAF} == 2',
3691             PrintConvColumns => 2,
3692             PrintConv => {
3693             0 => '(none)',
3694             1 => 'Center',
3695             2 => 'Top',
3696             3 => 'Bottom',
3697             4 => 'Mid-left',
3698             5 => 'Upper-left',
3699             6 => 'Lower-left',
3700             7 => 'Far Left',
3701             8 => 'Mid-right',
3702             9 => 'Upper-right',
3703             10 => 'Lower-right',
3704             11 => 'Far Right',
3705             },
3706             },
3707             { #29
3708             Name => 'PrimaryAFPoint',
3709             Condition => '$$self{PhaseDetectAF} == 3',
3710             Notes => 'models with 39-point AF: D600 and D7000',
3711             PrintConvColumns => 5,
3712             PrintConv => {
3713             0 => '(none)',
3714             %afPoints39,
3715             1 => 'C6 (Center)', # (add " (Center)" to central point)
3716             },
3717             },
3718             { #PH
3719             Name => 'PrimaryAFPoint',
3720             Condition => '$$self{PhaseDetectAF} == 4',
3721             Notes => 'Nikon 1 models with older 135-point AF and 73-point phase-detect AF',
3722             PrintConvColumns => 5,
3723             PrintConv => {
3724             0 => '(none)',
3725             %afPoints135,
3726             1 => 'E8 (Center)', # (add " (Center)" to central point)
3727             },
3728             },
3729             { #PH (NC)
3730             Name => 'PrimaryAFPoint',
3731             Condition => '$$self{PhaseDetectAF} == 5',
3732             Notes => q{
3733             Nikon 1 models with newer 135-point AF and 73-point phase-detect AF -- 9
3734             rows (B-J) and 15 columns (1-15), inside a grid of 11 rows by 15 columns.
3735             The points are numbered sequentially, with F8 at the center
3736             },
3737             PrintConv => {
3738             0 => '(none)',
3739             82 => 'F8 (Center)',
3740             OTHER => sub {
3741             my ($val, $inv) = @_;
3742             return GetAFPointGrid($val, 15, $inv);
3743             },
3744             },
3745             },
3746             { #PH
3747             Name => 'PrimaryAFPoint',
3748             Condition => '$$self{PhaseDetectAF} == 6',
3749             Notes => q{
3750             Nikon 1 models with 171-point AF and 105-point phase-detect AF -- 9 rows
3751             (B-J) and 19 columns (2-20), inside a grid of 11 rows by 21 columns. The
3752             points are numbered sequentially, with F11 at the center
3753             },
3754             PrintConv => {
3755             0 => '(none)',
3756             #22 => 'B2 (Top-left)',
3757             #40 => 'B20 (Top-right)',
3758             115 => 'F11 (Center)',
3759             #190 => 'J2 (Bottom-left)',
3760             #208 => 'J20 (Bottom-right)',
3761             OTHER => sub {
3762             my ($val, $inv) = @_;
3763             return GetAFPointGrid($val, 21, $inv);
3764             },
3765             },
3766             },
3767             { #PH
3768             Name => 'PrimaryAFPoint',
3769             Condition => '$$self{PhaseDetectAF} == 7 and $$self{AFInfo2Version} eq "0100"',
3770             Notes => q{
3771             Nikon models with 153-point AF -- 9 rows (A-I) and 17 columns (1-17): D5,
3772             D500 and D850
3773             },
3774             PrintConvColumns => 5,
3775             PrintConv => {
3776             0 => '(none)',
3777             %afPoints153,
3778             1 => 'E9 (Center)',
3779             },
3780             },
3781             { #PH (Z7) (NC)
3782             Name => 'PrimaryAFPoint',
3783             Condition => '$$self{PhaseDetectAF} == 8 and $$self{AFInfo2Version} =~ /^03/',
3784             Notes => q{
3785             Nikon models with 493-point AF -- 17 rows (A-Q) and 29 columns (1-29), I15
3786             at the center
3787             },
3788             PrintConv => {
3789             0 => '(none)',
3790             246 => 'I15 (Center)',
3791             OTHER => sub {
3792             my ($val, $inv) = @_;
3793             return GetAFPointGrid($val, 29, $inv);
3794             },
3795             },
3796             },
3797             {
3798             Name => 'PrimaryAFPoint',
3799             Condition => '$$self{AFInfo2Version} eq "0100"',
3800             Notes => 'future models?...',
3801             PrintConv => {
3802             0 => '(none)',
3803             1 => 'Center',
3804             },
3805             },
3806             ],
3807             8 => [
3808             { #JD/PH
3809             Name => 'AFPointsUsed',
3810             Condition => '$$self{PhaseDetectAF} < 2 and $$self{AFInfo2Version} ne "0301"',
3811             Notes => q{
3812             models with 51-point AF -- 5 rows: A1-9, B1-11, C1-11, D1-11, E1-9. Center
3813             point is C6
3814             },
3815             Format => 'undef[7]',
3816             ValueConv => 'join(" ", unpack("H2"x7, $val))',
3817             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
3818             PrintConv => sub { PrintAFPoints(shift, \%afPoints51); },
3819             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints51); },
3820             },
3821             { #10
3822             Name => 'AFPointsUsed',
3823             Condition => '$$self{PhaseDetectAF} == 2',
3824             Notes => 'models with 11-point AF',
3825             # read as int16u in little-endian byte order
3826             Format => 'undef[2]',
3827             ValueConv => 'unpack("v",$val)',
3828             ValueConvInv => 'pack("v",$val)',
3829             PrintConvColumns => 2,
3830             PrintConv => {
3831             0 => '(none)',
3832             0x7ff => 'All 11 Points',
3833             BITMASK => {
3834             0 => 'Center',
3835             1 => 'Top',
3836             2 => 'Bottom',
3837             3 => 'Mid-left',
3838             4 => 'Upper-left',
3839             5 => 'Lower-left',
3840             6 => 'Far Left',
3841             7 => 'Mid-right',
3842             8 => 'Upper-right',
3843             9 => 'Lower-right',
3844             10 => 'Far Right',
3845             },
3846             },
3847             },
3848             { #29/PH
3849             Name => 'AFPointsUsed',
3850             Condition => '$$self{PhaseDetectAF} == 3',
3851             Notes => q{
3852             models with 39-point AF -- 5 rows: A1-3, B1-11, C1-11, D1-11, E1-3. Center
3853             point is C6
3854             },
3855             Format => 'undef[5]',
3856             ValueConv => 'join(" ", unpack("H2"x5, $val))',
3857             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
3858             PrintConv => sub { PrintAFPoints(shift, \%afPoints39); },
3859             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints39); },
3860             },
3861             { #PH (1AW1,1J1,1J2,1J3,1S1,1V1,1V2)
3862             Name => 'AFPointsUsed',
3863             Condition => '$$self{PhaseDetectAF} == 4',
3864             Notes => q{
3865             older models with 135-point AF -- 9 rows (A-I) and 15 columns (1-15).
3866             Center point is E8. The odd-numbered columns, columns 2 and 14, and the
3867             remaining corner points are not used for 41-point AF mode
3868             },
3869             Format => 'undef[17]',
3870             ValueConv => 'join(" ", unpack("H2"x17, $val))',
3871             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
3872             PrintConv => sub { PrintAFPoints(shift, \%afPoints135); },
3873             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints135); },
3874             },
3875             { #PH (1S2)
3876             Name => 'AFPointsUsed',
3877             Condition => '$$self{PhaseDetectAF} == 5',
3878             Notes => q{
3879             newer models with 135-point AF -- 9 rows (B-J) and 15 columns (1-15). Center
3880             point is F8
3881             },
3882             Format => 'undef[21]',
3883             ValueConv => 'join(" ", unpack("H2"x21, $val))',
3884             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
3885             PrintConv => sub { PrintAFPointsGrid(shift, 15); },
3886             PrintConvInv => sub { PrintAFPointsGridInv(shift, 15, 21); },
3887             },
3888             { #PH (1J4,1V3)
3889             Name => 'AFPointsUsed',
3890             Condition => '$$self{PhaseDetectAF} == 6',
3891             Notes => q{
3892             models with 171-point AF -- 9 rows (B-J) and 19 columns (2-20). Center
3893             point is F10
3894             },
3895             Format => 'undef[29]',
3896             ValueConv => 'join(" ", unpack("H2"x29, $val))',
3897             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
3898             PrintConv => sub { PrintAFPointsGrid(shift, 21); },
3899             PrintConvInv => sub { PrintAFPointsGridInv(shift, 21, 29); },
3900             },
3901             { #PH (D5,D500)
3902             Name => 'AFPointsUsed',
3903             Condition => '$$self{PhaseDetectAF} == 7',
3904             Notes => q{
3905             models with 153-point AF -- 9 rows (A-I) and 17 columns (1-17). Center
3906             point is E9
3907             },
3908             Format => 'undef[20]',
3909             ValueConv => 'join(" ", unpack("H2"x20, $val))',
3910             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
3911             PrintConv => sub { PrintAFPoints(shift, \%afPoints153); },
3912             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints153); },
3913             },
3914             { #38 (Z6/Z7/Z50)
3915             Name => 'AFPointsUsed',
3916             Condition => '$$self{PhaseDetectAF} == 8 and $$self{Model} =~ /^NIKON Z/',
3917             Notes => q{
3918             models with 81-selectable point AF -- 9 rows (A-I) and 9 columns (1-9) for
3919             phase detect AF points. Center point is E5
3920             },
3921             Format => 'undef[13]',
3922             ValueConv => 'join(" ", unpack("H2"x13, $val))',
3923             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
3924             PrintConv => sub { PrintAFPoints(shift, \%afPoints81); },
3925             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints81); },
3926             },
3927             { #PH
3928             Name => 'AFPointsUsed',
3929             # version 301 uses a separate field at offset 0x0a for this tag (ref 28)
3930             Condition => '$$self{AFInfo2Version} ne "0301"',
3931             Format => 'undef[7]',
3932             ValueConv => 'join(" ", unpack("H2"x7, $val))',
3933             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
3934             PrintConv => '"Unknown ($val)"',
3935             PrintConvInv => '$val=~s/Unknown \\((.*)\\)/$1/; $val',
3936             },
3937             ],
3938             0x0a => { #28 (D6) in any of the 3 Group modes on the D6, the points specify the outer boundaries of the focus point area; otherwise the tag value is consistent with other Nikon bodies
3939             Name => 'AFPointsUsed',
3940             Condition => '$$self{AFInfo2Version} eq "0301" and $$self{PhaseDetectAF} == 9',
3941             Notes => q{
3942             models with 105-point AF -- 7 rows (A-G) and 15 columns (1-15). Center
3943             point is D8
3944             },
3945             Format => 'undef[14]',
3946             ValueConv => 'join(" ", unpack("H2"x14, $val))',
3947             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
3948             PrintConv => sub { PrintAFPoints(shift, \%afPoints105); },
3949             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints105); },
3950             },
3951             0x10 => { #PH (D90 and D5000)
3952             Name => 'AFImageWidth',
3953             Condition => '$$self{AFInfo2Version} eq "0100"',
3954             Format => 'int16u',
3955             RawConv => '$val ? $val : undef',
3956             Notes => 'this and the following tags are valid only for contrast-detect AF',
3957             },
3958             0x12 => { #PH
3959             Name => 'AFImageHeight',
3960             Condition => '$$self{AFInfo2Version} eq "0100"',
3961             Format => 'int16u',
3962             RawConv => '$val ? $val : undef',
3963             },
3964             0x14 => { #PH
3965             Name => 'AFAreaXPosition',
3966             Condition => '$$self{AFInfo2Version} eq "0100"',
3967             Notes => 'center of AF area in AFImage coordinates',
3968             Format => 'int16u',
3969             RawConv => '$val ? $val : undef',
3970             },
3971             0x16 => { #PH
3972             Name => 'AFAreaYPosition',
3973             Condition => '$$self{AFInfo2Version} eq "0100"',
3974             Format => 'int16u',
3975             RawConv => '$val ? $val : undef',
3976             },
3977             # AFAreaWidth/Height for the D90 and D5000:
3978             # 352x288 (AF normal area),
3979             # 704x576 (AF face priority, wide area, subject tracking)
3980             0x18 => { #PH
3981             Name => 'AFAreaWidth',
3982             Condition => '$$self{AFInfo2Version} eq "0100"',
3983             Format => 'int16u',
3984             Notes => 'size of AF area in AFImage coordinates',
3985             RawConv => '$val ? $val : undef',
3986             },
3987             0x1a => { #PH
3988             Name => 'AFAreaHeight',
3989             Condition => '$$self{AFInfo2Version} eq "0100"',
3990             Format => 'int16u',
3991             RawConv => '$val ? $val : undef',
3992             },
3993             0x1c => [
3994             { #PH
3995             Name => 'ContrastDetectAFInFocus',
3996             Condition => '$$self{AFInfo2Version} eq "0100"',
3997             PrintConv => { 0 => 'No', 1 => 'Yes' },
3998             },{ #PH (D500, see forum11190)
3999             Name => 'AFPointsSelected',
4000             Condition => '$$self{AFInfo2Version} eq "0101" and $$self{PhaseDetectAF} == 7',
4001             Format => 'undef[20]',
4002             ValueConv => 'join(" ", unpack("H2"x20, $val))',
4003             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4004             PrintConv => sub { PrintAFPoints(shift, \%afPoints153); },
4005             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints153); },
4006             },
4007             ],
4008             # 0x1d - always zero (with or without live view)
4009             0x2a => { #PH (Z7)
4010             Name => 'AFImageWidth',
4011             Condition => '$$self{AFInfo2Version} =~ /^03/',
4012             Format => 'int16u',
4013             RawConv => '$val ? $val : undef',
4014             },
4015             0x2c => { #PH (Z7)
4016             Name => 'AFImageHeight',
4017             Condition => '$$self{AFInfo2Version} =~ /^03/',
4018             Format => 'int16u',
4019             RawConv => '$val ? $val : undef',
4020             },
4021             0x2e => { #PH (Z7)
4022             Name => 'AFAreaXPosition',
4023             Condition => q{
4024             $$self{ContrastDetectAF} == 2 and $$self{AFInfo2Version} =~ /^03/ or
4025             $$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} =~ /^0301/
4026             },
4027             Format => 'int16u',
4028             },
4029             0x2f => { #28 (Z7) Still photography range 1-17 for the 493 point Z7 (arranged in a 29x17 grid. Center at x=16, y=10).
4030             Name => 'AFFocusPointXPosition',
4031             Condition => q{
4032             $$self{ContrastDetectAF} == 2 and $$self{AFInfo2Version} =~ /^03/ or
4033             $$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} =~ /^0301/
4034             },
4035             PrintConv => sub { my ($val) = @_; PrintAFPointsLeftRight($val, 29 ); },
4036             },
4037             0x30 => [
4038             { #PH (Z7)
4039             Name => 'AFAreaYPosition',
4040             Condition => q{
4041             $$self{ContrastDetectAF} == 2 and $$self{AFInfo2Version} =~ /^03/ or
4042             $$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} =~ /^0301/
4043             },
4044             Format => 'int16u',
4045             },{ #PH (D500, see forum11190)
4046             Name => 'AFPointsInFocus',
4047             Condition => '$$self{AFInfo2Version} eq "0101" and $$self{PhaseDetectAF} == 7',
4048             Notes => 'AF points in focus at the time time image was captured',
4049             Format => 'undef[20]',
4050             ValueConv => 'join(" ", unpack("H2"x20, $val))',
4051             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4052             PrintConv => sub { PrintAFPoints(shift, \%afPoints153); },
4053             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints153); },
4054             },
4055             ],
4056             0x31 => { #28 (Z7)
4057             Name => 'AFFocusPointYPosition',
4058             Condition => q{
4059             $$self{ContrastDetectAF} == 2 and $$self{AFInfo2Version} =~ /^03/ or
4060             $$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} =~ /^0301/
4061             },
4062             PrintConv => sub { my ($val) = @_; PrintAFPointsUpDown($val, 17 ); },
4063             },
4064             0x32 => { #PH (Z7)
4065             Name => 'AFAreaWidth',
4066             Condition => '$$self{AFInfo2Version} =~ /^03/',
4067             Format => 'int16u',
4068             RawConv => '$val ? $val : undef',
4069             },
4070             0x34 => { #PH (Z7)
4071             Name => 'AFAreaHeight',
4072             Condition => '$$self{AFInfo2Version} =~ /^03/',
4073             Format => 'int16u',
4074             RawConv => '$val ? $val : undef',
4075             },
4076             0x38 => { #28
4077             Name => 'PrimaryAFPoint',
4078             Condition => '$$self{PhaseDetectAF} == 9 and $$self{AFInfo2Version} =~ /^03/',
4079             Notes => q{
4080             Nikon models with 105-point AF -- 7 rows (A-G) and 15 columns (1-15): D6
4081             },
4082             PrintConvColumns => 5,
4083             PrintConv => {
4084             0 => '(none)',
4085             %afPoints105,
4086             1 => 'D8 (Center)',
4087             },
4088             },
4089             0x44 => [
4090             {
4091             Name => 'PrimaryAFPoint',
4092             Condition => '$$self{PhaseDetectAF} == 7 and $$self{AFInfo2Version} eq "0101"',
4093             PrintConvColumns => 5,
4094             PrintConv => {
4095             0 => '(none)',
4096             %afPoints153,
4097             1 => 'E9 (Center)',
4098             },
4099             },
4100             { #PH
4101             Name => 'PrimaryAFPoint',
4102             Notes => 'D3500',
4103             Condition => '$$self{PhaseDetectAF} == 2 and $$self{AFInfo2Version} eq "0101"',
4104             PrintConvColumns => 2,
4105             PrintConv => {
4106             0 => '(none)',
4107             1 => 'Center',
4108             2 => 'Top',
4109             3 => 'Bottom',
4110             4 => 'Mid-left',
4111             5 => 'Upper-left',
4112             6 => 'Lower-left',
4113             7 => 'Far Left',
4114             8 => 'Mid-right',
4115             9 => 'Upper-right',
4116             10 => 'Lower-right',
4117             11 => 'Far Right',
4118             },
4119             },
4120             {
4121             Name => 'PrimaryAFPoint',
4122             Condition => '$$self{AFInfo2Version} eq "0101"',
4123             Notes => 'future models?...',
4124             Priority => 0,
4125             PrintConv => {
4126             0 => '(none)',
4127             1 => 'Center',
4128             },
4129             },
4130             ],
4131             0x46 => {
4132             Name => 'AFImageWidth',
4133             Condition => '$$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} eq "0101"',
4134             Format => 'int16u',
4135             RawConv => '$val ? $val : undef',
4136             Notes => 'this and the following tags are valid only for contrast-detect AF',
4137             },
4138             0x48 => {
4139             Name => 'AFImageHeight',
4140             Condition => '$$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} eq "0101"',
4141             Format => 'int16u',
4142             RawConv => '$val ? $val : undef',
4143             },
4144             0x4a => {
4145             Name => 'AFAreaXPosition',
4146             Condition => '$$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} eq "0101"',
4147             Notes => 'center of AF area in AFImage coordinates',
4148             Format => 'int16u',
4149             RawConv => '$val ? $val : undef',
4150             },
4151             0x4c => {
4152             Name => 'AFAreaYPosition',
4153             Condition => '$$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} eq "0101"',
4154             Format => 'int16u',
4155             RawConv => '$val ? $val : undef',
4156             },
4157             0x4e => {
4158             Name => 'AFAreaWidth',
4159             Condition => '$$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} eq "0101"',
4160             Format => 'int16u',
4161             Notes => 'size of AF area in AFImage coordinates',
4162             RawConv => '$val ? $val : undef',
4163             },
4164             0x50 => {
4165             Name => 'AFAreaHeight',
4166             Condition => '$$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} eq "0101"',
4167             Format => 'int16u',
4168             RawConv => '$val ? $val : undef',
4169             },
4170             0x52 => {
4171             Name => 'ContrastDetectAFInFocus',
4172             Condition => '$$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} eq "0101"',
4173             PrintConv => { 0 => 'No', 1 => 'Yes' },
4174             },
4175             );
4176              
4177             %Image::ExifTool::Nikon::AFInfo2V0400 = ( #V0400 related fields begin at x'3c' ( Z9)
4178             %binaryDataAttrs,
4179             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4180             DATAMEMBER => [ 0 ],
4181             0 => {
4182             Name => 'AFInfo2Version',
4183             Format => 'undef[4]',
4184             Writable => 0,
4185             RawConv => '$$self{AFInfo2Version} = $val',
4186             },
4187             0x3e => {
4188             Name => 'AFImageWidth',
4189             Format => 'int16u',
4190             },
4191             0x40 => {
4192             Name => 'AFImageHeight',
4193             Format => 'int16u',
4194             },
4195             0x43 => {
4196             Name => 'FocusPositionHorizontal',
4197             PrintConv => sub { my ($val) = @_; PrintAFPointsLeftRight($val, 29 ); }, #493 focus points for Z9 fall in a 30x18 grid (some coordinates are not accessible)
4198             },
4199             0x45 => {
4200             Name => 'FocusPositionVertical',
4201             PrintConv => sub { my ($val) = @_; PrintAFPointsUpDown($val, 17 ); },
4202             },
4203             0x46 => {
4204             Name => 'AFAreaWidth',
4205             Format => 'int16u',
4206             Notes => 'size of AF area in AFImage pixels',
4207             RawConv => '$val ? $val : undef',
4208             },
4209             0x48 => {
4210             Name => 'AFAreaHeight',
4211             Format => 'int16u',
4212             RawConv => '$val ? $val : undef',
4213             }
4214             # AFFocusResult is the result of the last AF operation and not necessarily an indication of the state of the of the capture (e.g., the subject may have moved or the image re-framed)
4215             #0x4a => { Name => 'AFFocusResult',PrintConv => {0=> "No Focus", 1=>"Focus"} }, #new tag created because Z9 uses a hybrid contrast/phase AF (closest former tag was ContrastDetectAFInFocus).
4216             );
4217              
4218             # Nikon AF fine-tune information (ref 28)
4219             %Image::ExifTool::Nikon::AFTune = (
4220             %binaryDataAttrs,
4221             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4222             0 => {
4223             Name => 'AFFineTune',
4224             PrintConv => {
4225             0 => 'Off',
4226             # (don't know what the difference between 1 and 2 is)
4227             1 => 'On (1)',
4228             2 => 'On (2)',
4229             3 => 'On (Zoom)', #28
4230             },
4231             },
4232             1 => {
4233             Name => 'AFFineTuneIndex',
4234             Notes => 'index of saved lens',
4235             PrintConv => '$val == 255 ? "n/a" : $val',
4236             PrintConvInv => '$val eq "n/a" ? 255 : $val',
4237             },
4238             2 => {
4239             # when AFFineTune = 3 (indicating a zoom lens), this Tag stores the tuning adjustment for the wide end of the zoom range (ref 28)
4240             Name => 'AFFineTuneAdj',
4241             Priority => 0, # so other value takes priority if it exists
4242             Notes => 'may only be valid for saved lenses',
4243             Format => 'int8s',
4244             PrintConv => '$val > 0 ? "+$val" : $val',
4245             PrintConvInv => '$val',
4246             },
4247             3 => {
4248             Name => 'AFFineTuneAdjTele',
4249             # should probably insert a Condition that restricts this to AFFineTune = 3 (ref 28)
4250             Notes => 'only valid for zoom lenses (ie, AFTune=3)',
4251             Format => 'int8s',
4252             PrintConv => '$val > 0 ? "+$val" : $val',
4253             PrintConvInv => '$val',
4254             },
4255             );
4256              
4257             # Nikon NEF processing information (ref forum6281)
4258             %Image::ExifTool::Nikon::RetouchInfo = (
4259             %binaryDataAttrs,
4260             FORMAT => 'int8s',
4261             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4262             DATAMEMBER => [ 0 ],
4263             0 => {
4264             Name => 'RetouchInfoVersion',
4265             Format => 'undef[4]',
4266             Writable => 0,
4267             RawConv => '$$self{RetouchInfoVersion} = $val',
4268             },
4269             # 4 - RetouchExposureComp (+$val/6 or -$val/6?)
4270             5 => {
4271             Name => 'RetouchNEFProcessing',
4272             Condition => '$$self{RetouchInfoVersion} ge "0200"',
4273             PrintConv => {
4274             -1 => 'Off',
4275             1 => 'On',
4276             },
4277             },
4278             );
4279              
4280             # Nikon File information - D60, D3 and D300 (ref PH)
4281             %Image::ExifTool::Nikon::FileInfo = (
4282             %binaryDataAttrs,
4283             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
4284             FORMAT => 'int16u',
4285             0 => {
4286             Name => 'FileInfoVersion',
4287             Format => 'undef[4]',
4288             Writable => 0,
4289             },
4290             2 => 'MemoryCardNumber',
4291             3 => {
4292             Name => 'DirectoryNumber',
4293             PrintConv => 'sprintf("%.3d", $val)',
4294             PrintConvInv => '$val',
4295             },
4296             4 => {
4297             Name => 'FileNumber',
4298             PrintConv => 'sprintf("%.4d", $val)',
4299             PrintConvInv => '$val',
4300             },
4301             );
4302              
4303             # ref PH
4304             %Image::ExifTool::Nikon::BarometerInfo = (
4305             %binaryDataAttrs,
4306             GROUPS => { 0 => 'MakerNotes', 2 => 'Location' },
4307             0 => {
4308             Name => 'BarometerInfoVersion',
4309             Format => 'undef[4]',
4310             Writable => 0,
4311             },
4312             6 => {
4313             Name => 'Altitude',
4314             Format => 'int32s',
4315             PrintConv => '"$val m"', # (always stored as metres)
4316             PrintConvInv => '$val=~s/\s*m$//; $val',
4317             },
4318             # 10: int16u - values: 0 (display in metres?), 18 (display in feet?)
4319             );
4320              
4321             # ref PH
4322             %Image::ExifTool::Nikon::CaptureOffsets = (
4323             PROCESS_PROC => \&ProcessNikonCaptureOffsets,
4324             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4325             # (note that these are duplicates of offsets in the normal TIFF structure,
4326             # and that these offsets are not updated when ExifTool rewrites the file)
4327             1 => 'IFD0_Offset',
4328             2 => 'PreviewIFD_Offset',
4329             3 => 'SubIFD_Offset',
4330             );
4331              
4332             # ref PH (Written by capture NX)
4333             %Image::ExifTool::Nikon::CaptureOutput = (
4334             %binaryDataAttrs,
4335             FORMAT => 'int32u',
4336             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
4337             # 1 = 1
4338             2 => 'OutputImageWidth',
4339             3 => 'OutputImageHeight',
4340             4 => 'OutputResolution',
4341             # 5 = 1
4342             );
4343              
4344             # ref IB
4345             %Image::ExifTool::Nikon::ColorBalanceA = (
4346             %binaryDataAttrs,
4347             FORMAT => 'int16u',
4348             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4349             624 => { #4
4350             Name => 'WB_RBLevels',
4351             Notes => 'as shot', #IB
4352             Format => 'int16u[2]',
4353             Protected => 1,
4354             },
4355             626 => {
4356             Name => 'WB_RBLevelsAuto',
4357             Format => 'int16u[2]',
4358             Protected => 1,
4359             },
4360             628 => {
4361             Name => 'WB_RBLevelsDaylight',
4362             Notes => 'red/blue levels for 0,+3,+2,+1,-1,-2,-3',
4363             Format => 'int16u[14]',
4364             Protected => 1,
4365             },
4366             642 => {
4367             Name => 'WB_RBLevelsIncandescent',
4368             Format => 'int16u[14]',
4369             Protected => 1,
4370             },
4371             656 => {
4372             Name => 'WB_RBLevelsFluorescent',
4373             Format => 'int16u[6]',
4374             Notes => 'red/blue levels for fluorescent W,N,D',
4375             Protected => 1,
4376             },
4377             662 => {
4378             Name => 'WB_RBLevelsCloudy',
4379             Format => 'int16u[14]',
4380             Protected => 1,
4381             },
4382             676 => {
4383             Name => 'WB_RBLevelsFlash',
4384             Format => 'int16u[14]',
4385             Protected => 1,
4386             },
4387             690 => {
4388             Name => 'WB_RBLevelsShade',
4389             Condition => '$$self{Model} ne "E8700"',
4390             Notes => 'not valid for E8700',
4391             Format => 'int16u[14]',
4392             Protected => 1,
4393             },
4394             );
4395              
4396             my %nrwLevels = (
4397             Format => 'int32u[4]',
4398             Protected => 1,
4399             ValueConv => 'my @a=split " ",$val;$a[0]*=2;$a[3]*=2;"@a"',
4400             ValueConvInv => 'my @a=split " ",$val;$a[0]/=2;$a[3]/=2;"@a"',
4401             );
4402              
4403             # (ref IB)
4404             %Image::ExifTool::Nikon::ColorBalanceB = (
4405             %binaryDataAttrs,
4406             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4407             NOTES => 'Color balance tags used by the P6000.',
4408             0x0004 => {
4409             Name => 'ColorBalanceVersion',
4410             Format => 'undef[4]',
4411             },
4412             0x13e8 => { Name => 'WB_RGGBLevels', %nrwLevels },
4413             0x13f8 => { Name => 'WB_RGGBLevelsDaylight', %nrwLevels },
4414             0x1408 => { Name => 'WB_RGGBLevelsCloudy', %nrwLevels },
4415             0x1428 => { Name => 'WB_RGGBLevelsTungsten', %nrwLevels },
4416             0x1438 => { Name => 'WB_RGGBLevelsFluorescentW',%nrwLevels },
4417             0x1448 => { Name => 'WB_RGGBLevelsFlash', %nrwLevels },
4418             0x1468 => { Name => 'WB_RGGBLevelsCustom', %nrwLevels, Notes => 'all zero if preset WB not used' },
4419             0x1478 => { Name => 'WB_RGGBLevelsAuto', %nrwLevels },
4420             );
4421              
4422             # (ref IB)
4423             %Image::ExifTool::Nikon::ColorBalanceC = (
4424             %binaryDataAttrs,
4425             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4426             DATAMEMBER => [ 4 ],
4427             NOTES => 'Color balance tags used by the P1000, P7000, P7100 and B700.',
4428             0x0004 => {
4429             Name => 'ColorBalanceVersion',
4430             Format => 'undef[4]',
4431             RawConv => '$$self{ColorBalanceVersion} = $val',
4432             },
4433             0x0020 => { Name => 'BlackLevel', Format => 'int16u' },
4434             0x0038 => { Name => 'WB_RGGBLevels', %nrwLevels },
4435             0x004c => { Name => 'WB_RGGBLevelsDaylight', %nrwLevels },
4436             0x0060 => { Name => 'WB_RGGBLevelsCloudy', %nrwLevels },
4437             0x0074 => {
4438             Name => 'WB_RGGBLevelsShade',
4439             Condition => '$$self{ColorBalanceVersion} ge "0104"',
4440             Notes => 'valid only for some models',
4441             %nrwLevels,
4442             },
4443             0x0088 => { Name => 'WB_RGGBLevelsTungsten', %nrwLevels },
4444             0x009c => { Name => 'WB_RGGBLevelsFluorescentW',%nrwLevels },
4445             0x00b0 => { Name => 'WB_RGGBLevelsFluorescentN',%nrwLevels },
4446             0x00c4 => { Name => 'WB_RGGBLevelsFluorescentD',%nrwLevels },
4447             0x00d8 => { Name => 'WB_RGGBLevelsHTMercury', %nrwLevels },
4448             0x0100 => { Name => 'WB_RGGBLevelsCustom', %nrwLevels, Notes => 'all zero if preset WB not used' },
4449             0x0114 => { Name => 'WB_RGGBLevelsAuto', %nrwLevels },
4450             );
4451              
4452             # ref 4
4453             %Image::ExifTool::Nikon::ColorBalance1 = (
4454             %binaryDataAttrs,
4455             FORMAT => 'int16u',
4456             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4457             0 => {
4458             Name => 'WB_RBGGLevels',
4459             Format => 'int16u[4]',
4460             Protected => 1,
4461             },
4462             );
4463              
4464             # ref 4
4465             %Image::ExifTool::Nikon::ColorBalance2 = (
4466             %binaryDataAttrs,
4467             FORMAT => 'int16u',
4468             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4469             NOTES => 'This information is encrypted for most camera models.',
4470             0 => {
4471             Name => 'WB_RGGBLevels',
4472             Format => 'int16u[4]',
4473             Protected => 1,
4474             },
4475             );
4476              
4477             # ref 4
4478             %Image::ExifTool::Nikon::ColorBalance3 = (
4479             %binaryDataAttrs,
4480             FORMAT => 'int16u',
4481             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4482             0 => {
4483             Name => 'WB_RGBGLevels',
4484             Format => 'int16u[4]',
4485             Protected => 1,
4486             },
4487             );
4488              
4489             # ref 4
4490             %Image::ExifTool::Nikon::ColorBalance4 = (
4491             %binaryDataAttrs,
4492             FORMAT => 'int16u',
4493             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4494             0 => {
4495             Name => 'WB_GRBGLevels',
4496             Format => 'int16u[4]',
4497             Protected => 1,
4498             },
4499             );
4500              
4501             %Image::ExifTool::Nikon::ColorBalanceUnknown = (
4502             %binaryDataAttrs,
4503             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4504             0 => {
4505             Name => 'ColorBalanceVersion',
4506             Format => 'undef[4]',
4507             },
4508             );
4509              
4510             %Image::ExifTool::Nikon::Type2 = (
4511             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
4512             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
4513             WRITABLE => 1,
4514             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4515             0x0003 => 'Quality',
4516             0x0004 => 'ColorMode',
4517             0x0005 => 'ImageAdjustment',
4518             0x0006 => 'CCDSensitivity',
4519             0x0007 => 'WhiteBalance',
4520             0x0008 => 'Focus',
4521             0x000A => 'DigitalZoom',
4522             0x000B => 'Converter',
4523             );
4524              
4525             # these are standard EXIF tags, but they are duplicated here so we can
4526             # set the family 0 group to 'MakerNotes' and set the MINOR_ERRORS flag
4527             %Image::ExifTool::Nikon::PreviewIFD = (
4528             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
4529             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
4530             GROUPS => { 0 => 'MakerNotes', 1 => 'PreviewIFD', 2 => 'Image'},
4531             VARS => { MINOR_ERRORS => 1 }, # this IFD is non-essential and often corrupted
4532             # (these tags are priority 0 by default because PreviewIFD is flagged in LOW_PRIORITY_DIR)
4533             0xfe => { # (not used by Nikon, but SRW images also use this table)
4534             Name => 'SubfileType',
4535             DataMember => 'SubfileType',
4536             RawConv => '$$self{SubfileType} = $val',
4537             PrintConv => \%Image::ExifTool::Exif::subfileType,
4538             },
4539             0x103 => {
4540             Name => 'Compression',
4541             SeparateTable => 'EXIF Compression',
4542             PrintConv => \%Image::ExifTool::Exif::compression,
4543             },
4544             0x11a => 'XResolution',
4545             0x11b => 'YResolution',
4546             0x128 => {
4547             Name => 'ResolutionUnit',
4548             PrintConv => {
4549             1 => 'None',
4550             2 => 'inches',
4551             3 => 'cm',
4552             },
4553             },
4554             0x201 => {
4555             Name => 'PreviewImageStart',
4556             Flags => [ 'IsOffset', 'Permanent' ],
4557             OffsetPair => 0x202,
4558             DataTag => 'PreviewImage',
4559             Writable => 'int32u',
4560             WriteGroup => 'MakerNotes',
4561             Protected => 2,
4562             },
4563             0x202 => {
4564             Name => 'PreviewImageLength',
4565             Flags => 'Permanent' ,
4566             OffsetPair => 0x201,
4567             DataTag => 'PreviewImage',
4568             Writable => 'int32u',
4569             WriteGroup => 'MakerNotes',
4570             Protected => 2,
4571             },
4572             0x213 => {
4573             Name => 'YCbCrPositioning',
4574             PrintConv => {
4575             1 => 'Centered',
4576             2 => 'Co-sited',
4577             },
4578             },
4579             );
4580              
4581             # these are duplicated enough times to make it worthwhile to define them centrally
4582             my %nikonApertureConversions = (
4583             ValueConv => '2**($val/24)',
4584             ValueConvInv => '$val>0 ? 24*log($val)/log(2) : 0',
4585             PrintConv => 'sprintf("%.1f",$val)',
4586             PrintConvInv => '$val',
4587             );
4588              
4589             my %nikonFocalConversions = (
4590             ValueConv => '5 * 2**($val/24)',
4591             ValueConvInv => '$val>0 ? 24*log($val/5)/log(2) : 0',
4592             PrintConv => 'sprintf("%.1f mm",$val)',
4593             PrintConvInv => '$val=~s/\s*mm$//;$val',
4594             );
4595              
4596             # Version 100 Nikon lens data
4597             %Image::ExifTool::Nikon::LensData00 = (
4598             %binaryDataAttrs,
4599             NOTES => 'This structure is used by the D100, and D1X with firmware version 1.1.',
4600             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4601             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
4602             0x00 => {
4603             Name => 'LensDataVersion',
4604             Format => 'undef[4]',
4605             Writable => 0,
4606             },
4607             0x06 => { #8
4608             Name => 'LensIDNumber',
4609             Notes => 'see LensID values below',
4610             },
4611             0x07 => { #8
4612             Name => 'LensFStops',
4613             ValueConv => '$val / 12',
4614             ValueConvInv => '$val * 12',
4615             PrintConv => 'sprintf("%.2f", $val)',
4616             PrintConvInv => '$val',
4617             },
4618             0x08 => { #8/9
4619             Name => 'MinFocalLength',
4620             %nikonFocalConversions,
4621             },
4622             0x09 => { #8/9
4623             Name => 'MaxFocalLength',
4624             %nikonFocalConversions,
4625             },
4626             0x0a => { #8
4627             Name => 'MaxApertureAtMinFocal',
4628             %nikonApertureConversions,
4629             },
4630             0x0b => { #8
4631             Name => 'MaxApertureAtMaxFocal',
4632             %nikonApertureConversions,
4633             },
4634             0x0c => 'MCUVersion', #8 (MCU = Micro Controller Unit)
4635             );
4636              
4637             # Nikon lens data (note: needs decrypting if LensDataVersion is 020x)
4638             %Image::ExifTool::Nikon::LensData01 = (
4639             %binaryDataAttrs,
4640             NOTES => q{
4641             Nikon encrypts the LensData information below if LensDataVersion is 0201 or
4642             higher, but the decryption algorithm is known so the information can be
4643             extracted.
4644             },
4645             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4646             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
4647             0x00 => {
4648             Name => 'LensDataVersion',
4649             Format => 'string[4]',
4650             Writable => 0,
4651             },
4652             0x04 => { #8
4653             Name => 'ExitPupilPosition',
4654             ValueConv => '$val ? 2048 / $val : $val',
4655             ValueConvInv => '$val ? 2048 / $val : $val',
4656             PrintConv => 'sprintf("%.1f mm",$val)',
4657             PrintConvInv => '$val=~s/\s*mm$//; $val',
4658             },
4659             0x05 => { #8
4660             Name => 'AFAperture',
4661             %nikonApertureConversions,
4662             },
4663             0x08 => { #8
4664             # this seems to be 2 values: the upper nibble gives the far focus
4665             # range and the lower nibble gives the near focus range. The values
4666             # are in the range 1-N, where N is lens-dependent. A value of 0 for
4667             # the far focus range indicates infinity. (ref JD)
4668             Name => 'FocusPosition',
4669             PrintConv => 'sprintf("0x%02x", $val)',
4670             PrintConvInv => '$val',
4671             },
4672             0x09 => { #8/9
4673             # With older AF lenses this does not work... (ref 13)
4674             # eg) AF Nikkor 50mm f/1.4 => 48 (0x30)
4675             # AF Zoom-Nikkor 35-105mm f/3.5-4.5 => @35mm => 15 (0x0f), @105mm => 141 (0x8d)
4676             Notes => 'this focus distance is approximate, and not very accurate for some lenses',
4677             Name => 'FocusDistance',
4678             ValueConv => '0.01 * 10**($val/40)', # in m
4679             ValueConvInv => '$val>0 ? 40*log($val*100)/log(10) : 0',
4680             PrintConv => '$val ? sprintf("%.2f m",$val) : "inf"',
4681             PrintConvInv => '$val eq "inf" ? 0 : $val =~ s/\s*m$//, $val',
4682             },
4683             0x0a => { #8/9
4684             Name => 'FocalLength',
4685             Priority => 0,
4686             %nikonFocalConversions,
4687             },
4688             0x0b => { #8
4689             Name => 'LensIDNumber',
4690             Notes => 'see LensID values below',
4691             },
4692             0x0c => { #8
4693             Name => 'LensFStops',
4694             ValueConv => '$val / 12',
4695             ValueConvInv => '$val * 12',
4696             PrintConv => 'sprintf("%.2f", $val)',
4697             PrintConvInv => '$val',
4698             },
4699             0x0d => { #8/9
4700             Name => 'MinFocalLength',
4701             %nikonFocalConversions,
4702             },
4703             0x0e => { #8/9
4704             Name => 'MaxFocalLength',
4705             %nikonFocalConversions,
4706             },
4707             0x0f => { #8
4708             Name => 'MaxApertureAtMinFocal',
4709             %nikonApertureConversions,
4710             },
4711             0x10 => { #8
4712             Name => 'MaxApertureAtMaxFocal',
4713             %nikonApertureConversions,
4714             },
4715             0x11 => 'MCUVersion', #8 (MCU = Micro Controller Unit)
4716             0x12 => { #8
4717             Name => 'EffectiveMaxAperture',
4718             %nikonApertureConversions,
4719             },
4720             );
4721              
4722             # Nikon lens data (note: needs decrypting)
4723             %Image::ExifTool::Nikon::LensData0204 = (
4724             %binaryDataAttrs,
4725             NOTES => q{
4726             Nikon encrypts the LensData information below if LensDataVersion is 0201 or
4727             higher, but the decryption algorithm is known so the information can be
4728             extracted.
4729             },
4730             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4731             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
4732             0x00 => {
4733             Name => 'LensDataVersion',
4734             Format => 'string[4]',
4735             Writable => 0,
4736             },
4737             0x04 => { #8
4738             Name => 'ExitPupilPosition',
4739             ValueConv => '$val ? 2048 / $val : $val',
4740             ValueConvInv => '$val ? 2048 / $val : $val',
4741             PrintConv => 'sprintf("%.1f mm",$val)',
4742             PrintConvInv => '$val=~s/\s*mm$//; $val',
4743             },
4744             0x05 => { #8
4745             Name => 'AFAperture',
4746             %nikonApertureConversions,
4747             },
4748             0x08 => { #8
4749             # this seems to be 2 values: the upper nibble gives the far focus
4750             # range and the lower nibble gives the near focus range. The values
4751             # are in the range 1-N, where N is lens-dependent. A value of 0 for
4752             # the far focus range indicates infinity. (ref JD)
4753             Name => 'FocusPosition',
4754             PrintConv => 'sprintf("0x%02x", $val)',
4755             PrintConvInv => '$val',
4756             },
4757             # --> extra byte at position 0x09 in this version of LensData (PH)
4758             0x0a => { #8/9
4759             # With older AF lenses this does not work... (ref 13)
4760             # eg) AF Nikkor 50mm f/1.4 => 48 (0x30)
4761             # AF Zoom-Nikkor 35-105mm f/3.5-4.5 => @35mm => 15 (0x0f), @105mm => 141 (0x8d)
4762             Notes => 'this focus distance is approximate, and not very accurate for some lenses',
4763             Name => 'FocusDistance',
4764             ValueConv => '0.01 * 10**($val/40)', # in m
4765             ValueConvInv => '$val>0 ? 40*log($val*100)/log(10) : 0',
4766             PrintConv => '$val ? sprintf("%.2f m",$val) : "inf"',
4767             PrintConvInv => '$val eq "inf" ? 0 : $val =~ s/\s*m$//, $val',
4768             },
4769             0x0b => { #8/9
4770             Name => 'FocalLength',
4771             Priority => 0,
4772             %nikonFocalConversions,
4773             },
4774             0x0c => { #8
4775             Name => 'LensIDNumber',
4776             Notes => 'see LensID values below',
4777             },
4778             0x0d => { #8
4779             Name => 'LensFStops',
4780             ValueConv => '$val / 12',
4781             ValueConvInv => '$val * 12',
4782             PrintConv => 'sprintf("%.2f", $val)',
4783             PrintConvInv => '$val',
4784             },
4785             0x0e => { #8/9
4786             Name => 'MinFocalLength',
4787             %nikonFocalConversions,
4788             },
4789             0x0f => { #8/9
4790             Name => 'MaxFocalLength',
4791             %nikonFocalConversions,
4792             },
4793             0x10 => { #8
4794             Name => 'MaxApertureAtMinFocal',
4795             %nikonApertureConversions,
4796             },
4797             0x11 => { #8
4798             Name => 'MaxApertureAtMaxFocal',
4799             %nikonApertureConversions,
4800             },
4801             0x12 => 'MCUVersion', #8 (MCU = Micro Controller Unit)
4802             0x13 => { #8
4803             Name => 'EffectiveMaxAperture',
4804             %nikonApertureConversions,
4805             },
4806             );
4807              
4808             # Nikon lens data version 0400 (note: needs decrypting) (ref PH)
4809             %Image::ExifTool::Nikon::LensData0400 = (
4810             %binaryDataAttrs,
4811             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4812             NOTES => 'Tags extracted from the encrypted lens data of the Nikon 1J1/1V1/1J2.',
4813             0x00 => {
4814             Name => 'LensDataVersion',
4815             Format => 'string[4]',
4816             Writable => 0,
4817             },
4818             0x18a => { #PH
4819             Name => 'LensModel',
4820             Format => 'string[64]',
4821             },
4822             );
4823              
4824             # Nikon lens data version 0402 (note: needs decrypting) (ref PH)
4825             %Image::ExifTool::Nikon::LensData0402 = (
4826             %binaryDataAttrs,
4827             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4828             NOTES => 'Tags extracted from the encrypted lens data of the Nikon 1J3/1S1/1V2.',
4829             0x00 => {
4830             Name => 'LensDataVersion',
4831             Format => 'string[4]',
4832             Writable => 0,
4833             },
4834             0x18b => { #PH
4835             Name => 'LensModel',
4836             Format => 'string[64]',
4837             },
4838             );
4839              
4840             # Nikon lens data version 0403 (note: needs decrypting) (ref PH)
4841             %Image::ExifTool::Nikon::LensData0403 = (
4842             %binaryDataAttrs,
4843             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4844             NOTES => 'Tags extracted from the encrypted lens data of the Nikon 1J4/1J5.',
4845             0x00 => {
4846             Name => 'LensDataVersion',
4847             Format => 'string[4]',
4848             Writable => 0,
4849             },
4850             0x2ac => { #PH
4851             Name => 'LensModel',
4852             Format => 'string[64]',
4853             },
4854             );
4855              
4856             # Nikon Z lens data (note: needs decrypting) (ref PH, based on LensData0204)
4857             %Image::ExifTool::Nikon::LensData0800 = (
4858             %binaryDataAttrs,
4859             NOTES => 'Tags found in the encrypted LensData from cameras such as the Z6 and Z7.',
4860             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4861             DATAMEMBER => [ 0x03, 0x2f ],
4862             0x00 => {
4863             Name => 'LensDataVersion',
4864             Format => 'string[4]',
4865             Writable => 0,
4866             },
4867             0x03 => { # look forward to see if new old data exists...
4868             Name => 'OldLensData',
4869             Format => 'undef[17]',
4870             RawConv => '$$self{OldLensData} = 1 unless $val =~ /^.\0+$/s; undef',
4871             Hidden => 1,
4872             },
4873             0x04 => {
4874             Name => 'ExitPupilPosition',
4875             Condition => '$$self{OldLensData}',
4876             ValueConv => '$val ? 2048 / $val : $val',
4877             ValueConvInv => '$val ? 2048 / $val : $val',
4878             PrintConv => 'sprintf("%.1f mm",$val)',
4879             PrintConvInv => '$val=~s/\s*mm$//; $val',
4880             },
4881             0x05 => {
4882             Name => 'AFAperture',
4883             Condition => '$$self{OldLensData}',
4884             %nikonApertureConversions,
4885             },
4886             # --> another extra byte at position 0x08 in this version of LensData (PH)
4887             0x09 => {
4888             Name => 'FocusPosition',
4889             Condition => '$$self{OldLensData}',
4890             PrintConv => 'sprintf("0x%02x", $val)',
4891             PrintConvInv => '$val',
4892             },
4893             0x0b => {
4894             Notes => 'this focus distance is approximate, and not very accurate for some lenses',
4895             Name => 'FocusDistance',
4896             Condition => '$$self{OldLensData}',
4897             ValueConv => '0.01 * 10**($val/40)', # in m
4898             ValueConvInv => '$val>0 ? 40*log($val*100)/log(10) : 0',
4899             PrintConv => '$val ? sprintf("%.2f m",$val) : "inf"',
4900             PrintConvInv => '$val eq "inf" ? 0 : $val =~ s/\s*m$//, $val',
4901             },
4902             0x0c => {
4903             Name => 'FocalLength',
4904             Condition => '$$self{OldLensData}',
4905             Priority => 0,
4906             %nikonFocalConversions,
4907             },
4908             0x0d => {
4909             Name => 'LensIDNumber',
4910             Condition => '$$self{OldLensData}',
4911             Notes => 'see LensID values below',
4912             },
4913             0x0e => {
4914             Name => 'LensFStops',
4915             Condition => '$$self{OldLensData}',
4916             ValueConv => '$val / 12',
4917             ValueConvInv => '$val * 12',
4918             PrintConv => 'sprintf("%.2f", $val)',
4919             PrintConvInv => '$val',
4920             },
4921             0x0f => {
4922             Name => 'MinFocalLength',
4923             Condition => '$$self{OldLensData}',
4924             %nikonFocalConversions,
4925             },
4926             0x10 => {
4927             Name => 'MaxFocalLength',
4928             Condition => '$$self{OldLensData}',
4929             %nikonFocalConversions,
4930             },
4931             0x11 => {
4932             Name => 'MaxApertureAtMinFocal',
4933             Condition => '$$self{OldLensData}',
4934             %nikonApertureConversions,
4935             },
4936             0x12 => {
4937             Name => 'MaxApertureAtMaxFocal',
4938             Condition => '$$self{OldLensData}',
4939             %nikonApertureConversions,
4940             },
4941             0x13 => {
4942             Name => 'MCUVersion',
4943             Condition => '$$self{OldLensData}',
4944             },
4945             0x14 => {
4946             Name => 'EffectiveMaxAperture',
4947             Condition => '$$self{OldLensData}',
4948             %nikonApertureConversions,
4949             },
4950             #
4951             # ---- new LensData tags used by Nikkor Z lenses ---- (ref PH)
4952             #
4953             0x2f => { # look forward to see if new lens data exists...
4954             Name => 'NewLensData',
4955             Format => 'undef[17]',
4956             RawConv => '$$self{NewLensData} = 1 unless $val =~ /^.\0+$/s; undef',
4957             Hidden => 1,
4958             },
4959             0x30 => {
4960             Name => 'LensID',
4961             Condition => '$$self{NewLensData}',
4962             Notes => 'tags from here onward used for Nikkor Z lenses only',
4963             Format => 'int16u',
4964             PrintConv => {
4965             1 => 'Nikkor Z 24-70mm f/4 S',
4966             2 => 'Nikkor Z 14-30mm f/4 S',
4967             4 => 'Nikkor Z 35mm f/1.8 S',
4968             8 => 'Nikkor Z 58mm f/0.95 S Noct', #IB
4969             9 => 'Nikkor Z 50mm f/1.8 S',
4970             11 => 'Nikkor Z DX 16-50mm f/3.5-6.3 VR',
4971             12 => 'Nikkor Z DX 50-250mm f/4.5-6.3 VR',
4972             13 => 'Nikkor Z 24-70mm f/2.8 S',
4973             14 => 'Nikkor Z 85mm f/1.8 S',
4974             15 => 'Nikkor Z 24mm f/1.8 S', #IB
4975             16 => 'Nikkor Z 70-200mm f/2.8 VR S', #IB
4976             17 => 'Nikkor Z 20mm f/1.8 S', #IB
4977             18 => 'Nikkor Z 24-200mm f/4-6.3 VR', #IB
4978             21 => 'Nikkor Z 50mm f/1.2 S', #IB
4979             22 => 'Nikkor Z 24-50mm f/4-6.3', #IB
4980             23 => 'Nikkor Z 14-24mm f/2.8 S', #IB
4981             24 => 'Nikkor Z MC 105mm f/2.8 VR S', #IB
4982             27 => 'Nikkor Z MC 50mm f/2.8', #IB
4983             28 => 'Nikkor Z 100-400mm f/4.5-5.6 VR S', #28
4984             29 => 'Nikkor Z 28mm f/2.8', #IB
4985             },
4986             },
4987             0x36 => {
4988             Name => 'MaxAperture',
4989             Condition => '$$self{NewLensData}',
4990             Format => 'int16u',
4991             Priority => 0,
4992             ValueConv => '2**($val/384-1)',
4993             ValueConvInv => '384*(log($val)/log(2)+1)',
4994             PrintConv => 'sprintf("%.1f",$val)',
4995             PrintConvInv => '$val',
4996             },
4997             0x38 => {
4998             Name => 'FNumber',
4999             Condition => '$$self{NewLensData}',
5000             Format => 'int16u',
5001             Priority => 0,
5002             ValueConv => '2**($val/384-1)',
5003             ValueConvInv => '384*(log($val)/log(2)+1)',
5004             PrintConv => 'sprintf("%.1f",$val)',
5005             PrintConvInv => '$val',
5006             },
5007             0x3c => {
5008             Name => 'FocalLength',
5009             Condition => '$$self{NewLensData}',
5010             Format => 'int16u',
5011             Priority => 0,
5012             PrintConv => '"$val mm"',
5013             PrintConvInv => '$val=~s/\s*mm$//;$val',
5014             },
5015             0x4f => {
5016             Name => 'FocusDistance',
5017             Condition => '$$self{NewLensData}',
5018             # (perhaps int16u Format? -- although upper byte would always be zero)
5019             ValueConv => '0.01 * 10**($val/40)', # in m
5020             ValueConvInv => '$val>0 ? 40*log($val*100)/log(10) : 0',
5021             PrintConv => '$val ? sprintf("%.2f m",$val) : "inf"',
5022             PrintConvInv => '$val eq "inf" ? 0 : $val =~ s/\s*m$//, $val',
5023             },
5024             );
5025              
5026             # Unknown Nikon lens data (note: data may need decrypting after byte 4)
5027             %Image::ExifTool::Nikon::LensDataUnknown = (
5028             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
5029             FIRST_ENTRY => 0,
5030             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5031             0x00 => {
5032             Name => 'LensDataVersion',
5033             Format => 'string[4]',
5034             },
5035             );
5036              
5037             # shot information (encrypted in some cameras) - ref 18
5038             %Image::ExifTool::Nikon::ShotInfo = (
5039             %binaryDataAttrs,
5040             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5041             DATAMEMBER => [ 0 ],
5042             NOTES => q{
5043             This information is encrypted for ShotInfoVersion 02xx, and some tags are
5044             only valid for specific models.
5045             },
5046             0x00 => {
5047             Name => 'ShotInfoVersion',
5048             Format => 'string[4]',
5049             Writable => 0,
5050             RawConv => '$$self{ShotInfoVersion} = $val; $val =~ /^\d+$/ ? $val : undef',
5051             },
5052             0x04 => {
5053             Name => 'FirmwareVersion',
5054             Format => 'string[5]',
5055             Writable => 0,
5056             RawConv => '$val =~ /^\d\.\d+.$/ ? $val : undef',
5057             },
5058             0x10 => {
5059             Name => 'DistortionControl',
5060             Condition => '$$self{Model} =~ /P6000\b/',
5061             Notes => 'P6000',
5062             PrintConv => \%offOn,
5063             },
5064             0x66 => {
5065             Name => 'VR_0x66',
5066             Condition => '$$self{ShotInfoVersion} eq "0204"',
5067             Format => 'int8u',
5068             Unknown => 1,
5069             Notes => 'D2X, D2Xs (unverified)',
5070             PrintConv => {
5071             0 => 'Off',
5072             1 => 'On (normal)',
5073             2 => 'On (active)',
5074             },
5075             },
5076             # 6a, 6e not correct for 0103 (D70), 0207 (D200)
5077             0x6a => {
5078             Name => 'ShutterCount',
5079             Condition => '$$self{ShotInfoVersion} eq "0204"',
5080             Format => 'int32u',
5081             Priority => 0,
5082             Notes => 'D2X, D2Xs',
5083             },
5084             0x6e => {
5085             Name => 'DeletedImageCount',
5086             Condition => '$$self{ShotInfoVersion} eq "0204"',
5087             Format => 'int32u',
5088             Priority => 0,
5089             Notes => 'D2X, D2Xs',
5090             },
5091             0x75 => { #JD
5092             Name => 'VibrationReduction',
5093             Condition => '$$self{ShotInfoVersion} eq "0207"',
5094             Format => 'int8u',
5095             Notes => 'D200',
5096             PrintConv => {
5097             0 => 'Off',
5098             # (not sure what the different values represent, but values
5099             # of 1 and 2 have even been observed for non-VR lenses!)
5100             1 => 'On (1)', #PH
5101             2 => 'On (2)', #PH
5102             3 => 'On (3)', #PH (rare -- only seen once)
5103             },
5104             },
5105             0x82 => { # educated guess, needs verification
5106             Name => 'VibrationReduction',
5107             Condition => '$$self{ShotInfoVersion} eq "0204"',
5108             Format => 'int8u',
5109             Notes => 'D2X, D2Xs',
5110             PrintConv => {
5111             0 => 'Off',
5112             1 => 'On',
5113             },
5114             },
5115             # 0xac - int16u[600] TiffMeteringImage1: 30x20 image (ShotInfoVersion 0800, ref JR)
5116             0x157 => { #JD
5117             Name => 'ShutterCount',
5118             Condition => '$$self{ShotInfoVersion} eq "0205"',
5119             Format => 'undef[2]',
5120             Priority => 0,
5121             Notes => 'D50',
5122             # treat as a 2-byte big-endian integer
5123             ValueConv => 'unpack("n", $val)',
5124             ValueConvInv => 'pack("n",$val)',
5125             },
5126             0x1ae => { #JD
5127             Name => 'VibrationReduction',
5128             Condition => '$$self{ShotInfoVersion} eq "0205"',
5129             Format => 'int8u',
5130             Notes => 'D50',
5131             PrintHex => 1,
5132             PrintConv => {
5133             0x00 => 'n/a',
5134             0x0c => 'Off',
5135             0x0f => 'On',
5136             },
5137             },
5138             0x24d => { #PH
5139             Name => 'ShutterCount',
5140             Condition => '$$self{ShotInfoVersion} eq "0211"',
5141             Notes => 'D60',
5142             Format => 'int32u',
5143             Priority => 0,
5144             },
5145             # note: DecryptLen currently set to 0x251
5146              
5147             # 0x55c - int16u[2400] TiffMeteringImage2: 60x40 image (ShotInfoVersion 0800, ref JR)
5148             # 0x181c - int16u[1200] TiffMeteringImage?: 60x20 image for some NEF's (ShotInfoVersion 0800, ref JR)
5149             # 0x217c - int16u[2400] TiffMeteringImage3: 60x40 image (ShotInfoVersion 0800, ref JR)
5150             # 0x3d9c - int16u[2400] TiffMeteringImage4: 60x40 image (ShotInfoVersion 0800, ref JR)
5151             # 0x59c0 - TiffMeteringImageWidth (ShotInfoVersion 0800, ref JR)
5152             # 0x59c2 - TiffMeteringImageHeight (ShotInfoVersion 0800, ref JR)
5153             # 0x59c4 - int16u[1800] TiffMeteringImage5: 30x20 RGB image (ShotInfoVersion 0800, ref JR)
5154             );
5155              
5156             # shot information for D40 and D40X (encrypted) - ref PH
5157             %Image::ExifTool::Nikon::ShotInfoD40 = (
5158             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5159             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5160             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5161             VARS => { ID_LABEL => 'Index' },
5162             IS_SUBDIR => [ 729 ],
5163             WRITABLE => 1,
5164             FIRST_ENTRY => 0,
5165             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5166             NOTES => 'These tags are extracted from encrypted data in D40 and D40X images.',
5167             0x00 => {
5168             Name => 'ShotInfoVersion',
5169             Format => 'string[4]',
5170             Writable => 0,
5171             },
5172             582 => {
5173             Name => 'ShutterCount',
5174             Format => 'int32u',
5175             Priority => 0,
5176             },
5177             586.1 => { #JD
5178             Name => 'VibrationReduction',
5179             Mask => 0x08,
5180             PrintConv => { 0 => 'Off', 1 => 'On' },
5181             },
5182             729 => { #JD
5183             Name => 'CustomSettingsD40',
5184             Format => 'undef[12]',
5185             SubDirectory => {
5186             TagTable => 'Image::ExifTool::NikonCustom::SettingsD40',
5187             },
5188             },
5189             # note: DecryptLen currently set to 748
5190             );
5191              
5192             # shot information for D80 (encrypted) - ref JD
5193             %Image::ExifTool::Nikon::ShotInfoD80 = (
5194             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5195             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5196             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5197             VARS => { ID_LABEL => 'Index' },
5198             IS_SUBDIR => [ 748 ],
5199             WRITABLE => 1,
5200             FIRST_ENTRY => 0,
5201             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5202             NOTES => 'These tags are extracted from encrypted data in D80 images.',
5203             0x00 => {
5204             Name => 'ShotInfoVersion',
5205             Format => 'string[4]',
5206             Writable => 0,
5207             },
5208             586 => {
5209             Name => 'ShutterCount',
5210             Format => 'int32u',
5211             Priority => 0,
5212             },
5213             # split 590 into a few different tags
5214             590.1 => {
5215             Name => 'Rotation',
5216             Mask => 0x07,
5217             PrintConv => {
5218             0 => 'Horizontal',
5219             1 => 'Rotate 270 CW',
5220             2 => 'Rotate 90 CW',
5221             3 => 'Rotate 180',
5222             },
5223             },
5224             590.2 => {
5225             Name => 'VibrationReduction',
5226             Mask => 0x18,
5227             PrintConv => {
5228             0 => 'Off',
5229             3 => 'On',
5230             },
5231             },
5232             590.3 => {
5233             Name => 'FlashFired',
5234             Mask => 0xe0,
5235             PrintConv => { BITMASK => {
5236             1 => 'Internal',
5237             2 => 'External',
5238             }},
5239             },
5240             708 => {
5241             Name => 'NikonImageSize',
5242             Mask => 0xf0,
5243             PrintConv => {
5244             0 => 'Large (10.0 M)',
5245             1 => 'Medium (5.6 M)',
5246             2 => 'Small (2.5 M)',
5247             },
5248             },
5249             708.1 => {
5250             Name => 'ImageQuality',
5251             Mask => 0x0f,
5252             PrintConv => {
5253             0 => 'NEF (RAW)',
5254             1 => 'JPEG Fine',
5255             2 => 'JPEG Normal',
5256             3 => 'JPEG Basic',
5257             4 => 'NEF (RAW) + JPEG Fine',
5258             5 => 'NEF (RAW) + JPEG Normal',
5259             6 => 'NEF (RAW) + JPEG Basic',
5260             },
5261             },
5262             748 => { #JD
5263             Name => 'CustomSettingsD80',
5264             Format => 'undef[17]',
5265             SubDirectory => {
5266             TagTable => 'Image::ExifTool::NikonCustom::SettingsD80',
5267             },
5268             },
5269             # note: DecryptLen currently set to 765
5270             );
5271              
5272             # shot information for D90 (encrypted) - ref PH
5273             %Image::ExifTool::Nikon::ShotInfoD90 = (
5274             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5275             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5276             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5277             VARS => { ID_LABEL => 'Index' },
5278             IS_SUBDIR => [ 0x374 ],
5279             WRITABLE => 1,
5280             FIRST_ENTRY => 0,
5281             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5282             NOTES => q{
5283             These tags are extracted from encrypted data in images from the D90 with
5284             firmware 1.00.
5285             },
5286             0x00 => {
5287             Name => 'ShotInfoVersion',
5288             Format => 'string[4]',
5289             Writable => 0,
5290             },
5291             0x04 => {
5292             Name => 'FirmwareVersion',
5293             Format => 'string[5]',
5294             Writable => 0,
5295             },
5296             0x2b5 => { #JD (same value found at offset 0x39, 0x2bf, 0x346)
5297             Name => 'ISO2',
5298             ValueConv => '100*exp(($val/12-5)*log(2))',
5299             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5300             PrintConv => 'int($val + 0.5)',
5301             PrintConvInv => '$val',
5302             },
5303             0x2d5 => {
5304             Name => 'ShutterCount',
5305             Format => 'int32u',
5306             Priority => 0,
5307             },
5308             0x374 => {
5309             Name => 'CustomSettingsD90',
5310             Format => 'undef[36]',
5311             SubDirectory => {
5312             TagTable => 'Image::ExifTool::NikonCustom::SettingsD90',
5313             },
5314             },
5315             # note: DecryptLen currently set to 0x398
5316             );
5317              
5318             # shot information for the D3 firmware 0.37 and 1.00 (encrypted) - ref PH
5319             %Image::ExifTool::Nikon::ShotInfoD3a = (
5320             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5321             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5322             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5323             VARS => { ID_LABEL => 'Index' },
5324             IS_SUBDIR => [ 0x301 ],
5325             WRITABLE => 1,
5326             FIRST_ENTRY => 0,
5327             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5328             NOTES => q{
5329             These tags are extracted from encrypted data in images from the D3 with
5330             firmware 1.00 and earlier.
5331             },
5332             0x00 => {
5333             Name => 'ShotInfoVersion',
5334             Format => 'string[4]',
5335             Writable => 0,
5336             },
5337             0x256 => { #JD (same value found at offset 0x26b)
5338             Name => 'ISO2',
5339             ValueConv => '100*exp(($val/12-5)*log(2))',
5340             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5341             PrintConv => 'int($val + 0.5)',
5342             PrintConvInv => '$val',
5343             },
5344             0x276 => { #JD
5345             Name => 'ShutterCount',
5346             Format => 'int32u',
5347             Priority => 0,
5348             },
5349             723.1 => {
5350             Name => 'NikonImageSize',
5351             Mask => 0x18,
5352             PrintConv => {
5353             0 => 'Large',
5354             1 => 'Medium',
5355             2 => 'Small',
5356             },
5357             },
5358             723.2 => {
5359             Name => 'ImageQuality',
5360             Mask => 0x07,
5361             PrintConv => {
5362             0 => 'NEF (RAW) + JPEG Fine',
5363             1 => 'NEF (RAW) + JPEG Norm',
5364             2 => 'NEF (RAW) + JPEG Basic',
5365             3 => 'NEF (RAW)',
5366             4 => 'TIF (RGB)',
5367             5 => 'JPEG Fine',
5368             6 => 'JPEG Normal',
5369             7 => 'JPEG Basic',
5370             },
5371             },
5372             0x301 => { #(NC)
5373             Name => 'CustomSettingsD3',
5374             Format => 'undef[24]',
5375             SubDirectory => {
5376             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
5377             },
5378             },
5379             # note: DecryptLen currently set to 0x318
5380             );
5381              
5382             # shot information for the D3 firmware 1.10, 2.00 and 2.01 (encrypted) - ref PH
5383             %Image::ExifTool::Nikon::ShotInfoD3b = (
5384             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5385             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5386             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5387             VARS => { ID_LABEL => 'Index' },
5388             IS_SUBDIR => [ 0x30a ],
5389             WRITABLE => 1,
5390             FIRST_ENTRY => 0,
5391             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5392             DATAMEMBER => [ 4 ],
5393             NOTES => q{
5394             These tags are extracted from encrypted data in images from the D3 with
5395             firmware 1.10, 2.00, 2.01 and 2.02.
5396             },
5397             0x00 => {
5398             Name => 'ShotInfoVersion',
5399             Format => 'string[4]',
5400             Writable => 0,
5401             },
5402             0x04 => {
5403             Name => 'FirmwareVersion',
5404             Format => 'string[5]',
5405             Writable => 0,
5406             RawConv => '$$self{FirmwareVersion} = $val',
5407             },
5408             0x10 => { #28
5409             Name => 'ImageArea',
5410             PrintConv => {
5411             0 => 'FX (36.0 x 23.9 mm)',
5412             1 => 'DX (23.5 x 15.6 mm)',
5413             2 => '5:4 (30.0 x 23.9 mm)',
5414             },
5415             },
5416             0x25d => {
5417             Name => 'ISO2',
5418             ValueConv => '100*exp(($val/12-5)*log(2))',
5419             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5420             PrintConv => 'int($val + 0.5)',
5421             PrintConvInv => '$val',
5422             },
5423             0x27d => {
5424             Name => 'ShutterCount',
5425             Condition => '$$self{FirmwareVersion} =~ /^1.01/',
5426             Notes => 'firmware 1.10',
5427             Format => 'int32u',
5428             Priority => 0,
5429             },
5430             0x27f => {
5431             Name => 'ShutterCount',
5432             Condition => '$$self{FirmwareVersion} =~ /^2.0/',
5433             Notes => 'firmware 2.00, 2.01 and 2.02',
5434             Format => 'int32u',
5435             Priority => 0,
5436             },
5437             732.1 => { #28
5438             Name => 'NikonImageSize',
5439             Mask => 0x18,
5440             PrintConv => {
5441             0 => 'Large',
5442             1 => 'Medium',
5443             2 => 'Small',
5444             },
5445             },
5446             732.2 => { #28
5447             Name => 'ImageQuality',
5448             Mask => 0x07,
5449             PrintConv => {
5450             0 => 'NEF (RAW) + JPEG Fine',
5451             1 => 'NEF (RAW) + JPEG Norm',
5452             2 => 'NEF (RAW) + JPEG Basic',
5453             3 => 'NEF (RAW)',
5454             4 => 'TIF (RGB)',
5455             5 => 'JPEG Fine',
5456             6 => 'JPEG Normal',
5457             7 => 'JPEG Basic',
5458             },
5459             },
5460             0x28a => { #28
5461             Name => 'PreFlashReturnStrength',
5462             Notes => 'valid in TTL and TTL-BL flash control modes',
5463             # this is used to set the flash power using this relationship
5464             # for the SB-800 and SB-900:
5465             # $val < 140 ? 2**(0.08372*$val-12.352) : $val
5466             },
5467             0x30a => { # tested with firmware 2.00
5468             Name => 'CustomSettingsD3',
5469             Format => 'undef[24]',
5470             SubDirectory => {
5471             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
5472             },
5473             },
5474             # note: DecryptLen currently set to 0x321
5475             );
5476              
5477             # shot information for the D3X firmware 1.00 (encrypted) - ref PH
5478             %Image::ExifTool::Nikon::ShotInfoD3X = (
5479             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5480             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5481             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5482             VARS => { ID_LABEL => 'Index' },
5483             IS_SUBDIR => [ 0x30b ],
5484             WRITABLE => 1,
5485             FIRST_ENTRY => 0,
5486             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5487             NOTES => q{
5488             These tags are extracted from encrypted data in images from the D3X with
5489             firmware 1.00.
5490             },
5491             0x00 => {
5492             Name => 'ShotInfoVersion',
5493             Format => 'string[4]',
5494             Writable => 0,
5495             },
5496             0x04 => {
5497             Name => 'FirmwareVersion',
5498             Format => 'string[5]',
5499             Writable => 0,
5500             },
5501             0x25d => {
5502             Name => 'ISO2',
5503             ValueConv => '100*exp(($val/12-5)*log(2))',
5504             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5505             PrintConv => 'int($val + 0.5)',
5506             PrintConvInv => '$val',
5507             },
5508             0x280 => {
5509             Name => 'ShutterCount',
5510             Format => 'int32u',
5511             Priority => 0,
5512             },
5513             0x30b => { #(NC)
5514             Name => 'CustomSettingsD3X',
5515             Format => 'undef[24]',
5516             SubDirectory => {
5517             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
5518             },
5519             },
5520             # note: DecryptLen currently set to 0x323
5521             );
5522              
5523             # shot information for the D3S firmware 0.16 and 1.00 (encrypted) - ref PH
5524             %Image::ExifTool::Nikon::ShotInfoD3S = (
5525             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5526             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5527             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5528             VARS => { ID_LABEL => 'Index' },
5529             IS_SUBDIR => [ 0x2ce ],
5530             WRITABLE => 1,
5531             FIRST_ENTRY => 0,
5532             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5533             NOTES => q{
5534             These tags are extracted from encrypted data in images from the D3S with
5535             firmware 1.00 and earlier.
5536             },
5537             0x00 => {
5538             Name => 'ShotInfoVersion',
5539             Format => 'string[4]',
5540             Writable => 0,
5541             },
5542             0x04 => {
5543             Name => 'FirmwareVersion',
5544             Format => 'string[5]',
5545             Writable => 0,
5546             },
5547             0x10 => { #28
5548             Name => 'ImageArea',
5549             PrintConv => {
5550             0 => 'FX (36x24)',
5551             1 => 'DX (24x16)',
5552             2 => '5:4 (30x24)',
5553             3 => '1.2x (30x20)',
5554             },
5555             },
5556             0x221 => {
5557             Name => 'ISO2',
5558             ValueConv => '100*exp(($val/12-5)*log(2))',
5559             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5560             PrintConv => 'int($val + 0.5)',
5561             PrintConvInv => '$val',
5562             },
5563             0x242 => {
5564             Name => 'ShutterCount',
5565             Format => 'int32u',
5566             Priority => 0,
5567             },
5568             0x2ce => { #(NC)
5569             Name => 'CustomSettingsD3S',
5570             Format => 'undef[27]',
5571             SubDirectory => {
5572             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
5573             },
5574             },
5575             # note: DecryptLen currently set to 0x2e9
5576             );
5577              
5578             # shot information for the D300 firmware 1.00 (encrypted) - ref JD
5579             %Image::ExifTool::Nikon::ShotInfoD300a = (
5580             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5581             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5582             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5583             VARS => { ID_LABEL => 'Index' },
5584             IS_SUBDIR => [ 790 ],
5585             WRITABLE => 1,
5586             FIRST_ENTRY => 0,
5587             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5588             NOTES => q{
5589             These tags are extracted from encrypted data in images from the D300 with
5590             firmware 1.00 and earlier.
5591             },
5592             0x00 => {
5593             Name => 'ShotInfoVersion',
5594             Format => 'string[4]',
5595             Writable => 0,
5596             },
5597             604 => {
5598             Name => 'ISO2',
5599             ValueConv => '100*exp(($val/12-5)*log(2))',
5600             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5601             PrintConv => 'int($val + 0.5)',
5602             PrintConvInv => '$val',
5603             },
5604             633 => {
5605             Name => 'ShutterCount',
5606             Format => 'int32u',
5607             Priority => 0,
5608             },
5609             721 => { #PH
5610             Name => 'AFFineTuneAdj',
5611             Format => 'int16u',
5612             PrintHex => 1,
5613             PrintConvColumns => 3,
5614             # thanks to Neil Nappe for the samples to decode this!...
5615             # (have seen various unknown values here when flash is enabled, but
5616             # these are yet to be decoded: 0x2e,0x619,0xd0d,0x103a,0x2029 - PH)
5617             PrintConv => {
5618             0x403e => '+20',
5619             0x303e => '+19',
5620             0x203e => '+18',
5621             0x103e => '+17',
5622             0x003e => '+16',
5623             0xe03d => '+15',
5624             0xc03d => '+14',
5625             0xa03d => '+13',
5626             0x803d => '+12',
5627             0x603d => '+11',
5628             0x403d => '+10',
5629             0x203d => '+9',
5630             0x003d => '+8',
5631             0xc03c => '+7',
5632             0x803c => '+6',
5633             0x403c => '+5',
5634             0x003c => '+4',
5635             0x803b => '+3',
5636             0x003b => '+2',
5637             0x003a => '+1',
5638             0x0000 => '0',
5639             0x00c6 => '-1',
5640             0x00c5 => '-2',
5641             0x80c5 => '-3',
5642             0x00c4 => '-4',
5643             0x40c4 => '-5',
5644             0x80c4 => '-6',
5645             0xc0c4 => '-7',
5646             0x00c3 => '-8',
5647             0x20c3 => '-9',
5648             0x40c3 => '-10',
5649             0x60c3 => '-11',
5650             0x80c3 => '-12',
5651             0xa0c3 => '-13',
5652             0xc0c3 => '-14',
5653             0xe0c3 => '-15',
5654             0x00c2 => '-16',
5655             0x10c2 => '-17',
5656             0x20c2 => '-18',
5657             0x30c2 => '-19',
5658             0x40c2 => '-20',
5659             },
5660             },
5661             790 => {
5662             Name => 'CustomSettingsD300',
5663             Format => 'undef[24]',
5664             SubDirectory => {
5665             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
5666             },
5667             },
5668             # note: DecryptLen currently set to 813
5669             );
5670              
5671             # shot information for the D300 firmware 1.10 (encrypted) - ref PH
5672             %Image::ExifTool::Nikon::ShotInfoD300b = (
5673             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5674             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5675             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5676             VARS => { ID_LABEL => 'Index' },
5677             DATAMEMBER => [ 4 ],
5678             IS_SUBDIR => [ 802 ],
5679             WRITABLE => 1,
5680             FIRST_ENTRY => 0,
5681             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5682             NOTES => q{
5683             These tags are extracted from encrypted data in images from the D300 with
5684             firmware 1.10.
5685             },
5686             0x00 => {
5687             Name => 'ShotInfoVersion',
5688             Format => 'string[4]',
5689             Writable => 0,
5690             },
5691             0x04 => { #PH
5692             Name => 'FirmwareVersion',
5693             DataMember => 'FirmwareVersion',
5694             Format => 'string[5]',
5695             Writable => 0,
5696             RawConv => '$$self{FirmwareVersion} = $val',
5697             },
5698             613 => {
5699             Name => 'ISO2',
5700             ValueConv => '100*exp(($val/12-5)*log(2))',
5701             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5702             PrintConv => 'int($val + 0.5)',
5703             PrintConvInv => '$val',
5704             },
5705             644 => {
5706             Name => 'ShutterCount',
5707             Format => 'int32u',
5708             Priority => 0,
5709             },
5710             732 => [{
5711             Name => 'AFFineTuneAdj',
5712             Condition => '$$self{FirmwareVersion} eq "1.10B"',
5713             Notes => 'firmware version 1.10B',
5714             Format => 'int16u',
5715             PrintHex => 1,
5716             PrintConvColumns => 3,
5717             # thanks to Michael Tapes for the samples to decode this!...
5718             PrintConv => {
5719             0xe03e => '+20',
5720             0xc83e => '+19',
5721             0xb03e => '+18',
5722             0x983e => '+17',
5723             0x803e => '+16',
5724             0x683e => '+15',
5725             0x503e => '+14',
5726             0x383e => '+13',
5727             0x203e => '+12',
5728             0x083e => '+11',
5729             0xe03d => '+10',
5730             0xb03d => '+9',
5731             0x803d => '+8',
5732             0x503d => '+7',
5733             0x203d => '+6',
5734             0xe03c => '+5',
5735             0x803c => '+4',
5736             0x203c => '+3',
5737             0x803b => '+2',
5738             0x803a => '+1',
5739             0x0000 => '0',
5740             0x80c6 => '-1',
5741             0x80c5 => '-2',
5742             0x20c4 => '-3',
5743             0x80c4 => '-4',
5744             0xe0c4 => '-5',
5745             0x20c3 => '-6',
5746             0x50c3 => '-7',
5747             0x80c3 => '-8',
5748             0xb0c3 => '-9',
5749             0xe0c3 => '-10',
5750             0x08c2 => '-11',
5751             0x20c2 => '-12',
5752             0x38c2 => '-13',
5753             0x50c2 => '-14',
5754             0x68c2 => '-15',
5755             0x80c2 => '-16',
5756             0x98c2 => '-17',
5757             0xb0c2 => '-18',
5758             0xc8c2 => '-19',
5759             0xe0c2 => '-20',
5760             },
5761             },{
5762             Name => 'AFFineTuneAdj',
5763             Notes => 'other versions',
5764             Format => 'int16u',
5765             PrintHex => 1,
5766             PrintConvColumns => 3,
5767             # thanks to Stuart Solomon for the samples to decode this!...
5768             PrintConv => {
5769             0x903e => '+20',
5770             0x7c3e => '+19',
5771             0x683e => '+18',
5772             0x543e => '+17',
5773             0x403e => '+16',
5774             0x2c3e => '+15',
5775             0x183e => '+14',
5776             0x043e => '+13',
5777             0xe03d => '+12',
5778             0xb83d => '+11',
5779             0x903d => '+10',
5780             0x683d => '+9',
5781             0x403d => '+8',
5782             0x183d => '+7',
5783             0xe03c => '+6',
5784             0x903c => '+5',
5785             0x403c => '+4',
5786             0xe03b => '+3',
5787             0x403b => '+2',
5788             0x403a => '+1',
5789             0x0000 => '0',
5790             0x40c6 => '-1',
5791             0x40c5 => '-2',
5792             0xe0c5 => '-3',
5793             0x40c4 => '-4',
5794             0x90c4 => '-5',
5795             0xe0c4 => '-6',
5796             0x18c3 => '-7',
5797             0x40c3 => '-8',
5798             0x68c3 => '-9',
5799             0x90c3 => '-10',
5800             0xb8c3 => '-11',
5801             0xe0c3 => '-12',
5802             0x04c2 => '-13',
5803             0x18c2 => '-14',
5804             0x2cc2 => '-15',
5805             0x40c2 => '-16',
5806             0x54c2 => '-17',
5807             0x68c2 => '-18',
5808             0x7cc2 => '-19',
5809             0x90c2 => '-20',
5810             },
5811             }],
5812             802 => {
5813             Name => 'CustomSettingsD300',
5814             Format => 'undef[24]',
5815             SubDirectory => {
5816             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
5817             },
5818             },
5819             # note: DecryptLen currently set to 825
5820             );
5821              
5822             # shot information for the D300S firmware 1.00 (encrypted) - ref PH
5823             %Image::ExifTool::Nikon::ShotInfoD300S = (
5824             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5825             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5826             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5827             VARS => { ID_LABEL => 'Index' },
5828             IS_SUBDIR => [ 804 ],
5829             WRITABLE => 1,
5830             FIRST_ENTRY => 0,
5831             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5832             NOTES => q{
5833             These tags are extracted from encrypted data in images from the D300S with
5834             firmware 1.00.
5835             },
5836             0x00 => {
5837             Name => 'ShotInfoVersion',
5838             Format => 'string[4]',
5839             Writable => 0,
5840             },
5841             0x04 => {
5842             Name => 'FirmwareVersion',
5843             Format => 'string[5]',
5844             Writable => 0,
5845             },
5846             613 => {
5847             Name => 'ISO2',
5848             ValueConv => '100*exp(($val/12-5)*log(2))',
5849             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5850             PrintConv => 'int($val + 0.5)',
5851             PrintConvInv => '$val',
5852             },
5853             646 => {
5854             Name => 'ShutterCount',
5855             Format => 'int32u',
5856             Priority => 0,
5857             },
5858             804 => { #(NC)
5859             Name => 'CustomSettingsD300S',
5860             Format => 'undef[24]',
5861             SubDirectory => {
5862             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
5863             },
5864             },
5865             # note: DecryptLen currently set to 827
5866             );
5867              
5868             # shot information for the D700 firmware 1.02f (encrypted) - ref 29
5869             %Image::ExifTool::Nikon::ShotInfoD700 = (
5870             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5871             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5872             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5873             VARS => { ID_LABEL => 'Index' },
5874             IS_SUBDIR => [ 804 ],
5875             WRITABLE => 1,
5876             FIRST_ENTRY => 0,
5877             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5878             NOTES => q{
5879             These tags are extracted from encrypted data in images from the D700 with
5880             firmware 1.02f.
5881             },
5882             0x00 => {
5883             Name => 'ShotInfoVersion',
5884             Format => 'string[4]',
5885             Writable => 0,
5886             },
5887             0x04 => {
5888             Name => 'FirmwareVersion',
5889             Format => 'string[5]',
5890             Writable => 0,
5891             },
5892             613 => { # 0x265
5893             Name => 'ISO2',
5894             ValueConv => '100*exp(($val/12-5)*log(2))',
5895             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5896             PrintConv => 'int($val + 0.5)',
5897             PrintConvInv => '$val',
5898             },
5899             0x287 => {
5900             Name => 'ShutterCount',
5901             Format => 'int32u',
5902             Priority => 0,
5903             },
5904             804 => { # 0x324 (NC)
5905             Name => 'CustomSettingsD700',
5906             Format => 'undef[48]',
5907             SubDirectory => {
5908             TagTable => 'Image::ExifTool::NikonCustom::SettingsD700',
5909             },
5910             },
5911             # note: DecryptLen currently set to 852
5912             );
5913              
5914             # shot information for the D5000 firmware 1.00 (encrypted) - ref PH
5915             %Image::ExifTool::Nikon::ShotInfoD5000 = (
5916             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5917             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5918             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5919             VARS => { ID_LABEL => 'Index' },
5920             IS_SUBDIR => [ 0x378 ],
5921             WRITABLE => 1,
5922             FIRST_ENTRY => 0,
5923             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5924             NOTES => q{
5925             These tags are extracted from encrypted data in images from the D5000 with
5926             firmware 1.00.
5927             },
5928             0x00 => {
5929             Name => 'ShotInfoVersion',
5930             Format => 'string[4]',
5931             Writable => 0,
5932             },
5933             0x04 => {
5934             Name => 'FirmwareVersion',
5935             Format => 'string[5]',
5936             Writable => 0,
5937             },
5938             0x2b5 => { # (also found at 0x2c0)
5939             Name => 'ISO2',
5940             ValueConv => '100*exp(($val/12-5)*log(2))',
5941             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5942             PrintConv => 'int($val + 0.5)',
5943             PrintConvInv => '$val',
5944             },
5945             0x2d6 => {
5946             Name => 'ShutterCount',
5947             Format => 'int32u',
5948             Priority => 0,
5949             },
5950             0x378 => {
5951             Name => 'CustomSettingsD5000',
5952             Format => 'undef[34]',
5953             SubDirectory => {
5954             TagTable => 'Image::ExifTool::NikonCustom::SettingsD5000',
5955             },
5956             },
5957             # note: DecryptLen currently set to 0x39a
5958             );
5959              
5960             # shot information for the D5100 firmware 1.00f (encrypted) - ref PH
5961             %Image::ExifTool::Nikon::ShotInfoD5100 = (
5962             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5963             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5964             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5965             VARS => { ID_LABEL => 'Index' },
5966             IS_SUBDIR => [ 0x407 ],
5967             WRITABLE => 1,
5968             FIRST_ENTRY => 0,
5969             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5970             0x00 => {
5971             Name => 'ShotInfoVersion',
5972             Format => 'string[4]',
5973             Writable => 0,
5974             },
5975             0x04 => {
5976             Name => 'FirmwareVersion',
5977             Format => 'string[5]',
5978             Writable => 0,
5979             },
5980             0x321 => {
5981             Name => 'ShutterCount',
5982             Format => 'int32u',
5983             Priority => 0,
5984             },
5985             0x407 => {
5986             Name => 'CustomSettingsD5100',
5987             Format => 'undef[34]',
5988             SubDirectory => {
5989             TagTable => 'Image::ExifTool::NikonCustom::SettingsD5100',
5990             },
5991             },
5992             # note: DecryptLen currently set to 0x430
5993             );
5994              
5995             # shot information for the D5200 firmware 1.00 (encrypted) - ref PH
5996             %Image::ExifTool::Nikon::ShotInfoD5200 = (
5997             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5998             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
5999             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6000             VARS => { ID_LABEL => 'Index' },
6001             IS_SUBDIR => [ 0xcd5 ],
6002             WRITABLE => 1,
6003             FIRST_ENTRY => 0,
6004             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6005             0x00 => {
6006             Name => 'ShotInfoVersion',
6007             Format => 'string[4]',
6008             Writable => 0,
6009             },
6010             0x04 => {
6011             Name => 'FirmwareVersion',
6012             Format => 'string[5]',
6013             Writable => 0,
6014             },
6015             # 0x101 - 2=VR Off, 3=VR On
6016             # 0x13d - 0=VR On, 1=VR Off
6017             0xbd8 => {
6018             Name => 'ShutterCount',
6019             Format => 'int32u',
6020             Priority => 0,
6021             },
6022             # 0xcd2 - 12=VR Off, 15=VR On
6023             0xcd5 => {
6024             Name => 'CustomSettingsD5200',
6025             Format => 'undef[34]',
6026             SubDirectory => {
6027             TagTable => 'Image::ExifTool::NikonCustom::SettingsD5200',
6028             },
6029             },
6030             # note: DecryptLen currently set to 0xd00
6031             );
6032              
6033             # shot information for the D7000 firmware 1.01d (encrypted) - ref 29
6034             %Image::ExifTool::Nikon::ShotInfoD7000 = (
6035             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6036             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6037             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6038             VARS => { ID_LABEL => 'Index' },
6039             IS_SUBDIR => [ 1028 ],
6040             WRITABLE => 1,
6041             FIRST_ENTRY => 0,
6042             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6043             NOTES => q{
6044             These tags are extracted from encrypted data in images from the D7000 with
6045             firmware 1.01b.
6046             },
6047             0x00 => {
6048             Name => 'ShotInfoVersion',
6049             Format => 'string[4]',
6050             Writable => 0,
6051             },
6052             0x04 => {
6053             Name => 'FirmwareVersion',
6054             Format => 'string[5]',
6055             Writable => 0,
6056             },
6057             #613 => {
6058             # Name => 'ISO2',
6059             # ValueConv => '100*exp(($val/12-5)*log(2))',
6060             # ValueConvInv => '(log($val/100)/log(2)+5)*12',
6061             # PrintConv => 'int($val + 0.5)',
6062             # PrintConvInv => '$val',
6063             #},
6064             0x320 => { # 800
6065             Name => 'ShutterCount',
6066             Format => 'int32u',
6067             Priority => 0,
6068             },
6069             0x404 => { # 1028 (NC)
6070             Name => 'CustomSettingsD7000',
6071             Format => 'undef[48]',
6072             SubDirectory => {
6073             TagTable => 'Image::ExifTool::NikonCustom::SettingsD7000',
6074             },
6075             },
6076             );
6077              
6078             # shot information for the D800 firmware 1.01a (encrypted) - ref PH
6079             %Image::ExifTool::Nikon::ShotInfoD800 = (
6080             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6081             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6082             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6083             VARS => { ID_LABEL => 'Index' },
6084             IS_SUBDIR => [ 0x6ec ],
6085             WRITABLE => 1,
6086             FIRST_ENTRY => 0,
6087             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6088             NOTES => 'These tags are extracted from encrypted data in images from the D800.',
6089             0x00 => {
6090             Name => 'ShotInfoVersion',
6091             Format => 'string[4]',
6092             Writable => 0,
6093             },
6094             0x04 => {
6095             Name => 'FirmwareVersion',
6096             Format => 'string[5]',
6097             Writable => 0,
6098             },
6099             0x4c0 => {
6100             Name => 'RepeatingFlashOutputExternal',
6101             ValueConv => '2 ** (-$val/6)',
6102             ValueConvInv => '$val > 0 ? -6*log($val)/log(2) : 0',
6103             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
6104             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
6105             },
6106             0x4c2 => {
6107             Name => 'RepeatingFlashRateExternal',
6108             DelValue => 0,
6109             RawConv => '$val || undef',
6110             PrintConv => '"$val Hz"',
6111             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
6112             },
6113             0x4c3 => {
6114             Name => 'RepeatingFlashCountExternal',
6115             DelValue => 0,
6116             RawConv => '$val || undef',
6117             },
6118             0x4d2 => {
6119             Name => 'FlashExposureComp2',
6120             Notes => 'includes the effect of flash bracketing',
6121             Format => 'int8s',
6122             ValueConv => '-$val/6',
6123             ValueConvInv => '-6 * $val',
6124             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
6125             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
6126             },
6127             # 0x4d4 - FEC again, doesn't include bracketing this time (internal?)
6128             # (not fully decoded, and duplicated in custom settings)
6129             # 0x4d9 => {
6130             # Name => 'FlashControlBuilt-in',
6131             # PrintConv => {
6132             # 1 => 'TTL',
6133             # 6 => 'Manual',
6134             # 7 => 'Repeating Flash',
6135             # },
6136             # },
6137             0x4da => {
6138             Name => 'RepeatingFlashRateBuilt-in',
6139             DelValue => 0,
6140             RawConv => '$val || undef',
6141             PrintConv => '"$val Hz"',
6142             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
6143             },
6144             0x4db => {
6145             Name => 'RepeatingFlashCountBuilt-in',
6146             DelValue => 0,
6147             RawConv => '$val || undef',
6148             },
6149             # 1294.1 => { # (0x4dc)
6150             # Name => 'FlashModeBuilt-in',
6151             # Mask => 0x0f,
6152             # PrintConv => {
6153             # 0 => 'Front-curtain Sync',
6154             # 1 => 'Red-eye Reduction',
6155             # 2 => 'Redy-eye Reduction with Slow Sync',
6156             # 3 => 'Slow Sync',
6157             # 4 => 'Rear-curtain Sync',
6158             # 5 => 'Rear-curtain Sync 2', # got this in P exposure mode
6159             # },
6160             # },
6161             # 1294.2 => { # (0x4dc)
6162             # Name => 'ExposureMode2',
6163             # Mask => 0xf0,
6164             # PrintConv => {
6165             # 0 => 'Program',
6166             # 1 => 'Aperture Priority',
6167             # 3 => 'Manual',
6168             # },
6169             # },
6170             # 0x511 - related to FlashSyncSpeed
6171             0x51c => 'SequenceNumber',
6172             # 0x4ba+0x63 - interesting
6173             # 0x4ba+0x68 - general downward trend
6174             # 0x4ba+0x7b - FlashControlBuilt-in: 8=TTL, 72=Manual
6175             # (not reliable)
6176             # 1346.1 => { # (0x542)
6177             # Name => 'RepeatingFlashOutputBuilt-in',
6178             # DelValue => 112,
6179             # Mask => 0xfc,
6180             # RawConv => '$val == 0x1c ? undef : 2 ** ($val/3-7)',
6181             # ValueConvInv => '$val > 0 ? (log($val)/log(2)+7)*3 : 0',
6182             # PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
6183             # PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
6184             # },
6185             0x5fb => {
6186             Name => 'ShutterCount',
6187             Format => 'int32u',
6188             },
6189             0x6ec => {
6190             Name => 'CustomSettingsD800',
6191             Format => 'undef[48]',
6192             SubDirectory => {
6193             TagTable => 'Image::ExifTool::NikonCustom::SettingsD800',
6194             },
6195             },
6196             # note: DecryptLen currently set to 0x720
6197             );
6198              
6199             # shot information for the D5 firmware 1.10a and D500 firmware 1.01 (encrypted) - ref 28
6200             %Image::ExifTool::Nikon::ShotInfoD500 = (
6201             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6202             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6203             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6204             VARS => { ID_LABEL => 'Index' },
6205             DATAMEMBER => [ 0x04, 0x10, 0x14, 0x2c, 0x50, 0x58, 0xa0, 0xa8, 0xb0,
6206             0x07b0, 0x086c, 0x0e7c, 0x0eea, 0x2c23, 0x2c8f ],
6207             IS_SUBDIR => [ 0x0eeb ],
6208             WRITABLE => 1,
6209             FIRST_ENTRY => 0,
6210             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6211             NOTES => 'These tags are extracted from encrypted data in images from the D5 and D500.',
6212             0x00 => {
6213             Name => 'ShotInfoVersion',
6214             Format => 'string[4]',
6215             Writable => 0,
6216             },
6217             0x04 => {
6218             Name => 'FirmwareVersion',
6219             DataMember => 'FirmwareVersion',
6220             Format => 'string[5]',
6221             Writable => 0,
6222             RawConv => '$$self{FirmwareVersion} = $val',
6223             },
6224             0x10 => {
6225             Name => 'RotationInfoOffset',
6226             DataMember => 'RotationInfoOffset',
6227             Format => 'int32u',
6228             Writable => 0,
6229             Hidden => 1,
6230             RawConv => '$$self{RotationInfoOffset} = $val || 0x10000000; undef', # (ignore if 0)
6231             },
6232             0x14 => {
6233             Name => 'JPGInfoOffset',
6234             DataMember => 'JPGInfoOffset',
6235             Format => 'int32u',
6236             Writable => 0,
6237             Hidden => 1,
6238             RawConv => '$$self{JPGInfoOffset} = $val || 0x10000000; undef', # (ignore if 0)
6239             },
6240             0x2c => {
6241             Name => 'BracketingInfoOffset',
6242             DataMember => 'BracketingInfoOffset',
6243             Format => 'int32u',
6244             Writable => 0,
6245             Hidden => 1,
6246             RawConv => '$$self{BracketingInfoOffset} = $val || 0x10000000; undef', # (ignore if 0)
6247             },
6248             0x50 => {
6249             Name => 'ShootingMenuOffset',
6250             DataMember => 'ShootingMenuOffset',
6251             Format => 'int32u',
6252             Writable => 0,
6253             Hidden => 1,
6254             RawConv => '$$self{ShootingMenuOffset} = $val || 0x10000000; undef', # (ignore if 0)
6255             },
6256             0x58 => {
6257             Name => 'CustomSettingsOffset',
6258             DataMember => 'CustomSettingsOffset',
6259             Format => 'int32u',
6260             Writable => 0,
6261             Hidden => 1,
6262             RawConv => '$$self{CustomSettingsOffset} = $val || 0x10000000; undef', # (ignore if 0)
6263             },
6264             0xa0 => {
6265             Name => 'OrientationOffset',
6266             DataMember => 'OrientationOffset',
6267             Format => 'int32u',
6268             Writable => 0,
6269             Hidden => 1,
6270             RawConv => '$$self{OrientationOffset} = $val || 0x10000000; undef', # (ignore if 0)
6271             },
6272             0xa8 => {
6273             Name => 'OtherOffset',
6274             DataMember => 'OtherOffset',
6275             Format => 'int32u',
6276             Writable => 0,
6277             Hidden => 1,
6278             RawConv => '$$self{OtherOffset} = $val || 0x10000000; undef', # (ignore if 0)
6279             },
6280             #
6281             # Tag ID's below are the offsets for a D500 JPEG image, but these offsets change
6282             # for various image types according to the offset table above
6283             #
6284             ### 0xb0 - RotationInfo start
6285             0xb0 => {
6286             Name => 'Hook1',
6287             Hidden => 1,
6288             RawConv => 'undef',
6289             # account for variable location of Rotation data
6290             Hook => '$varSize = $$self{RotationInfoOffset} - 0xb0',
6291             },
6292             0xca => {
6293             Name => 'Rotation',
6294             Mask => 0x03,
6295             PrintConv => {
6296             0 => 'Horizontal',
6297             1 => 'Rotate 270 CW',
6298             2 => 'Rotate 90 CW',
6299             3 => 'Rotate 180',
6300             },
6301             },
6302             0x0d0 => {
6303             Name => 'Interval',
6304             # prior version of the d% firmware do not support this tag, nor does the D500 (at least thru firmware 1.3)
6305             Condition => '$$self{Model} eq "NIKON D5" and $$self{FirmwareVersion} ge "1.40"',
6306             PrintConv => '$val > 0 ? sprintf("%.0f", $val) : ""',
6307             },
6308             0x0d4 => {
6309             Name => 'IntervalFrame',
6310             # prior version of the d% firmware do not support this tag, nor does the D500 (at least thru firmware 1.3)
6311             Condition => '$$self{Model} eq "NIKON D5" and $$self{FirmwareVersion} ge "1.40"',
6312             PrintConv => '$val > 0 ? sprintf("%.0f", $val) : ""',
6313             },
6314             0x05e2 => {
6315             Name => 'FlickerReductionIndicator',
6316             Mask => 0x01,
6317             PrintConv => { 0 => 'On', 1 => 'Off' },
6318             },
6319             ### 0x07b0 - JPEGInfo start
6320             0x07b0 => {
6321             Name => 'Hook2',
6322             Hidden => 1,
6323             RawConv => 'undef',
6324             # account for variable location of Shooting Menu data
6325             Hook => '$varSize = $$self{JPGInfoOffset} - 0x07b0',
6326             },
6327             0x07d4 => {
6328             Name => 'JPGCompression',
6329             Mask => 0x01,
6330             PrintConv => {
6331             0 => 'Size Priority',
6332             1 => 'Optimal Quality',
6333             },
6334             },
6335             ### 0x0830 - ? start
6336             ### 0x086c - BracketingInfo start
6337             0x086c => {
6338             Name => 'Hook3',
6339             Hidden => 1,
6340             RawConv => 'undef',
6341             # account for variable location of Shooting Menu data
6342             Hook => '$varSize = $$self{BracketingInfoOffset} - 0x086c',
6343             },
6344             0x087b => {
6345             Name => 'AEBracketingSteps',
6346             Condition => '$$self{FILE_TYPE} ne "TIFF"', # (covers NEF and TIFF)
6347             Mask => 0xff,
6348             PrintHex => 1,
6349             PrintConvColumns => 2,
6350             PrintConv => {
6351             0x00 => 'AE Bracketing Disabled',
6352             0x20 => 'AE Bracketing Disabled',
6353             0x30 => 'AE Bracketing Disabled',
6354             0x40 => 'AE Bracketing Disabled',
6355             0x50 => 'AE Bracketing Disabled',
6356             0x81 => '+3F0.3',
6357             0x82 => '-3F0.3',
6358             0x83 => '+2F0.3',
6359             0x84 => '-2F0.3',
6360             0x85 => '3F0.3',
6361             0x86 => '5F0.3',
6362             0x87 => '7F0.3',
6363             0x88 => '9F0.3',
6364             0x91 => '+3F0.5',
6365             0x92 => '-3F0.5',
6366             0x93 => '+2F0.5',
6367             0x94 => '-2F0.5',
6368             0x95 => '3F0.5',
6369             0x96 => '5F0.5',
6370             0x97 => '7F0.5',
6371             0x98 => '9F0.5',
6372             0xa1 => '+3F0.7',
6373             0xa2 => '-3F0.7',
6374             0xa3 => '+2F0.7',
6375             0xa4 => '-2F0.7',
6376             0xa5 => '3F0.7',
6377             0xa6 => '5F0.7',
6378             0xa7 => '7F0.7',
6379             0xa8 => '9F0.7',
6380             0xb1 => '+3F1',
6381             0xb2 => '-3F1',
6382             0xb3 => '+2F1',
6383             0xb4 => '-2F1',
6384             0xb5 => '3F1',
6385             0xb6 => '5F1',
6386             0xb7 => '7F1',
6387             0xb8 => '9F1',
6388             0xc1 => '+3F2',
6389             0xc2 => '-3F2',
6390             0xc3 => '+2F2',
6391             0xc4 => '-2F2',
6392             0xc5 => '3F2',
6393             0xc6 => '5F2',
6394             0xd1 => '+3F3',
6395             0xd2 => '-3F3',
6396             0xd3 => '+2F3',
6397             0xd4 => '-2F3',
6398             0xd5 => '3F3',
6399             0xd6 => '5F3',
6400             },
6401             },
6402             0x087c => {
6403             Name => 'WBBracketingSteps',
6404             Condition => '$$self{FILE_TYPE} ne "TIFF"', # (covers NEF and TIFF)
6405             Mask => 0xff,
6406             PrintHex => 1,
6407             PrintConvColumns => 2,
6408             PrintConv => {
6409             0x00 => 'WB Bracketing Disabled',
6410             0x01 => 'b3F 1',
6411             0x02 => 'A3F 1',
6412             0x03 => 'b2F 1',
6413             0x04 => 'A2F 1',
6414             0x05 => '3F 1',
6415             0x06 => '5F 1',
6416             0x07 => '7F 1',
6417             0x08 => '9F 1',
6418             0x10 => '0F 2',
6419             0x11 => 'b3F 2',
6420             0x12 => 'A3F 2',
6421             0x13 => 'b2F 2',
6422             0x14 => 'A2F 2',
6423             0x15 => '3F 2',
6424             0x16 => '5F 2',
6425             0x17 => '7F 2',
6426             0x18 => '9F 2',
6427             0x20 => '0F 3',
6428             0x21 => 'b3F 3',
6429             0x22 => 'A3F 3',
6430             0x23 => 'b2F 3',
6431             0x24 => 'A2F 3',
6432             0x25 => '3F 3',
6433             0x26 => '5F 3',
6434             0x27 => '7F 3',
6435             0x28 => '9F 3',
6436             0x22 => 'A3F 3',
6437             0x23 => 'b2F 3',
6438             0x24 => 'A2F 3',
6439             0x25 => '3F 3',
6440             0x26 => '5F 3',
6441             0x27 => '7F 3',
6442             0x28 => '9F 3',
6443             },
6444             },
6445             0x0883 => {
6446             Name => 'ADLBracketingStep',
6447             Mask => 0xf0,
6448             PrintConv => {
6449             0 => 'Off',
6450             1 => 'Low',
6451             2 => 'Normal',
6452             3 => 'High',
6453             4 => 'Extra High',
6454             8 => 'Auto',
6455             },
6456             },
6457             0x0884 => {
6458             Name => 'ADLBracketingType',
6459             Mask => 0x0f,
6460             PrintConv => {
6461             0 => 'Off',
6462             1 => '2 Shots',
6463             2 => '3 Shots',
6464             3 => '4 Shots',
6465             4 => '5 Shots',
6466             },
6467             },
6468             ### 0x0887 - ? start
6469             ### 0x089f - ? start
6470             ### 0x0929 - ? start
6471             ### 0x09c9 - ? start
6472             ### 0x0ac5 - ? start
6473             ### 0x0bc1 - ? start
6474             ### 0x0cbd - ? start
6475             ### 0x0d98 - ? start
6476             ### 0x0e7d - ShootingMenuOffset start
6477             0x0e7c => {
6478             Name => 'Hook4',
6479             Hidden => 1,
6480             RawConv => 'undef',
6481             # account for variable location of Shooting Menu data
6482             Hook => '$varSize = $$self{ShootingMenuOffset} - 0x0e7d',
6483             },
6484             0x0e7d => {
6485             Name => 'PhotoShootingMenuBank',
6486             Mask => 0x03,
6487             PrintConv => {
6488             0 => 'A',
6489             1 => 'B',
6490             2 => 'C',
6491             3 => 'D',
6492             },
6493             },
6494             0x0e7f => {
6495             Name => 'PrimarySlot',
6496             Condition => '$$self{Model} =~ /\bD500\b/',
6497             Notes => 'D500 only',
6498             Mask => 0x80,
6499             PrintConv => {
6500             0 => 'XQD Card',
6501             1 => 'SD Card',
6502             },
6503             },
6504             0x0e81 => {
6505             Name => 'ISOAutoShutterTime',
6506             Mask => 0x3f,
6507             PrintConv => {
6508             0 => '1/4000 s',
6509             1 => '1/3200 s',
6510             2 => '1/2500 s',
6511             3 => '1/2000 s',
6512             4 => '1/1600 s',
6513             5 => '1/1250 s',
6514             6 => '1/1000 s',
6515             7 => '1/800 s',
6516             8 => '1/640 s',
6517             9 => '1/500 s',
6518             10 => '1/400 s',
6519             11 => '1/320 s',
6520             12 => '1/250 s',
6521             13 => '1/200 s',
6522             14 => '1/160 s',
6523             15 => '1/125 s',
6524             16 => '1/100 s',
6525             17 => '1/80 s',
6526             18 => '1/60 s',
6527             19 => '1/50 s',
6528             20 => '1/40 s',
6529             21 => '1/30 s',
6530             22 => '1/15 s',
6531             23 => '1/8 s',
6532             24 => '1/4 s',
6533             25 => '1/2 s',
6534             26 => '1 s',
6535             27 => '2 s',
6536             28 => '4 s',
6537             29 => '8 s',
6538             30 => '15 s',
6539             31 => '30 s',
6540             32 => 'Auto (Slowest)',
6541             33 => 'Auto (Slower)',
6542             34 => 'Auto',
6543             35 => 'Auto (Faster)',
6544             36 => 'Auto (Fastest)',
6545             },
6546             },
6547             0x0e82 => {
6548             Name => 'ISOAutoHiLimit',
6549             Mask => 0xff,
6550             PrintHex => 1,
6551             PrintConv => {
6552             0x24 => 'ISO 200',
6553             0x26 => 'ISO 250',
6554             0x27 => 'ISO 280',
6555             0x28 => 'ISO 320',
6556             0x2a => 'ISO 400',
6557             0x2c => 'ISO 500',
6558             0x2d => 'ISO 560',
6559             0x2e => 'ISO 640',
6560             0x30 => 'ISO 800',
6561             0x32 => 'ISO 1000',
6562             0x33 => 'ISO 1100',
6563             0x34 => 'ISO 1250',
6564             0x36 => 'ISO 1600',
6565             0x38 => 'ISO 2000',
6566             0x39 => 'ISO 2200',
6567             0x3a => 'ISO 2500',
6568             0x3c => 'ISO 3200',
6569             0x3e => 'ISO 4000',
6570             0x3f => 'ISO 4500',
6571             0x40 => 'ISO 5000',
6572             0x42 => 'ISO 6400',
6573             0x44 => 'ISO 8000',
6574             0x45 => 'ISO 9000',
6575             0x46 => 'ISO 10000',
6576             0x48 => 'ISO 12800',
6577             0x4a => 'ISO 16000',
6578             0x4b => 'ISO 18000',
6579             0x4c => 'ISO 20000',
6580             0x4e => 'ISO 25600',
6581             0x50 => 'ISO 32000',
6582             0x51 => 'ISO 36000',
6583             0x52 => 'ISO 40000',
6584             0x54 => 'ISO 51200',
6585             0x56 => 'ISO Hi 0.3',
6586             0x57 => 'ISO Hi 0.5',
6587             0x58 => 'ISO Hi 0.7',
6588             0x5a => 'ISO Hi 1.0',
6589             0x60 => 'ISO Hi 2.0',
6590             0x66 => 'ISO Hi 3.0',
6591             0x6c => 'ISO Hi 4.0',
6592             0x72 => 'ISO Hi 5.0',
6593             },
6594             },
6595             0x0e84 => {
6596             Name => 'FlickerReduction',
6597             Mask => 0x20,
6598             PrintConv => {
6599             0 => 'Enable',
6600             1 => 'Disable',
6601             },
6602             },
6603             3716.1 => { # (0x0e84)
6604             Name => 'PhotoShootingMenuBankImageArea',
6605             Mask => 0x07,
6606             PrintConv => {
6607             0 => 'FX (36x24)',
6608             1 => 'DX (24x16)',
6609             2 => '5:4 (30x24)',
6610             3 => '1.2x (30x20)',
6611             4 => '1.3x (18x12)',
6612             },
6613             },
6614             ### 0x0ec4 - ? start
6615             ### 0x0eeb - CustomSettings start
6616             0x0eea => {
6617             Name => 'Hook5',
6618             Hidden => 1,
6619             RawConv => 'undef',
6620             # account for variable location of CustomSettings data
6621             Hook => '$varSize = $$self{CustomSettingsOffset} - 0x0eeb',
6622             },
6623             0x0eeb => [{
6624             Name => 'CustomSettingsD5',
6625             Condition => '$$self{Model} =~ /\bD5\b/',
6626             Format => 'undef[90]',
6627             SubDirectory => {
6628             TagTable => 'Image::ExifTool::NikonCustom::SettingsD5',
6629             },
6630             },{
6631             Name => 'CustomSettingsD500',
6632             Format => 'undef[90]',
6633             SubDirectory => {
6634             TagTable => 'Image::ExifTool::NikonCustom::SettingsD500',
6635             },
6636             }],
6637             # 0x0f68 => { #this decode works, but involves more bits than should be necessary
6638             # Name => 'ShutterTrigger',
6639             # Mask => 0xff,
6640             # PrintConv => {
6641             # 0 => 'Timer',
6642             # 15 => 'Cable Release/Remote',
6643             # 195 => 'Shutter Button',
6644             # },
6645             # },
6646             ### 0x2c24 - OrientationInfo start (D5 firmware 1.10b)
6647             0x2c23 => {
6648             Name => 'Hook6',
6649             Hidden => 1,
6650             RawConv => 'undef',
6651             # account for variable location of OrientationInfo data
6652             Hook => '$varSize = $$self{OrientationOffset} - 0x2c24',
6653             },
6654             0x2c24 => {
6655             Name => 'RollAngle',
6656             Format => 'fixed32u',
6657             Notes => 'converted to degrees of clockwise camera roll',
6658             ValueConv => '$val <= 180 ? $val : $val - 360',
6659             ValueConvInv => '$val >= 0 ? $val : $val + 360',
6660             PrintConv => 'sprintf("%.1f", $val)',
6661             PrintConvInv => '$val',
6662             },
6663             0x2c28 => {
6664             Name => 'PitchAngle',
6665             Format => 'fixed32u',
6666             Notes => 'converted to degrees of upward camera tilt',
6667             ValueConv => '$val <= 180 ? $val : $val - 360',
6668             ValueConvInv => '$val >= 0 ? $val : $val + 360',
6669             PrintConv => 'sprintf("%.1f", $val)',
6670             PrintConvInv => '$val',
6671             },
6672             0x2c2c => {
6673             Name => 'YawAngle',
6674             Format => 'fixed32u',
6675             Notes => 'the camera yaw angle when shooting in portrait orientation',
6676             ValueConv => '$val <= 180 ? $val : $val - 360',
6677             ValueConvInv => '$val >= 0 ? $val : $val + 360',
6678             PrintConv => 'sprintf("%.1f", $val)',
6679             PrintConvInv => '$val',
6680             },
6681             ### 0x2c90 - OtherInfo start (D500 firmware 1.20d)
6682             0x2c8f => {
6683             Name => 'Hook7',
6684             Hidden => 1,
6685             RawConv => 'undef',
6686             # account for variable location of OtherInfo data
6687             Hook => '$varSize = $$self{OtherOffset} - 0x2c90',
6688             },
6689             # (needs testing)
6690             #0x2cb2 => {
6691             # Name => 'ExtendedPhotoShootingBanks',
6692             # Mask => 0x01,
6693             # PrintConv => {
6694             # 0 => 'On',
6695             # 1 => 'Off',
6696             # },
6697             #},
6698             # (may not be reliable and is found elsewhere)
6699             #0x2ea2 => {
6700             # Name => 'Rotation',
6701             # Condition => '$$self{Model} =~ /\bD500\b/',
6702             # Notes => 'D500 firmware 1.1x',
6703             # Mask => 0x30,
6704             # PrintConv => {
6705             # 0 => 'Horizontal',
6706             # 1 => 'Rotate 270 CW',
6707             # 2 => 'Rotate 90 CW',
6708             # 3 => 'Rotate 180',
6709             # },
6710             #},
6711             0x2ea4 => { #PH
6712             Name => 'NikonMeteringMode',
6713             Condition => '$$self{Model} =~ /\bD500\b/', # (didn't seem to work for D5, but I need more samples)
6714             Notes => 'D500 only',
6715             Mask => 0x03,
6716             PrintConv => {
6717             0 => 'Matrix',
6718             1 => 'Center',
6719             2 => 'Spot',
6720             3 => 'Highlight'
6721             },
6722             },
6723             # note: DecryptLen currently set to OtherOffset + 0x2ea5 - 0x2c90
6724             );
6725              
6726             # shot information for the D6 firmware 1.00 (encrypted) - ref 28
6727             %Image::ExifTool::Nikon::ShotInfoD6 = (
6728             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6729             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6730             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6731             VARS => { ID_LABEL => 'Index' },
6732             DATAMEMBER => [ 0x30, 0x60, 0x9c, 0xa4, 0x75e7, 0x760c, 0x7610, 0xc219, 0xc292, 0xc40e, 0xc412, 0xc4a6, 0xc4be ],
6733             WRITABLE => 1,
6734             FIRST_ENTRY => 0,
6735             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6736             NOTES => 'These tags are extracted from encrypted data in images from the D6.',
6737             0x00 => {
6738             Name => 'ShotInfoVersion',
6739             Format => 'string[4]',
6740             Writable => 0,
6741             },
6742             0x04 => {
6743             Name => 'FirmwareVersion',
6744             Format => 'string[8]',
6745             Writable => 0,
6746             },
6747             0x24 => {
6748             Name => 'NumberOffsets', # (number of entries in offset table. offsets are from start of ShotInfo data)
6749             DataMember => 'NumberOffsets',
6750             Format => 'int32u',
6751             Writable => 0,
6752             Hidden => 1,
6753             },
6754             0x30 => {
6755             Name => 'Offset3',
6756             DataMember => 'Offset3',
6757             Format => 'int32u',
6758             Writable => 0,
6759             Hidden => 1,
6760             RawConv => '$$self{Offset3} = $val || 0x10000000; undef', # (ignore if 0)
6761             },
6762             0x60 => {
6763             Name => 'Offset15',
6764             DataMember => 'Offset15',
6765             Format => 'int32u',
6766             Writable => 0,
6767             Hidden => 1,
6768             RawConv => '$$self{Offset15} = $val || 0x10000000; undef', # (ignore if 0)
6769             },
6770             0x9c => {
6771             Name => 'OrientationOffset',
6772             DataMember => 'OrientationOffset',
6773             Format => 'int32u',
6774             Writable => 0,
6775             Hidden => 1,
6776             RawConv => '$$self{OrientationOffset} = $val || 0x10000000; undef', # (ignore if 0)
6777             },
6778             0xa4 => {
6779             Name => 'Offset32',
6780             DataMember => 'Offset32',
6781             Format => 'int32u',
6782             Writable => 0,
6783             Hidden => 1,
6784             RawConv => '$$self{Offset32} = $val || 0x10000000; undef', # (ignore if 0)
6785             },
6786             ### 0x75e8 - Offset3 info start (D6 firmware 1.33)
6787             0x75e7 => {
6788             Name => 'Hook1',
6789             Hidden => 1,
6790             RawConv => 'undef',
6791             # account for variable location of Offset5 data
6792             Hook => '$varSize = $$self{Offset3} - 0x75e8',
6793             },
6794             0x760c => {
6795             Name => 'IntervalShooting',
6796             RawConv => '$$self{IntervalShooting} = $val',
6797             Format => 'int16u',
6798             PrintConv => q{
6799             return 'Off' if $val == 0 ;
6800             my $i = sprintf("Interval %.0f of %.0f",$val, $$self{IntervalShootingIntervals}); #something like "Interval 1 of 3"
6801             my $f = $$self{IntervalShootingShotsPerInterval} > 1 ? sprintf(" Frame %.0f of %.0f",$$self{IntervalFrame}, $$self{IntervalShootingShotsPerInterval}): '' ; #something like "Frame 1 of 3" or blank
6802             return "On: $i$f"
6803             #$val == 0 ? 'Off' : sprintf("On: Interval %.0f of %.0f Frame %.0f of %.0f",$val, $$self{IntervalShootingIntervals}, $$self{IntervalFrame}, $$self{IntervalShootingShotsPerInterval}),
6804             },
6805             },
6806             0x7610 => {
6807             Name => 'IntervalFrame',
6808             RawConv => '$$self{IntervalFrame} = $val',
6809             Condition => '$$self{IntervalShooting} > 0',
6810             Format => 'int16u',
6811             Hidden => 1,
6812             },
6813             ### 0xc21a - OrientationInfo start (D6 firmware 1.00) (0xc952 for firmware 1.33)
6814             0xc219 => {
6815             Name => 'Hook2',
6816             Hidden => 1,
6817             RawConv => 'undef',
6818             # account for variable location of OrientationInfo data
6819             Hook => '$varSize = $$self{OrientationOffset} - 0xc21a',
6820             },
6821             0xc21a => {
6822             Name => 'RollAngle',
6823             Format => 'fixed32u',
6824             Notes => 'converted to degrees of clockwise camera roll',
6825             ValueConv => '$val <= 180 ? $val : $val - 360',
6826             ValueConvInv => '$val >= 0 ? $val : $val + 360',
6827             PrintConv => 'sprintf("%.1f", $val)',
6828             PrintConvInv => '$val',
6829             },
6830             0xc21e => {
6831             Name => 'PitchAngle',
6832             Format => 'fixed32u',
6833             Notes => 'converted to degrees of upward camera tilt',
6834             ValueConv => '$val <= 180 ? $val : $val - 360',
6835             ValueConvInv => '$val >= 0 ? $val : $val + 360',
6836             PrintConv => 'sprintf("%.1f", $val)',
6837             PrintConvInv => '$val',
6838             },
6839             0xc222 => {
6840             Name => 'YawAngle',
6841             Format => 'fixed32u',
6842             Notes => 'the camera yaw angle when shooting in portrait orientation',
6843             ValueConv => '$val <= 180 ? $val : $val - 360',
6844             ValueConvInv => '$val >= 0 ? $val : $val + 360',
6845             PrintConv => 'sprintf("%.1f", $val)',
6846             PrintConvInv => '$val',
6847             },
6848             ### 0xc9c6 - Offset32 start (D6 firmware 1.33)
6849             0xc292 => {
6850             Name => 'Hook3',
6851             Hidden => 1,
6852             RawConv => 'undef',
6853             # account for variable location of data
6854             Hook => '$varSize = $$self{Offset32} - 0xc292',
6855             },
6856             0xc40e => {
6857             Name => 'Intervals',
6858             Format => 'int32u',
6859             RawConv => '$$self{IntervalShootingIntervals} = $val',
6860             Condition => '$$self{IntervalShooting} > 0',
6861             },
6862             0xc412 => {
6863             Name => 'ShotsPerInterval',
6864             Format => 'int32u',
6865             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
6866             Condition => '$$self{IntervalShooting} > 0',
6867             },
6868             0xc416 => {
6869             Name => 'IntervalExposureSmoothing',
6870             Condition => '$$self{IntervalShooting} > 0',
6871             Format => 'int8u',
6872             PrintConv => \%offOn,
6873             },
6874             0xc418 => {
6875             Name => 'IntervalPriority',
6876             Condition => '$$self{IntervalShooting} > 0',
6877             Format => 'int8u',
6878             PrintConv => \%offOn,
6879             },
6880             0xc43a => {
6881             Name => 'FocusShiftNumberShots',
6882             },
6883             0xc43e => {
6884             Name => 'FocusShiftStepWidth',
6885             },
6886             0xc442 => {
6887             Name => 'FocusShiftInterval',
6888             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
6889             },
6890             0xc446 => {
6891             Name => 'FocusShiftExposureLock',
6892             PrintConv => \%offOn,
6893             },
6894             #0xc49c => HighISONoiseReduction
6895             0xc4a0 => {
6896             Name => 'DiffractionCompensation',
6897             Format => 'int8u',
6898             PrintConv => \%offOn,
6899             },
6900             #0xc4a1 => {Name => 'FlickerReductionShooting',}, #redundant with tag in NikonSettings
6901             0xc4a6 => {
6902             Name => 'FlashControlMode', #this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
6903             RawConv => '$$self{FlashControlMode} = $val',
6904             PrintConv => {
6905             0 => 'TTL',
6906             1 => 'Auto External Flash',
6907             2 => 'GN (distance priority)',
6908             3 => 'Manual',
6909             4 => 'Repeating Flash',
6910             },
6911             },
6912             0xc4ac => {
6913             Name => 'FlashGNDistance',
6914             Condition => '$$self{FlashControlMode} == 2',
6915             Unknown => 1,
6916             ValueConv => '$val + 3',
6917             PrintConv => \%flashGNDistance,
6918             },
6919             0xc4b0 => {
6920             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)
6921             Condition => '$$self{FlashControlMode} >= 3',
6922             Unknown => 1,
6923             ValueConv => '2 ** (-$val/3)',
6924             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
6925             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
6926             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
6927             },
6928             0xc4ba => {
6929             Name => 'FlashRemoteControl',
6930             Unknown => 1,
6931             PrintConv => {
6932             0 => 'Group',
6933             1 => 'Quick Wireless',
6934             2 => 'Remote Repeating',
6935             },
6936             },
6937             0xc4be => {
6938             Name => 'FlashMasterControlMode', #tag name chosen for compatibility with those found in FlashInfo0102 & FlashInfo0103
6939             RawConv => '$$self{FlashGroupOptionsMasterMode} = $val',
6940             PrintConv => \%flashGroupOptionsMode,
6941             },
6942             0xc4c0 => {
6943             Name => 'FlashMasterCompensation',
6944             Unknown => 1,
6945             Format => 'int8s',
6946             Condition => '$$self{FlashGroupOptionsMasterMode} != 3', #other than 'Off'
6947             ValueConv => '$val/6',
6948             ValueConvInv => '6 * $val',
6949             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
6950             PrintConvInv => '$val',
6951             },
6952             0xc4c4 => {
6953             Name => 'FlashMasterOutput',
6954             Unknown => 1,
6955             Condition => '$$self{FlashGroupOptionsMasterMode} == 1', #only for Mode=M
6956             ValueConv => '2 ** (-$val/3)',
6957             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
6958             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
6959             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
6960             },
6961             0xc4c6 => {
6962             Name => 'FlashWirelessOption',
6963             Unknown => 1,
6964             PrintConv => {
6965             0 => 'Optical AWL',
6966             1 => 'Off',
6967             },
6968             },
6969             0xc55c => {
6970             Name => 'MovieType',
6971             Unknown => 1,
6972             PrintConv => {
6973             0 => 'MOV',
6974             1 => 'MP4',
6975             },
6976             },
6977             # note: DecryptLen currently set to 0xc9c6 + 720
6978             );
6979              
6980             # shot information for the D610 firmware 1.00 (encrypted) - ref PH
6981             %Image::ExifTool::Nikon::ShotInfoD610 = (
6982             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6983             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
6984             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6985             VARS => { ID_LABEL => 'Index' },
6986             IS_SUBDIR => [ 0x07cf ],
6987             WRITABLE => 1,
6988             FIRST_ENTRY => 0,
6989             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6990             NOTES => 'These tags are extracted from encrypted data in images from the D610.',
6991             0x00 => {
6992             Name => 'ShotInfoVersion',
6993             Format => 'string[4]',
6994             Writable => 0,
6995             },
6996             0x04 => {
6997             Name => 'FirmwareVersion',
6998             Format => 'string[5]',
6999             Writable => 0,
7000             },
7001             0x07cf => {
7002             Name => 'CustomSettingsD610',
7003             Format => 'undef[48]',
7004             SubDirectory => {
7005             TagTable => 'Image::ExifTool::NikonCustom::SettingsD610',
7006             },
7007             },
7008             # note: DecryptLen currently set to 0x7ff
7009             );
7010              
7011             # shot information for the D810 firmware 1.00(PH)/1.01 (encrypted) - ref 28
7012             %Image::ExifTool::Nikon::ShotInfoD810 = (
7013             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7014             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7015             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7016             VARS => { ID_LABEL => 'Index' },
7017             DATAMEMBER => [ 0x04, 0x24, 0x38, 0x40, 0x84, 0x01d0, 0x175e, 0x185d, 0x18ab ],
7018             IS_SUBDIR => [ 0x18ab ],
7019             WRITABLE => 1,
7020             FIRST_ENTRY => 0,
7021             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7022             NOTES => q{
7023             These tags are extracted from encrypted data in images from the D810. Note
7024             that the indices listed below are for firmware version 1.0, but they may be
7025             different for other firmware versions.
7026             },
7027             0x00 => {
7028             Name => 'ShotInfoVersion',
7029             Format => 'string[4]',
7030             Writable => 0,
7031             },
7032             0x04 => {
7033             Name => 'FirmwareVersion',
7034             DataMember => 'FirmwareVersion',
7035             Format => 'string[5]',
7036             Writable => 0,
7037             RawConv => '$$self{FirmwareVersion} = $val',
7038             },
7039             # 0x0c - number of entries in offset table (= 0x21)
7040             # 0x10 - int32u[val 0x0c]: offset table
7041             0x24 => {
7042             Name => 'BracketingOffset',
7043             DataMember => 'BracketingOffset',
7044             Format => 'int32u',
7045             Writable => 0,
7046             Hidden => 1,
7047             RawConv => '$$self{BracketingOffset} = $val || 0x10000000; undef',
7048             },
7049             0x38 => {
7050             Name => 'ISOAutoOffset',
7051             DataMember => 'ISOAutoOffset',
7052             Format => 'int32u',
7053             Writable => 0,
7054             Hidden => 1,
7055             RawConv => '$$self{ISOAutoOffset} = $val || 0x10000000; undef',
7056             },
7057             0x40 => {
7058             Name => 'CustomSettingsOffset', # (relative offset from start of ShotInfo data)
7059             DataMember => 'CustomSettingsOffset',
7060             Format => 'int32u',
7061             Writable => 0,
7062             Hidden => 1,
7063             RawConv => '$$self{CustomSettingsOffset} = $val || 0x10000000; undef',
7064             },
7065             0x84 => {
7066             Name => 'OrientationOffset',
7067             DataMember => 'OrientationOffset',
7068             Format => 'int32u',
7069             Writable => 0,
7070             Hidden => 1,
7071             RawConv => '$$self{OrientationOffset} = $val || 0x10000000; undef',
7072             },
7073             0x01d0 => {
7074             Name => 'SecondarySlotFunction',
7075             Mask => 0x03,
7076             PrintConv => {
7077             0 => 'Overflow',
7078             2 => 'Backup',
7079             3 => 'NEF Primary + JPG Secondary',
7080             },
7081             Hook => '$varSize = $$self{BracketingOffset} - 0x1747',
7082             },
7083             0x1756 => {
7084             Name => 'AEBracketingSteps',
7085             Mask => 0xff,
7086             PrintHex => 1,
7087             PrintConvColumns => 2,
7088             PrintConv => {
7089             0x00 => 'AE Bracketing Disabled',
7090             0x20 => 'AE Bracketing Disabled',
7091             0x30 => 'AE Bracketing Disabled',
7092             0x40 => 'AE Bracketing Disabled',
7093             0x50 => 'AE Bracketing Disabled',
7094             0x81 => '+3F0.3',
7095             0x82 => '-3F0.3',
7096             0x83 => '+2F0.3',
7097             0x84 => '-2F0.3',
7098             0x85 => '3F0.3',
7099             0x86 => '5F0.3',
7100             0x87 => '7F0.3',
7101             0x88 => '9F0.3',
7102             0x91 => '+3F0.5',
7103             0x92 => '-3F0.5',
7104             0x93 => '+2F0.5',
7105             0x94 => '-2F0.5',
7106             0x95 => '3F0.5',
7107             0x96 => '5F0.5',
7108             0x97 => '7F0.5',
7109             0x98 => '9F0.5',
7110             0xa1 => '+3F0.7',
7111             0xa2 => '-3F0.7',
7112             0xa3 => '+2F0.7',
7113             0xa4 => '-2F0.7',
7114             0xa5 => '3F0.7',
7115             0xa6 => '5F0.7',
7116             0xa7 => '7F0.7',
7117             0xa8 => '9F0.7',
7118             0xb1 => '+3F1',
7119             0xb2 => '-3F1',
7120             0xb3 => '+2F1',
7121             0xb4 => '-2F1',
7122             0xb5 => '3F1',
7123             0xb6 => '5F1',
7124             0xb7 => '7F1',
7125             0xb8 => '9F1',
7126             0xc1 => '+3F2',
7127             0xc2 => '-3F2',
7128             0xc3 => '+2F2',
7129             0xc4 => '-2F2',
7130             0xc5 => '3F2',
7131             0xc6 => '5F2',
7132             0xd1 => '+3F3',
7133             0xd2 => '-3F3',
7134             0xd3 => '+2F3',
7135             0xd4 => '-2F3',
7136             0xd5 => '3F3',
7137             0xd6 => '5F3',
7138             },
7139             },
7140             0x1757 => {
7141             Name => 'WBBracketingSteps',
7142             Condition => '$$self{FILE_TYPE} ne "TIFF"', # (covers NEF and TIFF)
7143             Mask => 0xff,
7144             PrintHex => 1,
7145             PrintConvColumns => 2,
7146             PrintConv => {
7147             0x00 => 'WB Bracketing Disabled',
7148             0x01 => 'b3F 1',
7149             0x02 => 'A3F 1',
7150             0x03 => 'b2F 1',
7151             0x04 => 'A2F 1',
7152             0x05 => '3F 1',
7153             0x06 => '5F 1',
7154             0x07 => '7F 1',
7155             0x08 => '9F 1',
7156             0x10 => '0F 2',
7157             0x11 => 'b3F 2',
7158             0x12 => 'A3F 2',
7159             0x13 => 'b2F 2',
7160             0x14 => 'A2F 2',
7161             0x15 => '3F 2',
7162             0x16 => '5F 2',
7163             0x17 => '7F 2',
7164             0x18 => '9F 2',
7165             0x20 => '0F 3',
7166             0x21 => 'b3F 3',
7167             0x22 => 'A3F 3',
7168             0x23 => 'b2F 3',
7169             0x24 => 'A2F 3',
7170             0x25 => '3F 3',
7171             0x26 => '5F 3',
7172             0x27 => '7F 3',
7173             0x28 => '9F 3',
7174             0x22 => 'A3F 3',
7175             0x23 => 'b2F 3',
7176             0x24 => 'A2F 3',
7177             0x25 => '3F 3',
7178             0x26 => '5F 3',
7179             0x27 => '7F 3',
7180             0x28 => '9F 3',
7181             },
7182             },
7183             0x175e => {
7184             Name => 'NikonMeteringMode',
7185             Mask => 0x03,
7186             PrintConv => {
7187             0 => 'Matrix',
7188             1 => 'Center',
7189             2 => 'Spot',
7190             3 => 'Highlight'
7191             },
7192             Hook => '$varSize = $$self{ISOAutoOffset} - 0x1858',
7193             },
7194             0x185c => {
7195             Name => 'ISOAutoShutterTime',
7196             Mask => 0x3f,
7197             PrintConv => {
7198             0 => '1/4000 s',
7199             1 => '1/3200 s',
7200             2 => '1/2500 s',
7201             3 => '1/2000 s',
7202             4 => '1/1600 s',
7203             5 => '1/1250 s',
7204             6 => '1/1000 s',
7205             7 => '1/800 s',
7206             8 => '1/640 s',
7207             9 => '1/500 s',
7208             10 => '1/400 s',
7209             11 => '1/320 s',
7210             12 => '1/250 s',
7211             13 => '1/200 s',
7212             14 => '1/160 s',
7213             15 => '1/125 s',
7214             16 => '1/100 s',
7215             17 => '1/80 s',
7216             18 => '1/60 s',
7217             19 => '1/50 s',
7218             20 => '1/40 s',
7219             21 => '1/30 s',
7220             22 => '1/15 s',
7221             23 => '1/8 s',
7222             24 => '1/4 s',
7223             25 => '1/2 s',
7224             26 => '1 s',
7225             27 => '2 s',
7226             28 => '4 s',
7227             29 => '8 s',
7228             30 => '15 s',
7229             31 => '30 s',
7230             32 => 'Auto (Slowest)',
7231             33 => 'Auto (Slower)',
7232             34 => 'Auto',
7233             35 => 'Auto (Faster)',
7234             36 => 'Auto (Fastest)',
7235             },
7236             },
7237             0x185d => {
7238             Name => 'ISOAutoHiLimit',
7239             Mask => 0xff,
7240             PrintHex => 1,
7241             PrintConv => {
7242             0x24 => 'ISO 200',
7243             0x26 => 'ISO 250',
7244             0x27 => 'ISO 280',
7245             0x28 => 'ISO 320',
7246             0x2a => 'ISO 400',
7247             0x2c => 'ISO 500',
7248             0x2d => 'ISO 560',
7249             0x2e => 'ISO 640',
7250             0x30 => 'ISO 800',
7251             0x32 => 'ISO 1000',
7252             0x33 => 'ISO 1100',
7253             0x34 => 'ISO 1250',
7254             0x36 => 'ISO 1600',
7255             0x38 => 'ISO 2000',
7256             0x39 => 'ISO 2200',
7257             0x3a => 'ISO 2500',
7258             0x3c => 'ISO 3200',
7259             0x3e => 'ISO 4000',
7260             0x3f => 'ISO 4500',
7261             0x40 => 'ISO 5000',
7262             0x42 => 'ISO 6400',
7263             0x44 => 'ISO 8000',
7264             0x45 => 'ISO 9000',
7265             0x46 => 'ISO 10000',
7266             0x48 => 'ISO 12800',
7267             0x4a => 'ISO 16000',
7268             0x4b => 'ISO 18000',
7269             0x4c => 'ISO 20000',
7270             0x4e => 'ISO 25600',
7271             0x50 => 'ISO 32000',
7272             0x51 => 'ISO 36000',
7273             0x52 => 'ISO 40000',
7274             0x54 => 'ISO 51200',
7275             0x56 => 'ISO Hi 0.3',
7276             0x57 => 'ISO Hi 0.5',
7277             0x58 => 'ISO Hi 0.7',
7278             0x5a => 'ISO Hi 1.0',
7279             0x60 => 'ISO Hi 2.0',
7280             0x66 => 'ISO Hi 3.0',
7281             0x6c => 'ISO Hi 4.0',
7282             0x72 => 'ISO Hi 5.0',
7283             },
7284             Hook => '$varSize = $$self{CustomSettingsOffset} - 0x18ab',
7285             },
7286             0x18ab => { # (actual offset adjusted by Hook above)
7287             Name => 'CustomSettingsD810',
7288             Format => 'undef[53]',
7289             SubDirectory => {
7290             TagTable => 'Image::ExifTool::NikonCustom::SettingsD810',
7291             },
7292             Hook => '$varSize = $$self{OrientationOffset} - 0x36f4',
7293             },
7294             0x36f4 => {
7295             Name => 'RollAngle',
7296             Format => 'fixed32u',
7297             Notes => 'converted to degrees of clockwise camera roll',
7298             ValueConv => '$val <= 180 ? $val : $val - 360',
7299             ValueConvInv => '$val >= 0 ? $val : $val + 360',
7300             PrintConv => 'sprintf("%.1f", $val)',
7301             PrintConvInv => '$val',
7302             },
7303             0x36f8 => {
7304             Name => 'PitchAngle',
7305             Format => 'fixed32u',
7306             Notes => 'converted to degrees of upward camera tilt',
7307             ValueConv => '$val <= 180 ? $val : $val - 360',
7308             ValueConvInv => '$val >= 0 ? $val : $val + 360',
7309             PrintConv => 'sprintf("%.1f", $val)',
7310             PrintConvInv => '$val',
7311             },
7312             0x36fc => {
7313             Name => 'YawAngle',
7314             Format => 'fixed32u',
7315             Notes => 'the camera yaw angle when shooting in portrait orientation',
7316             ValueConv => '$val <= 180 ? $val : $val - 360',
7317             ValueConvInv => '$val >= 0 ? $val : $val + 360',
7318             PrintConv => 'sprintf("%.1f", $val)',
7319             PrintConvInv => '$val',
7320             },
7321             # note: DecryptLen currently set to OrientationOffset + 12
7322              
7323             # (moves around too much and doesn't fit cleanly in the offset table)
7324             #0x38be => {
7325             # Name => 'Rotation',
7326             # Condition => '$$self{FirmwareVersion} =~ /^1.0/',
7327             # Mask => 0x30,
7328             # PrintConv => {
7329             # 0 => 'Horizontal',
7330             # 1 => 'Rotate 270 CW',
7331             # 2 => 'Rotate 90 CW',
7332             # 3 => 'Rotate 180',
7333             # },
7334             #},
7335             );
7336              
7337             # shot information for the D850 firmware 1.00b (encrypted) - ref 28
7338             %Image::ExifTool::Nikon::ShotInfoD850 = (
7339             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7340             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7341             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7342             VARS => { ID_LABEL => 'Index' },
7343             DATAMEMBER => [ 0x04, 0x58, 0xa0, 0x0fbf, 0x2efa ],
7344             IS_SUBDIR => [ 0x1038 ],
7345             WRITABLE => 1,
7346             FIRST_ENTRY => 0,
7347             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7348             NOTES => 'These tags are extracted from encrypted data in images from the D850.',
7349             0x00 => {
7350             Name => 'ShotInfoVersion',
7351             Format => 'string[4]',
7352             Writable => 0,
7353             },
7354             0x04 => {
7355             Name => 'FirmwareVersion',
7356             DataMember => 'FirmwareVersion',
7357             Format => 'string[5]',
7358             Writable => 0,
7359             RawConv => '$$self{FirmwareVersion} = $val',
7360             },
7361             0x58 => {
7362             Name => 'CustomSettingsOffset', # (relative offset from start of ShotInfo data)
7363             DataMember => 'CustomSettingsOffset',
7364             Format => 'int32u',
7365             Writable => 0,
7366             Hidden => 1,
7367             RawConv => '$$self{CustomSettingsOffset} = $val || 0x10000000; undef',
7368             },
7369             0xa0 => {
7370             Name => 'OrientationOffset',
7371             DataMember => 'OrientationOffset',
7372             Format => 'int32u',
7373             Writable => 0,
7374             Hidden => 1,
7375             RawConv => '$$self{OrientationOffset} = $val || 0x10000000; undef',
7376             },
7377             0x0791 => {
7378             Name => 'PhotoShootingMenuBankImageArea',
7379             Mask => 0x07,
7380             PrintConv => {
7381             0 => 'FX (36x24)',
7382             1 => 'DX (24x16)',
7383             2 => '5:4 (30x24)',
7384             3 => '1.2x (30x20)',
7385             4 => '1:1 (24x24)',
7386             },
7387             },
7388             0x0fbd => {
7389             Name => 'PhotoShootingMenuBank',
7390             Condition => '$$self{FILE_TYPE} eq "JPEG"',
7391             Notes => 'valid for JPEG images only',
7392             Mask => 0x03,
7393             PrintConv => {
7394             0 => 'A',
7395             1 => 'B',
7396             2 => 'C',
7397             3 => 'D',
7398             },
7399             },
7400             0x0fbf => {
7401             Name => 'PrimarySlot',
7402             Mask => 0x80,
7403             PrintConv => {
7404             0 => 'XQD Card',
7405             1 => 'SD Card',
7406             },
7407             Hook => '$varSize = $$self{CustomSettingsOffset} - 0x1038',
7408             },
7409             0x1038 => {
7410             Name => 'CustomSettingsD850',
7411             Format => 'undef[90]',
7412             SubDirectory => {
7413             TagTable => 'Image::ExifTool::NikonCustom::SettingsD850',
7414             },
7415             },
7416             ### 0x2efb - OrientationInfo start (D850 firmware 1.01a)
7417             0x2efa => {
7418             Name => 'Hook1',
7419             Hidden => 1,
7420             RawConv => 'undef',
7421             # account for variable location of OrientationInfo data
7422             Hook => '$varSize = $$self{OrientationOffset} - 0x2efb',
7423             },
7424             0x2efb => { #28
7425             Name => 'RollAngle',
7426             Format => 'fixed32u',
7427             Notes => 'converted to degrees of clockwise camera roll',
7428             ValueConv => '$val <= 180 ? $val : $val - 360',
7429             ValueConvInv => '$val >= 0 ? $val : $val + 360',
7430             PrintConv => 'sprintf("%.1f", $val)',
7431             PrintConvInv => '$val',
7432             },
7433             0x2eff => { #28
7434             Name => 'PitchAngle',
7435             Format => 'fixed32u',
7436             Notes => 'converted to degrees of upward camera tilt',
7437             ValueConv => '$val <= 180 ? $val : $val - 360',
7438             ValueConvInv => '$val >= 0 ? $val : $val + 360',
7439             PrintConv => 'sprintf("%.1f", $val)',
7440             PrintConvInv => '$val',
7441             },
7442             0x2f03 => { #28
7443             Name => 'YawAngle',
7444             Format => 'fixed32u',
7445             Notes => 'the camera yaw angle when shooting in portrait orientation',
7446             ValueConv => '$val <= 180 ? $val : $val - 360',
7447             ValueConvInv => '$val >= 0 ? $val : $val + 360',
7448             PrintConv => 'sprintf("%.1f", $val)',
7449             PrintConvInv => '$val',
7450             },
7451             # note: DecryptLen currently set to 0x2f07
7452             );
7453             # shot information for the D4 firmware 1.00g (ref PH)
7454             %Image::ExifTool::Nikon::ShotInfoD4 = (
7455             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7456             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7457             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7458             VARS => { ID_LABEL => 'Index' },
7459             IS_SUBDIR => [ 0x0751 ],
7460             WRITABLE => 1,
7461             FIRST_ENTRY => 0,
7462             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7463             NOTES => q{
7464             These tags are extracted from encrypted data in images from the D4.
7465             },
7466             0x00 => {
7467             Name => 'ShotInfoVersion',
7468             Format => 'string[4]',
7469             Writable => 0,
7470             },
7471             0x04 => {
7472             Name => 'FirmwareVersion',
7473             Format => 'string[5]',
7474             Writable => 0,
7475             },
7476             0x0751 => { #PH (NC)
7477             Name => 'CustomSettingsD4',
7478             # (seems to work for 1.00g and 1.02b)
7479             Format => 'undef[56]',
7480             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsD4' },
7481             },
7482             # note: DecryptLen currently set to 0x789
7483             );
7484              
7485             # shot information for the D4S firmware 1.01a (ref 28, encrypted)
7486             %Image::ExifTool::Nikon::ShotInfoD4S = (
7487             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7488             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7489             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7490             VARS => { ID_LABEL => 'Index' },
7491             DATAMEMBER => [ 4 ],
7492             IS_SUBDIR => [ 0x189d, 0x193d ],
7493             WRITABLE => 1,
7494             FIRST_ENTRY => 0,
7495             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7496             NOTES => 'These tags are extracted from encrypted data in images from the D4S.',
7497             0x00 => {
7498             Name => 'ShotInfoVersion',
7499             Format => 'string[4]',
7500             Writable => 0,
7501             },
7502             0x04 => {
7503             Name => 'FirmwareVersion',
7504             DataMember => 'FirmwareVersion',
7505             Format => 'string[5]',
7506             Writable => 0,
7507             RawConv => '$$self{FirmwareVersion} = $val',
7508             },
7509             0x01d0 => {
7510             Name => 'SecondarySlotFunction',
7511             Mask => 0x03,
7512             PrintConv => {
7513             0 => 'Overflow',
7514             2 => 'Backup',
7515             3 => 'NEF Primary + JPG Secondary',
7516             },
7517             },
7518             0x174c => {
7519             Name => 'AEBracketingSteps',
7520             Mask => 0xff,
7521             PrintHex => 1,
7522             PrintConvColumns => 2,
7523             PrintConv => {
7524             0x00 => 'AE Bracketing Disabled',
7525             0x20 => 'AE Bracketing Disabled',
7526             0x30 => 'AE Bracketing Disabled',
7527             0x40 => 'AE Bracketing Disabled',
7528             0x50 => 'AE Bracketing Disabled',
7529             0x81 => '+3F0.3',
7530             0x82 => '-3F0.3',
7531             0x83 => '+2F0.3',
7532             0x84 => '-2F0.3',
7533             0x85 => '3F0.3',
7534             0x86 => '5F0.3',
7535             0x87 => '7F0.3',
7536             0x88 => '9F0.3',
7537             0x91 => '+3F0.5',
7538             0x92 => '-3F0.5',
7539             0x93 => '+2F0.5',
7540             0x94 => '-2F0.5',
7541             0x95 => '3F0.5',
7542             0x96 => '5F0.5',
7543             0x97 => '7F0.5',
7544             0x98 => '9F0.5',
7545             0xa1 => '+3F0.7',
7546             0xa2 => '-3F0.7',
7547             0xa3 => '+2F0.7',
7548             0xa4 => '-2F0.7',
7549             0xa5 => '3F0.7',
7550             0xa6 => '5F0.7',
7551             0xa7 => '7F0.7',
7552             0xa8 => '9F0.7',
7553             0xb1 => '+3F1',
7554             0xb2 => '-3F1',
7555             0xb3 => '+2F1',
7556             0xb4 => '-2F1',
7557             0xb5 => '3F1',
7558             0xb6 => '5F1',
7559             0xb7 => '7F1',
7560             0xb8 => '9F1',
7561             0xc1 => '+3F2',
7562             0xc2 => '-3F2',
7563             0xc3 => '+2F2',
7564             0xc4 => '-2F2',
7565             0xc5 => '3F2',
7566             0xc6 => '5F2',
7567             0xd1 => '+3F3',
7568             0xd2 => '-3F3',
7569             0xd3 => '+2F3',
7570             0xd4 => '-2F3',
7571             0xd5 => '3F3',
7572             0xd6 => '5F3',
7573             },
7574             },
7575             0x174d => {
7576             Name => 'WBBracketingSteps',
7577             Condition => '$$self{FILE_TYPE} ne "TIFF"', # (covers NEF and TIFF)
7578             Mask => 0xff,
7579             PrintHex => 1,
7580             PrintConvColumns => 2,
7581             PrintConv => {
7582             0x00 => 'WB Bracketing Disabled',
7583             0x01 => 'b3F 1',
7584             0x02 => 'A3F 1',
7585             0x03 => 'b2F 1',
7586             0x04 => 'A2F 1',
7587             0x05 => '3F 1',
7588             0x06 => '5F 1',
7589             0x07 => '7F 1',
7590             0x08 => '9F 1',
7591             0x10 => '0F 2',
7592             0x11 => 'b3F 2',
7593             0x12 => 'A3F 2',
7594             0x13 => 'b2F 2',
7595             0x14 => 'A2F 2',
7596             0x15 => '3F 2',
7597             0x16 => '5F 2',
7598             0x17 => '7F 2',
7599             0x18 => '9F 2',
7600             0x20 => '0F 3',
7601             0x21 => 'b3F 3',
7602             0x22 => 'A3F 3',
7603             0x23 => 'b2F 3',
7604             0x24 => 'A2F 3',
7605             0x25 => '3F 3',
7606             0x26 => '5F 3',
7607             0x27 => '7F 3',
7608             0x28 => '9F 3',
7609             0x22 => 'A3F 3',
7610             0x23 => 'b2F 3',
7611             0x24 => 'A2F 3',
7612             0x25 => '3F 3',
7613             0x26 => '5F 3',
7614             0x27 => '7F 3',
7615             0x28 => '9F 3',
7616             },
7617             },
7618             0x184d => {
7619             Name => 'ReleaseMode',
7620             Mask => 0xff,
7621             PrintConv => {
7622             0 => 'Single Frame',
7623             1 => 'Continuous High Speed',
7624             3 => 'Continuous Low Speed',
7625             4 => 'Timer',
7626             32 => 'Mirror-Up',
7627             64 => 'Quiet',
7628             },
7629             },
7630             0x189d => { #PH (NC)
7631             Name => 'CustomSettingsD4S',
7632             Condition => '$$self{FirmwareVersion} =~ /^1.00/',
7633             Notes => 'firmware version 1.00',
7634             Format => 'undef[56]',
7635             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsD4' },
7636             },
7637             0x18c2 => { # CSf1-c (no idea why it is so far away from the rest of the settings)
7638             Name => 'MultiSelectorLiveViewMode',
7639             Groups => { 1 => 'NikonCustom' },
7640             Condition => '$$self{FirmwareVersion} !~ /^1.00/',
7641             Mask => 0xc0,
7642             PrintConv => {
7643             0 => 'Reset',
7644             1 => 'Zoom',
7645             3 => 'None',
7646             },
7647             },
7648             0x18ea => {
7649             Name => 'ISOAutoShutterTime',
7650             Mask => 0x3f,
7651             PrintConv => {
7652             0 => '1/4000 s',
7653             1 => '1/3200 s',
7654             2 => '1/2500 s',
7655             3 => '1/2000 s',
7656             4 => '1/1600 s',
7657             5 => '1/1250 s',
7658             6 => '1/1000 s',
7659             7 => '1/800 s',
7660             8 => '1/640 s',
7661             9 => '1/500 s',
7662             10 => '1/400 s',
7663             11 => '1/320 s',
7664             12 => '1/250 s',
7665             13 => '1/200 s',
7666             14 => '1/160 s',
7667             15 => '1/125 s',
7668             16 => '1/100 s',
7669             17 => '1/80 s',
7670             18 => '1/60 s',
7671             19 => '1/50 s',
7672             20 => '1/40 s',
7673             21 => '1/30 s',
7674             22 => '1/15 s',
7675             23 => '1/8 s',
7676             24 => '1/4 s',
7677             25 => '1/2 s',
7678             26 => '1 s',
7679             27 => '2 s',
7680             28 => '4 s',
7681             29 => '8 s',
7682             30 => '15 s',
7683             31 => '30 s',
7684             32 => 'Auto (Slowest)',
7685             33 => 'Auto (Slower)',
7686             34 => 'Auto',
7687             35 => 'Auto (Faster)',
7688             36 => 'Auto (Fastest)',
7689             },
7690             },
7691             0x18eb => {
7692             Name => 'ISOAutoHiLimit',
7693             Mask => 0xff,
7694             PrintHex => 1,
7695             PrintConv => {
7696             0x24 => 'ISO 200',
7697             0x26 => 'ISO 250',
7698             0x27 => 'ISO 280',
7699             0x28 => 'ISO 320',
7700             0x2a => 'ISO 400',
7701             0x2c => 'ISO 500',
7702             0x2d => 'ISO 560',
7703             0x2e => 'ISO 640',
7704             0x30 => 'ISO 800',
7705             0x32 => 'ISO 1000',
7706             0x33 => 'ISO 1100',
7707             0x34 => 'ISO 1250',
7708             0x36 => 'ISO 1600',
7709             0x38 => 'ISO 2000',
7710             0x39 => 'ISO 2200',
7711             0x3a => 'ISO 2500',
7712             0x3c => 'ISO 3200',
7713             0x3e => 'ISO 4000',
7714             0x3f => 'ISO 4500',
7715             0x40 => 'ISO 5000',
7716             0x42 => 'ISO 6400',
7717             0x44 => 'ISO 8000',
7718             0x45 => 'ISO 9000',
7719             0x46 => 'ISO 10000',
7720             0x48 => 'ISO 12800',
7721             0x4a => 'ISO 16000',
7722             0x4b => 'ISO 18000',
7723             0x4c => 'ISO 20000',
7724             0x4e => 'ISO 25600',
7725             0x50 => 'ISO 32000',
7726             0x51 => 'ISO 36000',
7727             0x52 => 'ISO 40000',
7728             0x54 => 'ISO 51200',
7729             0x56 => 'ISO Hi 0.3',
7730             0x57 => 'ISO Hi 0.5',
7731             0x58 => 'ISO Hi 0.7',
7732             0x5a => 'ISO Hi 1.0',
7733             0x60 => 'ISO Hi 2.0',
7734             0x66 => 'ISO Hi 3.0',
7735             0x6c => 'ISO Hi 4.0',
7736             0x72 => 'ISO Hi 5.0',
7737             },
7738             },
7739             0x193d => {
7740             Name => 'CustomSettingsD4S',
7741             Condition => '$$self{FirmwareVersion} !~ /^1.00/',
7742             Notes => 'firmware version 1.01',
7743             Format => 'undef[56]',
7744             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsD4' },
7745             },
7746             # 0x1978 => { # this decode works, but involves more bits than should be necessary
7747             # Name => 'ShutterTrigger',
7748             # Mask => 0xff,
7749             # PrintConv => {
7750             # 0 => 'Timer',
7751             # 15 => 'Cable Release/Remote',
7752             # 195 => 'Shutter Button',
7753             # },
7754             # },
7755             0x350b => {
7756             Name => 'RollAngle',
7757             Format => 'fixed32u',
7758             Notes => 'converted to degrees of clockwise camera roll',
7759             ValueConv => '$val < 180 ? -$val : 360 - $val',
7760             ValueConvInv => '$val <= 0 ? -$val : 360 - $val',
7761             PrintConv => 'sprintf("%.1f", $val)',
7762             PrintConvInv => '$val',
7763             },
7764             0x350f => {
7765             Name => 'PitchAngle',
7766             Format => 'fixed32u',
7767             Notes => 'converted to degrees of upward camera tilt',
7768             ValueConv => '$val <= 180 ? $val : $val - 360',
7769             ValueConvInv => '$val >= 0 ? $val : $val + 360',
7770             PrintConv => 'sprintf("%.1f", $val)',
7771             PrintConvInv => '$val',
7772             },
7773             0x3513 => {
7774             Name => 'YawAngle',
7775             Format => 'fixed32u',
7776             Notes => 'the camera yaw angle when shooting in portrait orientation',
7777             ValueConv => '$val <= 180 ? $val : $val - 360',
7778             ValueConvInv => '$val >= 0 ? $val : $val + 360',
7779             PrintConv => 'sprintf("%.1f", $val)',
7780             PrintConvInv => '$val',
7781             },
7782             0x3693 => {
7783             Name => 'Rotation',
7784             Mask => 0x30,
7785             PrintConv => {
7786             0 => 'Horizontal',
7787             1 => 'Rotate 270 CW',
7788             2 => 'Rotate 90 CW',
7789             3 => 'Rotate 180',
7790             },
7791             },
7792             # note: DecryptLen currently set to 0x3697
7793             );
7794              
7795             # shot information for the Z7II firmware 1.00 (encrypted) - ref 28
7796             %Image::ExifTool::Nikon::ShotInfoZ7II = (
7797             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7798             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7799             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7800             VARS => { ID_LABEL => 'Index' },
7801             DATAMEMBER => [ 0x04, 0x30, 0x38, 0x98, 0xa0, 0x75e7, 0x760c,
7802             0x7610, 0x7eff, 0xce31, 0xcea5, 0xceb6, 0xceb7 ],
7803             IS_SUBDIR => [ 0xceb8 ],
7804             WRITABLE => 1,
7805             FIRST_ENTRY => 0,
7806             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7807             NOTES => 'These tags are extracted from encrypted data in images from the Z7II.',
7808             0x00 => {
7809             Name => 'ShotInfoVersion',
7810             Format => 'string[4]',
7811             Writable => 0,
7812             },
7813             0x04 => {
7814             Name => 'FirmwareVersion',
7815             DataMember => 'FirmwareVersion',
7816             Format => 'string[8]',
7817             Writable => 0,
7818             RawConv => '$$self{FirmwareVersion} = $val',
7819             },
7820             0x0e => {
7821             Name => 'FirmwareVersion2',
7822             Format => 'string[8]',
7823             Writable => 0,
7824             Hidden => 1,
7825             },
7826             0x18 => {
7827             Name => 'FirmwareVersion3',
7828             Format => 'string[8]',
7829             Writable => 0,
7830             Hidden => 1,
7831             },
7832             0x24 => {
7833             Name => 'NumberOffsets', # number of entries in offset table. offsets are from start of ShotInfo data.
7834             DataMember => 'NumberOffsets',
7835             Format => 'int32u',
7836             Writable => 0,
7837             Hidden => 1,
7838             },
7839             0x30 => {
7840             Name => 'Offset3',
7841             DataMember => 'Offset3',
7842             Format => 'int32u',
7843             Writable => 0,
7844             Hidden => 1,
7845             RawConv => '$$self{Offset3} = $val || 0x10000000; undef', # (ignore if 0)
7846             },
7847             0x38 => {
7848             Name => 'Offset5',
7849             DataMember => 'Offset5',
7850             Format => 'int32u',
7851             Writable => 0,
7852             Hidden => 1,
7853             RawConv => '$$self{Offset5} = $val || 0x10000000; undef', # (ignore if 0)
7854             },
7855             0x98 => {
7856             Name => 'OrientationOffset',
7857             DataMember => 'OrientationOffset',
7858             Format => 'int32u',
7859             Writable => 0,
7860             Hidden => 1,
7861             RawConv => '$$self{OrientationOffset} = $val || 0x10000000; undef', # (ignore if 0)
7862             },
7863             0xa0 => {
7864             Name => 'Offset31',
7865             DataMember => 'Offset31',
7866             Format => 'int32u',
7867             Writable => 0,
7868             Hidden => 1,
7869             RawConv => '$$self{Offset31} = $val || 0x10000000; undef', # (ignore if 0)
7870             },
7871             ### 0x75e8 - Offset3 info start (Z7II firmware 1.30)
7872             0x75e7 => {
7873             Name => 'Hook1',
7874             Hidden => 1,
7875             RawConv => 'undef',
7876             # account for variable location of Offset3 data
7877             Hook => '$varSize = $$self{Offset3} - 0x75e8',
7878             },
7879             0x760c => {
7880             Name => 'IntervalShooting',
7881             RawConv => '$$self{IntervalShooting} = $val',
7882             Format => 'int16u',
7883             PrintConv => q{
7884             return 'Off' if $val == 0 ;
7885             my $i = sprintf("Interval %.0f of %.0f",$val, $$self{IntervalShootingIntervals}); # something like "Interval 1 of 3"
7886             my $f = $$self{IntervalShootingShotsPerInterval} > 1 ? sprintf(" Frame %.0f of %.0f",$$self{IntervalFrame}, $$self{IntervalShootingShotsPerInterval}): '' ; # something like "Frame 1 of 3" or blank
7887             return "On: $i$f"
7888             #$val == 0 ? 'Off' : sprintf("On: Interval %.0f of %.0f Frame %.0f of %.0f",$val, $$self{IntervalShootingIntervals}, $$self{IntervalFrame}, $$self{IntervalShootingShotsPerInterval}),
7889             },
7890             },
7891             0x7610 => {
7892             Name => 'IntervalFrame',
7893             RawConv => '$$self{IntervalFrame} = $val',
7894             Condition => '$$self{IntervalShooting} > 0',
7895             Format => 'int16u',
7896             Hidden => 1,
7897             },
7898             ### 0x7f00 - Offset5 info start (Z7II firmware 1.30)
7899             0x7eff => {
7900             Name => 'Hook2',
7901             Hidden => 1,
7902             RawConv => 'undef',
7903             # account for variable location of Offset5 data
7904             Hook => '$varSize = $$self{Offset5} - 0x7f00',
7905             },
7906             0x7fa0 => { #28
7907             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
7908             # offset5+160; 128 is neutral; >128 increases Yellow; <128 increases Magenta; increments of 4 result from 1 full unit adjustment on the camera
7909             # offset5+161 128 is neutral; >128 increases Brightness; <128 decreases Brightness
7910             # 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]
7911             Format => 'int8u[2]',
7912             Condition => '$$self{FirmwareVersion} ge "01.30"',
7913             PrintConv => q{
7914             return 'Off' if $val eq '0 0' or $val eq '255 255';
7915             my @v = split ' ', $val;
7916             my $brightness = $v[1]==128 ? 'Brightness: Neutral' : sprintf('Brightness: %+.1f',($v[1]-128)/4);
7917             my $color = $v[0]==128 ? 'Color: Neutral' : sprintf('%s: %.1f', $v[0]>128 ? 'Yellow' : 'Magenta', abs($v[0]-128)/4);
7918             # will return something like: 'Magenta: 1.0 Brightness: Neutral'
7919             return "$color $brightness"
7920             },
7921             },
7922             ### 0xce32 - OrientationInfo start (Z7II firmware 1.00)
7923             0xce31 => {
7924             Name => 'Hook3',
7925             Hidden => 1,
7926             RawConv => 'undef',
7927             # account for variable location of OrientationInfo data
7928             Hook => '$varSize = $$self{OrientationOffset} - 0xce32',
7929             },
7930              
7931             0xce32 => {
7932             Name => 'RollAngle',
7933             Format => 'fixed32u',
7934             Notes => 'converted to degrees of clockwise camera roll',
7935             ValueConv => '$val <= 180 ? $val : $val - 360',
7936             ValueConvInv => '$val >= 0 ? $val : $val + 360',
7937             PrintConv => 'sprintf("%.1f", $val)',
7938             PrintConvInv => '$val',
7939             },
7940             0xce36 => {
7941             Name => 'PitchAngle',
7942             Format => 'fixed32u',
7943             Notes => 'converted to degrees of upward camera tilt',
7944             ValueConv => '$val <= 180 ? $val : $val - 360',
7945             ValueConvInv => '$val >= 0 ? $val : $val + 360',
7946             PrintConv => 'sprintf("%.1f", $val)',
7947             PrintConvInv => '$val',
7948             },
7949             0xce3a => {
7950             Name => 'YawAngle',
7951             Format => 'fixed32u',
7952             Notes => 'the camera yaw angle when shooting in portrait orientation',
7953             ValueConv => '$val <= 180 ? $val : $val - 360',
7954             ValueConvInv => '$val >= 0 ? $val : $val + 360',
7955             PrintConv => 'sprintf("%.1f", $val)',
7956             PrintConvInv => '$val',
7957             },
7958             0xcea5 => {
7959             Name => 'Hook4',
7960             Hidden => 1,
7961             RawConv => 'undef',
7962             # account for variable location of Offset31 data
7963             Hook => '$varSize = $$self{Offset31} - 0xcea6',
7964             },
7965             ### 0xcea6 - Offset31 info start (Z7II firmware 1.30)
7966             0xceb6 => {
7967             Name => 'MenuSettingsZ7IIOffset',
7968             # offset to MenuSettingsZ7II is relative to start of Offset31 block
7969             RawConv => '$$self{MenuSettingsZ7IIOffset} = ($val || 0x10000000) + $$self{Offset31}; undef', # (ignore if 0)
7970             },
7971             0xceb7 => {
7972             Name => 'Hook5',
7973             Hidden => 1,
7974             RawConv => 'undef',
7975             # account for variable location of Offset5 data
7976             Hook => '$varSize = $$self{MenuSettingsZ7IIOffset} - 0xceb8',
7977             },
7978             0xceb8 => { # (this is 0xd04e for the Z50)
7979             Name => 'MenuSettingsZ7II',
7980             Format => 'undef[860]',
7981             SubDirectory => {
7982             TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ7II',
7983             },
7984             }
7985             # note: DecryptLen currently set to 0xd04e + 860 (offset for Z50 is 0xd04e)
7986             );
7987              
7988             # shot information for the Z9 firmware 1.00 (encrypted) - ref 28
7989             %Image::ExifTool::Nikon::ShotInfoZ9 = (
7990             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7991             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
7992             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7993             VARS => { ID_LABEL => 'Index' },
7994             DATAMEMBER => [ 0x04, 0x30, 0x38, 0x84, 0x8c, 0x6c6f, 0x6c98,
7995             0x6c9a, 0x7717, 0x7844, 0xeaea, 0xeb6f, 0xeb70 ],
7996             IS_SUBDIR => [ 0xec4b ],
7997             WRITABLE => 1,
7998             FIRST_ENTRY => 0,
7999             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8000             NOTES => 'These tags are extracted from encrypted data in images from the Z9.',
8001             0x00 => {
8002             Name => 'ShotInfoVersion',
8003             Format => 'string[4]',
8004             Writable => 0,
8005             },
8006             0x04 => {
8007             Name => 'FirmwareVersion',
8008             DataMember => 'FirmwareVersion',
8009             Format => 'string[8]',
8010             Writable => 0,
8011             RawConv => '$$self{FirmwareVersion} = $val',
8012             },
8013             0x0e => {
8014             Name => 'FirmwareVersion2',
8015             Format => 'string[8]',
8016             Writable => 0,
8017             Hidden => 1,
8018             },
8019             0x18 => {
8020             Name => 'FirmwareVersion3',
8021             Format => 'string[8]',
8022             Writable => 0,
8023             Hidden => 1,
8024             },
8025             0x24 => {
8026             Name => 'NumberOffsets', # number of entries in offset table. offsets are from start of ShotInfo data.
8027             DataMember => 'NumberOffsets',
8028             Format => 'int32u',
8029             Writable => 0,
8030             Hidden => 1,
8031             },
8032             0x30 => {
8033             Name => 'Offset3', #offset3 - length 2528 (Z9 firmware 1.0)
8034             DataMember => 'Offset3',
8035             Format => 'int32u',
8036             Writable => 0,
8037             Hidden => 1,
8038             RawConv => '$$self{Offset3} = $val || 0x10000000; undef', # (ignore if 0)
8039             },
8040             0x38 => {
8041             Name => 'Offset5', #offset5 - length 2488 (Z9 firmware 1.0)
8042             DataMember => 'Offset5',
8043             Format => 'int32u',
8044             Writable => 0,
8045             Hidden => 1,
8046             RawConv => '$$self{Offset5} = $val || 0x10000000; undef', # (ignore if 0)
8047             },
8048             0x84 => {
8049             Name => 'OrientationOffset', #offset24 - length 108 (Z9 firmware 1.0)
8050             DataMember => 'OrientationOffset',
8051             Format => 'int32u',
8052             Writable => 0,
8053             Hidden => 1,
8054             RawConv => '$$self{OrientationOffset} = $val || 0x10000000; undef', # (ignore if 0)
8055             },
8056             0x8c => {
8057             Name => 'Offset26', #offset26 - length 1895 (Z9 firmware 1.0)
8058             DataMember => 'Offset26',
8059             Format => 'int32u',
8060             Writable => 0,
8061             Hidden => 1,
8062             RawConv => '$$self{Offset26} = $val || 0x10000000; undef', # (ignore if 0)
8063             },
8064             ### 0x6c70 - Offset3 info start (Z9 firmware 1.00)
8065             0x6c6f => {
8066             Name => 'Offset3Hook',
8067             Hidden => 1,
8068             RawConv => 'undef',
8069             # account for variable location of Offset3 data
8070             Hook => '$varSize = $$self{Offset3} - 0x6c70',
8071             },
8072             0x6c98 => {
8073             Name => 'IntervalShooting',
8074             RawConv => '$$self{IntervalShooting} = $val',
8075             Format => 'int16u',
8076             PrintConv => q{
8077             return 'Off' if $val == 0 ;
8078             my $i = sprintf("Interval %.0f of %.0f",$val, $$self{IntervalShootingIntervals}); # something like "Interval 1 of 3"
8079             my $f = $$self{IntervalShootingShotsPerInterval} > 1 ? sprintf(" Frame %.0f of %.0f",$$self{IntervalFrame}, $$self{IntervalShootingShotsPerInterval}): '' ; # something like "Frame 1 of 3" or blank
8080             return "On: $i$f"
8081             #$val == 0 ? 'Off' : sprintf("On: Interval %.0f of %.0f Frame %.0f of %.0f",$val, $$self{IntervalShootingIntervals}, $$self{IntervalFrame}, $$self{IntervalShootingShotsPerInterval}),
8082             },
8083             },
8084             0x6c9a => {
8085             Name => 'IntervalFrame',
8086             RawConv => '$$self{IntervalFrame} = $val',
8087             Condition => '$$self{IntervalShooting} > 0',
8088             Format => 'int16u',
8089             Hidden => 1,
8090             },
8091             ### 0x7718 - Offset5 info start (Z9 firmware 1.00)
8092             0x7717 => {
8093             Name => 'Offsset5Hook',
8094             Hidden => 1,
8095             RawConv => 'undef',
8096             # account for variable location of Offset5 data
8097             Hook => '$varSize = $$self{Offset5} - 0x7718',
8098             },
8099             0x7844 => {
8100             Name => 'FocusShiftShooting',
8101             RawConv => '$$self{FocusShiftShooting} = $val',
8102             PrintConv => q{
8103             return 'Off' if $val == 0 ;
8104             my $i = sprintf("Frame %.0f of %.0f",$val, $$self{FocusShiftNumberShots}); # something like Frame 1 of 100"
8105             return "On: $i"
8106             },
8107             },
8108             ### 0xeaeb - OrientationInfo start (Z9 firmware 1.00)
8109             0xeaea => {
8110             Name => 'OrientationHook',
8111             Hidden => 1,
8112             RawConv => 'undef',
8113             # account for variable location of OrientationInfo data
8114             Hook => '$varSize = $$self{OrientationOffset} - 0xeaeb',
8115             },
8116             0xeaeb => {
8117             Name => 'RollAngle',
8118             Format => 'fixed32u',
8119             Notes => 'converted to degrees of clockwise camera roll',
8120             ValueConv => '$val <= 180 ? $val : $val - 360',
8121             ValueConvInv => '$val >= 0 ? $val : $val + 360',
8122             PrintConv => 'sprintf("%.1f", $val)',
8123             PrintConvInv => '$val',
8124             },
8125             0xeaef => {
8126             Name => 'PitchAngle',
8127             Format => 'fixed32u',
8128             Notes => 'converted to degrees of upward camera tilt',
8129             ValueConv => '$val <= 180 ? $val : $val - 360',
8130             ValueConvInv => '$val >= 0 ? $val : $val + 360',
8131             PrintConv => 'sprintf("%.1f", $val)',
8132             PrintConvInv => '$val',
8133             },
8134             0xeaf3 => {
8135             Name => 'YawAngle',
8136             Format => 'fixed32u',
8137             Notes => 'the camera yaw angle when shooting in portrait orientation',
8138             ValueConv => '$val <= 180 ? $val : $val - 360',
8139             ValueConvInv => '$val >= 0 ? $val : $val + 360',
8140             PrintConv => 'sprintf("%.1f", $val)',
8141             PrintConvInv => '$val',
8142             },
8143             ### 0xeb5f - Offset26 info start (Z9 firmware 1.00)
8144             0xeb6f => {
8145             Name => 'MenuSettingsZ9Offset',
8146             Writable => 0,
8147             Hidden => 1,
8148             # offset to MenuSettingsZ9 is relative to start of Offset26 block
8149             RawConv => '$$self{MenuSettingsZ9Offset} = ($val || 0x10000000) + $$self{Offset26}; undef', # (ignore if 0)
8150             },
8151             0xeb70 => {
8152             Name => 'Hook5',
8153             Hidden => 1,
8154             RawConv => 'undef',
8155             # account for variable location of menu settings data
8156             Hook => '$varSize = $$self{MenuSettingsZ9Offset} - 0xec4b',
8157             },
8158             0xec4b => {
8159             Name => 'MenuSettingsZ9',
8160             Format => 'undef[1646]',
8161             SubDirectory => {
8162             TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ9',
8163             },
8164             },
8165             # note: DecryptLen currently set to 0xec4b + 1646
8166             );
8167              
8168             %Image::ExifTool::Nikon::MenuSettingsZ7II = (
8169             %binaryDataAttrs,
8170             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8171             DATAMEMBER => [ 176, 180, 328, 352, 858 ],
8172             NOTES => 'These tags are used by the Z5, Z6, Z7, Z6II, Z7II, Z50 and Zfc.',
8173             160 => {
8174             Name => 'IntervalDurationHours',
8175             Format => 'int32u',
8176             #Condition => '$$self{IntervalShooting} > 0',
8177             },
8178             164 => {
8179             Name => 'IntervalDurationMinutes',
8180             Format => 'int32u',
8181             #Condition => '$$self{IntervalShooting} > 0',
8182             },
8183             168 => {
8184             Name => 'IntervalDurationSeconds',
8185             Format => 'int32u',
8186             #Condition => '$$self{IntervalShooting} > 0',
8187             },
8188             176 => {
8189             Name => 'Intervals',
8190             Format => 'int32u',
8191             RawConv => '$$self{IntervalShootingIntervals} = $val',
8192             #Condition => '$$self{IntervalShooting} > 0',
8193             },
8194             180 => {
8195             Name => 'ShotsPerInterval',
8196             Format => 'int32u',
8197             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
8198             #Condition => '$$self{IntervalShooting} > 0',
8199             },
8200             184 => {
8201             Name => 'IntervalExposureSmoothing',
8202             #Condition => '$$self{IntervalShooting} > 0',
8203             Format => 'int8u',
8204             PrintConv => \%offOn,
8205             },
8206             186 => {
8207             Name => 'IntervalPriority',
8208             #Condition => '$$self{IntervalShooting} > 0',
8209             Format => 'int8u',
8210             PrintConv => \%offOn,
8211             },
8212             220 => {
8213             Name => 'FocusShiftNumberShots',
8214             },
8215             224 => {
8216             Name => 'FocusShiftStepWidth',
8217             },
8218             228 => {
8219             Name => 'FocusShiftInterval',
8220             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
8221             },
8222             232 => {
8223             Name => 'FocusShiftExposureLock',
8224             PrintConv => \%offOn,
8225             },
8226             #304 => White Balance - Kelvin Temp
8227             #312 => ColorSpace
8228             #314 => ActiveD-Lighting
8229             #318 => HighISONoiseReduction
8230             322 => {
8231             Name => 'DiffractionCompensation',
8232             Format => 'int8u',
8233             PrintConv => \%offOn,
8234             },
8235             323 => {
8236             Name => 'AutoDistortionControl',
8237             Format => 'int8u',
8238             PrintConv => \%offOn,
8239             },
8240             #324 => {Name => 'FlickerReductionShooting',}, # redundant with tag in NikonSettings
8241             326 => {
8242             Name => 'NikonMeteringMode',
8243             Unknown => 1,
8244             PrintConv => {
8245             0 => 'Matrix',
8246             1 => 'Center',
8247             2 => 'Spot',
8248             3 => 'Highlight'
8249             },
8250             },
8251             326 => { Name => 'NikonMeteringMode', PrintConv => \%meteringModeZ7},
8252             328 => {
8253             Name => 'FlashControlMode', # this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
8254             RawConv => '$$self{FlashControlMode} = $val',
8255             PrintConv => \%flashControlModeZ7,
8256             },
8257             334 => {
8258             Name => 'FlashGNDistance',
8259             Condition => '$$self{FlashControlMode} == 2',
8260             Unknown => 1,
8261             ValueConv => '$val + 3',
8262             PrintConv => \%flashGNDistance,
8263             },
8264             338 => {
8265             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)
8266             Condition => '$$self{FlashControlMode} >= 3',
8267             Unknown => 1,
8268             ValueConv => '2 ** (-$val/3)',
8269             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
8270             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
8271             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
8272             },
8273             346 => { Name => 'FlashWirelessOption', PrintConv => \%flashWirelessOptionZ7, Unknown => 1},
8274             348 => { Name => 'FlashRemoteControl', PrintConv => \%flashRemoteControlZ7, Unknown => 1},
8275             352 => {
8276             Name => 'FlashMasterControlMode', # tag name chosen for compatibility with those found in FlashInfo0102 & FlashInfo0103
8277             RawConv => '$$self{FlashGroupOptionsMasterMode} = $val',
8278             PrintConv => \%flashGroupOptionsMode,
8279             },
8280             354 => {
8281             Name => 'FlashMasterCompensation',
8282             Format => 'int8s',
8283             Condition => '$$self{FlashGroupOptionsMasterMode} != 3', # other than 'Off'
8284             Unknown => 1,
8285             ValueConv => '$val/6',
8286             ValueConvInv => '6 * $val',
8287             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
8288             PrintConvInv => '$val',
8289             },
8290             358 => {
8291             Name => 'FlashMasterOutput',
8292             Unknown => 1,
8293             Condition => '$$self{FlashGroupOptionsMasterMode} == 1', # only for Mode=M
8294             ValueConv => '2 ** (-$val/3)',
8295             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
8296             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
8297             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
8298             },
8299             #360 => {Name => 'FlashGroupAControlMode', }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupACompensation at 362 and FlashGroupAOutput at 368
8300             #368 => {Name => 'FlashGroupBControlMode', }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupBCompensation at 370 and FlashGroupBOutput at 374
8301             #376 => {Name => 'FlashGroupCControlMode', }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupCCompensation at 378 and FlashGroupCOutput at 382
8302             #384 => {Name => 'FlashGroupDControlMode', }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupDCompensation at 386 and FlashGroupDOutput at 390
8303             #392 => {Name => 'FlashGroupEControlMode', }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupECompensation at 394 and FlashGroupEOutput at 398
8304             #400 => {Name => 'FlashGroupFControlMode', }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupFCompensation at 402 and FlashGroupFOutput at 406
8305             #434 => FocusMode
8306             #436 => AFAreaMode
8307             #438 => VibrationReduction
8308             #442 => BracketSet
8309             #444 => BracketProgram
8310             #446 => BracketIncrement
8311             #463 => SilentPhotography
8312             502 => { Name => 'MovieFrameSize', PrintConv => \%movieFrameSizeZ9, Unknown => 1},
8313             504 => { Name => 'MovieFrameRate', PrintConv => \%movieFrameRateZ7, Unknown => 1},
8314             506 => {
8315             Name => 'MovieSlowMotion',
8316             Unknown => 1,
8317             PrintConv => {
8318             0 => 'Off',
8319             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]
8320             2 => 'On (5x)', # 120p recording with playback @ 24p [1920 x 1080; 20p x 5]
8321             },
8322             },
8323             510 => {
8324             Name => 'MovieType',
8325             Unknown => 1,
8326             PrintConv => {
8327             0 => 'MOV',
8328             1 => 'MP4',
8329             },
8330             },
8331             #512 => MovieISOAutoHiLimit
8332             516 => {
8333             Name => 'MovieISOAutoManualMode',
8334             Condition => '$$self{Model} =~ /^NIKON 7/', #ISO ranges vary by model. These mappings are for the Z7 and Z7II
8335             Format => 'int16u',
8336             Unknown => 1,
8337             ValueConv => '($val-104)/8',
8338             ValueConvInv => '8 * ($val + 104)',
8339             PrintConv => \%iSOAutoHiLimitZ7,
8340             },
8341             #520 => MovieWhiteBalanceSameAsPhoto
8342             568 => { Name => 'MovieActiveD-Lighting', PrintConv => \%activeDLightingZ7, Unknown => 1},
8343             572 => { Name => 'MovieHighISONoiseReduction', PrintConv => \%offLowNormalHighZ7, Unknown => 1},
8344             574 => { Name => 'MovieVignetteControl', PrintConv => \%offLowNormalHighZ7, Unknown => 1},
8345             576 => {
8346             Name => 'MovieVignetteControlSameAsPhoto',
8347             Unknown => 1,
8348             PrintConv => \%noYes
8349             },
8350             577 => {
8351             Name => 'MovieDiffractionCompensation',
8352             Unknown => 1,
8353             PrintConv => \%offOn
8354             },
8355             578 => {
8356             Name => 'MovieAutoDistortionControl',
8357             Unknown => 1,
8358             PrintConv => \%offOn
8359             },
8360             584 => { Name => 'MovieFocusMode', PrintConv => \%focusModeZ7, Unknown => 1},
8361             #586 => MovieAFAreaMode
8362             590 => {
8363             Name => 'MovieVibrationReduction',
8364             Unknown => 1,
8365             PrintConv => {
8366             0 => 'Off',
8367             1 => 'On (Normal)',
8368             2 => 'On (Sport)',
8369             },
8370             },
8371             591 => {
8372             Name => 'MovieVibrationReductionSameAsPhoto',
8373             Unknown => 1,
8374             PrintConv => \%noYes
8375             },
8376             #848 => HDMIOutputResolution
8377             #850 => HDMIOutputRange
8378             #854 => HDMIExternalRecorder
8379             #856 => HDMIBitDepth
8380             858 => {
8381             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
8382             Condition => '$$self{HDMIBitDepth} and $$self{HDMIBitDepth} == 2', # only for 10 bit
8383             RawConv => '$$self{HDMIOutputNLog} = $val',
8384             Unknown => 1,
8385             PrintConv => \%offOn,
8386             },
8387             #859 => HDMIViewAssist
8388             );
8389              
8390             %Image::ExifTool::Nikon::MenuSettingsZ9 = (
8391             %binaryDataAttrs,
8392             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8393             DATAMEMBER => [ 140, 188, 192, 232, 424, 534 ],
8394             IS_SUBDIR => [ 799 ],
8395             NOTES => 'These tags are used by the Z9.',
8396             #90 ISO
8397             140 => {
8398             Name => 'MultipleExposureMode',
8399             RawConv => '$$self{MultipleExposureMode} = $val',
8400             PrintConv => {
8401             0 => 'Off',
8402             1 => 'On (Series)',
8403             2 => 'On',
8404             },
8405             },
8406             142 => {Name => 'MultiExposureShots', Condition => '$$self{MultipleExposureMode} != 0' }, #range 2-9
8407             188 => {
8408             Name => 'Intervals',
8409             Format => 'int32u',
8410             RawConv => '$$self{IntervalShootingIntervals} = $val',
8411             Condition => '$$self{IntervalShooting} > 0',
8412             },
8413             192 => {
8414             Name => 'ShotsPerInterval',
8415             Format => 'int32u',
8416             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
8417             Condition => '$$self{IntervalShooting} > 0',
8418             },
8419             #220 NEFCompression 0=> 'Lossless' 1=> 'High Efficiency*' 4=> 'High Efficientcy'
8420             232 => {
8421             Name => 'FocusShiftNumberShots', #1-300
8422             RawConv => '$$self{FocusShiftNumberShots} = $val',
8423             Condition => '$$self{FocusShiftShooting} > 0',
8424             },
8425             236 => {
8426             Name => 'FocusShiftStepWidth', #1(Narrow) to 10 (Wide)
8427             Condition => '$$self{FocusShiftShooting} > 0',
8428             },
8429             240 => {
8430             Name => 'FocusShiftInterval',
8431             Condition => '$$self{FocusShiftShooting} > 0',
8432             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
8433             },
8434             244 => {
8435             Name => 'FocusShiftExposureLock',
8436             Unknown => 1,
8437             PrintConv => \%offOn,
8438             Condition => '$$self{FocusShiftShooting} > 0',
8439             },
8440             274 => {
8441             Name => 'PhotoShootingMenuBank',
8442             PrintConv => {
8443             0 => 'A',
8444             1 => 'B',
8445             2 => 'C',
8446             3 => 'D',
8447             },
8448             },
8449             276 => { Name => 'ExtendedMenuBanks', PrintConv => \%offOn, }, #single tag from both Photo & Video menus
8450             308 => {
8451             Name => 'PhotoShootingMenuBankImageArea',
8452             PrintConv => {
8453             0 => 'FX',
8454             1 => 'DX',
8455             4 => '16:9',
8456             8 => '1:1',
8457             },
8458             },
8459             #310 ImageQuality
8460             322 => { Name => 'AutoISO', PrintConv => \%offOn, },
8461             324 => {
8462             Name => 'ISOAutoHiLimit',
8463             Format => 'int16u',
8464             Unknown => 1,
8465             ValueConv => '($val-104)/8',
8466             ValueConvInv => '8 * ($val + 104)',
8467             PrintConv => \%iSOAutoHiLimitZ7,
8468             },
8469             326 => {
8470             Name => 'ISOAutoFlashLimit',
8471             Format => 'int16u',
8472             Unknown => 1,
8473             ValueConv => '($val-104)/8',
8474             ValueConvInv => '8 * ($val + 104)',
8475             PrintConv => \%iSOAutoHiLimitZ7,
8476             },
8477             #332 ISOAutoShutterTime - Auto setting 0=> 'Auto (Slowest)', 1 => 'Auto (Slower)', 2=> 'Auto', 3=> 'Auto (Faster)', 4=> 'Auto (Fastest)'
8478             334 => {
8479             Name => 'ISOAutoShutterTime', #shutter speed is 2 ** (-$val/24)
8480             ValueConv => '$val / 8',
8481             Format => 'int16s',
8482             PrintConv => {
8483             -15 => 'Auto', #z9 firmware 1.00 maps both 'Auto' and '30 s' to -15
8484             -12 => '15 s',
8485             -9 => '8 s',
8486             -6 => '4 s',
8487             -3 => '2 s',
8488             0 => '1 s',
8489             1 => '1/1.3 s',
8490             2 => '1/1.6 s',
8491             3 => '1/2 s',
8492             4 => '1/2.5 s',
8493             5 => '1/3 s',
8494             6 => '1/4 s',
8495             7 => '1/5 s',
8496             8 => '1/6 s',
8497             9 => '1/8 s',
8498             10 => '1/10 s',
8499             11 => '1/13 s',
8500             12 => '1/15 s',
8501             13 => '1/20 s',
8502             14 => '1/25 s',
8503             15 => '1/30 s',
8504             16 => '1/40 s',
8505             17 => '1/50 s',
8506             18 => '1/60 s',
8507             19 => '1/80 s',
8508             20 => '1/100 s',
8509             21 => '1/120 s',
8510             22 => '1/160 s',
8511             23 => '1/200 s',
8512             24 => '1/250 s',
8513             25 => '1/320 s',
8514             26 => '1/400 s',
8515             27 => '1/500 s',
8516             28 => '1/640 s',
8517             29 => '1/800 s',
8518             30 => '1/1000 s',
8519             31 => '1/1250 s',
8520             32 => '1/1600 s',
8521             33 => '1/2000 s',
8522             34 => '1/2500 s',
8523             35 => '1/3200 s',
8524             36 => '1/4000 s',
8525             37 => '1/5000 s',
8526             37.5 => '1/6000 s',
8527             38 => '1/6400 s',
8528             39 => '1/8000 s',
8529             40 => '1/10000 s',
8530             40.5 => '1/12000 s',
8531             41 => '1/13000 s',
8532             42 => '1/16000 s',
8533             },
8534             },
8535             #336 WhiteBalance
8536             #406 PictureControl
8537             #408 ColorSpace
8538             #410 ActiveD-Lighting
8539             #412 => { Name => 'NoiseReduction', PrintConv => \%offOn }, #Long Exposure Noise Reduction
8540             #414 HighISONoiseReduction
8541             #414 VignetteControl
8542             416 => { Name => 'MovieVignetteControl', PrintConv => \%offLowNormalHighZ7, Unknown => 1},
8543             418 => { Name => 'DiffractionCompensation', PrintConv => \%offOn }, #value can be set from both the Photo Shoot Menu and the Video Shooting Menu
8544             #419 AutoDistortionControl #value can be set from both the Photo Shoot Menu and the Video Shooting Menu
8545             420 => { Name => 'FlickerReductionShooting', PrintConv => \%offOn },
8546             #422 MeteringMode
8547             424 => {
8548             Name => 'FlashControlMode', # this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
8549             RawConv => '$$self{FlashControlMode} = $val',
8550             PrintConv => \%flashControlModeZ7,
8551             },
8552             426 => {
8553             Name => 'FlashMasterCompensation',
8554             Format => 'int8s',
8555             Unknown => 1,
8556             ValueConv => '$val/6',
8557             ValueConvInv => '6 * $val',
8558             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
8559             PrintConvInv => '$val',
8560             },
8561             430 => {
8562             Name => 'FlashGNDistance',
8563             Condition => '$$self{FlashControlMode} == 2',
8564             Unknown => 1,
8565             ValueConv => '$val + 3',
8566             PrintConv => \%flashGNDistance,
8567             },
8568             434 => {
8569             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)
8570             Condition => '$$self{FlashControlMode} >= 3',
8571             Unknown => 1,
8572             ValueConv => '2 ** (-$val/3)',
8573             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
8574             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
8575             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
8576             },
8577             #442 flash wirelss control 0=> 'Off' 1=> 'CMD'
8578             444 => { Name => 'FlashRemoteControl', PrintConv => \%flashRemoteControlZ7, Unknown => 1},
8579             456 => { Name => 'FlashWirelessOption', PrintConv => \%flashWirelessOptionZ7, Unknown => 1},
8580             #526 FocusMode
8581             528 => {
8582             Name => 'AFAreaMode',
8583             PrintConv => {
8584             1 => 'Single',
8585             2 => 'Dynamic',
8586             3 => 'Wide (S)',
8587             4 => 'Wide (L)',
8588             5 => '3D',
8589             6 => 'Auto',
8590             12 => 'Wide (C1)',
8591             13 => 'Wide (C2)',
8592             },
8593             },
8594             530 => { Name => 'VRMode', PrintConv => \%vRModeZ9},
8595             534 => {
8596             Name => 'BracketSet',
8597             RawConv => '$$self{BracketSet} = $val',
8598             PrintConv => {
8599             0 => 'AE/Flash',
8600             1 => 'AE',
8601             2 => 'Flash',
8602             3 => 'White Balance',
8603             4 => 'Active-D Lighting',
8604             },
8605             },
8606             536 => {
8607             Name => 'BracketProgram',
8608             Condition => '$$self{BracketSet} < 3',
8609             Notes => 'AE and/or Flash Bracketing',
8610             PrintConv => {
8611             0 => 'Disabled',
8612             2 => '2F',
8613             3 => '3F',
8614             4 => '4F',
8615             5 => '5F',
8616             7 => '7F',
8617             9 => '9F',
8618             },
8619             },
8620             538 => {
8621             Name => 'BracketIncrement',
8622             Condition => '$$self{BracketSet} < 3',
8623             Notes => 'AE and/or Flash Bracketing',
8624             PrintConv => {
8625             0 => '0.3',
8626             #1 => '0.5',
8627             2 => '0.7',
8628             3 => '1.0',
8629             4 => '2.0',
8630             5 => '3.0',
8631             },
8632             },
8633             #544 BracketProgram for ADL
8634             556 => {
8635             Name => 'SecondarySlotFunction',
8636             PrintConv => {
8637             0 => 'Overflow',
8638             1 => 'Backup',
8639             2 => 'NEF Primary + JPG Secondary',
8640             3 => 'JPG Primary + JPG Secondary',
8641             },
8642             },
8643             572 => { Name => 'DXCropAlert', PrintConv => \%offOn, },
8644             574 => { Name => 'SubjectDetection', PrintConv => \%subjectDetectionZ9},
8645             604 => {
8646             Name => 'MovieImageArea',
8647             Unknown => 1,
8648             Mask => 0x01, #without the mask 4 => 'FX' 5 => DX only the 2nd Z-series field encountered with a mask.
8649             PrintConv => {
8650             0 => 'FX',
8651             1 => 'DX',
8652             },
8653             },
8654             614 => {
8655             Name => 'MovieType',
8656             Unknown => 1,
8657             PrintConv => {
8658             1 => 'H.265 8-bit (MP4)',
8659             2 => 'H.265 8-bit (MOV)',
8660             3 => 'H.265 10-bit (MOV)',
8661             4 => 'ProRes 422 HQ 10-bit (MOV)',
8662             5 => 'ProRes RAW HQ 12-bit (MOV)',
8663             6 => 'NRAW 12-bit (NEV)'
8664             },
8665             },
8666             616 => {
8667             Name => 'MovieISOAutoHiLimit',
8668             Format => 'int16u',
8669             Unknown => 1,
8670             ValueConv => '($val-104)/8',
8671             ValueConvInv => '8 * ($val + 104)',
8672             PrintConv => \%iSOAutoHiLimitZ7,
8673             },
8674             618 => { Name => 'MovieISOAutoControlManualMode', PrintConv => \%offOn, Unknown => 1},
8675             620 => {
8676             Name => 'MovieISOAutoManualMode',
8677             Format => 'int16u',
8678             Unknown => 1,
8679             ValueConv => '($val-104)/8',
8680             ValueConvInv => '8 * ($val + 104)',
8681             PrintConv => \%iSOAutoHiLimitZ7,
8682             },
8683             696 => { Name => 'MovieActiveD-Lighting', PrintConv => \%activeDLightingZ7, Unknown => 1},
8684             698 => { Name => 'MovieHighISONoiseReduction', PrintConv => \%offLowNormalHighZ7, Unknown => 1},
8685             704 => {
8686             Name => 'MovieFlickerReduction',
8687             PrintConv => {
8688             0 => 'Auto',
8689             1 => '50Hz',
8690             2 => '60Hz',
8691             },
8692             },
8693             706 => { Name => 'MovieMeteringMode', PrintConv => \%meteringModeZ7, , Unknown => 1},
8694             708 => { Name => 'MovieFocusMode', PrintConv => \%focusModeZ7, Unknown => 1},
8695             710 => {
8696             Name => 'MovieAFAreaMode',
8697             PrintConv => {
8698             1 => 'Single',
8699             3 => 'Wide (S)',
8700             4 => 'Wide (L)',
8701             6 => 'Auto',
8702             11 => 'Subject Tracking',
8703             },
8704             },
8705             712 => { Name => 'MovieVRMode', PrintConv => \%vRModeZ9, Unknown => 1},
8706             716 => { Name => 'MovieElectronicVR', PrintConv => \%offOn, Unknown => 1 }, #distinct from MoveieVRMode
8707             718 => { Name => 'MovieSoundRecording', PrintConv => { 0 => 'Off', 1 => 'On', 2 => 'On' }, Unknown => 1 }, #not sure why the unusal mapping with 2 => 'On'
8708             720 => { Name => 'MicrophoneSensitivity', Unknown => 1}, #1-20
8709             722 => { Name => 'MicrophoneAttenuator', PrintConv => \%offOn, Unknown => 1 }, #distinct from MoveieVRMode
8710             724 => { Name => 'MicrophoneFrequencyResponse', PrintConv => { 0 => 'Wide Range', 1 => 'Vocal Range' }, Unknown => 1 },
8711             726 => { Name => 'WindNoiseReduction', PrintConv => \%offOn, Unknown => 1 },
8712             748 => {
8713             Name => 'MovieToneMap',
8714             Unknown => 1,
8715             PrintConv => {
8716             0 => 'SDR',
8717             1 => 'HLG',
8718             2 => 'N-Log',
8719             },
8720             },
8721             754 => { Name => 'MovieFrameSize', PrintConv => \%movieFrameSizeZ9, Unknown => 1},
8722             756 => { Name => 'MovieFrameRate', PrintConv => \%movieFrameRateZ7, Unknown => 1},
8723             762 => { Name => 'MicrophoneJackPower', PrintConv => \%offOn, Unknown => 1 },
8724             763 => { Name => 'MovieDXCropAlert', PrintConv => \%offOn, Unknown => 1 },
8725             764 => { Name => 'MovieSubjectDetection', PrintConv => \%subjectDetectionZ9, Unknown => 1},
8726             799 => {
8727             Name => 'CustomSettingsZ9',
8728             Format => 'undef[608]',
8729             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsZ9' },
8730             },
8731             1426 => {
8732             Name => 'Language',
8733             Unknown => 1,
8734             PrintConv => {
8735             4 => 'English',
8736             5 => 'Spanish',
8737             7 => 'French',
8738             },
8739             },
8740             1428 => {
8741             Name => 'TimeZone',
8742             PrintConv => {
8743             5 => '+09:00 (Tokyo)',
8744             6 => '+08:00 (Beijing, Honk Kong, Sinapore)',
8745             10 => '+05:45 (Kathmandu)',
8746             11 => '+05:30 (New Dehli)',
8747             16 => '+03:00 (Moscow, Nairobi)',
8748             15 => '+02:00 (Athens)',
8749             16 => '+01:00 (Madrid, Paris, Berlin)',
8750             17 => '+02:00 (Athens, Helsinki)',
8751             18 => '+00:00 (London)',
8752             19 => '+00:00', #PH (unknown city)
8753             22 => '-03:00 (Buenos Aires, Sao Paulo)',
8754             24 => '-04:00 (Manaus, Caracas)',
8755             25 => '-05:00 (New York, Toronto, Lima)',
8756             26 => '-06:00 (Chicago, Mexico City)',
8757             27 => '-07:00 (Denver)',
8758             28 => '-08:00 (Los Angeles, Vancouver)',
8759             29 => '-09:00 (Anchorage)',
8760             30 => '-10:00 (Hawaii)',
8761             },
8762             },
8763             1434 => {Name => 'MonitorBrightness', ValueConv => '$val - 5', Unknown => 1}, # settings: -5 to +5
8764             1456 => { Name => 'AFFineTune', PrintConv => \%offOn, Unknown => 1 },
8765             1552 => {
8766             Name => 'HDMIOutputResolution',
8767             PrintConv => {
8768             0 => 'Auto',
8769             1 => '4320p',
8770             2 => '2160p',
8771             3 => '1080p',
8772             #4 => '1080i',
8773             5 => '720p',
8774             #6 => '576p',
8775             #7 => '480p',
8776             },
8777             },
8778             1565 => { Name => 'SetClockFromLocationData', PrintConv => \%offOn, Unknown => 1 },
8779             1572 => { Name => 'AirplaneMode', PrintConv => \%offOn, Unknown => 1 },
8780             1573 => { Name => 'EmptySlotRelease', PrintConv => { 0 => 'Disable Release', 1 => 'Enable Release' }, Unknown => 1 },
8781             1608 => { Name => 'EnergySavingMode', PrintConv =>\%offOn, Unknown => 1 },
8782             1632 => { Name => 'RecordLocationData', PrintConv => \%offOn, Unknown => 1 },
8783             1636 => { Name => 'USBPowerDelivery', PrintConv => \%offOn, Unknown => 1 },
8784             1645 => { Name => 'SensorShield', PrintConv => { 0 => 'Stays Open', 1 => 'Closes' }, Unknown => 1 },
8785             );
8786              
8787             # Flash information (ref JD)
8788             %Image::ExifTool::Nikon::FlashInfo0100 = (
8789             %binaryDataAttrs,
8790             DATAMEMBER => [ 9.2, 15, 16 ],
8791             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8792             NOTES => q{
8793             These tags are used by the D2H, D2Hs, D2X, D2Xs, D50, D70, D70s, D80 and
8794             D200.
8795             },
8796             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
8797             0 => {
8798             Name => 'FlashInfoVersion',
8799             Format => 'string[4]',
8800             Writable => 0,
8801             },
8802             4 => { #PH
8803             Name => 'FlashSource',
8804             PrintConv => {
8805             0 => 'None',
8806             1 => 'External',
8807             2 => 'Internal',
8808             },
8809             },
8810             # 5 - values: 46,48,50,54,78
8811             6 => {
8812             Format => 'int8u[2]',
8813             Name => 'ExternalFlashFirmware',
8814             SeparateTable => 'FlashFirmware',
8815             PrintConv => \%flashFirmware,
8816             },
8817             8 => {
8818             Name => 'ExternalFlashFlags',
8819             PrintConv => { 0 => '(none)',
8820             BITMASK => {
8821             0 => 'Fired', #28
8822             2 => 'Bounce Flash', #PH
8823             4 => 'Wide Flash Adapter',
8824             5 => 'Dome Diffuser', #28
8825             },
8826             },
8827             },
8828             9.1 => {
8829             Name => 'FlashCommanderMode',
8830             Mask => 0x80,
8831             PrintConv => { 0 => 'Off', 1 => 'On' },
8832             },
8833             9.2 => {
8834             Name => 'FlashControlMode',
8835             Mask => 0x7f,
8836             DataMember => 'FlashControlMode',
8837             RawConv => '$$self{FlashControlMode} = $val',
8838             PrintConv => \%flashControlMode,
8839             SeparateTable => 'FlashControlMode',
8840             },
8841             10 => [
8842             {
8843             Name => 'FlashOutput',
8844             Condition => '$$self{FlashControlMode} >= 0x06',
8845             ValueConv => '2 ** (-$val/6)',
8846             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
8847             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
8848             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
8849             },
8850             {
8851             Name => 'FlashCompensation',
8852             Format => 'int8s',
8853             Priority => 0,
8854             ValueConv => '-$val/6',
8855             ValueConvInv => '-6 * $val',
8856             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
8857             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
8858             },
8859             ],
8860             11 => {
8861             Name => 'FlashFocalLength',
8862             RawConv => '$val ? $val : undef',
8863             PrintConv => '"$val mm"',
8864             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
8865             },
8866             12 => {
8867             Name => 'RepeatingFlashRate',
8868             RawConv => '$val ? $val : undef',
8869             PrintConv => '"$val Hz"',
8870             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
8871             },
8872             13 => {
8873             Name => 'RepeatingFlashCount',
8874             RawConv => '$val ? $val : undef',
8875             },
8876             14 => { #PH
8877             Name => 'FlashGNDistance',
8878             SeparateTable => 1,
8879             PrintConv => \%flashGNDistance,
8880             },
8881             15 => {
8882             Name => 'FlashGroupAControlMode',
8883             Mask => 0x0f,
8884             DataMember => 'FlashGroupAControlMode',
8885             RawConv => '$$self{FlashGroupAControlMode} = $val',
8886             PrintConv => \%flashControlMode,
8887             SeparateTable => 'FlashControlMode',
8888             },
8889             16 => {
8890             Name => 'FlashGroupBControlMode',
8891             Mask => 0x0f,
8892             DataMember => 'FlashGroupBControlMode',
8893             RawConv => '$$self{FlashGroupBControlMode} = $val',
8894             PrintConv => \%flashControlMode,
8895             SeparateTable => 'FlashControlMode',
8896             },
8897             17 => [
8898             {
8899             Name => 'FlashGroupAOutput',
8900             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
8901             ValueConv => '2 ** (-$val/6)',
8902             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
8903             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
8904             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
8905             },
8906             {
8907             Name => 'FlashGroupACompensation',
8908             Format => 'int8s',
8909             ValueConv => '-$val/6',
8910             ValueConvInv => '-6 * $val',
8911             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
8912             PrintConvInv => '$val',
8913             },
8914             ],
8915             18 => [
8916             {
8917             Name => 'FlashGroupBOutput',
8918             Condition => '$$self{FlashGroupBControlMode} >= 0x06',
8919             ValueConv => '2 ** (-$val/6)',
8920             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
8921             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
8922             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
8923             },
8924             {
8925             Name => 'FlashGroupBCompensation',
8926             Format => 'int8s',
8927             ValueConv => '-$val/6',
8928             ValueConvInv => '-6 * $val',
8929             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
8930             PrintConvInv => '$val',
8931             },
8932             ],
8933             );
8934              
8935             # Flash information for D40, D40x, D3 and D300 (ref JD)
8936             %Image::ExifTool::Nikon::FlashInfo0102 = (
8937             %binaryDataAttrs,
8938             DATAMEMBER => [ 9.2, 16.1, 17.1, 17.2 ],
8939             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8940             NOTES => q{
8941             These tags are used by the D3 (firmware 1.x), D40, D40X, D60 and D300
8942             (firmware 1.00).
8943             },
8944             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
8945             0 => {
8946             Name => 'FlashInfoVersion',
8947             Format => 'string[4]',
8948             Writable => 0,
8949             },
8950             4 => { #PH
8951             Name => 'FlashSource',
8952             PrintConv => {
8953             0 => 'None',
8954             1 => 'External',
8955             2 => 'Internal',
8956             },
8957             },
8958             # 5 - values: 46,48,50,54,78
8959             6 => {
8960             Format => 'int8u[2]',
8961             Name => 'ExternalFlashFirmware',
8962             SeparateTable => 'FlashFirmware',
8963             PrintConv => \%flashFirmware,
8964             },
8965             8 => {
8966             Name => 'ExternalFlashFlags',
8967             PrintConv => { BITMASK => {
8968             0 => 'Fired', #28
8969             2 => 'Bounce Flash', #PH
8970             4 => 'Wide Flash Adapter',
8971             5 => 'Dome Diffuser', #28
8972             }},
8973             },
8974             9.1 => {
8975             Name => 'FlashCommanderMode',
8976             Mask => 0x80,
8977             PrintConv => { 0 => 'Off', 1 => 'On' },
8978             },
8979             9.2 => {
8980             Name => 'FlashControlMode',
8981             Mask => 0x7f,
8982             DataMember => 'FlashControlMode',
8983             RawConv => '$$self{FlashControlMode} = $val',
8984             PrintConv => \%flashControlMode,
8985             SeparateTable => 'FlashControlMode',
8986             },
8987             10 => [
8988             {
8989             Name => 'FlashOutput',
8990             Condition => '$$self{FlashControlMode} >= 0x06',
8991             ValueConv => '2 ** (-$val/6)',
8992             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
8993             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
8994             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
8995             },
8996             {
8997             Name => 'FlashCompensation',
8998             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
8999             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
9000             Format => 'int8s',
9001             Priority => 0,
9002             ValueConv => '-$val/6',
9003             ValueConvInv => '-6 * $val',
9004             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9005             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9006             },
9007             ],
9008             12 => {
9009             Name => 'FlashFocalLength',
9010             RawConv => '$val ? $val : undef',
9011             PrintConv => '"$val mm"',
9012             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9013             },
9014             13 => {
9015             Name => 'RepeatingFlashRate',
9016             RawConv => '$val ? $val : undef',
9017             PrintConv => '"$val Hz"',
9018             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9019             },
9020             14 => {
9021             Name => 'RepeatingFlashCount',
9022             RawConv => '$val ? $val : undef',
9023             },
9024             15 => { #PH
9025             Name => 'FlashGNDistance',
9026             SeparateTable => 1,
9027             PrintConv => \%flashGNDistance,
9028             },
9029             16.1 => {
9030             Name => 'FlashGroupAControlMode',
9031             Mask => 0x0f,
9032             Notes => 'note: group A tags may apply to the built-in flash settings for some models',
9033             DataMember => 'FlashGroupAControlMode',
9034             RawConv => '$$self{FlashGroupAControlMode} = $val',
9035             PrintConv => \%flashControlMode,
9036             SeparateTable => 'FlashControlMode',
9037             },
9038             17.1 => {
9039             Name => 'FlashGroupBControlMode',
9040             Mask => 0xf0,
9041             Notes => 'note: group B tags may apply to group A settings for some models',
9042             DataMember => 'FlashGroupBControlMode',
9043             RawConv => '$$self{FlashGroupBControlMode} = $val',
9044             PrintConv => \%flashControlMode,
9045             SeparateTable => 'FlashControlMode',
9046             },
9047             17.2 => { #PH
9048             Name => 'FlashGroupCControlMode',
9049             Mask => 0x0f,
9050             Notes => 'note: group C tags may apply to group B settings for some models',
9051             DataMember => 'FlashGroupCControlMode',
9052             RawConv => '$$self{FlashGroupCControlMode} = $val',
9053             PrintConv => \%flashControlMode,
9054             SeparateTable => 'FlashControlMode',
9055             },
9056             18 => [
9057             {
9058             Name => 'FlashGroupAOutput',
9059             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
9060             ValueConv => '2 ** (-$val/6)',
9061             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9062             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9063             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9064             },
9065             {
9066             Name => 'FlashGroupACompensation',
9067             Format => 'int8s',
9068             ValueConv => '-$val/6',
9069             ValueConvInv => '-6 * $val',
9070             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9071             PrintConvInv => '$val',
9072             },
9073             ],
9074             19 => [
9075             {
9076             Name => 'FlashGroupBOutput',
9077             Condition => '$$self{FlashGroupBControlMode} >= 0x60',
9078             ValueConv => '2 ** (-$val/6)',
9079             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9080             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9081             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9082             },
9083             {
9084             Name => 'FlashGroupBCompensation',
9085             Format => 'int8s',
9086             ValueConv => '-$val/6',
9087             ValueConvInv => '-6 * $val',
9088             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9089             PrintConvInv => '$val',
9090             },
9091             ],
9092             20 => [ #PH
9093             {
9094             Name => 'FlashGroupCOutput',
9095             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
9096             ValueConv => '2 ** (-$val/6)',
9097             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9098             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9099             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9100             },
9101             {
9102             Name => 'FlashGroupCCompensation',
9103             Format => 'int8s',
9104             ValueConv => '-$val/6',
9105             ValueConvInv => '-6 * $val',
9106             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9107             PrintConvInv => '$val',
9108             },
9109             ],
9110             );
9111              
9112             # Flash information (ref JD)
9113             %Image::ExifTool::Nikon::FlashInfo0100 = (
9114             %binaryDataAttrs,
9115             DATAMEMBER => [ 9.2, 15, 16 ],
9116             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9117             NOTES => q{
9118             These tags are used by the D2H, D2Hs, D2X, D2Xs, D50, D70, D70s, D80 and
9119             D200.
9120             },
9121             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
9122             0 => {
9123             Name => 'FlashInfoVersion',
9124             Format => 'string[4]',
9125             Writable => 0,
9126             },
9127             4 => { #PH
9128             Name => 'FlashSource',
9129             PrintConv => {
9130             0 => 'None',
9131             1 => 'External',
9132             2 => 'Internal',
9133             },
9134             },
9135             # 5 - values: 46,48,50,54,78
9136             6 => {
9137             Format => 'int8u[2]',
9138             Name => 'ExternalFlashFirmware',
9139             SeparateTable => 'FlashFirmware',
9140             PrintConv => \%flashFirmware,
9141             },
9142             8 => {
9143             Name => 'ExternalFlashFlags',
9144             PrintConv => { 0 => '(none)',
9145             BITMASK => {
9146             0 => 'Fired', #28
9147             2 => 'Bounce Flash', #PH
9148             4 => 'Wide Flash Adapter',
9149             5 => 'Dome Diffuser', #28
9150             },
9151             },
9152             },
9153             9.1 => {
9154             Name => 'FlashCommanderMode',
9155             Mask => 0x80,
9156             PrintConv => { 0 => 'Off', 1 => 'On' },
9157             },
9158             9.2 => {
9159             Name => 'FlashControlMode',
9160             Mask => 0x7f,
9161             DataMember => 'FlashControlMode',
9162             RawConv => '$$self{FlashControlMode} = $val',
9163             PrintConv => \%flashControlMode,
9164             SeparateTable => 'FlashControlMode',
9165             },
9166             10 => [
9167             {
9168             Name => 'FlashOutput',
9169             Condition => '$$self{FlashControlMode} >= 0x06',
9170             ValueConv => '2 ** (-$val/6)',
9171             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9172             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9173             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9174             },
9175             {
9176             Name => 'FlashCompensation',
9177             Format => 'int8s',
9178             Priority => 0,
9179             ValueConv => '-$val/6',
9180             ValueConvInv => '-6 * $val',
9181             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9182             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9183             },
9184             ],
9185             11 => {
9186             Name => 'FlashFocalLength',
9187             RawConv => '$val ? $val : undef',
9188             PrintConv => '"$val mm"',
9189             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9190             },
9191             12 => {
9192             Name => 'RepeatingFlashRate',
9193             RawConv => '$val ? $val : undef',
9194             PrintConv => '"$val Hz"',
9195             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9196             },
9197             13 => {
9198             Name => 'RepeatingFlashCount',
9199             RawConv => '$val ? $val : undef',
9200             },
9201             14 => { #PH
9202             Name => 'FlashGNDistance',
9203             SeparateTable => 1,
9204             PrintConv => \%flashGNDistance,
9205             },
9206             15 => {
9207             Name => 'FlashGroupAControlMode',
9208             Mask => 0x0f,
9209             DataMember => 'FlashGroupAControlMode',
9210             RawConv => '$$self{FlashGroupAControlMode} = $val',
9211             PrintConv => \%flashControlMode,
9212             SeparateTable => 'FlashControlMode',
9213             },
9214             16 => {
9215             Name => 'FlashGroupBControlMode',
9216             Mask => 0x0f,
9217             DataMember => 'FlashGroupBControlMode',
9218             RawConv => '$$self{FlashGroupBControlMode} = $val',
9219             PrintConv => \%flashControlMode,
9220             SeparateTable => 'FlashControlMode',
9221             },
9222             17 => [
9223             {
9224             Name => 'FlashGroupAOutput',
9225             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
9226             ValueConv => '2 ** (-$val/6)',
9227             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9228             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9229             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9230             },
9231             {
9232             Name => 'FlashGroupACompensation',
9233             Format => 'int8s',
9234             ValueConv => '-$val/6',
9235             ValueConvInv => '-6 * $val',
9236             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9237             PrintConvInv => '$val',
9238             },
9239             ],
9240             18 => [
9241             {
9242             Name => 'FlashGroupBOutput',
9243             Condition => '$$self{FlashGroupBControlMode} >= 0x06',
9244             ValueConv => '2 ** (-$val/6)',
9245             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9246             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9247             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9248             },
9249             {
9250             Name => 'FlashGroupBCompensation',
9251             Format => 'int8s',
9252             ValueConv => '-$val/6',
9253             ValueConvInv => '-6 * $val',
9254             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9255             PrintConvInv => '$val',
9256             },
9257             ],
9258             );
9259              
9260             # Flash information for D40, D40x, D3 and D300 (ref JD)
9261             %Image::ExifTool::Nikon::FlashInfo0102 = (
9262             %binaryDataAttrs,
9263             DATAMEMBER => [ 9.2, 16.1, 17.1, 17.2 ],
9264             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9265             NOTES => q{
9266             These tags are used by the D3 (firmware 1.x), D40, D40X, D60 and D300
9267             (firmware 1.00).
9268             },
9269             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
9270             0 => {
9271             Name => 'FlashInfoVersion',
9272             Format => 'string[4]',
9273             Writable => 0,
9274             },
9275             4 => { #PH
9276             Name => 'FlashSource',
9277             PrintConv => {
9278             0 => 'None',
9279             1 => 'External',
9280             2 => 'Internal',
9281             },
9282             },
9283             # 5 - values: 46,48,50,54,78
9284             6 => {
9285             Format => 'int8u[2]',
9286             Name => 'ExternalFlashFirmware',
9287             SeparateTable => 'FlashFirmware',
9288             PrintConv => \%flashFirmware,
9289             },
9290             8 => {
9291             Name => 'ExternalFlashFlags',
9292             PrintConv => { BITMASK => {
9293             0 => 'Fired', #28
9294             2 => 'Bounce Flash', #PH
9295             4 => 'Wide Flash Adapter',
9296             5 => 'Dome Diffuser', #28
9297             }},
9298             },
9299             9.1 => {
9300             Name => 'FlashCommanderMode',
9301             Mask => 0x80,
9302             PrintConv => { 0 => 'Off', 1 => 'On' },
9303             },
9304             9.2 => {
9305             Name => 'FlashControlMode',
9306             Mask => 0x7f,
9307             DataMember => 'FlashControlMode',
9308             RawConv => '$$self{FlashControlMode} = $val',
9309             PrintConv => \%flashControlMode,
9310             SeparateTable => 'FlashControlMode',
9311             },
9312             10 => [
9313             {
9314             Name => 'FlashOutput',
9315             Condition => '$$self{FlashControlMode} >= 0x06',
9316             ValueConv => '2 ** (-$val/6)',
9317             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9318             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9319             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9320             },
9321             {
9322             Name => 'FlashCompensation',
9323             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
9324             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
9325             Format => 'int8s',
9326             Priority => 0,
9327             ValueConv => '-$val/6',
9328             ValueConvInv => '-6 * $val',
9329             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9330             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9331             },
9332             ],
9333             12 => {
9334             Name => 'FlashFocalLength',
9335             RawConv => '$val ? $val : undef',
9336             PrintConv => '"$val mm"',
9337             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9338             },
9339             13 => {
9340             Name => 'RepeatingFlashRate',
9341             RawConv => '$val ? $val : undef',
9342             PrintConv => '"$val Hz"',
9343             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9344             },
9345             14 => {
9346             Name => 'RepeatingFlashCount',
9347             RawConv => '$val ? $val : undef',
9348             },
9349             15 => { #PH
9350             Name => 'FlashGNDistance',
9351             SeparateTable => 1,
9352             PrintConv => \%flashGNDistance,
9353             },
9354             16.1 => {
9355             Name => 'FlashGroupAControlMode',
9356             Mask => 0x0f,
9357             Notes => 'note: group A tags may apply to the built-in flash settings for some models',
9358             DataMember => 'FlashGroupAControlMode',
9359             RawConv => '$$self{FlashGroupAControlMode} = $val',
9360             PrintConv => \%flashControlMode,
9361             SeparateTable => 'FlashControlMode',
9362             },
9363             17.1 => {
9364             Name => 'FlashGroupBControlMode',
9365             Mask => 0xf0,
9366             Notes => 'note: group B tags may apply to group A settings for some models',
9367             DataMember => 'FlashGroupBControlMode',
9368             RawConv => '$$self{FlashGroupBControlMode} = $val',
9369             PrintConv => \%flashControlMode,
9370             SeparateTable => 'FlashControlMode',
9371             },
9372             17.2 => { #PH
9373             Name => 'FlashGroupCControlMode',
9374             Mask => 0x0f,
9375             Notes => 'note: group C tags may apply to group B settings for some models',
9376             DataMember => 'FlashGroupCControlMode',
9377             RawConv => '$$self{FlashGroupCControlMode} = $val',
9378             PrintConv => \%flashControlMode,
9379             SeparateTable => 'FlashControlMode',
9380             },
9381             18 => [
9382             {
9383             Name => 'FlashGroupAOutput',
9384             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
9385             ValueConv => '2 ** (-$val/6)',
9386             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9387             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9388             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9389             },
9390             {
9391             Name => 'FlashGroupACompensation',
9392             Format => 'int8s',
9393             ValueConv => '-$val/6',
9394             ValueConvInv => '-6 * $val',
9395             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9396             PrintConvInv => '$val',
9397             },
9398             ],
9399             19 => [
9400             {
9401             Name => 'FlashGroupBOutput',
9402             Condition => '$$self{FlashGroupBControlMode} >= 0x60',
9403             ValueConv => '2 ** (-$val/6)',
9404             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9405             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9406             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9407             },
9408             {
9409             Name => 'FlashGroupBCompensation',
9410             Format => 'int8s',
9411             ValueConv => '-$val/6',
9412             ValueConvInv => '-6 * $val',
9413             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9414             PrintConvInv => '$val',
9415             },
9416             ],
9417             20 => [ #PH
9418             {
9419             Name => 'FlashGroupCOutput',
9420             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
9421             ValueConv => '2 ** (-$val/6)',
9422             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9423             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9424             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9425             },
9426             {
9427             Name => 'FlashGroupCCompensation',
9428             Format => 'int8s',
9429             ValueConv => '-$val/6',
9430             ValueConvInv => '-6 * $val',
9431             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9432             PrintConvInv => '$val',
9433             },
9434             ],
9435             );
9436              
9437             # Flash information for D90 and D700 (ref PH)
9438             # - confirmed in detail for D800 (0105) - PH
9439             %Image::ExifTool::Nikon::FlashInfo0103 = (
9440             %binaryDataAttrs,
9441             DATAMEMBER => [ 9.2, 17.1, 18.1, 18.2 ],
9442             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9443             NOTES => q{
9444             These tags are used by the D3 (firmware 2.x), D3X, D3S, D4, D90, D300
9445             (firmware 1.10), D300S, D600, D700, D800, D3000, D3100, D3200, D5000, D5100,
9446             D5200, D7000.
9447             },
9448             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
9449             0 => {
9450             Name => 'FlashInfoVersion',
9451             Format => 'string[4]',
9452             Writable => 0,
9453             },
9454             4 => { #PH
9455             Name => 'FlashSource',
9456             PrintConv => {
9457             0 => 'None',
9458             1 => 'External',
9459             2 => 'Internal',
9460             },
9461             },
9462             # 5 - values: 46,48,50,54,78
9463             6 => {
9464             Format => 'int8u[2]',
9465             Name => 'ExternalFlashFirmware',
9466             SeparateTable => 'FlashFirmware',
9467             PrintConv => \%flashFirmware,
9468             },
9469             8 => {
9470             Name => 'ExternalFlashFlags',
9471             PrintConv => { BITMASK => {
9472             0 => 'Fired', #28
9473             2 => 'Bounce Flash', #PH
9474             4 => 'Wide Flash Adapter',
9475             5 => 'Dome Diffuser', #28
9476             }},
9477             },
9478             9.1 => {
9479             Name => 'FlashCommanderMode',
9480             Mask => 0x80,
9481             PrintConv => { 0 => 'Off', 1 => 'On' },
9482             },
9483             9.2 => {
9484             Name => 'FlashControlMode',
9485             Mask => 0x7f,
9486             DataMember => 'FlashControlMode',
9487             RawConv => '$$self{FlashControlMode} = $val',
9488             PrintConv => \%flashControlMode,
9489             SeparateTable => 'FlashControlMode',
9490             },
9491             10 => [
9492             {
9493             Name => 'FlashOutput',
9494             Condition => '$$self{FlashControlMode} >= 0x06',
9495             ValueConv => '2 ** (-$val/6)',
9496             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9497             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9498             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9499             },
9500             {
9501             Name => 'FlashCompensation',
9502             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
9503             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
9504             Format => 'int8s',
9505             Priority => 0,
9506             ValueConv => '-$val/6',
9507             ValueConvInv => '-6 * $val',
9508             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9509             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9510             },
9511             ],
9512             12 => { #JD
9513             Name => 'FlashFocalLength',
9514             RawConv => '($val and $val != 255) ? $val : undef',
9515             PrintConv => '"$val mm"',
9516             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9517             },
9518             13 => { #JD
9519             Name => 'RepeatingFlashRate',
9520             RawConv => '($val and $val != 255) ? $val : undef',
9521             PrintConv => '"$val Hz"',
9522             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9523             },
9524             14 => { #JD
9525             Name => 'RepeatingFlashCount',
9526             RawConv => '($val and $val != 255) ? $val : undef',
9527             },
9528             15 => { #28
9529             Name => 'FlashGNDistance',
9530             SeparateTable => 1,
9531             PrintConv => \%flashGNDistance,
9532             },
9533             16 => { #28
9534             Name => 'FlashColorFilter',
9535             SeparateTable => 1,
9536             PrintConv => \%flashColorFilter,
9537             },
9538             17.1 => {
9539             Name => 'FlashGroupAControlMode',
9540             Mask => 0x0f,
9541             Notes => 'note: group A tags may apply to the built-in flash settings for some models',
9542             DataMember => 'FlashGroupAControlMode',
9543             RawConv => '$$self{FlashGroupAControlMode} = $val',
9544             PrintConv => \%flashControlMode,
9545             SeparateTable => 'FlashControlMode',
9546             },
9547             18.1 => {
9548             Name => 'FlashGroupBControlMode',
9549             Mask => 0xf0,
9550             Notes => 'note: group B tags may apply to group A settings for some models',
9551             DataMember => 'FlashGroupBControlMode',
9552             RawConv => '$$self{FlashGroupBControlMode} = $val',
9553             PrintConv => \%flashControlMode,
9554             SeparateTable => 'FlashControlMode',
9555             },
9556             18.2 => { #PH
9557             Name => 'FlashGroupCControlMode',
9558             Mask => 0x0f,
9559             Notes => 'note: group C tags may apply to group B settings for some models',
9560             DataMember => 'FlashGroupCControlMode',
9561             RawConv => '$$self{FlashGroupCControlMode} = $val',
9562             PrintConv => \%flashControlMode,
9563             SeparateTable => 'FlashControlMode',
9564             },
9565             0x13 => [
9566             {
9567             Name => 'FlashGroupAOutput',
9568             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
9569             ValueConv => '2 ** (-$val/6)',
9570             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9571             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9572             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9573             },
9574             {
9575             Name => 'FlashGroupACompensation',
9576             Format => 'int8s',
9577             ValueConv => '-$val/6',
9578             ValueConvInv => '-6 * $val',
9579             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9580             PrintConvInv => '$val',
9581             },
9582             ],
9583             0x14 => [
9584             {
9585             Name => 'FlashGroupBOutput',
9586             Condition => '$$self{FlashGroupBControlMode} >= 0x60',
9587             ValueConv => '2 ** (-$val/6)',
9588             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9589             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9590             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9591             },
9592             {
9593             Name => 'FlashGroupBCompensation',
9594             Format => 'int8s',
9595             ValueConv => '-$val/6',
9596             ValueConvInv => '-6 * $val',
9597             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9598             PrintConvInv => '$val',
9599             },
9600             ],
9601             0x15 => [ #PH
9602             {
9603             Name => 'FlashGroupCOutput',
9604             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
9605             ValueConv => '2 ** (-$val/6)',
9606             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9607             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9608             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9609             },
9610             {
9611             Name => 'FlashGroupCCompensation',
9612             Format => 'int8s',
9613             ValueConv => '-$val/6',
9614             ValueConvInv => '-6 * $val',
9615             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9616             PrintConvInv => '$val',
9617             },
9618             ],
9619             0x1b => { #PH
9620             Name => 'ExternalFlashCompensation',
9621             Format => 'int8s',
9622             Priority => 0,
9623             ValueConv => '-$val/6',
9624             ValueConvInv => '-6 * $val',
9625             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9626             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9627             },
9628             0x1d => { #PH
9629             Name => 'FlashExposureComp3',
9630             Format => 'int8s',
9631             # (does not include the built-in compensation for FlashType "Built-in,TTL&Comdr.")
9632             Notes => 'does not include the effect of flash bracketing',
9633             Priority => 0,
9634             ValueConv => '-$val/6',
9635             ValueConvInv => '-6 * $val',
9636             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9637             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9638             },
9639             0x27 => { #PH (same as ShotInfoD800 0x4d2 but also valid for repeating flash)
9640             Name => 'FlashExposureComp4',
9641             Format => 'int8s',
9642             Notes => 'includes the effect of flash bracketing. Valid for repeating flash',
9643             Priority => 0,
9644             ValueConv => '-$val/6',
9645             ValueConvInv => '-6 * $val',
9646             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9647             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9648             },
9649             # 0x2b - related to flash power (PH, D800, 96=full,62=1/4,2=1/128)
9650             );
9651              
9652             # Flash information for the D7100 (ref PH)
9653             # (this is VERY similar to FlashInfo0107, but there are a few differences that
9654             # would need to be resolved if these two definitions were to be combined)
9655             %Image::ExifTool::Nikon::FlashInfo0106 = (
9656             %binaryDataAttrs,
9657             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9658             DATAMEMBER => [ 9.2, 17.1, 18.1, 18.2 ],
9659             NOTES => 'These tags are used by the Df, D610, D3300, D5300, D7100 and Coolpix A.',
9660             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
9661             0 => {
9662             Name => 'FlashInfoVersion',
9663             Format => 'string[4]',
9664             Writable => 0,
9665             },
9666             4 => {
9667             Name => 'FlashSource',
9668             PrintConv => {
9669             0 => 'None',
9670             1 => 'External',
9671             2 => 'Internal',
9672             },
9673             },
9674             6 => {
9675             Format => 'int8u[2]',
9676             Name => 'ExternalFlashFirmware',
9677             SeparateTable => 'FlashFirmware',
9678             PrintConv => \%flashFirmware,
9679             },
9680             8 => {
9681             Name => 'ExternalFlashFlags',
9682             PrintConv => { BITMASK => {
9683             0 => 'Fired',
9684             2 => 'Bounce Flash',
9685             4 => 'Wide Flash Adapter',
9686             5 => 'Dome Diffuser', # (NC, not true for the SB-910 anyway)
9687             # 7 - ? (set for SB-910 when an advanced option is used, eg. diff pattern)
9688             }},
9689             },
9690             9.1 => { # (NC)
9691             Name => 'FlashCommanderMode',
9692             Mask => 0x80,
9693             PrintConv => { 0 => 'Off', 1 => 'On' },
9694             },
9695             9.2 => {
9696             Name => 'FlashControlMode',
9697             Mask => 0x7f,
9698             DataMember => 'FlashControlMode',
9699             RawConv => '$$self{FlashControlMode} = $val',
9700             PrintConv => \%flashControlMode,
9701             SeparateTable => 'FlashControlMode',
9702             },
9703             # 10 - similar to 0x27 but zero sometimes when I don't think it should be
9704             12 => {
9705             Name => 'FlashFocalLength',
9706             Notes => 'only valid if flash pattern is "Standard Illumination"',
9707             RawConv => '($val and $val != 255) ? $val : undef',
9708             PrintConv => '"$val mm"',
9709             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9710             },
9711             13 => {
9712             Name => 'RepeatingFlashRate',
9713             RawConv => '($val and $val != 255) ? $val : undef',
9714             PrintConv => '"$val Hz"',
9715             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9716             },
9717             14 => {
9718             Name => 'RepeatingFlashCount',
9719             RawConv => '($val and $val != 255) ? $val : undef',
9720             },
9721             15 => { # (NC)
9722             Name => 'FlashGNDistance',
9723             SeparateTable => 1,
9724             PrintConv => \%flashGNDistance,
9725             },
9726             16 => {
9727             Name => 'FlashColorFilter',
9728             SeparateTable => 1,
9729             PrintConv => \%flashColorFilter,
9730             },
9731             17.1 => {
9732             Name => 'FlashGroupAControlMode',
9733             Mask => 0x0f,
9734             DataMember => 'FlashGroupAControlMode',
9735             RawConv => '$$self{FlashGroupAControlMode} = $val',
9736             PrintConv => \%flashControlMode,
9737             SeparateTable => 'FlashControlMode',
9738             },
9739             18.1 => {
9740             Name => 'FlashGroupBControlMode',
9741             Mask => 0xf0,
9742             DataMember => 'FlashGroupBControlMode',
9743             RawConv => '$$self{FlashGroupBControlMode} = $val',
9744             PrintConv => \%flashControlMode,
9745             SeparateTable => 'FlashControlMode',
9746             },
9747             18.2 => {
9748             Name => 'FlashGroupCControlMode',
9749             Mask => 0x0f,
9750             DataMember => 'FlashGroupCControlMode',
9751             RawConv => '$$self{FlashGroupCControlMode} = $val',
9752             PrintConv => \%flashControlMode,
9753             SeparateTable => 'FlashControlMode',
9754             },
9755             # 0x13 - same as 0x28 but not zero when flash group A is Off
9756             # 0x14 - same as 0x29 but not zero when flash group B is Off
9757             # 0x15 - same as 0x2a but not zero when flash group B is Off
9758             # 0x1a - changes with illumination pattern (0=normal,1=narrow,2=wide), but other values seen
9759             # 0x26 - changes when diffuser is used
9760             0x27 => [
9761             {
9762             Name => 'FlashOutput',
9763             Condition => '$$self{FlashControlMode} >= 0x06',
9764             ValueConv => '2 ** (-$val/6)',
9765             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9766             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9767             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9768             },
9769             {
9770             Name => 'FlashCompensation',
9771             Format => 'int8s',
9772             Priority => 0,
9773             ValueConv => '-$val/6',
9774             ValueConvInv => '-6 * $val',
9775             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9776             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9777             },
9778             ],
9779             0x28 => [
9780             {
9781             Name => 'FlashGroupAOutput',
9782             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
9783             ValueConv => '2 ** (-$val/6)',
9784             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9785             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9786             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9787             },
9788             {
9789             Name => 'FlashGroupACompensation',
9790             Format => 'int8s',
9791             ValueConv => '-$val/6',
9792             ValueConvInv => '-6 * $val',
9793             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9794             PrintConvInv => '$val',
9795             },
9796             ],
9797             0x29 => [
9798             {
9799             Name => 'FlashGroupBOutput',
9800             Condition => '$$self{FlashGroupBControlMode} >= 0x60',
9801             ValueConv => '2 ** (-$val/6)',
9802             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9803             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9804             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9805             },
9806             {
9807             Name => 'FlashGroupBCompensation',
9808             Format => 'int8s',
9809             ValueConv => '-$val/6',
9810             ValueConvInv => '-6 * $val',
9811             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9812             PrintConvInv => '$val',
9813             },
9814             ],
9815             0x2a => [
9816             {
9817             Name => 'FlashGroupCOutput',
9818             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
9819             ValueConv => '2 ** (-$val/6)',
9820             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9821             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9822             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9823             },
9824             {
9825             Name => 'FlashGroupCCompensation',
9826             Format => 'int8s',
9827             ValueConv => '-$val/6',
9828             ValueConvInv => '-6 * $val',
9829             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9830             PrintConvInv => '$val',
9831             },
9832             ],
9833             );
9834              
9835             # Flash information for the D4S/D750/D810/D5500/D7200 (0107)
9836             # and D5/D500/D850/D3400 (0108) (ref 28)
9837             %Image::ExifTool::Nikon::FlashInfo0107 = (
9838             %binaryDataAttrs,
9839             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9840             DATAMEMBER => [ 17.1, 18.1, 18.2 ],
9841             NOTES => q{
9842             These tags are used by the D4S, D750, D810, D5500, D7200 (FlashInfoVersion
9843             0107) and the D5, D500, D850 and D3400 (FlashInfoVersion 0108).
9844             },
9845             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
9846             0 => {
9847             Name => 'FlashInfoVersion',
9848             Format => 'string[4]',
9849             Writable => 0,
9850             },
9851             4 => {
9852             Name => 'FlashSource',
9853             PrintConv => {
9854             0 => 'None',
9855             1 => 'External',
9856             2 => 'Internal',
9857             },
9858             },
9859             6 => {
9860             Format => 'int8u[2]',
9861             Name => 'ExternalFlashFirmware',
9862             SeparateTable => 'FlashFirmware',
9863             PrintConv => \%flashFirmware,
9864             },
9865             8.1 => {
9866             Name => 'ExternalFlashZoomOverride',
9867             Mask => 0x80,
9868             Notes => 'indicates that the user has overridden the flash zoom distance',
9869             PrintConv => { 0 => 'No', 1 => 'Yes' },
9870             },
9871             8.2 => {
9872             Name => 'ExternalFlashStatus',
9873             Mask => 0x01,
9874             PrintConv => {
9875             0 => 'Flash Not Attached',
9876             1 => 'Flash Attached',
9877             },
9878             },
9879             9.1 => {
9880             Name => 'ExternalFlashReadyState',
9881             Mask => 0x07,
9882             PrintConv => {
9883             0 => 'n/a',
9884             1 => 'Ready',
9885             6 => 'Not Ready',
9886             },
9887             },
9888             10 => {
9889             Name => 'FlashCompensation',
9890             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
9891             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
9892             Format => 'int8s',
9893             Priority => 0,
9894             ValueConv => '-$val/6',
9895             ValueConvInv => '-6 * $val',
9896             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9897             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9898             },
9899             12 => {
9900             Name => 'FlashFocalLength',
9901             Notes => 'only valid if flash pattern is "Standard Illumination"',
9902             RawConv => '($val and $val != 255) ? $val : undef',
9903             PrintConv => '"$val mm"',
9904             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9905             },
9906             13 => {
9907             Name => 'RepeatingFlashRate',
9908             RawConv => '($val and $val != 255) ? $val : undef',
9909             PrintConv => '"$val Hz"',
9910             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9911             },
9912             14 => {
9913             Name => 'RepeatingFlashCount',
9914             RawConv => '($val and $val != 255) ? $val : undef',
9915             },
9916             15 => {
9917             Name => 'FlashGNDistance',
9918             SeparateTable => 1,
9919             PrintConv => \%flashGNDistance,
9920             },
9921             17.1 => { #PH
9922             Name => 'FlashGroupAControlMode',
9923             Mask => 0x0f,
9924             Notes => 'note: group A tags may apply to the built-in flash settings for some models',
9925             DataMember => 'FlashGroupAControlMode',
9926             RawConv => '$$self{FlashGroupAControlMode} = $val',
9927             PrintConv => \%flashControlMode,
9928             SeparateTable => 'FlashControlMode',
9929             },
9930             18.1 => { #PH
9931             Name => 'FlashGroupBControlMode',
9932             Mask => 0xf0,
9933             Notes => 'note: group B tags may apply to group A settings for some models',
9934             DataMember => 'FlashGroupBControlMode',
9935             RawConv => '$$self{FlashGroupBControlMode} = $val',
9936             PrintConv => \%flashControlMode,
9937             SeparateTable => 'FlashControlMode',
9938             },
9939             18.2 => { #PH
9940             Name => 'FlashGroupCControlMode',
9941             Mask => 0x0f,
9942             Notes => 'note: group C tags may apply to group B settings for some models',
9943             DataMember => 'FlashGroupCControlMode',
9944             RawConv => '$$self{FlashGroupCControlMode} = $val',
9945             PrintConv => \%flashControlMode,
9946             SeparateTable => 'FlashControlMode',
9947             },
9948             # 0x13 - very similar to 0x28
9949             # 0x18 or 0x19 may indicate flash illumination pattern (Standard, Center-weighted, Even)
9950             0x28 => [ #PH
9951             {
9952             Name => 'FlashGroupAOutput',
9953             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
9954             ValueConv => '2 ** (-$val/6)',
9955             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9956             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9957             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9958             },
9959             {
9960             Name => 'FlashGroupACompensation',
9961             Format => 'int8s',
9962             ValueConv => '-$val/6',
9963             ValueConvInv => '-6 * $val',
9964             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9965             PrintConvInv => '$val',
9966             },
9967             ],
9968             0x29 => [ #PH
9969             {
9970             Name => 'FlashGroupBOutput',
9971             Condition => '$$self{FlashGroupBControlMode} >= 0x60',
9972             ValueConv => '2 ** (-$val/6)',
9973             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9974             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9975             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9976             },
9977             {
9978             Name => 'FlashGroupBCompensation',
9979             Format => 'int8s',
9980             ValueConv => '-$val/6',
9981             ValueConvInv => '-6 * $val',
9982             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9983             PrintConvInv => '$val',
9984             },
9985             ],
9986             0x2a => [ #PH
9987             {
9988             Name => 'FlashGroupCOutput',
9989             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
9990             ValueConv => '2 ** (-$val/6)',
9991             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9992             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9993             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9994             },
9995             {
9996             Name => 'FlashGroupCCompensation',
9997             Format => 'int8s',
9998             ValueConv => '-$val/6',
9999             ValueConvInv => '-6 * $val',
10000             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
10001             PrintConvInv => '$val',
10002             },
10003             ],
10004             );
10005              
10006             # Flash information for the Z7II (ref 28)
10007             # (likey similar to FlashInfo010 and FlashInfo0108 with addition of support for radio controlled units such as the SB-5000?
10008             %Image::ExifTool::Nikon::FlashInfo0300 = (
10009             %binaryDataAttrs,
10010             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10011             0 => {
10012             Name => 'FlashInfoVersion',
10013             Format => 'string[4]',
10014             Writable => 0,
10015             },
10016             4 => {
10017             Name => 'FlashSource',
10018             PrintConv => {
10019             0 => 'None',
10020             1 => 'External',
10021             2 => 'Internal',
10022             },
10023             },
10024             6 => {
10025             Format => 'int8u[2]',
10026             Name => 'ExternalFlashFirmware',
10027             SeparateTable => 'FlashFirmware',
10028             PrintConv => \%flashFirmware,
10029             },
10030             10 => {
10031             Name => 'FlashCompensation',
10032             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
10033             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
10034             Format => 'int8s',
10035             Priority => 0,
10036             ValueConv => '-$val/6',
10037             ValueConvInv => '-6 * $val',
10038             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
10039             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
10040             },
10041             );
10042             # Unknown Flash information
10043             %Image::ExifTool::Nikon::FlashInfoUnknown = (
10044             %binaryDataAttrs,
10045             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10046             0 => {
10047             Name => 'FlashInfoVersion',
10048             Format => 'string[4]',
10049             Writable => 0,
10050             },
10051             );
10052              
10053             # Multi exposure / image overlay information (ref PH)
10054             %Image::ExifTool::Nikon::MultiExposure = (
10055             %binaryDataAttrs,
10056             FORMAT => 'int32u',
10057             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10058             0 => {
10059             Name => 'MultiExposureVersion',
10060             Format => 'string[4]',
10061             Writable => 0,
10062             },
10063             1 => {
10064             Name => 'MultiExposureMode',
10065             PrintConv => {
10066             0 => 'Off',
10067             1 => 'Multiple Exposure',
10068             2 => 'Image Overlay',
10069             3 => 'HDR', #31
10070             },
10071             },
10072             2 => 'MultiExposureShots',
10073             3 => {
10074             Name => 'MultiExposureAutoGain',
10075             PrintConv => \%offOn,
10076             },
10077             );
10078              
10079             # HDR information (ref 32)
10080             %Image::ExifTool::Nikon::HDRInfo = (
10081             %binaryDataAttrs,
10082             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
10083             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
10084             0 => {
10085             Name => 'HDRInfoVersion',
10086             Format => 'string[4]',
10087             },
10088             4 => {
10089             Name => 'HDR',
10090             PrintConv => {
10091             0 => 'Off',
10092             1 => 'On',
10093             48 => 'Auto', #PH (NC)
10094             },
10095             },
10096             5 => {
10097             Name => 'HDRLevel',
10098             PrintConv => {
10099             0 => 'Auto',
10100             1 => '1 EV',
10101             2 => '2 EV',
10102             3 => '3 EV',
10103             # 5 - seen for 1J4
10104             255 => 'n/a', #PH
10105             },
10106             },
10107             6 => {
10108             Name => 'HDRSmoothing',
10109             PrintConv => {
10110             0 => 'Off',
10111             1 => 'Normal',
10112             2 => 'Low',
10113             3 => 'High',
10114             48 => 'Auto', #PH (NC)
10115             255 => 'n/a', #PH
10116             },
10117             },
10118             7 => { #PH (P330, HDRInfoVersion=0101)
10119             Name => 'HDRLevel2',
10120             PrintConv => {
10121             0 => 'Auto',
10122             1 => '1 EV',
10123             2 => '2 EV',
10124             3 => '3 EV',
10125             255 => 'n/a',
10126             },
10127             },
10128             );
10129              
10130             # location information (ref PH)
10131             %Image::ExifTool::Nikon::LocationInfo = (
10132             %binaryDataAttrs,
10133             DATAMEMBER => [ 4 ],
10134             GROUPS => { 0 => 'MakerNotes', 2 => 'Location' },
10135             NOTES => 'Tags written by some Nikon GPS-equipped cameras like the AW100.',
10136             0 => {
10137             Name => 'LocationInfoVersion',
10138             Format => 'undef[4]',
10139             },
10140             4 => {
10141             Name => 'TextEncoding',
10142             DataMember => 'TextEncoding',
10143             RawConv => q{
10144             $$self{TextEncoding} = $Image::ExifTool::Nikon::nikonTextEncoding{$val} if $val;
10145             return $val;
10146             },
10147             PrintConv => \%Image::ExifTool::Nikon::nikonTextEncoding,
10148             },
10149             # (the CountryCode and Location tag names chosen to correspond with XMP::iptcCore)
10150             5 => {
10151             Name => 'CountryCode',
10152             Format => 'undef[3]',
10153             ValueConv => '$val=~s/\0.*//s; $val', # truncate at null
10154             ValueConvInv => '$val',
10155             },
10156             8 => 'POILevel', #forum5782
10157             9 => {
10158             Name => 'Location',
10159             Format => 'undef[70]',
10160             RawConv => '$$self{TextEncoding} ? $self->Decode($val,$$self{TextEncoding},"MM") : $val',
10161             RawConvInv => '$$self{TextEncoding} ? $self->Encode($val,$$self{TextEncoding},"MM") : $val',
10162             },
10163             );
10164              
10165             # MakerNotes0x51 - compression info for Z9
10166             %Image::ExifTool::Nikon::MakerNotes0x51 = (
10167             %binaryDataAttrs,
10168             DATAMEMBER => [ 0 ],
10169             GROUPS => { 0 => 'MakerNotes' },
10170             0 => {
10171             Name => 'FirmwareVersion',
10172             Format => 'string[8]',
10173             Writable => 0,
10174             RawConv => '$$self{FirmwareVersion} = $val',
10175             },
10176             10 => {
10177             Name => 'NEFCompression',
10178             Writable => 'int16u',
10179             SeparateTable => 'NEFCompression',
10180             PrintConv => \%nefCompression,
10181             },
10182             );
10183              
10184             # extra info found in IFD0 of NEF files (ref PH, Z6/Z7)
10185             %Image::ExifTool::Nikon::NEFInfo = (
10186             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10187             NOTES => q{
10188             As-yet unknown information found in SubIFD1 tag 0xc7d5 of NEF images from
10189             cameras such as the Z6 and Z7, and NRW images from some Coolpix cameras.
10190             },
10191             # 0x01 - undef[12]
10192             # 0x02 - undef[148]
10193             # 0x03 - undef[284]
10194             # 0x04 - undef[148,212]
10195             # 0x05 - undef[84] (barrel distortion params at offsets 0x14,0x1c,0x24, ref 28)
10196             # 0x06 - undef[116] (vignette correction params at offsets 0x24,0x34,0x44, ref 28)
10197             # 0x07 - undef[104]
10198             # 0x08 - undef[24]
10199             # 0x09 - undef[36]
10200             );
10201              
10202             # tags in Nikon QuickTime videos (PH - observations with Coolpix S3)
10203             # (similar information in Kodak,Minolta,Nikon,Olympus,Pentax and Sanyo videos)
10204             %Image::ExifTool::Nikon::MOV = (
10205             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
10206             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10207             FIRST_ENTRY => 0,
10208             NOTES => q{
10209             This information is found in MOV and QT videos from some Nikon cameras.
10210             },
10211             0x00 => {
10212             Name => 'Make',
10213             Format => 'string[24]',
10214             },
10215             0x18 => {
10216             Name => 'Model',
10217             Description => 'Camera Model Name',
10218             Format => 'string[8]',
10219             },
10220             # (01 00 at offset 0x20)
10221             0x26 => {
10222             Name => 'ExposureTime',
10223             Format => 'int32u',
10224             ValueConv => '$val ? 10 / $val : 0',
10225             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
10226             },
10227             0x2a => {
10228             Name => 'FNumber',
10229             Format => 'rational64u',
10230             PrintConv => 'sprintf("%.1f",$val)',
10231             },
10232             0x32 => {
10233             Name => 'ExposureCompensation',
10234             Format => 'rational64s',
10235             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
10236             },
10237             0x44 => {
10238             Name => 'WhiteBalance',
10239             Format => 'int16u',
10240             PrintConv => {
10241             0 => 'Auto',
10242             1 => 'Daylight',
10243             2 => 'Shade',
10244             3 => 'Fluorescent', #2
10245             4 => 'Tungsten',
10246             5 => 'Manual',
10247             },
10248             },
10249             0x48 => {
10250             Name => 'FocalLength',
10251             Format => 'rational64u',
10252             PrintConv => 'sprintf("%.1f mm",$val)',
10253             },
10254             0xaf => {
10255             Name => 'Software',
10256             Format => 'string[16]',
10257             },
10258             0xdf => { # (this is a guess ... could also be offset 0xdb)
10259             Name => 'ISO',
10260             Format => 'int16u',
10261             RawConv => '$val < 50 ? undef : $val', # (not valid for Coolpix L10)
10262             },
10263             );
10264              
10265             # Nikon metadata in AVI videos (PH)
10266             %Image::ExifTool::Nikon::AVI = (
10267             NOTES => 'Nikon-specific RIFF tags found in AVI videos.',
10268             GROUPS => { 0 => 'MakerNotes', 2 => 'Video' },
10269             nctg => {
10270             Name => 'NikonTags',
10271             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AVITags' },
10272             },
10273             ncth => {
10274             Name => 'ThumbnailImage',
10275             Groups => { 2 => 'Preview' },
10276             Binary => 1,
10277             },
10278             ncvr => {
10279             Name => 'NikonVers',
10280             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AVIVers' },
10281             },
10282             ncvw => {
10283             Name => 'PreviewImage',
10284             Groups => { 2 => 'Preview' },
10285             RawConv => 'length($val) ? $val : undef',
10286             Binary => 1,
10287             },
10288             );
10289              
10290             # version information in AVI videos (PH)
10291             %Image::ExifTool::Nikon::AVIVers = (
10292             GROUPS => { 0 => 'MakerNotes', 2 => 'Video' },
10293             PROCESS_PROC => \&ProcessNikonAVI,
10294             FORMAT => 'string',
10295             0x01 => 'MakerNoteType',
10296             0x02 => {
10297             Name => 'MakerNoteVersion',
10298             Format => 'int8u',
10299             ValueConv => 'my @a = reverse split " ", $val; join ".", @a;',
10300             },
10301             );
10302              
10303             # tags in AVI videos (PH)
10304             %Image::ExifTool::Nikon::AVITags = (
10305             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10306             PROCESS_PROC => \&ProcessNikonAVI,
10307             FORMAT => 'string',
10308             NOTES => q{
10309             These tags and the AVIVer tags below are found in proprietary-format records
10310             of Nikon AVI videos.
10311             },
10312             0x03 => 'Make',
10313             0x04 => 'Model',
10314             0x05 => {
10315             Name => 'Software',
10316             Format => 'undef',
10317             ValueConv => '$val =~ tr/\0//d; $val',
10318             },
10319             0x06 => 'Equipment', # "NIKON DIGITAL CAMERA"
10320             0x07 => { # (guess)
10321             Name => 'Orientation',
10322             Format => 'int16u',
10323             Groups => { 2 => 'Image' },
10324             PrintConv => \%Image::ExifTool::Exif::orientation,
10325             },
10326             0x08 => {
10327             Name => 'ExposureTime',
10328             Format => 'rational64u',
10329             Groups => { 2 => 'Image' },
10330             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
10331             },
10332             0x09 => {
10333             Name => 'FNumber',
10334             Format => 'rational64u',
10335             Groups => { 2 => 'Image' },
10336             PrintConv => 'sprintf("%.1f",$val)',
10337             },
10338             0x0a => {
10339             Name => 'ExposureCompensation',
10340             Format => 'rational64s',
10341             Groups => { 2 => 'Image' },
10342             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
10343             },
10344             0x0b => {
10345             Name => 'MaxApertureValue',
10346             Format => 'rational64u',
10347             ValueConv => '2 ** ($val / 2)',
10348             PrintConv => 'sprintf("%.1f",$val)',
10349             },
10350             0x0c => {
10351             Name => 'MeteringMode', # (guess)
10352             Format => 'int16u',
10353             PrintConv => {
10354             0 => 'Unknown',
10355             1 => 'Average',
10356             2 => 'Center-weighted average',
10357             3 => 'Spot',
10358             4 => 'Multi-spot',
10359             5 => 'Multi-segment',
10360             6 => 'Partial',
10361             255 => 'Other',
10362             },
10363             },
10364             0x0d => { # val: 0
10365             Name => 'Nikon_AVITags_0x000d',
10366             Format => 'int16u',
10367             Flags => [ 'Hidden', 'Unknown' ],
10368             },
10369             0x0e => { # val: 0
10370             Name => 'Nikon_AVITags_0x000e',
10371             Format => 'int16u',
10372             Flags => [ 'Hidden', 'Unknown' ],
10373             },
10374             0x0f => {
10375             Name => 'FocalLength',
10376             Format => 'rational64u',
10377             PrintConv => 'sprintf("%.1f mm",$val)',
10378             },
10379             0x10 => {
10380             Name => 'XResolution',
10381             Format => 'rational64u',
10382             Groups => { 2 => 'Image' },
10383             },
10384             0x11 => {
10385             Name => 'YResolution',
10386             Format => 'rational64u',
10387             Groups => { 2 => 'Image' },
10388             },
10389             0x12 => {
10390             Name => 'ResolutionUnit',
10391             Format => 'int16u',
10392             Groups => { 2 => 'Image' },
10393             PrintConv => {
10394             1 => 'None',
10395             2 => 'inches',
10396             3 => 'cm',
10397             },
10398             },
10399             0x13 => {
10400             Name => 'DateTimeOriginal', # (guess)
10401             Description => 'Date/Time Original',
10402             Groups => { 2 => 'Time' },
10403             PrintConv => '$self->ConvertDateTime($val)',
10404             },
10405             0x14 => {
10406             Name => 'CreateDate', # (guess)
10407             Groups => { 2 => 'Time' },
10408             PrintConv => '$self->ConvertDateTime($val)',
10409             },
10410             0x15 => {
10411             Name => 'Nikon_AVITags_0x0015',
10412             Format => 'int16u',
10413             Flags => [ 'Hidden', 'Unknown' ],
10414             },
10415             0x16 => {
10416             Name => 'Duration',
10417             Format => 'rational64u',
10418             PrintConv => '"$val s"',
10419             },
10420             0x17 => { # val: 1
10421             Name => 'Nikon_AVITags_0x0017',
10422             Format => 'int16u',
10423             Flags => [ 'Hidden', 'Unknown' ],
10424             },
10425             0x18 => 'FocusMode',
10426             0x19 => { # vals: -5, -2, 3, 5, 6, 8, 11, 12, 14, 20, 22
10427             Name => 'Nikon_AVITags_0x0019',
10428             Format => 'int32s',
10429             Flags => [ 'Hidden', 'Unknown' ],
10430             },
10431             0x1b => { # vals: 1 (640x480), 1.25 (320x240)
10432             Name => 'DigitalZoom',
10433             Format => 'rational64u',
10434             },
10435             0x1c => { # (same as Nikon_0x000a)
10436             Name => 'Nikon_AVITags_0x001c',
10437             Format => 'rational64u',
10438             Flags => [ 'Hidden', 'Unknown' ],
10439             },
10440             0x1d => 'ColorMode',
10441             0x1e => { # string[8] - val: "AUTO"
10442             Name => 'Sharpness', # (guess, could also be ISOSelection)
10443             },
10444             0x1f => { # string[16] - val: "AUTO"
10445             Name => 'WhiteBalance', # (guess, could also be ImageAdjustment)
10446             },
10447             0x20 => { # string[4] - val: "OFF"
10448             Name => 'NoiseReduction', # (guess)
10449             },
10450             0x801a => { # val: 0 (why is the 0x8000 bit set in the ID?)
10451             Name => 'Nikon_AVITags_0x801a',
10452             Format => 'int32s',
10453             Flags => [ 'Hidden', 'Unknown' ],
10454             }
10455             );
10456              
10457             # Nikon NCDT atoms (ref PH)
10458             %Image::ExifTool::Nikon::NCDT = (
10459             GROUPS => { 0 => 'MakerNotes', 1 => 'Nikon', 2 => 'Video' },
10460             NOTES => q{
10461             Nikon-specific QuickTime tags found in the NCDT atom of MOV videos from
10462             various Nikon models.
10463             },
10464             NCHD => {
10465             Name => 'MakerNoteVersion',
10466             Format => 'undef',
10467             ValueConv => q{
10468             $val =~ s/\0$//; # remove trailing null
10469             $val =~ s/([\0-\x1f])/'.'.ord($1)/ge;
10470             $val =~ s/\./ /; return $val;
10471             },
10472             },
10473             NCTG => {
10474             Name => 'NikonTags',
10475             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::NCTG' },
10476             },
10477             NCTH => {
10478             Name => 'ThumbnailImage',
10479             Groups => { 2 => 'Preview' },
10480             Format => 'undef',
10481             Binary => 1,
10482             },
10483             NCVW => {
10484             Name => 'PreviewImage',
10485             Groups => { 2 => 'Preview' },
10486             Format => 'undef',
10487             Binary => 1,
10488             },
10489             NCDB => { # (often 0 bytes long, or 4 null bytes)
10490             Name => 'NikonNCDB',
10491             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::NCDB' },
10492             },
10493             NCM1 => {
10494             Name => 'PreviewImage1',
10495             Groups => { 2 => 'Preview' },
10496             Format => 'undef',
10497             Binary => 1,
10498             RawConv => 'length $val ? $val : undef',
10499             },
10500             NCM2 => { #PH (guess - have only seen 0 bytes)
10501             Name => 'PreviewImage2',
10502             Groups => { 2 => 'Preview' },
10503             Format => 'undef',
10504             Binary => 1,
10505             RawConv => 'length $val ? $val : undef',
10506             },
10507             );
10508              
10509             # Nikon NCDB tags from MOV videos (ref PH)
10510             %Image::ExifTool::Nikon::NCDB = (
10511             GROUPS => { 0 => 'MakerNotes', 1 => 'Nikon', 2 => 'Video' },
10512             # the following probably contain encrypted data -- look into decryping these!
10513             # OP01 - 320 bytes, starts with "0200" (D600,D610,D810,D3200,D5200)
10514             # - 638 bytes, starts with "0200" (D7100)
10515             # OP02 - 2048 bytes, starts with "0200" (D810)
10516             );
10517              
10518             # Nikon NCTG tags from MOV videos (ref PH)
10519             %Image::ExifTool::Nikon::NCTG = (
10520             PROCESS_PROC => \&ProcessNikonMOV,
10521             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10522             NOTES => q{
10523             These tags are found in proprietary-format records of the NCTG atom in MOV
10524             videos from some Nikon cameras.
10525             },
10526             0x01 => 'Make',
10527             0x02 => 'Model',
10528             0x03 => 'Software',
10529             0x11 => {
10530             Name => 'CreateDate', #(guess, but matches QuickTime CreateDate)
10531             Groups => { 2 => 'Time' },
10532             PrintConv => '$self->ConvertDateTime($val)',
10533             },
10534             0x12 => {
10535             Name => 'DateTimeOriginal', #(guess, but time is 1 sec before tag 0x11)
10536             Description => 'Date/Time Original',
10537             Groups => { 2 => 'Time' },
10538             PrintConv => '$self->ConvertDateTime($val)',
10539             },
10540             0x13 => {
10541             Name => 'FrameCount',
10542             # int32u[2]: "467 0", "1038 0", "1127 0"
10543             ValueConv => '$val =~ s/ 0$//; $val', # (not sure what the extra "0" is for)
10544             },
10545             # 0x14 - int32u[2]: "0 0"
10546             # 0x15 - int32u[2]: "0 0"
10547             0x16 => {
10548             Name => 'FrameRate',
10549             Groups => { 2 => 'Video' },
10550             PrintConv => 'int($val * 1000 + 0.5) / 1000',
10551             },
10552             # 0x17 - rational62u: same value as FrameRate
10553             # 0x18 - int16u: 1, 2
10554             0x19 => {
10555             Name => 'TimeZone',
10556             Groups => { 2 => 'Time' },
10557             },
10558             # 0x21 - int16u: 1, 2
10559             0x22 => {
10560             Name => 'FrameWidth',
10561             Groups => { 2 => 'Video' },
10562             },
10563             0x23 => {
10564             Name => 'FrameHeight',
10565             Groups => { 2 => 'Video' },
10566             },
10567             # 0x24 - int16u: 1, 2
10568             # 0x31 - int16u: 0, 1, 2
10569             0x32 => { #(guess)
10570             Name => 'AudioChannels',
10571             Groups => { 2 => 'Audio' },
10572             },
10573             0x33 => {
10574             Name => 'AudioBitsPerSample',
10575             Groups => { 2 => 'Audio' },
10576             },
10577             0x34 => {
10578             Name => 'AudioSampleRate',
10579             Groups => { 2 => 'Audio' },
10580             },
10581             # 0x101 - int16u[4]: "160 120 1280 720", "160 120 3840 2160"
10582             # 0x102 - int16u[8]: "640 360 0 0 0 0 0 0", "640 360 1920 1080 0 0 0 0"
10583             # 0x1001 - int16s: 0
10584             0x1002 => {
10585             Name => 'NikonDateTime', #?
10586             Groups => { 2 => 'Time' },
10587             PrintConv => '$self->ConvertDateTime($val)',
10588             },
10589             # 0x1011 - int32u: 0
10590             # 0x1012 - int32u: 0
10591             0x1013 => { #HayoBaan
10592             Name => 'ElectronicVR',
10593             PrintConv => \%offOn,
10594             },
10595             # 0x1014 - int16u: 1
10596             # 0x1021 - int32u[32]: all zeros
10597             #
10598             # 0x110**** tags correspond to 0x**** tags in Exif::Main
10599             #
10600             0x110829a => { #34
10601             Name => 'ExposureTime',
10602             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
10603             },
10604             0x110829d => { #34
10605             Name => 'FNumber',
10606             PrintConv => 'Image::ExifTool::Exif::PrintFNumber($val)',
10607             },
10608             0x1108822 => {
10609             Name => 'ExposureProgram',
10610             PrintConv => {
10611             0 => 'Not Defined',
10612             1 => 'Manual',
10613             2 => 'Program AE',
10614             3 => 'Aperture-priority AE',
10615             4 => 'Shutter speed priority AE',
10616             5 => 'Creative (Slow speed)',
10617             6 => 'Action (High speed)',
10618             7 => 'Portrait',
10619             8 => 'Landscape',
10620             # 9 => 'Bulb', # (non-standard Canon value)
10621             },
10622             },
10623             0x1109204 => {
10624             Name => 'ExposureCompensation',
10625             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
10626             },
10627             0x1109207 => {
10628             Name => 'MeteringMode',
10629             PrintConv => {
10630             0 => 'Unknown',
10631             1 => 'Average',
10632             2 => 'Center-weighted average',
10633             3 => 'Spot',
10634             4 => 'Multi-spot',
10635             5 => 'Multi-segment',
10636             6 => 'Partial',
10637             255 => 'Other',
10638             },
10639             },
10640             0x110920a => { #34
10641             Name => 'FocalLength',
10642             PrintConv => 'sprintf("%.1f mm",$val)',
10643             },
10644             0x110a431 => 'SerialNumber',
10645             0x110a432 => {
10646             Name => 'LensInfo',
10647             PrintConv => \&Image::ExifTool::Exif::PrintLensInfo,
10648             },
10649             0x110a433 => 'LensMake',
10650             0x110a434 => 'LensModel',
10651             0x110a435 => 'LensSerialNumber',
10652             #
10653             # 0x120**** tags correspond to 0x**** tags in GPS::Main
10654             #
10655             0x1200000 => {
10656             Name => 'GPSVersionID',
10657             Groups => { 1 => 'GPS', 2 => 'Location' },
10658             PrintConv => '$val =~ tr/ /./; $val',
10659             },
10660             0x1200001 => {
10661             Name => 'GPSLatitudeRef',
10662             Groups => { 1 => 'GPS', 2 => 'Location' },
10663             PrintConv => {
10664             N => 'North',
10665             S => 'South',
10666             },
10667             },
10668             0x1200002 => {
10669             Name => 'GPSLatitude',
10670             Groups => { 1 => 'GPS', 2 => 'Location' },
10671             ValueConv => q{
10672             require Image::ExifTool::GPS;
10673             Image::ExifTool::GPS::ToDegrees($val);
10674             },
10675             PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1)',
10676             },
10677             0x1200003 => {
10678             Name => 'GPSLongitudeRef',
10679             Groups => { 1 => 'GPS', 2 => 'Location' },
10680             PrintConv => {
10681             E => 'East',
10682             W => 'West',
10683             },
10684             },
10685             0x1200004 => {
10686             Name => 'GPSLongitude',
10687             Groups => { 1 => 'GPS', 2 => 'Location' },
10688             ValueConv => q{
10689             require Image::ExifTool::GPS;
10690             Image::ExifTool::GPS::ToDegrees($val);
10691             },
10692             PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1)',
10693             },
10694             0x1200005 => {
10695             Name => 'GPSAltitudeRef',
10696             Groups => { 1 => 'GPS', 2 => 'Location' },
10697             PrintConv => {
10698             0 => 'Above Sea Level',
10699             1 => 'Below Sea Level',
10700             },
10701             },
10702             0x1200006 => {
10703             Name => 'GPSAltitude',
10704             Groups => { 1 => 'GPS', 2 => 'Location' },
10705             PrintConv => '$val =~ /^(inf|undef)$/ ? $val : "$val m"',
10706             },
10707             0x1200007 => {
10708             Name => 'GPSTimeStamp',
10709             Groups => { 1 => 'GPS', 2 => 'Time' },
10710             ValueConv => q{
10711             require Image::ExifTool::GPS;
10712             Image::ExifTool::GPS::ConvertTimeStamp($val);
10713             },
10714             PrintConv => 'Image::ExifTool::GPS::PrintTimeStamp($val)',
10715             },
10716             0x1200008 => {
10717             Name => 'GPSSatellites',
10718             Groups => { 1 => 'GPS', 2 => 'Location' },
10719             },
10720             0x1200010 => {
10721             Name => 'GPSImgDirectionRef',
10722             Groups => { 1 => 'GPS', 2 => 'Location' },
10723             PrintConv => {
10724             M => 'Magnetic North',
10725             T => 'True North',
10726             },
10727             },
10728             0x1200011 => {
10729             Name => 'GPSImgDirection',
10730             Groups => { 1 => 'GPS', 2 => 'Location' },
10731             },
10732             0x1200012 => {
10733             Name => 'GPSMapDatum',
10734             Groups => { 1 => 'GPS', 2 => 'Location' },
10735             },
10736             0x120001d => {
10737             Name => 'GPSDateStamp',
10738             Groups => { 1 => 'GPS', 2 => 'Time' },
10739             ValueConv => 'Image::ExifTool::Exif::ExifDate($val)',
10740             },
10741             #
10742             # 0x200**** tags correspond to 0x**** tags in Nikon::Main
10743             # (must be duplicated here so tagInfo "Table" entry will point to correct table.
10744             # Also there would be a problem with the PRINT_CONV from the Main table)
10745             #
10746             0x2000001 => {
10747             Name => 'MakerNoteVersion',
10748             PrintConv => '$_=$val;s/^(\d{2})/$1\./;s/^0//;$_',
10749             },
10750             0x2000005 => 'WhiteBalance',
10751             0x2000007 => { Name => 'FocusMode', Writable => 'string' }, #34
10752             0x200000b => 'WhiteBalanceFineTune',
10753             0x200001b => {
10754             Name => 'CropHiSpeed',
10755             Writable => 'int16u',
10756             Count => 7,
10757             PrintConv => \%cropHiSpeed,
10758             },
10759             0x200001e => {
10760             Name => 'ColorSpace',
10761             PrintConv => {
10762             1 => 'sRGB',
10763             2 => 'Adobe RGB',
10764             },
10765             },
10766             0x200001f => {
10767             Name => 'VRInfo',
10768             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::VRInfo' },
10769             },
10770             0x2000022 => {
10771             Name => 'ActiveD-Lighting',
10772             Writable => 'int16u',
10773             PrintConv => {
10774             0 => 'Off',
10775             1 => 'Low',
10776             3 => 'Normal',
10777             5 => 'High',
10778             7 => 'Extra High',
10779             8 => 'Extra High 1',
10780             9 => 'Extra High 2',
10781             10 => 'Extra High 3',
10782             11 => 'Extra High 4',
10783             0xffff => 'Auto',
10784             },
10785             },
10786             0x2000023 => [
10787             { #PH (D300, but also found in D3,D3S,D3X,D90,D300S,D700,D3000,D5000)
10788             Name => 'PictureControlData',
10789             Condition => '$$valPt =~ /^01/',
10790             Writable => 'undef',
10791             Permanent => 0,
10792             Flags => [ 'Binary', 'Protected' ],
10793             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl' },
10794             },{ #28
10795             Name => 'PictureControlData',
10796             Condition => '$$valPt =~ /^02/',
10797             Writable => 'undef',
10798             Permanent => 0,
10799             Flags => [ 'Binary', 'Protected' ],
10800             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl2' },
10801             },{
10802             Name => 'PictureControlData',
10803             Condition => '$$valPt =~ /^03/',
10804             Writable => 'undef',
10805             Permanent => 0,
10806             Flags => [ 'Binary', 'Protected' ],
10807             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl3' },
10808             },{
10809             Name => 'PictureControlData',
10810             Writable => 'undef',
10811             Permanent => 0,
10812             Flags => [ 'Binary', 'Protected' ],
10813             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControlUnknown' },
10814             },
10815             ],
10816             0x2000024 => {
10817             Name => 'WorldTime',
10818             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::WorldTime' },
10819             },
10820             0x2000025 => { #34
10821             Name => 'ISOInfo',
10822             SubDirectory => {
10823             TagTable => 'Image::ExifTool::Nikon::ISOInfo',
10824             ByteOrder => 'BigEndian', # (BigEndian even for D810, which is a little-endian camera)
10825             },
10826             },
10827             0x200002a => { #23 (this tag added with D3 firmware 1.10 -- also written by Nikon utilities)
10828             Name => 'VignetteControl',
10829             Writable => 'int16u',
10830             PrintConv => {
10831             0 => 'Off',
10832             1 => 'Low',
10833             3 => 'Normal',
10834             5 => 'High',
10835             },
10836             },
10837             0x200002c => {
10838             Name => 'UnknownInfo',
10839             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::UnknownInfo' },
10840             },
10841             # 0x200002d - int16u[3]: "512 0 0"
10842             0x2000032 => {
10843             Name => 'UnknownInfo2',
10844             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::UnknownInfo2' },
10845             },
10846             0x2000039 => {
10847             Name => 'LocationInfo',
10848             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LocationInfo' },
10849             },
10850             # 0x200003f - rational64s[2]: "0 0"
10851             # 0x2000042 - undef[6]: "0100\x03\0"
10852             # 0x2000043 - undef[12]: all zeros
10853             0x2000083 => {
10854             Name => 'LensType',
10855             # credit to Tom Christiansen (ref 7) for figuring this out...
10856             PrintConv => q[$_ = $val ? Image::ExifTool::DecodeBits($val,
10857             {
10858             0 => 'MF',
10859             1 => 'D',
10860             2 => 'G',
10861             3 => 'VR',
10862             4 => '1', #PH
10863             # bit 5 set for FT-1 adapter? - PH
10864             6 => 'E', #PH (electromagnetic aperture mechanism)
10865             # bit 7 set for AF-P lenses? - PH
10866             }) : 'AF';
10867             # remove commas and change "D G" to just "G"
10868             s/,//g; s/\bD G\b/G/;
10869             s/ E\b// and s/^(G )?/E /; # put "E" at the start instead of "G"
10870             s/ 1// and $_ = "1 $_"; # put "1" at start
10871             return $_;
10872             ],
10873             },
10874             0x2000084 => {
10875             Name => "Lens",
10876             # short focal, long focal, aperture at short focal, aperture at long focal
10877             PrintConv => \&Image::ExifTool::Exif::PrintLensInfo,
10878             },
10879             0x2000087 => {
10880             Name => 'FlashMode',
10881             Writable => 'int8u',
10882             PrintConv => {
10883             0 => 'Did Not Fire',
10884             1 => 'Fired, Manual', #14
10885             3 => 'Not Ready', #28
10886             7 => 'Fired, External', #14
10887             8 => 'Fired, Commander Mode',
10888             9 => 'Fired, TTL Mode',
10889             18 => 'LED Light', #G.F. (movie LED light)
10890             },
10891             },
10892             0x2000098 => [
10893             { #8
10894             Condition => '$$valPt =~ /^0100/', # D100, D1X - PH
10895             Name => 'LensData0100',
10896             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LensData00' },
10897             },
10898             { #8
10899             Condition => '$$valPt =~ /^0101/', # D70, D70s - PH
10900             Name => 'LensData0101',
10901             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LensData01' },
10902             },
10903             # note: this information is encrypted if the version is 02xx
10904             { #8
10905             # 0201 - D200, D2Hs, D2X and D2Xs
10906             # 0202 - D40, D40X and D80
10907             # 0203 - D300
10908             Condition => '$$valPt =~ /^020[1-3]/',
10909             Name => 'LensData0201',
10910             SubDirectory => {
10911             TagTable => 'Image::ExifTool::Nikon::LensData01',
10912             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
10913             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
10914             DecryptStart => 4,
10915             },
10916             },
10917             { #PH
10918             Condition => '$$valPt =~ /^0204/', # D90, D7000
10919             Name => 'LensData0204',
10920             SubDirectory => {
10921             TagTable => 'Image::ExifTool::Nikon::LensData0204',
10922             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
10923             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
10924             DecryptStart => 4,
10925             },
10926             },
10927             {
10928             Condition => '$$valPt =~ /^040[01]/', # 0=1J1/1V1, 1=1J2
10929             Name => 'LensData0400',
10930             SubDirectory => {
10931             TagTable => 'Image::ExifTool::Nikon::LensData0400',
10932             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
10933             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
10934             DecryptStart => 4,
10935             },
10936             },
10937             {
10938             Condition => '$$valPt =~ /^0402/', # 1J3/1S1/1V2
10939             Name => 'LensData0402',
10940             SubDirectory => {
10941             TagTable => 'Image::ExifTool::Nikon::LensData0402',
10942             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
10943             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
10944             DecryptStart => 4,
10945             },
10946             },
10947             {
10948             Condition => '$$valPt =~ /^0403/', # 1J4,1J5
10949             Name => 'LensData0403',
10950             SubDirectory => {
10951             TagTable => 'Image::ExifTool::Nikon::LensData0403',
10952             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
10953             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
10954             DecryptStart => 4,
10955             },
10956             },
10957             {
10958             Condition => '$$valPt =~ /^080[012]/', # Z6/Z7/Z9
10959             Name => 'LensData0800',
10960             SubDirectory => {
10961             TagTable => 'Image::ExifTool::Nikon::LensData0800',
10962             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
10963             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
10964             DecryptStart => 4,
10965             ByteOrder => 'LittleEndian',
10966             # 0x5a0c - NikonMeteringMode for some Z6 ver1.00 samples (ref PH)
10967             },
10968             },
10969             {
10970             Name => 'LensDataUnknown',
10971             SubDirectory => {
10972             TagTable => 'Image::ExifTool::Nikon::LensDataUnknown',
10973             ProcessProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
10974             WriteProc => \&Image::ExifTool::Nikon::ProcessNikonEncrypted,
10975             DecryptStart => 4,
10976             },
10977             },
10978             ],
10979             0x20000a7 => { # Number of shots taken by camera so far (ref 2)
10980             Name => 'ShutterCount',
10981             PrintConv => '$val == 4294965247 ? "n/a" : $val',
10982             },
10983             0x20000a8 => [
10984             {
10985             Name => 'FlashInfo0100',
10986             Condition => '$$valPt =~ /^010[01]/',
10987             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0100' },
10988             },
10989             {
10990             Name => 'FlashInfo0102',
10991             Condition => '$$valPt =~ /^0102/',
10992             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0102' },
10993             },
10994             {
10995             Name => 'FlashInfo0103',
10996             # (0104 for D7000, 0105 for D800)
10997             Condition => '$$valPt =~ /^010[345]/',
10998             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0103' },
10999             },
11000             {
11001             Name => 'FlashInfo0106', # (0106 for D7100)
11002             Condition => '$$valPt =~ /^0106/',
11003             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0106' },
11004             },
11005             {
11006             Name => 'FlashInfo0107', # (0107 for D4S/D750/D810/D5500/D7200, 0108 for D5/D500/D3400)
11007             Condition => '$$valPt =~ /^010[78]/',
11008             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0107' },
11009             },
11010             {
11011             Name => 'FlashInfoUnknown',
11012             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfoUnknown' },
11013             },
11014             ],
11015             0x20000ab => { Name => 'VariProgram', Writable => 'string' }, #2 (scene mode for DSLR's - PH)
11016             0x20000b1 => { #34
11017             Name => 'HighISONoiseReduction',
11018             Writable => 'int16u',
11019             PrintConv => {
11020             0 => 'Off',
11021             1 => 'Minimal', # for high ISO (>800) when setting is "Off"
11022             2 => 'Low', # Low,Normal,High take effect for ISO > 400
11023             3 => 'Medium Low',
11024             4 => 'Normal',
11025             5 => 'Medium High',
11026             6 => 'High',
11027             },
11028             },
11029             0x20000b7 => {
11030             Name => 'AFInfo2',
11031             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2' },
11032             },
11033             # 0x20000c0 - undef[8]
11034             0x20000c3 => {
11035             Name => 'BarometerInfo',
11036             SubDirectory => {
11037             TagTable => 'Image::ExifTool::Nikon::BarometerInfo',
11038             # (little-endian in II EXIF, big-endian in MOV)
11039             },
11040             },
11041             );
11042              
11043             # Nikon XMP tags written in NKSC metadata
11044             %Image::ExifTool::Nikon::ast = (
11045             GROUPS => { 0 => 'XMP', 1 => 'XMP-ast', 2 => 'Image' },
11046             PROCESS_PROC => \&Image::ExifTool::XMP::ProcessXMP,
11047             NAMESPACE => 'ast',
11048             VARS => { NO_ID => 1 },
11049             NOTES => 'Tags used by Nikon NX Studio in Nikon NKSC sidecar files and trailers.',
11050             about => { },
11051             version => { },
11052             XMLPackets => {
11053             SubDirectory => { TagTable => 'Image::ExifTool::XMP::Main' },
11054             Encoding => 'Base64',
11055             Binary => 1,
11056             },
11057             IPTC => {
11058             SubDirectory => { TagTable => 'Image::ExifTool::IPTC::Main' },
11059             Encoding => 'Base64',
11060             Binary => 1,
11061             },
11062             GPSVersionID => { Groups => { 2 => 'Location' }, %base64bytes },
11063             GPSLatitudeRef => {
11064             Groups => { 2 => 'Location' },
11065             %base64int32u,
11066             PrintConv => { 0 => 'North', 1 => 'South' }, #PH (NC)
11067             },
11068             GPSLatitude => { Groups => { 2 => 'Location' }, %base64coord },
11069             GPSLongitudeRef => {
11070             Groups => { 2 => 'Location' },
11071             %base64int32u,
11072             PrintConv => { 2 => 'East', 3 => 'West' }, #PH (NC)
11073             },
11074             GPSLongitude => { Groups => { 2 => 'Location' }, %base64coord },
11075             GPSAltitudeRef => {
11076             Groups => { 2 => 'Location' },
11077             %base64bytes,
11078             PrintConv => {
11079             0 => 'Above Sea Level',
11080             1 => 'Below Sea Level',
11081             },
11082             },
11083             GPSAltitude => {
11084             Groups => { 2 => 'Location' },
11085             %base64double,
11086             PrintConv => '"$val m"',
11087             },
11088             GPSMapDatum => { Groups => { 2 => 'Location' } },
11089             GPSImgDirection => {
11090             Groups => { 2 => 'Location' },
11091             %base64double,
11092             PrintConv => 'sprintf("%.2f", $val)',
11093             },
11094             GPSImgDirectionRef => {
11095             Groups => { 2 => 'Location' },
11096             PrintConv => {
11097             M => 'Magnetic North',
11098             T => 'True North',
11099             },
11100             },
11101             );
11102             %Image::ExifTool::Nikon::sdc = (
11103             GROUPS => { 0 => 'XMP', 1 => 'XMP-sdc', 2 => 'Image' },
11104             PROCESS_PROC => \&Image::ExifTool::XMP::ProcessXMP,
11105             NAMESPACE => 'sdc',
11106             VARS => { NO_ID => 1 },
11107             about => { },
11108             version => { },
11109             appversion => { Name => 'AppVersion' },
11110             appname => { Name => 'AppName' },
11111             );
11112             %Image::ExifTool::Nikon::nine = (
11113             GROUPS => { 0 => 'XMP', 1 => 'XMP-nine', 2 => 'Image' },
11114             PROCESS_PROC => \&Image::ExifTool::XMP::ProcessXMP,
11115             NAMESPACE => 'nine',
11116             VARS => { NO_ID => 1 },
11117             about => { },
11118             version => { },
11119             Label => { },
11120             Rating => { },
11121             Trim => { %base64bin },
11122             NineEdits => {
11123             SubDirectory => {
11124             TagTable => 'Image::ExifTool::Nikon::NineEdits',
11125             IgnoreProp => { userData => 1 }, # remove "UserData" from already overly long tag names
11126             },
11127             Binary => 1,
11128             },
11129             );
11130             %Image::ExifTool::Nikon::NineEdits = (
11131             GROUPS => { 0 => 'XML', 1 => 'NineEdits', 2 => 'Image' },
11132             PROCESS_PROC => \&Image::ExifTool::XMP::ProcessXMP,
11133             VARS => { NO_ID => 1 },
11134             NOTES => 'XML-based tags used to store editing information.',
11135             filterParametersBinary => { %base64bin },
11136             filterParametersExportExportData => { %base64bin },
11137             filterParametersCustomCustomData => { %base64bin },
11138             );
11139              
11140             # Nikon composite tags
11141             %Image::ExifTool::Nikon::Composite = (
11142             GROUPS => { 2 => 'Camera' },
11143             LensSpec => {
11144             Require => {
11145             0 => 'Nikon:Lens',
11146             1 => 'Nikon:LensType',
11147             },
11148             ValueConv => '"$val[0] $val[1]"',
11149             PrintConv => '"$prt[0] $prt[1]"',
11150             },
11151             LensID => {
11152             SeparateTable => 'Nikon LensID', # print values in a separate table
11153             Require => {
11154             0 => 'Nikon:LensIDNumber',
11155             1 => 'LensFStops',
11156             2 => 'MinFocalLength',
11157             3 => 'MaxFocalLength',
11158             4 => 'MaxApertureAtMinFocal',
11159             5 => 'MaxApertureAtMaxFocal',
11160             6 => 'MCUVersion',
11161             7 => 'Nikon:LensType',
11162             },
11163             # construct lens ID string as per ref 11
11164             ValueConv => 'sprintf("%.2X"." %.2X"x7, @raw)',
11165             PrintConv => \%nikonLensIDs,
11166             },
11167             AutoFocus => {
11168             Require => {
11169             0 => 'Nikon:PhaseDetectAF',
11170             1 => 'Nikon:ContrastDetectAF',
11171             },
11172             ValueConv => '($val[0] or $val[1]) ? 1 : 0',
11173             PrintConv => \%offOn,
11174             },
11175             );
11176              
11177             # add our composite tags
11178             Image::ExifTool::AddCompositeTags('Image::ExifTool::Nikon');
11179              
11180             #------------------------------------------------------------------------------
11181             # Process Nikon AVI tags (D5000 videos)
11182             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
11183             # Returns: 1 on success
11184             sub ProcessNikonAVI($$$)
11185             {
11186 0     0 0 0 my ($et, $dirInfo, $tagTablePtr) = @_;
11187 0         0 my $dataPt = $$dirInfo{DataPt};
11188 0   0     0 my $pos = $$dirInfo{DirStart} || 0;
11189 0         0 my $dirEnd = $pos + $$dirInfo{DirLen};
11190 0         0 $et->VerboseDir($dirInfo, undef, $$dirInfo{DirLen});
11191 0         0 SetByteOrder('II');
11192 0         0 while ($pos + 4 <= $dirEnd) {
11193 0         0 my $tag = Get16u($dataPt, $pos);
11194 0         0 my $size = Get16u($dataPt, $pos + 2);
11195 0         0 $pos += 4;
11196 0 0       0 last if $pos + $size > $dirEnd;
11197 0         0 $et->HandleTag($tagTablePtr, $tag, undef,
11198             DataPt => $dataPt,
11199             Start => $pos,
11200             Size => $size,
11201             );
11202 0         0 $pos += $size;
11203             }
11204 0         0 return 1;
11205             }
11206              
11207             #------------------------------------------------------------------------------
11208             # Print conversion for Nikon AF points
11209             # Inputs: 0) value to convert (as a string of hex bytes),
11210             # 1) lookup for AF point bit number (starting at 1)
11211             sub PrintAFPoints($$)
11212             {
11213 0     0 0 0 my ($val, $afPoints) = @_;
11214 0         0 my ($i, $j, @points);
11215 0         0 $val =~ tr/ //d; # remove spaces from hex string
11216 0         0 my @dat = unpack 'C*', pack 'H*', $val; # convert to array of bytes
11217             # loop through all bytes to find active AF points
11218 0         0 for ($i=0; $i<=@dat; ++$i) {
11219 0 0       0 next unless $dat[$i];
11220 0         0 for ($j=0; $j<8; ++$j) {
11221 0 0       0 next unless $dat[$i] & (1 << $j);
11222 0         0 my $point = $$afPoints{$i*8 + $j + 1};
11223 0 0       0 push @points, $point if defined $point;
11224             }
11225             }
11226 0 0       0 return '(none)' unless @points;
11227             # sort the points and return as comma-separated string
11228             return join ',', sort {
11229 0 0       0 return $a cmp $b if length($a) == length($b);
  0         0  
11230 0 0       0 return substr($a,0,1).'0'.substr($a,1,1) cmp $b if length($a) == 2;
11231 0         0 return $a cmp substr($b,0,1).'0'.substr($b,1,1);
11232             } @points;
11233             }
11234              
11235             #------------------------------------------------------------------------------
11236             # Inverse print conversion for AF points
11237             # Inputs: 0) AF point string, 1) AF point lookup
11238             # Returns: AF point data as a string of hex bytes
11239             sub PrintAFPointsInv($$)
11240             {
11241 10     10 0 34 my ($val, $afPoints) = @_;
11242 10         43 my @points = ($val =~ /[A-Za-z]\d+/g);
11243 10         58 my $size = int((scalar(keys %$afPoints) + 7) / 8);
11244 10         77 my @dat = (0) x $size;
11245 10 50       41 if (@points) {
11246 0         0 my (%bitNum, $point);
11247 0         0 $bitNum{$$afPoints{$_}} = $_ foreach keys %$afPoints; # build reverse lookup
11248 0         0 foreach $point (@points) {
11249 0 0       0 my $bitNum = $bitNum{uc $point} or next;
11250 0         0 my $byte = int(($bitNum - 1) / 8);
11251 0         0 $dat[$byte] |= (1 << (($bitNum - 1) % 8));
11252             }
11253             }
11254 10         180 return join(" ", unpack("H2"x$size, pack('C*', @dat)));
11255             }
11256              
11257             #------------------------------------------------------------------------------
11258             # Get AF point name for grid-type AF
11259             # Inputs: 0) AF point number, 1) number of columns, 2) true for inverse conversion
11260             # Returns: AF point name, or undef
11261             sub GetAFPointGrid($$;$)
11262             {
11263 0     0 0 0 my ($val, $ncol, $inv) = @_;
11264 0 0       0 if ($inv) {
11265 0 0       0 return undef unless $val =~ /^([A-J])(\d+)$/i;
11266 0         0 return (ord(uc($1))-65) * $ncol + $2 - 1;
11267             } else {
11268 0         0 my $row = int(($val + 0.5) / $ncol) & 0xff;
11269 0         0 my $col = $val - $ncol * $row + 1;
11270 0         0 return chr(65+$row) . $col;
11271             }
11272             }
11273              
11274             #------------------------------------------------------------------------------
11275             # Print conversion for grid-type AF points
11276             # Inputs: 0) value to convert (as a string of hex bytes),
11277             # 1) number of columns in grid
11278             sub PrintAFPointsGrid($$)
11279             {
11280 0     0 0 0 my ($val, $ncol) = @_;
11281 0         0 my ($i, $j, @points);
11282 0         0 $val =~ tr/ //d; # remove spaces from hex string
11283 0         0 my @dat = unpack 'C*', pack 'H*', $val; # convert to array of bytes
11284             # loop through all bytes to find active AF points
11285 0         0 for ($i=0; $i<@dat; ++$i) {
11286 0 0       0 next unless $dat[$i];
11287 0         0 for ($j=0; $j<8; ++$j) {
11288 0 0       0 next unless $dat[$i] & (1 << $j);
11289 0         0 my $point = GetAFPointGrid($i*8 + $j, $ncol);
11290 0 0       0 push @points, $point if defined $point;
11291             }
11292             }
11293 0 0       0 return '(none)' unless @points;
11294 0         0 return join ',', @points; # return as comma-separated string
11295             }
11296              
11297             #------------------------------------------------------------------------------
11298             # Inverse print conversion for AF points
11299             # Inputs: 0) AF point string, 1) number of columns, 2) size of data
11300             # Returns: AF point data as a string of hex bytes
11301             sub PrintAFPointsGridInv($$$)
11302             {
11303 0     0 0 0 my ($val, $ncol, $size) = @_;
11304 0         0 my @points = ($val =~ /[A-Za-z]\d+/g);
11305 0         0 my @dat = (0) x $size;
11306 0         0 foreach (@points) {
11307 0         0 my $n = GetAFPointGrid($_, $ncol, 1);
11308 0 0       0 next unless defined $n;
11309 0         0 my $byte = int($n / 8);
11310 0 0       0 next if $byte > $size;
11311 0         0 $dat[$byte] |= (1 << ($n - $byte * 8));
11312             }
11313 0         0 return join(" ", unpack("H2"x$size, pack('C*', @dat)));
11314             }
11315              
11316             #------------------------------------------------------------------------------
11317             # Print conversion for relative Left/Right AF points (ref 28)
11318             # Inputs: 0) column, 1) number of columns
11319             # Returns: AF point data as a string (e.g. '2L' or 'C' or '3R')
11320             sub PrintAFPointsLeftRight($$)
11321             {
11322 0     0 0 0 my ($col, $ncol) = @_;
11323 0         0 my $center = 1 + ($ncol + 1)/2;
11324 0 0       0 return 'C' if $col == $center;
11325 0 0       0 return sprintf('%d', $center - $col) . 'L of Center' if $col < $center;
11326 0 0       0 return sprintf('%d', $col - $center) . 'R of Center' if $col > $center;
11327             }
11328              
11329             #------------------------------------------------------------------------------
11330             # Print conversion for relative Up/Down AF points (ref 28)
11331             # Inputs: 0) row, 1) number of rows
11332             # Returns: AF point data as a string (e.g. '2U' or 'C' or '3D')
11333             sub PrintAFPointsUpDown($$)
11334             {
11335 0     0 0 0 my ($row, $nrow) = @_;
11336 0         0 my $center = 1 + ($nrow + 1)/2;
11337 0 0       0 return 'C' if $row == $center;
11338 0 0       0 return sprintf('%d', $center - $row) . 'U from Center' if $row < $center;
11339 0 0       0 return sprintf('%d', $row - $center) . 'D from Center' if $row > $center;
11340             }
11341              
11342             #------------------------------------------------------------------------------
11343             # Print PictureControl value
11344             # Inputs: 0) value (with 0x80 subtracted),
11345             # 1) 'Normal' (0 value) string (default 'Normal')
11346             # 2) format string for numbers (default '%+d'), 3) v2 divisor
11347             # Returns: PrintConv value
11348             sub PrintPC($;$$$)
11349             {
11350 0     0 0 0 my ($val, $norm, $fmt, $div) = @_;
11351 0 0 0     0 return $norm || 'Normal' if $val == 0;
11352 0 0       0 return 'n/a' if $val == 0x7f;
11353 0 0       0 return 'Auto' if $val == -128;
11354             # -127 = custom curve created in Camera Control Pro (show as "User" by D3) - ref 28
11355 0 0       0 return 'User' if $val == -127; #28
11356 0   0     0 return sprintf($fmt || '%+d', $val / ($div || 1));
      0        
11357             }
11358              
11359             #------------------------------------------------------------------------------
11360             # Inverse of PrintPC
11361             # Inputs: 0) PrintConv value (after subracting 0x80 from raw value), 1) v2 divisor
11362             # Returns: unconverted value
11363             # Notes: raw values: 0=Auto, 1=User, 0xff=n/a, ... 0x7f=-1, 0x80=0, 0x81=1, ...
11364             sub PrintPCInv($;$)
11365             {
11366 114     114 0 307 my ($val, $div) = @_;
11367 114 100 100     1028 return $val * ($div || 1) if $val =~ /^[-+]?\d+(\.\d+)?$/;
11368 114 50       150 return 0x7f if $val =~ /n\/a/i;
11369 114 100       165 return -128 if $val =~ /auto/i;
11370 111 50       124 return -127 if $val =~ /user/i; #28
11371 111         356 return 0;
11372             }
11373              
11374             #------------------------------------------------------------------------------
11375             # Convert unknown LensID values
11376             # Inputs: 0) value, 1) flag for inverse conversion, 2) PrintConv hash ref
11377             sub LensIDConv($$$)
11378             {
11379 0     0 0 0 my ($val, $inv, $conv) = @_;
11380 0 0       0 return undef if $inv;
11381             # multiple lenses with the same LensID are distinguished by decimal values
11382 0 0       0 if ($$conv{"$val.1"}) {
11383 0         0 my ($i, @vals, @user);
11384 0         0 for ($i=1; ; ++$i) {
11385 0 0       0 my $lens = $$conv{"$val.$i"} or last;
11386 0 0       0 if ($Image::ExifTool::userLens{$lens}) {
11387 0         0 push @user, $lens;
11388             } else {
11389 0         0 push @vals, $lens;
11390             }
11391             }
11392 0 0       0 return join(' or ', @user) if @user;
11393 0         0 return join(' or ', @vals);
11394             }
11395             # Sigma has been changing the LensIDNumber on some new lenses
11396             # and with some Sigma lenses the LensFStops changes! (argh!)
11397             # Also, older cameras my not set bits 4-7 of LensType
11398 0         0 my $pat = $val;
11399 0         0 $pat =~ s/^\w+ \w+/.. ../; # ignore LensIDNumber and LensFStops
11400 0         0 $pat =~ s/\w(\w)$/.$1/; # ignore bits 4-7 of LensType
11401 0         0 my @ids = sort grep /^$pat$/, keys %$conv;
11402 0 0       0 if (@ids) {
11403             # first try different LensFStops (2nd value)
11404 0         0 ($pat = $val) =~ s/ \w+/ ../;
11405 0         0 my @good = grep /^$pat$/, @ids;
11406 0 0       0 return $$conv{$good[0]} if @good;
11407             # then try different LensIDNumber (1st value)
11408 0         0 ($pat = $val) =~ s/^\w+/../;
11409 0         0 @good = grep /^$pat$/, @ids;
11410 0 0       0 return "Unknown ($val) $$conv{$good[0]} ?" if @good;
11411             # older cameras may not set bits 4-7 of LensType
11412 0         0 ($pat = $val) =~ s/\w(\w)$/.$1/;
11413 0         0 @good = grep /^$pat$/, @ids;
11414 0 0       0 return "Unknown ($val) $$conv{$good[0]} ?" if @good;
11415             }
11416 0         0 return undef;
11417             }
11418              
11419             #------------------------------------------------------------------------------
11420             # Clean up formatting of string values
11421             # Inputs: 0) string value
11422             # Returns: formatted string value
11423             # - removes trailing spaces and changes case to something more sensible
11424             sub FormatString($)
11425             {
11426 153     153 0 249 my $str = shift;
11427             # limit string length (can be very long for some unknown tags)
11428 153 50       292 if (length($str) > 60) {
11429 0         0 $str = substr($str,0,55) . "[...]";
11430             } else {
11431 153         582 $str =~ s/\s+$//; # remove trailing white space
11432             # Don't change case of non-words (no vowels)
11433 153 100       425 if ($str =~ /[AEIOUY]/) {
11434             # change all letters but the first to lower case,
11435             # but only in words containing a vowel
11436 97 100       502 if ($str =~ s/\b([AEIOUY])([A-Z]+)/$1\L$2/g) {
11437 50         134 $str =~ s/\bAf\b/AF/; # patch for "AF"
11438             # patch for a number of models that write improper string
11439             # terminator for ImageStabilization (VR-OFF, VR-ON)
11440 50         81 $str =~ s/ +.$//s;
11441             }
11442 97 100       475 if ($str =~ s/\b([A-Z])([A-Z]*[AEIOUY][A-Z]*)/$1\L$2/g) {
11443 46         112 $str =~ s/\bRaw\b/RAW/; # patch for "RAW"
11444             }
11445             }
11446             }
11447 153         398 return $str;
11448             }
11449              
11450             #------------------------------------------------------------------------------
11451             # decoding tables from ref 4
11452             my @xlat = (
11453             [ 0xc1,0xbf,0x6d,0x0d,0x59,0xc5,0x13,0x9d,0x83,0x61,0x6b,0x4f,0xc7,0x7f,0x3d,0x3d,
11454             0x53,0x59,0xe3,0xc7,0xe9,0x2f,0x95,0xa7,0x95,0x1f,0xdf,0x7f,0x2b,0x29,0xc7,0x0d,
11455             0xdf,0x07,0xef,0x71,0x89,0x3d,0x13,0x3d,0x3b,0x13,0xfb,0x0d,0x89,0xc1,0x65,0x1f,
11456             0xb3,0x0d,0x6b,0x29,0xe3,0xfb,0xef,0xa3,0x6b,0x47,0x7f,0x95,0x35,0xa7,0x47,0x4f,
11457             0xc7,0xf1,0x59,0x95,0x35,0x11,0x29,0x61,0xf1,0x3d,0xb3,0x2b,0x0d,0x43,0x89,0xc1,
11458             0x9d,0x9d,0x89,0x65,0xf1,0xe9,0xdf,0xbf,0x3d,0x7f,0x53,0x97,0xe5,0xe9,0x95,0x17,
11459             0x1d,0x3d,0x8b,0xfb,0xc7,0xe3,0x67,0xa7,0x07,0xf1,0x71,0xa7,0x53,0xb5,0x29,0x89,
11460             0xe5,0x2b,0xa7,0x17,0x29,0xe9,0x4f,0xc5,0x65,0x6d,0x6b,0xef,0x0d,0x89,0x49,0x2f,
11461             0xb3,0x43,0x53,0x65,0x1d,0x49,0xa3,0x13,0x89,0x59,0xef,0x6b,0xef,0x65,0x1d,0x0b,
11462             0x59,0x13,0xe3,0x4f,0x9d,0xb3,0x29,0x43,0x2b,0x07,0x1d,0x95,0x59,0x59,0x47,0xfb,
11463             0xe5,0xe9,0x61,0x47,0x2f,0x35,0x7f,0x17,0x7f,0xef,0x7f,0x95,0x95,0x71,0xd3,0xa3,
11464             0x0b,0x71,0xa3,0xad,0x0b,0x3b,0xb5,0xfb,0xa3,0xbf,0x4f,0x83,0x1d,0xad,0xe9,0x2f,
11465             0x71,0x65,0xa3,0xe5,0x07,0x35,0x3d,0x0d,0xb5,0xe9,0xe5,0x47,0x3b,0x9d,0xef,0x35,
11466             0xa3,0xbf,0xb3,0xdf,0x53,0xd3,0x97,0x53,0x49,0x71,0x07,0x35,0x61,0x71,0x2f,0x43,
11467             0x2f,0x11,0xdf,0x17,0x97,0xfb,0x95,0x3b,0x7f,0x6b,0xd3,0x25,0xbf,0xad,0xc7,0xc5,
11468             0xc5,0xb5,0x8b,0xef,0x2f,0xd3,0x07,0x6b,0x25,0x49,0x95,0x25,0x49,0x6d,0x71,0xc7 ],
11469             [ 0xa7,0xbc,0xc9,0xad,0x91,0xdf,0x85,0xe5,0xd4,0x78,0xd5,0x17,0x46,0x7c,0x29,0x4c,
11470             0x4d,0x03,0xe9,0x25,0x68,0x11,0x86,0xb3,0xbd,0xf7,0x6f,0x61,0x22,0xa2,0x26,0x34,
11471             0x2a,0xbe,0x1e,0x46,0x14,0x68,0x9d,0x44,0x18,0xc2,0x40,0xf4,0x7e,0x5f,0x1b,0xad,
11472             0x0b,0x94,0xb6,0x67,0xb4,0x0b,0xe1,0xea,0x95,0x9c,0x66,0xdc,0xe7,0x5d,0x6c,0x05,
11473             0xda,0xd5,0xdf,0x7a,0xef,0xf6,0xdb,0x1f,0x82,0x4c,0xc0,0x68,0x47,0xa1,0xbd,0xee,
11474             0x39,0x50,0x56,0x4a,0xdd,0xdf,0xa5,0xf8,0xc6,0xda,0xca,0x90,0xca,0x01,0x42,0x9d,
11475             0x8b,0x0c,0x73,0x43,0x75,0x05,0x94,0xde,0x24,0xb3,0x80,0x34,0xe5,0x2c,0xdc,0x9b,
11476             0x3f,0xca,0x33,0x45,0xd0,0xdb,0x5f,0xf5,0x52,0xc3,0x21,0xda,0xe2,0x22,0x72,0x6b,
11477             0x3e,0xd0,0x5b,0xa8,0x87,0x8c,0x06,0x5d,0x0f,0xdd,0x09,0x19,0x93,0xd0,0xb9,0xfc,
11478             0x8b,0x0f,0x84,0x60,0x33,0x1c,0x9b,0x45,0xf1,0xf0,0xa3,0x94,0x3a,0x12,0x77,0x33,
11479             0x4d,0x44,0x78,0x28,0x3c,0x9e,0xfd,0x65,0x57,0x16,0x94,0x6b,0xfb,0x59,0xd0,0xc8,
11480             0x22,0x36,0xdb,0xd2,0x63,0x98,0x43,0xa1,0x04,0x87,0x86,0xf7,0xa6,0x26,0xbb,0xd6,
11481             0x59,0x4d,0xbf,0x6a,0x2e,0xaa,0x2b,0xef,0xe6,0x78,0xb6,0x4e,0xe0,0x2f,0xdc,0x7c,
11482             0xbe,0x57,0x19,0x32,0x7e,0x2a,0xd0,0xb8,0xba,0x29,0x00,0x3c,0x52,0x7d,0xa8,0x49,
11483             0x3b,0x2d,0xeb,0x25,0x49,0xfa,0xa3,0xaa,0x39,0xa7,0xc5,0xa7,0x50,0x11,0x36,0xfb,
11484             0xc6,0x67,0x4a,0xf5,0xa5,0x12,0x65,0x7e,0xb0,0xdf,0xaf,0x4e,0xb3,0x61,0x7f,0x2f ]
11485             );
11486              
11487             # Decrypt Nikon data block (ref 4)
11488             # Inputs: 0) reference to data block, 1) serial number key, 2) shutter count key
11489             # 4) optional start offset (default 0)
11490             # 5) optional number of bytes to decode (default to the end of the data)
11491             # Returns: data block with specified data decrypted
11492             sub Decrypt($$$;$$)
11493             {
11494 4     4 0 20 my ($dataPt, $serial, $count, $start, $len) = @_;
11495 4         7 my ($i, $dat);
11496              
11497 4 100       11 $start or $start = 0;
11498 4         7 my $maxLen = length($$dataPt) - $start;
11499 4 100 66     16 $len = $maxLen if not defined $len or $len > $maxLen;
11500 4 50       10 return $$dataPt if $len <= 0;
11501 4         6 my $key = 0;
11502 4         13 for ($i=0; $i<4; ++$i) {
11503 16         29 $key ^= ($count >> ($i*8)) & 0xff;
11504             }
11505 4         13 my $ci = $xlat[0][$serial & 0xff];
11506 4         8 my $cj = $xlat[1][$key];
11507 4         7 my $ck = 0x60;
11508 4         45 my @data = unpack("x${start}C$len", $$dataPt);
11509 4         12 foreach $dat (@data) {
11510 638         670 $cj = ($cj + $ci * $ck) & 0xff;
11511 638         665 $ck = ($ck + 1) & 0xff;
11512 638         693 $dat ^= $cj;
11513             }
11514 4         10 my $end = $start + $len;
11515 4 100       16 my $pre = $start ? substr($$dataPt, 0, $start) : '';
11516 4 100       12 my $post = $end < length($$dataPt) ? substr($$dataPt, $end) : '';
11517 4         40 return $pre . pack('C*',@data) . $post;
11518             }
11519              
11520             #------------------------------------------------------------------------------
11521             # Get serial number for use as a decryption key
11522             # Inputs: 0) ExifTool object ref, 1) serial number string
11523             # Returns: serial key integer or undef if no serial number provided
11524             sub SerialKey($$)
11525             {
11526 26     26 0 58 my ($et, $serial) = @_;
11527             # use serial number as key if integral
11528 26 50 66     242 return $serial if not defined $serial or $serial =~ /^\d+$/;
11529 0 0       0 return 0x22 if $$et{Model} =~ /\bD50$/; # D50 (ref 8)
11530 0         0 return 0x60; # D200 (ref 10), D40X (ref PH), etc
11531             }
11532              
11533             #------------------------------------------------------------------------------
11534             # Extract information from "NIKON APP" trailer (ref PH)
11535             # Inputs: 0) ExifTool ref, 1) Optional dirInfo ref for returning trailer info
11536             # Returns: true on success
11537             sub ProcessNikonApp($;$)
11538             {
11539 0     0 0 0 local $_;
11540 0         0 my ($et, $dirInfo) = @_;
11541 0         0 my $raf = $$et{RAF};
11542 0 0 0     0 my $offset = $dirInfo ? $$dirInfo{Offset} || 0 : 0;
11543 0         0 my $buff;
11544              
11545 0 0 0     0 return 0 unless $raf->Seek(-20-$offset, 2) and $raf->Read($buff, 20) == 20 and
      0        
11546             substr($buff,-16) eq "\0\0\0\0\0\0/NIKON APP"; # check magic number
11547              
11548 0         0 my $verbose = $et->Options('Verbose');
11549 0         0 my $fileEnd = $raf->Tell();
11550 0         0 my $trailerLen = unpack('N', $buff);
11551 0 0       0 $trailerLen > $fileEnd and $et->Warn('Bad NikonApp trailer size'), return 0;
11552 0 0       0 if ($dirInfo) {
11553 0 0       0 $$dirInfo{DirLen} = $trailerLen if $dirInfo;
11554 0         0 $$dirInfo{DataPos} = $fileEnd - $trailerLen;
11555 0 0       0 if ($$dirInfo{OutFile}) {
11556 0 0 0     0 if ($$et{DEL_GROUP}{NikonApp}) {
    0 0        
11557 0         0 ++$$et{CHANGED};
11558             # just copy the trailer when writing
11559             } elsif ($trailerLen > $fileEnd or not $raf->Seek($$dirInfo{DataPos}, 0) or
11560 0         0 $raf->Read(${$$dirInfo{OutFile}}, $trailerLen) != $trailerLen)
11561             {
11562 0         0 return 0;
11563             } else {
11564 0         0 return 1;
11565             }
11566             }
11567 0 0 0     0 $et->DumpTrailer($dirInfo) if $verbose or $$et{HTML_DUMP};
11568             }
11569 0 0 0     0 unless ($trailerLen >= 0x40 and $raf->Seek($fileEnd - $trailerLen, 0) and
      0        
      0        
11570             $raf->Read($buff, 0x40) == 0x40 and $buff =~ m(NIKON APP\0))
11571             {
11572 0         0 $et->Warn('Error reading NikonApp trailer');
11573 0         0 return 0;
11574             }
11575 0         0 $$et{SET_GROUP0} = 'NikonApp';
11576 0         0 while ($raf->Read($buff, 8) == 8) {
11577 0         0 my ($id, $len) = unpack('N2', $buff);
11578 0 0       0 if ($len & 0x80000000) {
11579 0         0 $et->Warn('Invalid NikonApp record length');
11580 0         0 last;
11581             }
11582 0 0 0     0 last if $id == 0 and $len == 0;
11583 0 0       0 unless ($raf->Read($buff, $len) == $len) {
11584 0         0 $et->Warn('Truncated NikonApp record');
11585 0         0 last;
11586             }
11587 0 0       0 if ($id == 1) {
11588 0         0 require Image::ExifTool::XMP;
11589 0         0 Image::ExifTool::XMP::ProcessXMP($et, { DataPt => \$buff });
11590             } else { # (haven't seen any other types of records)
11591 0         0 $et->Warn("Unknown NikonApp record $id");
11592 0         0 last;
11593             }
11594             }
11595 0         0 delete $$et{SET_GROUP0};
11596 0         0 return 1;
11597             }
11598              
11599             #------------------------------------------------------------------------------
11600             # Read Nikon NCTG tags in MOV videos
11601             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
11602             # Returns: 1 on success
11603             sub ProcessNikonMOV($$$)
11604             {
11605 0     0 0 0 my ($et, $dirInfo, $tagTablePtr) = @_;
11606 0         0 my $dataPt = $$dirInfo{DataPt};
11607 0         0 my $dataPos = $$dirInfo{DataPos};
11608 0         0 my %needTags = ( 0x110a431 => 0, 0x20000a7 => undef ); # needed for decryption
11609 0         0 $et->VerboseDir($$dirInfo{DirName}, 0, $$dirInfo{DirLen});
11610 0         0 my $pass;
11611             # do two passes so we can pre-scan for necessary decryption keys
11612 0         0 for ($pass=0; $pass<2; ++$pass) {
11613 0         0 my $pos = $$dirInfo{DirStart};
11614 0         0 my $end = $pos + $$dirInfo{DirLen};
11615 0         0 while ($pos + 8 < $end) {
11616 0         0 my $tag = Get32u($dataPt, $pos);
11617 0         0 my $fmt = Get16u($dataPt, $pos + 4); # (same format code as EXIF)
11618 0         0 my $count = Get16u($dataPt, $pos + 6);
11619 0         0 $pos += 8;
11620 0         0 my $fmtStr = $Image::ExifTool::Exif::formatName[$fmt];
11621 0 0       0 unless ($fmtStr) {
11622 0 0       0 $et->Warn(sprintf("Unknown format ($fmt) for $$dirInfo{DirName} tag 0x%x",$tag)) if $pass;
11623 0         0 last;
11624             }
11625 0         0 my $size = $count * $Image::ExifTool::Exif::formatSize[$fmt];
11626 0 0       0 if ($pos + $size > $end) {
11627 0 0       0 $et->Warn(sprintf("Truncated data for $$dirInfo{DirName} tag 0x%x",$tag)) if $pass;
11628 0         0 last;
11629             }
11630 0 0       0 if ($pass) {
    0          
11631 0         0 my $rational;
11632 0         0 my $val = ReadValue($dataPt, $pos, $fmtStr, $count, $size, \$rational);
11633             my $key = $et->HandleTag($tagTablePtr, $tag, $val,
11634             DataPt => $dataPt,
11635             DataPos => $dataPos,
11636             Format => $fmtStr,
11637             Start => $pos,
11638             Size => $size,
11639             Base => $$dirInfo{Base},
11640 0         0 );
11641 0 0 0     0 $$et{RATIONAL}{$key} = $rational if $rational and $key;
11642             } elsif (exists $needTags{$tag}) {
11643 0         0 $needTags{$tag} = ReadValue($dataPt, $pos, $fmtStr, $count, $size);
11644 0         0 $$et{NikonSerialKey} = SerialKey($et, $needTags{0x110a431});
11645 0         0 $$et{NikonCountKey} = $needTags{0x20000a7};
11646             }
11647 0         0 $pos += $size; # is this padded to an even offset????
11648             }
11649             }
11650 0         0 return 1;
11651             }
11652              
11653             #------------------------------------------------------------------------------
11654             # Read/Write Nikon Encrypted data block
11655             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
11656             # Returns: 1 on success when reading, or new directory when writing (IsWriting set)
11657             sub ProcessNikonEncrypted($$$)
11658             {
11659 207     207 0 404 my ($et, $dirInfo, $tagTablePtr) = @_;
11660 207 100       684 $et or return 1; # allow dummy access
11661 3         5 my $serial = $$et{NikonSerialKey};
11662 3         6 my $count = $$et{NikonCountKey};
11663 3 50 33     35 unless (defined $serial and defined $count and $serial =~ /^\d+$/ and $count =~ /^\d+$/) {
      33        
      33        
11664 0 0 0     0 if (defined $serial or defined $count) {
11665 0         0 my $msg;
11666 0 0 0     0 if (defined $serial and defined $count) {
11667 0 0       0 $msg = $serial =~ /^\d+$/ ? 'invalid ShutterCount' : 'invalid SerialNumber';
11668             } else {
11669 0 0       0 $msg = defined $serial ? 'no ShutterCount' : 'no SerialNumber';
11670             }
11671 0         0 $et->Warn("Can't decrypt Nikon information ($msg key)");
11672             }
11673 0         0 delete $$et{NikonSerialKey};
11674 0         0 delete $$et{NikonCountKey};
11675 0         0 return 0;
11676             }
11677 3 50       13 my $verbose = $$dirInfo{IsWriting} ? 0 : $et->Options('Verbose');
11678 3         7 my $tagInfo = $$dirInfo{TagInfo};
11679 3         5 my $dirStart = $$dirInfo{DirStart};
11680 3         4 my $data = substr(${$$dirInfo{DataPt}}, $dirStart, $$dirInfo{DirLen});
  3         10  
11681              
11682 3         5 my ($start, $len, $more, $offset, $byteOrder, $recrypt, $newSerial, $newCount);
11683              
11684             # must re-encrypt when writing if serial number or shutter count changes
11685 3 50       8 if ($$dirInfo{IsWriting}) {
11686 0 0       0 if ($$et{NewNikonSerialKey}) {
11687 0         0 $newSerial = $$et{NewNikonSerialKey};
11688 0         0 $recrypt = 1;
11689             }
11690 0 0       0 if ($$et{NewNikonCountKey}) {
11691 0         0 $newCount = $$et{NewNikonCountKey};
11692 0         0 $recrypt = 1;
11693             }
11694             }
11695 3 50 33     12 if ($tagInfo and $$tagInfo{SubDirectory}) {
11696 3         6 $start = $$tagInfo{SubDirectory}{DecryptStart};
11697             # may decrypt only part of the information to save time
11698 3 50 33     12 if ($verbose < 3 and $et->Options('Unknown') < 2 and not $recrypt) {
      33        
11699 3         7 $len = $$tagInfo{SubDirectory}{DecryptLen};
11700 3         4 $more = $$tagInfo{SubDirectory}{DecryptMore};
11701             }
11702 3         6 $offset = $$tagInfo{SubDirectory}{DirOffset};
11703 3         5 $byteOrder = $$tagInfo{SubDirectory}{ByteOrder};
11704             }
11705 3 50       8 $start or $start = 0;
11706 3 100       7 if (defined $offset) {
11707             # offset, if specified, is relative to start of encrypted data
11708 1         2 $offset += $start;
11709             } else {
11710 2         5 $offset = 0;
11711             }
11712 3         6 my $maxLen = length($data) - $start;
11713             # decrypt all the data unless DecryptLen is given
11714 3 100 66     12 unless ($len and $len < $maxLen) {
11715 1         3 $len = $maxLen;
11716 1         4 undef $more; # (can't decrypt more than this)
11717             }
11718              
11719 3         9 $data = Decrypt(\$data, $serial, $count, $start, $len);
11720              
11721             # set appropriate byte ordering before evaluating DecryptMore
11722 3         10 my $oldOrder = GetByteOrder();
11723 3 100       8 SetByteOrder($byteOrder) if $byteOrder;
11724              
11725 3 50       8 if ($more) {
11726             #### eval DecryptMore ($data)
11727 0         0 my $moreLen = eval $more;
11728 0 0       0 $moreLen = $maxLen if $moreLen > $maxLen;
11729             # re-decrypt with new length
11730 0 0       0 if ($len < $moreLen) {
11731 0         0 $len = $moreLen;
11732 0         0 $data = substr(${$$dirInfo{DataPt}}, $dirStart, $$dirInfo{DirLen});
  0         0  
11733 0         0 $data = Decrypt(\$data, $serial, $count, $start, $len);
11734             }
11735             }
11736 3 50       8 if ($verbose > 2) {
11737 0         0 $et->VerboseDir("Decrypted $$tagInfo{Name}");
11738             $et->VerboseDump(\$data,
11739 0         0 Prefix => $$et{INDENT} . ' ',
11740             # (remove this because it is useful to have decrypted offsets start at 0)
11741             #DataPos => $dirStart + $$dirInfo{DataPos} + ($$dirInfo{Base} || 0),
11742             );
11743             }
11744             # process the decrypted information
11745             my %subdirInfo = (
11746             DataPt => \$data,
11747             DirStart => $offset,
11748             DirLen => length($data) - $offset,
11749             DirName => $$dirInfo{DirName},
11750             DataPos => $$dirInfo{DataPos} + $dirStart,
11751             Base => $$dirInfo{Base},
11752 3         15 );
11753 3         4 my $rtnVal;
11754 3 50       9 if ($$dirInfo{IsWriting}) {
11755 0         0 my $changed = $$et{CHANGED};
11756 0         0 $rtnVal = $et->WriteBinaryData(\%subdirInfo, $tagTablePtr);
11757             # must re-encrypt if serial number or shutter count changes
11758 0 0       0 if ($recrypt) {
11759 0 0       0 $serial = $newSerial if defined $newSerial;
11760 0 0       0 $count = $newCount if defined $newCount;
11761 0         0 ++$$et{CHANGED};
11762             }
11763 0 0       0 if ($changed == $$et{CHANGED}) {
11764 0         0 undef $rtnVal; # nothing changed so use original data
11765             } else {
11766             # add back any un-encrypted data at start
11767 0 0       0 $rtnVal = substr($data, 0, $offset) . $rtnVal if $offset;
11768             # re-encrypt data (symmetrical algorithm)
11769 0         0 $rtnVal = Decrypt(\$rtnVal, $serial, $count, $start, $len);
11770             }
11771             } else {
11772 3         9 $rtnVal = $et->ProcessBinaryData(\%subdirInfo, $tagTablePtr);
11773             }
11774 3         10 SetByteOrder($oldOrder);
11775 3         10 return $rtnVal;
11776             }
11777              
11778             #------------------------------------------------------------------------------
11779             # Pre-scan EXIF directory to extract specific tags
11780             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) required tagID hash ref
11781             # Returns: 1 if directory was scanned successfully
11782             sub PrescanExif($$$)
11783             {
11784 19     19 0 52 my ($et, $dirInfo, $tagHash) = @_;
11785 19         44 my $dataPt = $$dirInfo{DataPt};
11786 19   100     88 my $dataPos = $$dirInfo{DataPos} || 0;
11787 19         43 my $dataLen = $$dirInfo{DataLen};
11788 19   50     69 my $dirStart = $$dirInfo{DirStart} || 0;
11789 19   50     62 my $base = $$dirInfo{Base} || 0;
11790 19         53 my $raf = $$dirInfo{RAF};
11791 19         43 my ($index, $numEntries, $data, $buff);
11792              
11793             # get number of entries in IFD
11794 19 50 33     116 if ($dirStart >= 0 and $dirStart <= $dataLen-2) {
11795 19         71 $numEntries = Get16u($dataPt, $dirStart);
11796             # reset $numEntries to read from file if necessary
11797 19 50       86 undef $numEntries if $dirStart + 2 + 12 * $numEntries > $dataLen;
11798             }
11799             # read IFD from file if necessary
11800 19 50       60 unless ($numEntries) {
11801 0 0       0 $raf or return 0;
11802 0         0 $dataPos += $dirStart; # read data from the start of the directory
11803 0 0 0     0 $raf->Seek($dataPos + $base, 0) and $raf->Read($data, 2) == 2 or return 0;
11804 0         0 $numEntries = Get16u(\$data, 0);
11805 0         0 my $len = 12 * $numEntries;
11806 0 0       0 $raf->Read($buff, $len) == $len or return 0;
11807 0         0 $data .= $buff;
11808             # update variables for the newly loaded IFD (already updated dataPos)
11809 0         0 $dataPt = \$data;
11810 0         0 $dataLen = length $data;
11811 0         0 $dirStart = 0;
11812             }
11813             # loop through Nikon MakerNote IFD entries
11814 19         77 for ($index=0; $index<$numEntries; ++$index) {
11815 507         607 my $entry = $dirStart + 2 + 12 * $index;
11816 507         700 my $tagID = Get16u($dataPt, $entry);
11817 507 100       1114 next unless exists $$tagHash{$tagID}; # only extract required tags
11818 8         32 my $format = Get16u($dataPt, $entry+2);
11819 8 50 33     42 next if $format < 1 or $format > 13;
11820 8         25 my $count = Get32u($dataPt, $entry+4);
11821 8         25 my $size = $count * $Image::ExifTool::Exif::formatSize[$format];
11822 8         23 my $formatStr = $Image::ExifTool::Exif::formatName[$format];
11823 8         21 my $valuePtr = $entry + 8; # pointer to value within $$dataPt
11824 8 100       25 if ($size > 4) {
11825 1 50       4 next if $size > 0x1000000; # set a reasonable limit on data size (16MB)
11826 1         3 $valuePtr = Get32u($dataPt, $valuePtr);
11827             # convert offset to pointer in $$dataPt
11828             # (don't yet handle EntryBased or FixOffsets)
11829 1         3 $valuePtr -= $dataPos;
11830 1 50 33     6 if ($valuePtr < 0 or $valuePtr+$size > $dataLen) {
11831 0 0 0     0 next unless $raf and $raf->Seek($base + $valuePtr + $dataPos,0) and
      0        
11832             $raf->Read($buff,$size) == $size;
11833 0         0 $$tagHash{$tagID} = ReadValue(\$buff,0,$formatStr,$count,$size);
11834 0         0 next;
11835             }
11836             }
11837 8         31 $$tagHash{$tagID} = ReadValue($dataPt,$valuePtr,$formatStr,$count,$size);
11838             }
11839 19         49 return 1;
11840             }
11841              
11842             #------------------------------------------------------------------------------
11843             # Process Nikon Capture history data
11844             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
11845             # Returns: 1 on success
11846             sub ProcessNikonCaptureEditVersions($$$)
11847             {
11848 0     0 0 0 my ($et, $dirInfo, $tagTablePtr) = @_;
11849 0         0 require Image::ExifTool::NikonCapture;
11850 0         0 return Image::ExifTool::NikonCapture::ProcessNikonCaptureEditVersions($et, $dirInfo, $tagTablePtr);
11851             }
11852              
11853             #------------------------------------------------------------------------------
11854             # Process Nikon Capture Offsets IFD (ref PH)
11855             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
11856             # Returns: 1 on success
11857             # Notes: This isn't a normal IFD, but is close...
11858             sub ProcessNikonCaptureOffsets($$$)
11859             {
11860 2     2 0 6 my ($et, $dirInfo, $tagTablePtr) = @_;
11861 2         5 my $dataPt = $$dirInfo{DataPt};
11862 2         7 my $dirStart = $$dirInfo{DirStart};
11863 2         5 my $dirLen = $$dirInfo{DirLen};
11864 2         5 my $success = 0;
11865 2 50       6 return 0 unless $dirLen > 2;
11866 2         8 my $count = Get16u($dataPt, $dirStart);
11867 2 50 33     16 return 0 unless $count and $count * 12 + 2 <= $dirLen;
11868 2 50       10 if ($et->Options('Verbose')) {
11869 0         0 $et->VerboseDir('NikonCaptureOffsets', $count);
11870             }
11871 2         4 my $index;
11872 2         9 for ($index=0; $index<$count; ++$index) {
11873 6         12 my $pos = $dirStart + 12 * $index + 2;
11874 6         13 my $tagID = Get32u($dataPt, $pos);
11875 6         15 my $value = Get32u($dataPt, $pos + 4);
11876 6 50       17 $et->HandleTag($tagTablePtr, $tagID, $value,
11877             Index => $index,
11878             DataPt => $dataPt,
11879             Start => $pos,
11880             Size => 12,
11881             ) and $success = 1;
11882             }
11883 2         5 return $success;
11884             }
11885              
11886             #------------------------------------------------------------------------------
11887             # Read/write Nikon MakerNotes directory
11888             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
11889             # Returns: 1 on success, otherwise returns 0 and sets a Warning when reading
11890             # or new directory when writing (IsWriting set in dirInfo)
11891             sub ProcessNikon($$$)
11892             {
11893 316     316 0 726 my ($et, $dirInfo, $tagTablePtr) = @_;
11894 316 100       1157 $et or return 1; # allow dummy access
11895              
11896             # pre-scan IFD to get SerialNumber (0x001d) and ShutterCount (0x00a7) for use in decryption
11897 19         79 my %needTags = ( 0x001d => 0, 0x00a7 => undef );
11898 19         96 PrescanExif($et, $dirInfo, \%needTags);
11899 19         88 $$et{NikonSerialKey} = SerialKey($et, $needTags{0x001d});
11900 19         64 $$et{NikonCountKey} = $needTags{0x00a7};
11901              
11902             # process Nikon makernotes
11903 19         37 my $rtnVal;
11904 19 100       64 if ($$dirInfo{IsWriting}) {
11905             # get new decryptino keys if they are being changed
11906 7         44 my $serial = $et->GetNewValue($Image::ExifTool::Nikon::Main{0x001d});
11907 7         35 my $count = $et->GetNewValue($Image::ExifTool::Nikon::Main{0x00a7});
11908 7         28 $$et{NewNikonSerialKey} = SerialKey($et, $serial);
11909 7         21 $$et{NewNikonCountKey} = $count;
11910 7         86 $rtnVal = Image::ExifTool::Exif::WriteExif($et, $dirInfo, $tagTablePtr);
11911 7         25 delete $$et{NewNikonSerialKey};
11912 7         19 delete $$et{NewNikonCountKey};
11913             } else {
11914 12         113 $rtnVal = Image::ExifTool::Exif::ProcessExif($et, $dirInfo, $tagTablePtr);
11915             }
11916 19         54 delete $$et{NikonSerialKey};
11917 19         41 delete $$et{NikonCountKey};
11918 19         64 return $rtnVal;
11919             }
11920              
11921             1; # end
11922              
11923             __END__