File Coverage

blib/lib/Image/ExifTool/Nikon.pm
Criterion Covered Total %
statement 204 498 40.9
branch 78 300 26.0
condition 31 144 21.5
subroutine 18 31 58.0
pod 0 24 0.0
total 331 997 33.2


line stmt bran cond sub pod time code
1             #------------------------------------------------------------------------------
2             # File: Nikon.pm
3             #
4             # Description: Nikon EXIF maker notes tags
5             #
6             # Revisions: 12/09/2003 - P. Harvey Created
7             # 05/17/2004 - P. Harvey Added information from Joseph Heled
8             # 09/21/2004 - P. Harvey Changed tag 2 to ISOUsed & added PrintConv
9             # 12/01/2004 - P. Harvey Added default PRINT_CONV
10             # 01/01/2005 - P. Harvey Decode preview image and preview IFD
11             # 03/35/2005 - T. Christiansen additions
12             # 05/10/2005 - P. Harvey Decode encrypted lens data
13             # [ongoing] - P. Harvey Constantly decoding new information
14             #
15             # References: 1) http://park2.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html
16             # 2) Joseph Heled private communication (tests with D70)
17             # 3) Thomas Walter private communication (tests with Coolpix 5400)
18             # 4) http://www.cybercom.net/~dcoffin/dcraw/
19             # 5) Brian Ristuccia private communication (tests with D70)
20             # 6) Danek Duvall private communication (tests with D70)
21             # 7) Tom Christiansen private communication (tests with D70)
22             # 8) Robert Rottmerhusen private communication
23             # 9) http://members.aol.com/khancock/pilot/nbuddy/
24             # 10) Werner Kober private communication (D2H, D2X, D100, D70, D200, D90)
25             # 11) http://www.rottmerhusen.com/objektives/lensid/thirdparty.html
26             # 12) http://libexif.sourceforge.net/internals/mnote-olympus-tag_8h-source.html
27             # 13) Roger Larsson private communication (tests with D200)
28             # 14) http://homepage3.nifty.com/kamisaka/makernote/makernote_nikon.htm (2007/09/15)
29             # 15) http://tomtia.plala.jp/DigitalCamera/MakerNote/index.asp
30             # 16) Jeffrey Friedl private communication (D200 with firmware update)
31             # 17) http://www.wohlberg.net/public/software/photo/nstiffexif/
32             # and Brendt Wohlberg private communication
33             # 18) Anonymous user private communication (D70, D200, D2x)
34             # 19) Bruce Stevens private communication
35             # 20) Vladimir Sauta private communication (D80)
36             # 21) Gregor Dorlars private communication (D300)
37             # 22) Tanel Kuusk private communication
38             # 23) Alexandre Naaman private communication (D3)
39             # 24) Geert De Soete private communication
40             # 26) Bozi (http://www.cpanforum.com/posts/8983)
41             # 27) Jens Kriese private communication
42             # 28) Warren Hatch private communication (D3v2.00 with SB-800 and SB-900)
43             # 29) Anonymous contribution 2011/05/25 (D700, D7000)
44             # 30) https://exiftool.org/forum/index.php/topic,3833.30.html
45             # 31) Michael Relt private communication
46             # 32) Stefan https://exiftool.org/forum/index.php/topic,4494.0.html
47             # 34) Stewart Bennett private communication (D4S, D810)
48             # 35) David Puschel private communication
49             # 36) Hayo Baann (forum10207)
50             # 37) Tom Lachecki, private communication
51             # 38) https://github.com/exiftool/exiftool/pull/40 (and forum10893)
52             # 39) Stefan Grube private communication (Z9)
53             # IB) Iliah Borg private communication (LibRaw)
54             # JD) Jens Duttke private communication
55             # NJ) Niels Kristian Bech Jensen private communication
56             #------------------------------------------------------------------------------
57              
58             package Image::ExifTool::Nikon;
59              
60 28     28   6157 use strict;
  28         81  
  28         1136  
61 28     28   220 use vars qw($VERSION %nikonLensIDs %nikonTextEncoding);
  28         86  
  28         1788  
62 28     28   211 use Image::ExifTool qw(:DataAccess :Utils);
  28         85  
  28         6584  
63 28     28   1527 use Image::ExifTool::Exif;
  28         133  
  28         738  
64 28     28   723 use Image::ExifTool::GPS;
  28         95  
  28         705  
65 28     28   11280 use Image::ExifTool::XMP;
  28         497  
  28         754813  
66              
67             $VERSION = '4.21';
68              
69             sub LensIDConv($$$);
70             sub ProcessNikonAVI($$$);
71             sub ProcessNikonMOV($$$);
72             sub ProcessNikonEncrypted($$$);
73             sub FormatString($);
74             sub ProcessNikonCaptureEditVersions($$$);
75             sub PrintAFPoints($$);
76             sub PrintAFPointsInv($$);
77             sub PrintAFPointsGrid($$);
78             sub PrintAFPointsGridInv($$$);
79             sub GetAFPointGrid($$;$);
80              
81             # nikon lens ID numbers (ref 8/11)
82             %nikonLensIDs = (
83             Notes => q{
84             The Nikon LensID is constructed as a Composite tag from the raw hex values
85             of 8 other tags: LensIDNumber, LensFStops, MinFocalLength, MaxFocalLength,
86             MaxApertureAtMinFocal, MaxApertureAtMaxFocal, MCUVersion and LensType, in
87             that order. The user-defined "Lenses" list may be used to specify the lens
88             for ExifTool to choose in these cases (see the
89             L for details).
90             },
91             OTHER => \&LensIDConv,
92             # Note: Sync this list with Robert's Perl version at
93             # http://www.rottmerhusen.com/objektives/lensid/files/exif/fmountlens.p.txt
94             # (hex digits must be uppercase in keys below)
95             '01 58 50 50 14 14 02 00' => 'AF Nikkor 50mm f/1.8',
96             '01 58 50 50 14 14 05 00' => 'AF Nikkor 50mm f/1.8',
97             '02 42 44 5C 2A 34 02 00' => 'AF Zoom-Nikkor 35-70mm f/3.3-4.5',
98             '02 42 44 5C 2A 34 08 00' => 'AF Zoom-Nikkor 35-70mm f/3.3-4.5',
99             '03 48 5C 81 30 30 02 00' => 'AF Zoom-Nikkor 70-210mm f/4',
100             '04 48 3C 3C 24 24 03 00' => 'AF Nikkor 28mm f/2.8',
101             '05 54 50 50 0C 0C 04 00' => 'AF Nikkor 50mm f/1.4',
102             '06 54 53 53 24 24 06 00' => 'AF Micro-Nikkor 55mm f/2.8',
103             '07 40 3C 62 2C 34 03 00' => 'AF Zoom-Nikkor 28-85mm f/3.5-4.5',
104             '08 40 44 6A 2C 34 04 00' => 'AF Zoom-Nikkor 35-105mm f/3.5-4.5',
105             '09 48 37 37 24 24 04 00' => 'AF Nikkor 24mm f/2.8',
106             '0A 48 8E 8E 24 24 03 00' => 'AF Nikkor 300mm f/2.8 IF-ED',
107             '0A 48 8E 8E 24 24 05 00' => 'AF Nikkor 300mm f/2.8 IF-ED N',
108             '0B 48 7C 7C 24 24 05 00' => 'AF Nikkor 180mm f/2.8 IF-ED',
109             '0D 40 44 72 2C 34 07 00' => 'AF Zoom-Nikkor 35-135mm f/3.5-4.5',
110             '0E 48 5C 81 30 30 05 00' => 'AF Zoom-Nikkor 70-210mm f/4',
111             '0F 58 50 50 14 14 05 00' => 'AF Nikkor 50mm f/1.8 N',
112             '10 48 8E 8E 30 30 08 00' => 'AF Nikkor 300mm f/4 IF-ED',
113             '11 48 44 5C 24 24 08 00' => 'AF Zoom-Nikkor 35-70mm f/2.8',
114             '11 48 44 5C 24 24 15 00' => 'AF Zoom-Nikkor 35-70mm f/2.8', #Jakob Dettner
115             '12 48 5C 81 30 3C 09 00' => 'AF Nikkor 70-210mm f/4-5.6',
116             '13 42 37 50 2A 34 0B 00' => 'AF Zoom-Nikkor 24-50mm f/3.3-4.5',
117             '14 48 60 80 24 24 0B 00' => 'AF Zoom-Nikkor 80-200mm f/2.8 ED',
118             '15 4C 62 62 14 14 0C 00' => 'AF Nikkor 85mm f/1.8',
119             '17 3C A0 A0 30 30 0F 00' => 'Nikkor 500mm f/4 P ED IF',
120             '17 3C A0 A0 30 30 11 00' => 'Nikkor 500mm f/4 P ED IF',
121             '18 40 44 72 2C 34 0E 00' => 'AF Zoom-Nikkor 35-135mm f/3.5-4.5 N',
122             '1A 54 44 44 18 18 11 00' => 'AF Nikkor 35mm f/2',
123             '1B 44 5E 8E 34 3C 10 00' => 'AF Zoom-Nikkor 75-300mm f/4.5-5.6',
124             '1C 48 30 30 24 24 12 00' => 'AF Nikkor 20mm f/2.8',
125             '1D 42 44 5C 2A 34 12 00' => 'AF Zoom-Nikkor 35-70mm f/3.3-4.5 N',
126             '1E 54 56 56 24 24 13 00' => 'AF Micro-Nikkor 60mm f/2.8',
127             '1F 54 6A 6A 24 24 14 00' => 'AF Micro-Nikkor 105mm f/2.8',
128             '20 48 60 80 24 24 15 00' => 'AF Zoom-Nikkor 80-200mm f/2.8 ED',
129             '21 40 3C 5C 2C 34 16 00' => 'AF Zoom-Nikkor 28-70mm f/3.5-4.5',
130             '22 48 72 72 18 18 16 00' => 'AF DC-Nikkor 135mm f/2',
131             '23 30 BE CA 3C 48 17 00' => 'Zoom-Nikkor 1200-1700mm f/5.6-8 P ED IF',
132             '24 48 60 80 24 24 1A 02' => 'AF Zoom-Nikkor 80-200mm f/2.8D ED',
133             '25 48 44 5C 24 24 1B 02' => 'AF Zoom-Nikkor 35-70mm f/2.8D',
134             '25 48 44 5C 24 24 3A 02' => 'AF Zoom-Nikkor 35-70mm f/2.8D',
135             '25 48 44 5C 24 24 52 02' => 'AF Zoom-Nikkor 35-70mm f/2.8D',
136             '26 40 3C 5C 2C 34 1C 02' => 'AF Zoom-Nikkor 28-70mm f/3.5-4.5D',
137             '27 48 8E 8E 24 24 1D 02' => 'AF-I Nikkor 300mm f/2.8D IF-ED',
138             '27 48 8E 8E 24 24 F1 02' => 'AF-I Nikkor 300mm f/2.8D IF-ED + TC-14E',
139             '27 48 8E 8E 24 24 E1 02' => 'AF-I Nikkor 300mm f/2.8D IF-ED + TC-17E',
140             '27 48 8E 8E 24 24 F2 02' => 'AF-I Nikkor 300mm f/2.8D IF-ED + TC-20E',
141             '28 3C A6 A6 30 30 1D 02' => 'AF-I Nikkor 600mm f/4D IF-ED',
142             '28 3C A6 A6 30 30 F1 02' => 'AF-I Nikkor 600mm f/4D IF-ED + TC-14E',
143             '28 3C A6 A6 30 30 E1 02' => 'AF-I Nikkor 600mm f/4D IF-ED + TC-17E',
144             '28 3C A6 A6 30 30 F2 02' => 'AF-I Nikkor 600mm f/4D IF-ED + TC-20E',
145             '2A 54 3C 3C 0C 0C 26 02' => 'AF Nikkor 28mm f/1.4D',
146             '2B 3C 44 60 30 3C 1F 02' => 'AF Zoom-Nikkor 35-80mm f/4-5.6D',
147             '2C 48 6A 6A 18 18 27 02' => 'AF DC-Nikkor 105mm f/2D',
148             '2D 48 80 80 30 30 21 02' => 'AF Micro-Nikkor 200mm f/4D IF-ED',
149             '2E 48 5C 82 30 3C 22 02' => 'AF Nikkor 70-210mm f/4-5.6D',
150             '2E 48 5C 82 30 3C 28 02' => 'AF Nikkor 70-210mm f/4-5.6D',
151             '2F 48 30 44 24 24 29 02.1' => 'AF Zoom-Nikkor 20-35mm f/2.8D IF',
152             '30 48 98 98 24 24 24 02' => 'AF-I Nikkor 400mm f/2.8D IF-ED',
153             '30 48 98 98 24 24 F1 02' => 'AF-I Nikkor 400mm f/2.8D IF-ED + TC-14E',
154             '30 48 98 98 24 24 E1 02' => 'AF-I Nikkor 400mm f/2.8D IF-ED + TC-17E',
155             '30 48 98 98 24 24 F2 02' => 'AF-I Nikkor 400mm f/2.8D IF-ED + TC-20E',
156             '31 54 56 56 24 24 25 02' => 'AF Micro-Nikkor 60mm f/2.8D',
157             '32 54 6A 6A 24 24 35 02.1' => 'AF Micro-Nikkor 105mm f/2.8D',
158             '33 48 2D 2D 24 24 31 02' => 'AF Nikkor 18mm f/2.8D',
159             '34 48 29 29 24 24 32 02' => 'AF Fisheye Nikkor 16mm f/2.8D',
160             '35 3C A0 A0 30 30 33 02' => 'AF-I Nikkor 500mm f/4D IF-ED',
161             '35 3C A0 A0 30 30 F1 02' => 'AF-I Nikkor 500mm f/4D IF-ED + TC-14E',
162             '35 3C A0 A0 30 30 E1 02' => 'AF-I Nikkor 500mm f/4D IF-ED + TC-17E',
163             '35 3C A0 A0 30 30 F2 02' => 'AF-I Nikkor 500mm f/4D IF-ED + TC-20E',
164             '36 48 37 37 24 24 34 02' => 'AF Nikkor 24mm f/2.8D',
165             '37 48 30 30 24 24 36 02' => 'AF Nikkor 20mm f/2.8D',
166             '38 4C 62 62 14 14 37 02' => 'AF Nikkor 85mm f/1.8D',
167             '3A 40 3C 5C 2C 34 39 02' => 'AF Zoom-Nikkor 28-70mm f/3.5-4.5D',
168             '3B 48 44 5C 24 24 3A 02' => 'AF Zoom-Nikkor 35-70mm f/2.8D N',
169             '3C 48 60 80 24 24 3B 02' => 'AF Zoom-Nikkor 80-200mm f/2.8D ED', #NJ
170             '3D 3C 44 60 30 3C 3E 02' => 'AF Zoom-Nikkor 35-80mm f/4-5.6D',
171             '3E 48 3C 3C 24 24 3D 02' => 'AF Nikkor 28mm f/2.8D',
172             '3F 40 44 6A 2C 34 45 02' => 'AF Zoom-Nikkor 35-105mm f/3.5-4.5D',
173             '41 48 7C 7C 24 24 43 02' => 'AF Nikkor 180mm f/2.8D IF-ED',
174             '42 54 44 44 18 18 44 02' => 'AF Nikkor 35mm f/2D',
175             '43 54 50 50 0C 0C 46 02' => 'AF Nikkor 50mm f/1.4D',
176             '44 44 60 80 34 3C 47 02' => 'AF Zoom-Nikkor 80-200mm f/4.5-5.6D',
177             '45 40 3C 60 2C 3C 48 02' => 'AF Zoom-Nikkor 28-80mm f/3.5-5.6D',
178             '46 3C 44 60 30 3C 49 02' => 'AF Zoom-Nikkor 35-80mm f/4-5.6D N',
179             '47 42 37 50 2A 34 4A 02' => 'AF Zoom-Nikkor 24-50mm f/3.3-4.5D',
180             '48 48 8E 8E 24 24 4B 02' => 'AF-S Nikkor 300mm f/2.8D IF-ED',
181             '48 48 8E 8E 24 24 F1 02' => 'AF-S Nikkor 300mm f/2.8D IF-ED + TC-14E',
182             '48 48 8E 8E 24 24 E1 02' => 'AF-S Nikkor 300mm f/2.8D IF-ED + TC-17E',
183             '48 48 8E 8E 24 24 F2 02' => 'AF-S Nikkor 300mm f/2.8D IF-ED + TC-20E',
184             '49 3C A6 A6 30 30 4C 02' => 'AF-S Nikkor 600mm f/4D IF-ED',
185             '49 3C A6 A6 30 30 F1 02' => 'AF-S Nikkor 600mm f/4D IF-ED + TC-14E',
186             '49 3C A6 A6 30 30 E1 02' => 'AF-S Nikkor 600mm f/4D IF-ED + TC-17E',
187             '49 3C A6 A6 30 30 F2 02' => 'AF-S Nikkor 600mm f/4D IF-ED + TC-20E',
188             '4A 54 62 62 0C 0C 4D 02' => 'AF Nikkor 85mm f/1.4D IF',
189             '4B 3C A0 A0 30 30 4E 02' => 'AF-S Nikkor 500mm f/4D IF-ED',
190             '4B 3C A0 A0 30 30 F1 02' => 'AF-S Nikkor 500mm f/4D IF-ED + TC-14E',
191             '4B 3C A0 A0 30 30 E1 02' => 'AF-S Nikkor 500mm f/4D IF-ED + TC-17E',
192             '4B 3C A0 A0 30 30 F2 02' => 'AF-S Nikkor 500mm f/4D IF-ED + TC-20E',
193             '4C 40 37 6E 2C 3C 4F 02' => 'AF Zoom-Nikkor 24-120mm f/3.5-5.6D IF',
194             '4D 40 3C 80 2C 3C 62 02' => 'AF Zoom-Nikkor 28-200mm f/3.5-5.6D IF',
195             '4E 48 72 72 18 18 51 02' => 'AF DC-Nikkor 135mm f/2D',
196             '4F 40 37 5C 2C 3C 53 06' => 'IX-Nikkor 24-70mm f/3.5-5.6',
197             '50 48 56 7C 30 3C 54 06' => 'IX-Nikkor 60-180mm f/4-5.6',
198             '53 48 60 80 24 24 57 02' => 'AF Zoom-Nikkor 80-200mm f/2.8D ED',
199             '53 48 60 80 24 24 60 02' => 'AF Zoom-Nikkor 80-200mm f/2.8D ED',
200             '54 44 5C 7C 34 3C 58 02' => 'AF Zoom-Micro Nikkor 70-180mm f/4.5-5.6D ED',
201             '54 44 5C 7C 34 3C 61 02' => 'AF Zoom-Micro Nikkor 70-180mm f/4.5-5.6D ED',
202             '56 48 5C 8E 30 3C 5A 02' => 'AF Zoom-Nikkor 70-300mm f/4-5.6D ED',
203             '59 48 98 98 24 24 5D 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED',
204             '59 48 98 98 24 24 F1 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED + TC-14E',
205             '59 48 98 98 24 24 E1 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED + TC-17E',
206             '59 48 98 98 24 24 F2 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED + TC-20E',
207             '5A 3C 3E 56 30 3C 5E 06' => 'IX-Nikkor 30-60mm f/4-5.6',
208             '5B 44 56 7C 34 3C 5F 06' => 'IX-Nikkor 60-180mm f/4.5-5.6',
209             '5D 48 3C 5C 24 24 63 02' => 'AF-S Zoom-Nikkor 28-70mm f/2.8D IF-ED',
210             '5E 48 60 80 24 24 64 02' => 'AF-S Zoom-Nikkor 80-200mm f/2.8D IF-ED',
211             '5F 40 3C 6A 2C 34 65 02' => 'AF Zoom-Nikkor 28-105mm f/3.5-4.5D IF',
212             '60 40 3C 60 2C 3C 66 02' => 'AF Zoom-Nikkor 28-80mm f/3.5-5.6D', #(http://www.exif.org/forum/topic.asp?TOPIC_ID=16)
213             '61 44 5E 86 34 3C 67 02' => 'AF Zoom-Nikkor 75-240mm f/4.5-5.6D',
214             '63 48 2B 44 24 24 68 02' => 'AF-S Nikkor 17-35mm f/2.8D IF-ED',
215             '64 00 62 62 24 24 6A 02' => 'PC Micro-Nikkor 85mm f/2.8D',
216             '65 44 60 98 34 3C 6B 0A' => 'AF VR Zoom-Nikkor 80-400mm f/4.5-5.6D ED',
217             '66 40 2D 44 2C 34 6C 02' => 'AF Zoom-Nikkor 18-35mm f/3.5-4.5D IF-ED',
218             '67 48 37 62 24 30 6D 02' => 'AF Zoom-Nikkor 24-85mm f/2.8-4D IF',
219             '68 42 3C 60 2A 3C 6E 06' => 'AF Zoom-Nikkor 28-80mm f/3.3-5.6G',
220             '69 48 5C 8E 30 3C 6F 06' => 'AF Zoom-Nikkor 70-300mm f/4-5.6G',
221             '6A 48 8E 8E 30 30 70 02' => 'AF-S Nikkor 300mm f/4D IF-ED',
222             '6B 48 24 24 24 24 71 02' => 'AF Nikkor ED 14mm f/2.8D',
223             '6D 48 8E 8E 24 24 73 02' => 'AF-S Nikkor 300mm f/2.8D IF-ED II',
224             '6E 48 98 98 24 24 74 02' => 'AF-S Nikkor 400mm f/2.8D IF-ED II',
225             '6F 3C A0 A0 30 30 75 02' => 'AF-S Nikkor 500mm f/4D IF-ED II',
226             '70 3C A6 A6 30 30 76 02' => 'AF-S Nikkor 600mm f/4D IF-ED II',
227             '72 48 4C 4C 24 24 77 00' => 'Nikkor 45mm f/2.8 P',
228             '74 40 37 62 2C 34 78 06' => 'AF-S Zoom-Nikkor 24-85mm f/3.5-4.5G IF-ED',
229             '75 40 3C 68 2C 3C 79 06' => 'AF Zoom-Nikkor 28-100mm f/3.5-5.6G',
230             '76 58 50 50 14 14 7A 02' => 'AF Nikkor 50mm f/1.8D',
231             '77 48 5C 80 24 24 7B 0E' => 'AF-S VR Zoom-Nikkor 70-200mm f/2.8G IF-ED',
232             '78 40 37 6E 2C 3C 7C 0E' => 'AF-S VR Zoom-Nikkor 24-120mm f/3.5-5.6G IF-ED',
233             '79 40 3C 80 2C 3C 7F 06' => 'AF Zoom-Nikkor 28-200mm f/3.5-5.6G IF-ED',
234             '7A 3C 1F 37 30 30 7E 06.1' => 'AF-S DX Zoom-Nikkor 12-24mm f/4G IF-ED',
235             '7B 48 80 98 30 30 80 0E' => 'AF-S VR Zoom-Nikkor 200-400mm f/4G IF-ED',
236             '7D 48 2B 53 24 24 82 06' => 'AF-S DX Zoom-Nikkor 17-55mm f/2.8G IF-ED',
237             '7F 40 2D 5C 2C 34 84 06' => 'AF-S DX Zoom-Nikkor 18-70mm f/3.5-4.5G IF-ED',
238             '80 48 1A 1A 24 24 85 06' => 'AF DX Fisheye-Nikkor 10.5mm f/2.8G ED',
239             '81 54 80 80 18 18 86 0E' => 'AF-S VR Nikkor 200mm f/2G IF-ED',
240             '82 48 8E 8E 24 24 87 0E' => 'AF-S VR Nikkor 300mm f/2.8G IF-ED',
241             '83 00 B0 B0 5A 5A 88 04' => 'FSA-L2, EDG 65, 800mm F13 G',
242             '89 3C 53 80 30 3C 8B 06' => 'AF-S DX Zoom-Nikkor 55-200mm f/4-5.6G ED',
243             '8A 54 6A 6A 24 24 8C 0E' => 'AF-S VR Micro-Nikkor 105mm f/2.8G IF-ED', #10
244             # when the TC-20 III 2x teleconverter is used with the above lens, the following have been observed:
245             # 8A 4D 6A 6A 24 24 8C 0E
246             # 8A 4E 6A 6A 24 24 8C 0E
247             # 8A 50 6A 6A 24 24 8C 0E
248             # 8A 51 6A 6A 24 24 8C 0E
249             # 8A 52 6A 6A 24 24 8C 0E
250             # 8A 53 6A 6A 24 24 8C 0E
251             # 8A 54 6A 6A 24 24 8C 0E (same as without the TC)
252             '8B 40 2D 80 2C 3C 8D 0E' => 'AF-S DX VR Zoom-Nikkor 18-200mm f/3.5-5.6G IF-ED',
253             '8B 40 2D 80 2C 3C FD 0E' => 'AF-S DX VR Zoom-Nikkor 18-200mm f/3.5-5.6G IF-ED [II]', #20
254             '8C 40 2D 53 2C 3C 8E 06' => 'AF-S DX Zoom-Nikkor 18-55mm f/3.5-5.6G ED',
255             '8D 44 5C 8E 34 3C 8F 0E' => 'AF-S VR Zoom-Nikkor 70-300mm f/4.5-5.6G IF-ED', #10
256             '8F 40 2D 72 2C 3C 91 06' => 'AF-S DX Zoom-Nikkor 18-135mm f/3.5-5.6G IF-ED',
257             '90 3B 53 80 30 3C 92 0E' => 'AF-S DX VR Zoom-Nikkor 55-200mm f/4-5.6G IF-ED',
258             '92 48 24 37 24 24 94 06' => 'AF-S Zoom-Nikkor 14-24mm f/2.8G ED',
259             '93 48 37 5C 24 24 95 06' => 'AF-S Zoom-Nikkor 24-70mm f/2.8G ED',
260             '94 40 2D 53 2C 3C 96 06' => 'AF-S DX Zoom-Nikkor 18-55mm f/3.5-5.6G ED II', #10 (D40)
261             '95 4C 37 37 2C 2C 97 02' => 'PC-E Nikkor 24mm f/3.5D ED',
262             '95 00 37 37 2C 2C 97 06' => 'PC-E Nikkor 24mm f/3.5D ED', #JD
263             '96 48 98 98 24 24 98 0E' => 'AF-S VR Nikkor 400mm f/2.8G ED',
264             '97 3C A0 A0 30 30 99 0E' => 'AF-S VR Nikkor 500mm f/4G ED',
265             '98 3C A6 A6 30 30 9A 0E' => 'AF-S VR Nikkor 600mm f/4G ED',
266             '99 40 29 62 2C 3C 9B 0E' => 'AF-S DX VR Zoom-Nikkor 16-85mm f/3.5-5.6G ED',
267             '9A 40 2D 53 2C 3C 9C 0E' => 'AF-S DX VR Zoom-Nikkor 18-55mm f/3.5-5.6G',
268             '9B 54 4C 4C 24 24 9D 02' => 'PC-E Micro Nikkor 45mm f/2.8D ED',
269             '9B 00 4C 4C 24 24 9D 06' => 'PC-E Micro Nikkor 45mm f/2.8D ED',
270             '9C 54 56 56 24 24 9E 06' => 'AF-S Micro Nikkor 60mm f/2.8G ED',
271             '9D 54 62 62 24 24 9F 02' => 'PC-E Micro Nikkor 85mm f/2.8D',
272             '9D 00 62 62 24 24 9F 06' => 'PC-E Micro Nikkor 85mm f/2.8D',
273             '9E 40 2D 6A 2C 3C A0 0E' => 'AF-S DX VR Zoom-Nikkor 18-105mm f/3.5-5.6G ED', #PH/10
274             '9F 58 44 44 14 14 A1 06' => 'AF-S DX Nikkor 35mm f/1.8G', #27
275             'A0 54 50 50 0C 0C A2 06' => 'AF-S Nikkor 50mm f/1.4G',
276             'A1 40 18 37 2C 34 A3 06' => 'AF-S DX Nikkor 10-24mm f/3.5-4.5G ED',
277             'A1 40 2D 53 2C 3C CB 86' => 'AF-P DX Nikkor 18-55mm f/3.5-5.6G', #30
278             'A2 48 5C 80 24 24 A4 0E' => 'AF-S Nikkor 70-200mm f/2.8G ED VR II',
279             'A3 3C 29 44 30 30 A5 0E' => 'AF-S Nikkor 16-35mm f/4G ED VR',
280             'A4 54 37 37 0C 0C A6 06' => 'AF-S Nikkor 24mm f/1.4G ED',
281             'A5 40 3C 8E 2C 3C A7 0E' => 'AF-S Nikkor 28-300mm f/3.5-5.6G ED VR',
282             'A6 48 8E 8E 24 24 A8 0E' => 'AF-S Nikkor 300mm f/2.8G IF-ED VR II',
283             'A7 4B 62 62 2C 2C A9 0E' => 'AF-S DX Micro Nikkor 85mm f/3.5G ED VR',
284             'A8 48 80 98 30 30 AA 0E' => 'AF-S Zoom-Nikkor 200-400mm f/4G IF-ED VR II', #https://exiftool.org/forum/index.php/topic,3218.msg15495.html#msg15495
285             'A9 54 80 80 18 18 AB 0E' => 'AF-S Nikkor 200mm f/2G ED VR II',
286             'AA 3C 37 6E 30 30 AC 0E' => 'AF-S Nikkor 24-120mm f/4G ED VR',
287             'AC 38 53 8E 34 3C AE 0E' => 'AF-S DX Nikkor 55-300mm f/4.5-5.6G ED VR',
288             'AD 3C 2D 8E 2C 3C AF 0E' => 'AF-S DX Nikkor 18-300mm f/3.5-5.6G ED VR',
289             'AE 54 62 62 0C 0C B0 06' => 'AF-S Nikkor 85mm f/1.4G',
290             'AF 54 44 44 0C 0C B1 06' => 'AF-S Nikkor 35mm f/1.4G',
291             'B0 4C 50 50 14 14 B2 06' => 'AF-S Nikkor 50mm f/1.8G',
292             'B1 48 48 48 24 24 B3 06' => 'AF-S DX Micro Nikkor 40mm f/2.8G', #27
293             'B2 48 5C 80 30 30 B4 0E' => 'AF-S Nikkor 70-200mm f/4G ED VR', #35
294             'B3 4C 62 62 14 14 B5 06' => 'AF-S Nikkor 85mm f/1.8G',
295             'B4 40 37 62 2C 34 B6 0E' => 'AF-S Zoom-Nikkor 24-85mm f/3.5-4.5G IF-ED VR', #30
296             'B5 4C 3C 3C 14 14 B7 06' => 'AF-S Nikkor 28mm f/1.8G', #30
297             'B6 3C B0 B0 3C 3C B8 0E' => 'AF-S VR Nikkor 800mm f/5.6E FL ED',
298             'B6 3C B0 B0 3C 3C B8 4E' => 'AF-S VR Nikkor 800mm f/5.6E FL ED', #PH
299             'B7 44 60 98 34 3C B9 0E' => 'AF-S Nikkor 80-400mm f/4.5-5.6G ED VR',
300             'B8 40 2D 44 2C 34 BA 06' => 'AF-S Nikkor 18-35mm f/3.5-4.5G ED',
301             'A0 40 2D 74 2C 3C BB 0E' => 'AF-S DX Nikkor 18-140mm f/3.5-5.6G ED VR', #PH
302             'A1 54 55 55 0C 0C BC 06' => 'AF-S Nikkor 58mm f/1.4G', #IB
303             'A1 48 6E 8E 24 24 DB 4E' => 'AF-S Nikkor 120-300mm f/2.8E FL ED SR VR', #28
304             'A2 40 2D 53 2C 3C BD 0E' => 'AF-S DX Nikkor 18-55mm f/3.5-5.6G VR II',
305             'A4 40 2D 8E 2C 40 BF 0E' => 'AF-S DX Nikkor 18-300mm f/3.5-6.3G ED VR',
306             'A5 4C 44 44 14 14 C0 06' => 'AF-S Nikkor 35mm f/1.8G ED', #35 ("ED" ref 11)
307             'A6 48 98 98 24 24 C1 0E' => 'AF-S Nikkor 400mm f/2.8E FL ED VR',
308             'A7 3C 53 80 30 3C C2 0E' => 'AF-S DX Nikkor 55-200mm f/4-5.6G ED VR II', #IB
309             'A8 48 8E 8E 30 30 C3 4E' => 'AF-S Nikkor 300mm f/4E PF ED VR', #35
310             'A8 48 8E 8E 30 30 C3 0E' => 'AF-S Nikkor 300mm f/4E PF ED VR', #30
311             'A9 4C 31 31 14 14 C4 06' => 'AF-S Nikkor 20mm f/1.8G ED', #30
312             'AA 48 37 5C 24 24 C5 4E' => 'AF-S Nikkor 24-70mm f/2.8E ED VR',
313             'AA 48 37 5C 24 24 C5 0E' => 'AF-S Nikkor 24-70mm f/2.8E ED VR',
314             'AB 3C A0 A0 30 30 C6 4E' => 'AF-S Nikkor 500mm f/4E FL ED VR',
315             'AC 3C A6 A6 30 30 C7 4E' => 'AF-S Nikkor 600mm f/4E FL ED VR', #PH
316             'AD 48 28 60 24 30 C8 4E' => 'AF-S DX Nikkor 16-80mm f/2.8-4E ED VR',
317             'AD 48 28 60 24 30 C8 0E' => 'AF-S DX Nikkor 16-80mm f/2.8-4E ED VR', #PH
318             'AE 3C 80 A0 3C 3C C9 4E' => 'AF-S Nikkor 200-500mm f/5.6E ED VR', #PH
319             'AE 3C 80 A0 3C 3C C9 0E' => 'AF-S Nikkor 200-500mm f/5.6E ED VR',
320             'A0 40 2D 53 2C 3C CA 8E' => 'AF-P DX Nikkor 18-55mm f/3.5-5.6G', #Yang You pvt communication
321             'A0 40 2D 53 2C 3C CA 0E' => 'AF-P DX Nikkor 18-55mm f/3.5-5.6G VR', #PH
322             'AF 4C 37 37 14 14 CC 06' => 'AF-S Nikkor 24mm f/1.8G ED', #IB
323             'A2 38 5C 8E 34 40 CD 86' => 'AF-P DX Nikkor 70-300mm f/4.5-6.3G VR', #PH
324             'A3 38 5C 8E 34 40 CE 8E' => 'AF-P DX Nikkor 70-300mm f/4.5-6.3G ED VR',
325             'A3 38 5C 8E 34 40 CE 0E' => 'AF-P DX Nikkor 70-300mm f/4.5-6.3G ED',
326             'A4 48 5C 80 24 24 CF 4E' => 'AF-S Nikkor 70-200mm f/2.8E FL ED VR',
327             'A4 48 5C 80 24 24 CF 0E' => 'AF-S Nikkor 70-200mm f/2.8E FL ED VR',
328             'A5 54 6A 6A 0C 0C D0 46' => 'AF-S Nikkor 105mm f/1.4E ED', #IB
329             'A5 54 6A 6A 0C 0C D0 06' => 'AF-S Nikkor 105mm f/1.4E ED', #IB
330             'A6 48 2F 2F 30 30 D1 46' => 'PC Nikkor 19mm f/4E ED',
331             'A6 48 2F 2F 30 30 D1 06' => 'PC Nikkor 19mm f/4E ED',
332             'A7 40 11 26 2C 34 D2 46' => 'AF-S Fisheye Nikkor 8-15mm f/3.5-4.5E ED',
333             'A7 40 11 26 2C 34 D2 06' => 'AF-S Fisheye Nikkor 8-15mm f/3.5-4.5E ED',
334             'A8 38 18 30 34 3C D3 8E' => 'AF-P DX Nikkor 10-20mm f/4.5-5.6G VR', #Yang You pvt communication
335             'A8 38 18 30 34 3C D3 0E' => 'AF-P DX Nikkor 10-20mm f/4.5-5.6G VR',
336             'A9 48 7C 98 30 30 D4 4E' => 'AF-S Nikkor 180-400mm f/4E TC1.4 FL ED VR', #IB
337             'A9 48 7C 98 30 30 D4 0E' => 'AF-S Nikkor 180-400mm f/4E TC1.4 FL ED VR',
338             'AA 48 88 A4 3C 3C D5 4E' => 'AF-S Nikkor 180-400mm f/4E TC1.4 FL ED VR + 1.4x TC', #IB
339             'AA 48 88 A4 3C 3C D5 0E' => 'AF-S Nikkor 180-400mm f/4E TC1.4 FL ED VR + 1.4x TC',
340             'AB 44 5C 8E 34 3C D6 CE' => 'AF-P Nikkor 70-300mm f/4.5-5.6E ED VR',
341             'AB 44 5C 8E 34 3C D6 0E' => 'AF-P Nikkor 70-300mm f/4.5-5.6E ED VR',
342             'AB 44 5C 8E 34 3C D6 4E' => 'AF-P Nikkor 70-300mm f/4.5-5.6E ED VR', #IB
343             'AC 54 3C 3C 0C 0C D7 46' => 'AF-S Nikkor 28mm f/1.4E ED',
344             'AC 54 3C 3C 0C 0C D7 06' => 'AF-S Nikkor 28mm f/1.4E ED',
345             'AD 3C A0 A0 3C 3C D8 0E' => 'AF-S Nikkor 500mm f/5.6E PF ED VR',
346             'AD 3C A0 A0 3C 3C D8 4E' => 'AF-S Nikkor 500mm f/5.6E PF ED VR',
347             '01 00 00 00 00 00 02 00' => 'TC-16A',
348             '01 00 00 00 00 00 08 00' => 'TC-16A',
349             '00 00 00 00 00 00 F1 0C' => 'TC-14E [II] or Sigma APO Tele Converter 1.4x EX DG or Kenko Teleplus PRO 300 DG 1.4x',
350             '00 00 00 00 00 00 F2 18' => 'TC-20E [II] or Sigma APO Tele Converter 2x EX DG or Kenko Teleplus PRO 300 DG 2.0x',
351             '00 00 00 00 00 00 E1 12' => 'TC-17E II',
352             'FE 47 00 00 24 24 4B 06' => 'Sigma 4.5mm F2.8 EX DC HSM Circular Fisheye', #JD
353             '26 48 11 11 30 30 1C 02' => 'Sigma 8mm F4 EX Circular Fisheye',
354             '79 40 11 11 2C 2C 1C 06' => 'Sigma 8mm F3.5 EX Circular Fisheye', #JD
355             'DB 40 11 11 2C 2C 1C 06' => 'Sigma 8mm F3.5 EX DG Circular Fisheye', #30
356             'DC 48 19 19 24 24 4B 06' => 'Sigma 10mm F2.8 EX DC HSM Fisheye',
357             'C2 4C 24 24 14 14 4B 06' => 'Sigma 14mm F1.8 DG HSM | A', #IB
358             '48 48 24 24 24 24 4B 02' => 'Sigma 14mm F2.8 EX Aspherical HSM',
359             '02 3F 24 24 2C 2C 02 00' => 'Sigma 14mm F3.5',
360             '26 48 27 27 24 24 1C 02' => 'Sigma 15mm F2.8 EX Diagonal Fisheye',
361             'EA 48 27 27 24 24 1C 02' => 'Sigma 15mm F2.8 EX Diagonal Fisheye', #30
362             '26 58 31 31 14 14 1C 02' => 'Sigma 20mm F1.8 EX DG Aspherical RF',
363             '79 54 31 31 0C 0C 4B 06' => 'Sigma 20mm F1.4 DG HSM | A', #Rolf Probst
364             '26 58 37 37 14 14 1C 02' => 'Sigma 24mm F1.8 EX DG Aspherical Macro',
365             'E1 58 37 37 14 14 1C 02' => 'Sigma 24mm F1.8 EX DG Aspherical Macro',
366             '02 46 37 37 25 25 02 00' => 'Sigma 24mm F2.8 Super Wide II Macro',
367             '7E 54 37 37 0C 0C 4B 06' => 'Sigma 24mm F1.4 DG HSM | A', #30
368             '26 58 3C 3C 14 14 1C 02' => 'Sigma 28mm F1.8 EX DG Aspherical Macro',
369             '48 54 3E 3E 0C 0C 4B 06' => 'Sigma 30mm F1.4 EX DC HSM',
370             'F8 54 3E 3E 0C 0C 4B 06' => 'Sigma 30mm F1.4 EX DC HSM', #JD
371             '91 54 44 44 0C 0C 4B 06' => 'Sigma 35mm F1.4 DG HSM', #30
372             'BD 54 48 48 0C 0C 4B 46' => 'Sigma 40mm F1.4 DG HSM | A', #30
373             'DE 54 50 50 0C 0C 4B 06' => 'Sigma 50mm F1.4 EX DG HSM',
374             '88 54 50 50 0C 0C 4B 06' => 'Sigma 50mm F1.4 DG HSM | A',
375             '02 48 50 50 24 24 02 00' => 'Sigma Macro 50mm F2.8', #https://exiftool.org/forum/index.php/topic,4027.0.html
376             '32 54 50 50 24 24 35 02' => 'Sigma Macro 50mm F2.8 EX DG',
377             '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
378             '79 48 5C 5C 24 24 1C 06' => 'Sigma Macro 70mm F2.8 EX DG', #JD
379             '9B 54 62 62 0C 0C 4B 06' => 'Sigma 85mm F1.4 EX DG HSM',
380             'C8 54 62 62 0C 0C 4B 46' => 'Sigma 85mm F1.4 DG HSM | A', #JamiBradley
381             'C8 54 62 62 0C 0C 4B 06' => 'Sigma 85mm F1.4 DG HSM | A', #KennethCochran
382             '02 48 65 65 24 24 02 00' => 'Sigma Macro 90mm F2.8',
383             '32 54 6A 6A 24 24 35 02.2' => 'Sigma Macro 105mm F2.8 EX DG', #JD
384             'E5 54 6A 6A 24 24 35 02' => 'Sigma Macro 105mm F2.8 EX DG',
385             '97 48 6A 6A 24 24 4B 0E' => 'Sigma Macro 105mm F2.8 EX DG OS HSM',
386             'BE 54 6A 6A 0C 0C 4B 46' => 'Sigma 105mm F1.4 DG HSM | A', #30
387             '48 48 76 76 24 24 4B 06' => 'Sigma APO Macro 150mm F2.8 EX DG HSM',
388             'F5 48 76 76 24 24 4B 06' => 'Sigma APO Macro 150mm F2.8 EX DG HSM', #24
389             '99 48 76 76 24 24 4B 0E' => 'Sigma APO Macro 150mm F2.8 EX DG OS HSM', #(Christian Hesse)
390             '48 4C 7C 7C 2C 2C 4B 02' => 'Sigma APO Macro 180mm F3.5 EX DG HSM',
391             '48 4C 7D 7D 2C 2C 4B 02' => 'Sigma APO Macro 180mm F3.5 EX DG HSM',
392             'F4 4C 7C 7C 2C 2C 4B 02' => 'Sigma APO Macro 180mm F3.5 EX DG HSM', #Bruno
393             '94 48 7C 7C 24 24 4B 0E' => 'Sigma APO Macro 180mm F2.8 EX DG OS HSM', #MichaelTapes (HSM from ref 8)
394             '48 54 8E 8E 24 24 4B 02' => 'Sigma APO 300mm F2.8 EX DG HSM',
395             'FB 54 8E 8E 24 24 4B 02' => 'Sigma APO 300mm F2.8 EX DG HSM', #26
396             '26 48 8E 8E 30 30 1C 02' => 'Sigma APO Tele Macro 300mm F4',
397             '02 2F 98 98 3D 3D 02 00' => 'Sigma APO 400mm F5.6',
398             '26 3C 98 98 3C 3C 1C 02' => 'Sigma APO Tele Macro 400mm F5.6',
399             '02 37 A0 A0 34 34 02 00' => 'Sigma APO 500mm F4.5', #19
400             '48 44 A0 A0 34 34 4B 02' => 'Sigma APO 500mm F4.5 EX HSM',
401             'F1 44 A0 A0 34 34 4B 02' => 'Sigma APO 500mm F4.5 EX DG HSM',
402             '02 34 A0 A0 44 44 02 00' => 'Sigma APO 500mm F7.2',
403             '02 3C B0 B0 3C 3C 02 00' => 'Sigma APO 800mm F5.6',
404             '48 3C B0 B0 3C 3C 4B 02' => 'Sigma APO 800mm F5.6 EX HSM',
405             '9E 38 11 29 34 3C 4B 06' => 'Sigma 8-16mm F4.5-5.6 DC HSM',
406             'A1 41 19 31 2C 2C 4B 06' => 'Sigma 10-20mm F3.5 EX DC HSM',
407             '48 3C 19 31 30 3C 4B 06' => 'Sigma 10-20mm F4-5.6 EX DC HSM',
408             'F9 3C 19 31 30 3C 4B 06' => 'Sigma 10-20mm F4-5.6 EX DC HSM', #JD
409             '48 38 1F 37 34 3C 4B 06' => 'Sigma 12-24mm F4.5-5.6 EX DG Aspherical HSM',
410             'F0 38 1F 37 34 3C 4B 06' => 'Sigma 12-24mm F4.5-5.6 EX DG Aspherical HSM',
411             '96 38 1F 37 34 3C 4B 06' => 'Sigma 12-24mm F4.5-5.6 II DG HSM', #Jurgen Sahlberg
412             'CA 3C 1F 37 30 30 4B 46' => 'Sigma 12-24mm F4 DG HSM | A', #github issue#101
413             'C1 48 24 37 24 24 4B 46' => 'Sigma 14-24mm F2.8 DG HSM | A', #30
414             '26 40 27 3F 2C 34 1C 02' => 'Sigma 15-30mm F3.5-4.5 EX DG Aspherical DF',
415             '48 48 2B 44 24 30 4B 06' => 'Sigma 17-35mm F2.8-4 EX DG Aspherical HSM',
416             '26 54 2B 44 24 30 1C 02' => 'Sigma 17-35mm F2.8-4 EX Aspherical',
417             '9D 48 2B 50 24 24 4B 0E' => 'Sigma 17-50mm F2.8 EX DC OS HSM',
418             '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
419             '7A 47 2B 5C 24 34 4B 06' => 'Sigma 17-70mm F2.8-4.5 DC Macro Asp. IF HSM',
420             '7A 48 2B 5C 24 34 4B 06' => 'Sigma 17-70mm F2.8-4.5 DC Macro Asp. IF HSM',
421             '7F 48 2B 5C 24 34 1C 06' => 'Sigma 17-70mm F2.8-4.5 DC Macro Asp. IF',
422             '8E 3C 2B 5C 24 30 4B 0E' => 'Sigma 17-70mm F2.8-4 DC Macro OS HSM | C',
423             '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
424             '8B 4C 2D 44 14 14 4B 06' => 'Sigma 18-35mm F1.8 DC HSM', #30/NJ
425             '26 40 2D 44 2B 34 1C 02' => 'Sigma 18-35mm F3.5-4.5 Aspherical',
426             '26 48 2D 50 24 24 1C 06' => 'Sigma 18-50mm F2.8 EX DC',
427             '7F 48 2D 50 24 24 1C 06' => 'Sigma 18-50mm F2.8 EX DC Macro', #NJ
428             '7A 48 2D 50 24 24 4B 06' => 'Sigma 18-50mm F2.8 EX DC Macro',
429             'F6 48 2D 50 24 24 4B 06' => 'Sigma 18-50mm F2.8 EX DC Macro',
430             'A4 47 2D 50 24 34 4B 0E' => 'Sigma 18-50mm F2.8-4.5 DC OS HSM',
431             '26 40 2D 50 2C 3C 1C 06' => 'Sigma 18-50mm F3.5-5.6 DC',
432             '7A 40 2D 50 2C 3C 4B 06' => 'Sigma 18-50mm F3.5-5.6 DC HSM',
433             '26 40 2D 70 2B 3C 1C 06' => 'Sigma 18-125mm F3.5-5.6 DC',
434             'CD 3D 2D 70 2E 3C 4B 0E' => 'Sigma 18-125mm F3.8-5.6 DC OS HSM',
435             '26 40 2D 80 2C 40 1C 06' => 'Sigma 18-200mm F3.5-6.3 DC',
436             'FF 40 2D 80 2C 40 4B 06' => 'Sigma 18-200mm F3.5-6.3 DC', #30
437             '7A 40 2D 80 2C 40 4B 0E' => 'Sigma 18-200mm F3.5-6.3 DC OS HSM',
438             'ED 40 2D 80 2C 40 4B 0E' => 'Sigma 18-200mm F3.5-6.3 DC OS HSM', #JD
439             '90 40 2D 80 2C 40 4B 0E' => 'Sigma 18-200mm F3.5-6.3 II DC OS HSM', #JohnHelour
440             '89 30 2D 80 2C 40 4B 0E' => 'Sigma 18-200mm F3.5-6.3 DC Macro OS HS | C', #JoeSchonberg
441             'A5 40 2D 88 2C 40 4B 0E' => 'Sigma 18-250mm F3.5-6.3 DC OS HSM',
442             # LensFStops varies with FocalLength for this lens (ref 2):
443             '92 2C 2D 88 2C 40 4B 0E' => 'Sigma 18-250mm F3.5-6.3 DC Macro OS HSM', #2
444             '87 2C 2D 8E 2C 40 4B 0E' => 'Sigma 18-300mm F3.5-6.3 DC Macro HSM', #30
445             # '92 2C 2D 88 2C 40 4B 0E' (250mm)
446             # '92 2B 2D 88 2C 40 4B 0E' (210mm)
447             # '92 2C 2D 88 2C 40 4B 0E' (185mm)
448             # '92 2D 2D 88 2C 40 4B 0E' (155mm)
449             # '92 2E 2D 88 2C 40 4B 0E' (130mm)
450             # '92 2F 2D 88 2C 40 4B 0E' (105mm)
451             # '92 30 2D 88 2C 40 4B 0E' (90mm)
452             # '92 32 2D 88 2C 40 4B 0E' (75mm)
453             # '92 33 2D 88 2C 40 4B 0E' (62mm)
454             # '92 35 2D 88 2C 40 4B 0E' (52mm)
455             # '92 37 2D 88 2C 40 4B 0E' (44mm)
456             # '92 39 2D 88 2C 40 4B 0E' (38mm)
457             # '92 3A 2D 88 2C 40 4B 0E' (32mm)
458             # '92 3E 2D 88 2C 40 4B 0E' (22mm)
459             # '92 40 2D 88 2C 40 4B 0E' (18mm)
460             '26 48 31 49 24 24 1C 02' => 'Sigma 20-40mm F2.8',
461             '7B 48 37 44 18 18 4B 06' => 'Sigma 24-35mm F2.0 DG HSM | A', #30
462             '02 3A 37 50 31 3D 02 00' => 'Sigma 24-50mm F4-5.6 UC',
463             '26 48 37 56 24 24 1C 02' => 'Sigma 24-60mm F2.8 EX DG',
464             'B6 48 37 56 24 24 1C 02' => 'Sigma 24-60mm F2.8 EX DG',
465             'A6 48 37 5C 24 24 4B 06' => 'Sigma 24-70mm F2.8 IF EX DG HSM', #JD
466             'C9 48 37 5C 24 24 4B 4E' => 'Sigma 24-70mm F2.8 DG OS HSM | A', #30
467             '26 54 37 5C 24 24 1C 02' => 'Sigma 24-70mm F2.8 EX DG Macro',
468             '67 54 37 5C 24 24 1C 02' => 'Sigma 24-70mm F2.8 EX DG Macro',
469             'E9 54 37 5C 24 24 1C 02' => 'Sigma 24-70mm F2.8 EX DG Macro',
470             '26 40 37 5C 2C 3C 1C 02' => 'Sigma 24-70mm F3.5-5.6 Aspherical HF',
471             '8A 3C 37 6A 30 30 4B 0E' => 'Sigma 24-105mm F4 DG OS HSM', #IB
472             '26 54 37 73 24 34 1C 02' => 'Sigma 24-135mm F2.8-4.5',
473             '02 46 3C 5C 25 25 02 00' => 'Sigma 28-70mm F2.8',
474             '26 54 3C 5C 24 24 1C 02' => 'Sigma 28-70mm F2.8 EX',
475             '26 48 3C 5C 24 24 1C 06' => 'Sigma 28-70mm F2.8 EX DG',
476             '79 48 3C 5C 24 24 1C 06' => 'Sigma 28-70mm F2.8 EX DG', #30 ("D" removed)
477             '26 48 3C 5C 24 30 1C 02' => 'Sigma 28-70mm F2.8-4 DG',
478             '02 3F 3C 5C 2D 35 02 00' => 'Sigma 28-70mm F3.5-4.5 UC',
479             '26 40 3C 60 2C 3C 1C 02' => 'Sigma 28-80mm F3.5-5.6 Mini Zoom Macro II Aspherical',
480             '26 40 3C 65 2C 3C 1C 02' => 'Sigma 28-90mm F3.5-5.6 Macro',
481             '26 48 3C 6A 24 30 1C 02' => 'Sigma 28-105mm F2.8-4 Aspherical',
482             '26 3E 3C 6A 2E 3C 1C 02' => 'Sigma 28-105mm F3.8-5.6 UC-III Aspherical IF',
483             '26 40 3C 80 2C 3C 1C 02' => 'Sigma 28-200mm F3.5-5.6 Compact Aspherical Hyperzoom Macro',
484             '26 40 3C 80 2B 3C 1C 02' => 'Sigma 28-200mm F3.5-5.6 Compact Aspherical Hyperzoom Macro',
485             '26 3D 3C 80 2F 3D 1C 02' => 'Sigma 28-300mm F3.8-5.6 Aspherical',
486             '26 41 3C 8E 2C 40 1C 02' => 'Sigma 28-300mm F3.5-6.3 DG Macro',
487             '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
488             '26 40 3C 8E 2C 40 1C 02' => 'Sigma 28-300mm F3.5-6.3 Macro',
489             '02 3B 44 61 30 3D 02 00' => 'Sigma 35-80mm F4-5.6',
490             '02 40 44 73 2B 36 02 00' => 'Sigma 35-135mm F3.5-4.5 a',
491             'CC 4C 50 68 14 14 4B 06' => 'Sigma 50-100mm F1.8 DC HSM | A', #30
492             '7A 47 50 76 24 24 4B 06' => 'Sigma 50-150mm F2.8 EX APO DC HSM',
493             'FD 47 50 76 24 24 4B 06' => 'Sigma 50-150mm F2.8 EX APO DC HSM II',
494             '98 48 50 76 24 24 4B 0E' => 'Sigma 50-150mm F2.8 EX APO DC OS HSM', #30
495             '48 3C 50 A0 30 40 4B 02' => 'Sigma 50-500mm F4-6.3 EX APO RF HSM',
496             '9F 37 50 A0 34 40 4B 0E' => 'Sigma 50-500mm F4.5-6.3 DG OS HSM', #16
497             '26 3C 54 80 30 3C 1C 06' => 'Sigma 55-200mm F4-5.6 DC',
498             '7A 3B 53 80 30 3C 4B 06' => 'Sigma 55-200mm F4-5.6 DC HSM',
499             '48 54 5C 80 24 24 4B 02' => 'Sigma 70-200mm F2.8 EX APO IF HSM',
500             '7A 48 5C 80 24 24 4B 06' => 'Sigma 70-200mm F2.8 EX APO DG Macro HSM II',
501             'EE 48 5C 80 24 24 4B 06' => 'Sigma 70-200mm F2.8 EX APO DG Macro HSM II', #JD
502             '9C 48 5C 80 24 24 4B 0E' => 'Sigma 70-200mm F2.8 EX DG OS HSM', #Rolando Ruzic
503             'BB 48 5C 80 24 24 4B 4E' => 'Sigma 70-200mm F2.8 DG OS HSM | S', #forum13207
504             '02 46 5C 82 25 25 02 00' => 'Sigma 70-210mm F2.8 APO', #JD
505             '02 40 5C 82 2C 35 02 00' => 'Sigma APO 70-210mm F3.5-4.5',
506             '26 3C 5C 82 30 3C 1C 02' => 'Sigma 70-210mm F4-5.6 UC-II',
507             '02 3B 5C 82 30 3C 02 00' => 'Sigma Zoom-K 70-210mm F4-5.6', #30
508             '26 3C 5C 8E 30 3C 1C 02' => 'Sigma 70-300mm F4-5.6 DG Macro',
509             '56 3C 5C 8E 30 3C 1C 02' => 'Sigma 70-300mm F4-5.6 APO Macro Super II',
510             'E0 3C 5C 8E 30 3C 4B 06' => 'Sigma 70-300mm F4-5.6 APO DG Macro HSM', #22
511             'A3 3C 5C 8E 30 3C 4B 0E' => 'Sigma 70-300mm F4-5.6 DG OS',
512             '02 37 5E 8E 35 3D 02 00' => 'Sigma 75-300mm F4.5-5.6 APO',
513             '02 3A 5E 8E 32 3D 02 00' => 'Sigma 75-300mm F4.0-5.6',
514             '77 44 61 98 34 3C 7B 0E' => 'Sigma 80-400mm F4.5-5.6 EX OS',
515             '77 44 60 98 34 3C 7B 0E' => 'Sigma 80-400mm F4.5-5.6 APO DG D OS',
516             '48 48 68 8E 30 30 4B 02' => 'Sigma APO 100-300mm F4 EX IF HSM',
517             'F3 48 68 8E 30 30 4B 02' => 'Sigma APO 100-300mm F4 EX IF HSM',
518             '26 45 68 8E 34 42 1C 02' => 'Sigma 100-300mm F4.5-6.7 DL', #30
519             '48 54 6F 8E 24 24 4B 02' => 'Sigma APO 120-300mm F2.8 EX DG HSM',
520             '7A 54 6E 8E 24 24 4B 02' => 'Sigma APO 120-300mm F2.8 EX DG HSM',
521             '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
522             'CF 38 6E 98 34 3C 4B 0E' => 'Sigma APO 120-400mm F4.5-5.6 DG OS HSM',
523             'C3 34 68 98 38 40 4B 4E' => 'Sigma 100-400mm F5-6.3 DG OS HSM | C', #JR (017)
524             '8D 48 6E 8E 24 24 4B 0E' => 'Sigma 120-300mm F2.8 DG OS HSM Sports',
525             '26 44 73 98 34 3C 1C 02' => 'Sigma 135-400mm F4.5-5.6 APO Aspherical',
526             'CE 34 76 A0 38 40 4B 0E' => 'Sigma 150-500mm F5-6.3 DG OS APO HSM', #JD
527             '81 34 76 A6 38 40 4B 0E' => 'Sigma 150-600mm F5-6.3 DG OS HSM | S', #Jaap Voets
528             '82 34 76 A6 38 40 4B 0E' => 'Sigma 150-600mm F5-6.3 DG OS HSM | C',
529             'C4 4C 73 73 14 14 4B 46' => 'Sigma 135mm F1.8 DG HSM | A', #forum3833
530             '26 40 7B A0 34 40 1C 02' => 'Sigma APO 170-500mm F5-6.3 Aspherical RF',
531             'A7 49 80 A0 24 24 4B 06' => 'Sigma APO 200-500mm F2.8 EX DG',
532             '48 3C 8E B0 3C 3C 4B 02' => 'Sigma APO 300-800mm F5.6 EX DG HSM',
533             'D2 3C 8E B0 3C 3C 4B 02' => 'Sigma APO 300-800mm F5.6 EX DG HSM', #forum10942
534             #
535             '00 47 25 25 24 24 00 02' => 'Tamron SP AF 14mm f/2.8 Aspherical (IF) (69E)',
536             'C8 54 44 44 0D 0D DF 46' => 'Tamron SP 35mm f/1.4 Di USD (F045)', #IB
537             'E8 4C 44 44 14 14 DF 0E' => 'Tamron SP 35mm f/1.8 Di VC USD (F012)', #35
538             'E7 4C 4C 4C 14 14 DF 0E' => 'Tamron SP 45mm f/1.8 Di VC USD (F013)',
539             'F4 54 56 56 18 18 84 06' => 'Tamron SP AF 60mm f/2.0 Di II Macro 1:1 (G005)', #24
540             'E5 4C 62 62 14 14 C9 4E' => 'Tamron SP 85mm f/1.8 Di VC USD (F016)', #30
541             '1E 5D 64 64 20 20 13 00' => 'Tamron SP AF 90mm f/2.5 (52E)',
542             '20 5A 64 64 20 20 14 00' => 'Tamron SP AF 90mm f/2.5 Macro (152E)',
543             '22 53 64 64 24 24 E0 02' => 'Tamron SP AF 90mm f/2.8 Macro 1:1 (72E)',
544             '32 53 64 64 24 24 35 02' => 'Tamron SP AF 90mm f/2.8 [Di] Macro 1:1 (172E/272E)',
545             'F8 55 64 64 24 24 84 06' => 'Tamron SP AF 90mm f/2.8 Di Macro 1:1 (272NII)',
546             'F8 54 64 64 24 24 DF 06' => 'Tamron SP AF 90mm f/2.8 Di Macro 1:1 (272NII)',
547             'FE 54 64 64 24 24 DF 0E' => 'Tamron SP 90mm f/2.8 Di VC USD Macro 1:1 (F004)', #Jurgen Sahlberg
548             'E4 54 64 64 24 24 DF 0E' => 'Tamron SP 90mm f/2.8 Di VC USD Macro 1:1 (F017)', #Rolf Probst
549             '00 4C 7C 7C 2C 2C 00 02' => 'Tamron SP AF 180mm f/3.5 Di Model (B01)',
550             '21 56 8E 8E 24 24 14 00' => 'Tamron SP AF 300mm f/2.8 LD-IF (60E)',
551             '27 54 8E 8E 24 24 1D 02' => 'Tamron SP AF 300mm f/2.8 LD-IF (360E)',
552             'E1 40 19 36 2C 35 DF 4E' => 'Tamron 10-24mm f/3.5-4.5 Di II VC HLD (B023)',
553             'F6 3F 18 37 2C 34 84 06' => 'Tamron SP AF 10-24mm f/3.5-4.5 Di II LD Aspherical (IF) (B001)',
554             '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
555             '00 36 1C 2D 34 3C 00 06' => 'Tamron SP AF 11-18mm f/4.5-5.6 Di II LD Aspherical (IF) (A13)',
556             'E9 48 27 3E 24 24 DF 0E' => 'Tamron SP 15-30mm f/2.8 Di VC USD (A012)', #IB
557             'CA 48 27 3E 24 24 DF 4E' => 'Tamron SP 15-30mm f/2.8 Di VC USD G2 (A041)', #IB
558             '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)
559             '07 46 2B 44 24 30 03 02' => 'Tamron SP AF 17-35mm f/2.8-4 Di LD Aspherical (IF) (A05)',
560             'CB 3C 2B 44 24 31 DF 46' => 'Tamron 17-35mm f/2.8-4 Di OSD (A037)', #IB
561             '00 53 2B 50 24 24 00 06' => 'Tamron SP AF 17-50mm f/2.8 XR Di II LD Aspherical (IF) (A16)', #PH
562             '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)
563             '00 54 2B 50 24 24 00 06' => 'Tamron SP AF 17-50mm f/2.8 XR Di II LD Aspherical (IF) (A16NII)',
564             '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
565             'F3 54 2B 50 24 24 84 0E' => 'Tamron SP AF 17-50mm f/2.8 XR Di II VC LD Aspherical (IF) (B005)',
566             '00 3F 2D 80 2B 40 00 06' => 'Tamron AF 18-200mm f/3.5-6.3 XR Di II LD Aspherical (IF) (A14)',
567             '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)',
568             'EC 3E 3C 8E 2C 40 DF 0E' => 'Tamron 28-300mm f/3.5-6.3 Di VC PZD A010', #30
569             '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
570             '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)
571             '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)
572             '00 40 2D 88 2C 40 62 06' => 'Tamron AF 18-250mm f/3.5-6.3 Di II LD Aspherical (IF) Macro (A18)',
573             '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
574             '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)',
575             'F0 3F 2D 8A 2C 40 DF 0E' => 'Tamron AF 18-270mm f/3.5-6.3 Di II VC PZD (B008)',
576             '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)
577             '07 40 2F 44 2C 34 03 02' => 'Tamron AF 19-35mm f/3.5-4.5 (A10)',
578             '07 40 30 45 2D 35 03 02.1' => 'Tamron AF 19-35mm f/3.5-4.5 (A10)',
579             '00 49 30 48 22 2B 00 02' => 'Tamron SP AF 20-40mm f/2.7-3.5 (166D)',
580             '0E 4A 31 48 23 2D 0E 02' => 'Tamron SP AF 20-40mm f/2.7-3.5 (166D)',
581             'FE 48 37 5C 24 24 DF 0E' => 'Tamron SP 24-70mm f/2.8 Di VC USD (A007)', #24
582             'CE 47 37 5C 25 25 DF 4E' => 'Tamron SP 24-70mm f/2.8 Di VC USD G2 (A032)', #forum9110
583             '45 41 37 72 2C 3C 48 02' => 'Tamron SP AF 24-135mm f/3.5-5.6 AD Aspherical (IF) Macro (190D)',
584             '33 54 3C 5E 24 24 62 02' => 'Tamron SP AF 28-75mm f/2.8 XR Di LD Aspherical (IF) Macro (A09)',
585             'FA 54 3C 5E 24 24 84 06' => 'Tamron SP AF 28-75mm f/2.8 XR Di LD Aspherical (IF) Macro (A09NII)', #JD
586             'FA 54 3C 5E 24 24 DF 06' => 'Tamron SP AF 28-75mm f/2.8 XR Di LD Aspherical (IF) Macro (A09NII)',
587             '10 3D 3C 60 2C 3C D2 02' => 'Tamron AF 28-80mm f/3.5-5.6 Aspherical (177D)',
588             '45 3D 3C 60 2C 3C 48 02' => 'Tamron AF 28-80mm f/3.5-5.6 Aspherical (177D)',
589             '00 48 3C 6A 24 24 00 02' => 'Tamron SP AF 28-105mm f/2.8 LD Aspherical IF (176D)',
590             '4D 3E 3C 80 2E 3C 62 02' => 'Tamron AF 28-200mm f/3.8-5.6 XR Aspherical (IF) Macro (A03N)',
591             '0B 3E 3D 7F 2F 3D 0E 00' => 'Tamron AF 28-200mm f/3.8-5.6 (71D)',
592             '0B 3E 3D 7F 2F 3D 0E 02' => 'Tamron AF 28-200mm f/3.8-5.6D (171D)',
593             '12 3D 3C 80 2E 3C DF 02' => 'Tamron AF 28-200mm f/3.8-5.6 AF Aspherical LD (IF) (271D)',
594             '4D 41 3C 8E 2B 40 62 02' => 'Tamron AF 28-300mm f/3.5-6.3 XR Di LD Aspherical (IF) (A061)',
595             '4D 41 3C 8E 2C 40 62 02' => 'Tamron AF 28-300mm f/3.5-6.3 XR LD Aspherical (IF) (185D)',
596             '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)',
597             'C9 3C 44 76 25 31 DF 4E' => 'Tamron 35-150mm f/2.8-4 Di VC OSD (A043)', #30
598             '00 47 53 80 30 3C 00 06' => 'Tamron AF 55-200mm f/4-5.6 Di II LD (A15)',
599             'F7 53 5C 80 24 24 84 06' => 'Tamron SP AF 70-200mm f/2.8 Di LD (IF) Macro (A001)',
600             'FE 53 5C 80 24 24 84 06' => 'Tamron SP AF 70-200mm f/2.8 Di LD (IF) Macro (A001)',
601             'F7 53 5C 80 24 24 40 06' => 'Tamron SP AF 70-200mm f/2.8 Di LD (IF) Macro (A001)',
602             # 'FE 54 5C 80 24 24 DF 0E' => 'Tamron SP AF 70-200mm f/2.8 Di VC USD (A009)',
603             'FE 54 5C 80 24 24 DF 0E' => 'Tamron SP 70-200mm f/2.8 Di VC USD (A009)', #NJ
604             'E2 47 5C 80 24 24 DF 4E' => 'Tamron SP 70-200mm f/2.8 Di VC USD G2 (A025)', #forum9549
605             '69 48 5C 8E 30 3C 6F 02' => 'Tamron AF 70-300mm f/4-5.6 LD Macro 1:2 (572D/772D)',
606             '69 47 5C 8E 30 3C 00 02' => 'Tamron AF 70-300mm f/4-5.6 Di LD Macro 1:2 (A17N)',
607             '00 48 5C 8E 30 3C 00 06' => 'Tamron AF 70-300mm f/4-5.6 Di LD Macro 1:2 (A17NII)', #JD
608             'F1 47 5C 8E 30 3C DF 0E' => 'Tamron SP 70-300mm f/4-5.6 Di VC USD (A005)',
609             'CF 47 5C 8E 31 3D DF 0E' => 'Tamron SP 70-300mm f/4-5.6 Di VC USD (A030)', #forum9773
610             'CC 44 68 98 34 41 DF 0E' => 'Tamron 100-400mm f/4.5-6.3 Di VC USD', #30
611             'EB 40 76 A6 38 40 DF 0E' => 'Tamron SP AF 150-600mm f/5-6.3 VC USD (A011)',
612             'E3 40 76 A6 38 40 DF 4E' => 'Tamron SP 150-600mm f/5-6.3 Di VC USD G2', #30
613             'E3 40 76 A6 38 40 DF 0E' => 'Tamron SP 150-600mm f/5-6.3 Di VC USD G2 (A022)', #forum3833
614             '20 3C 80 98 3D 3D 1E 02' => 'Tamron AF 200-400mm f/5.6 LD IF (75D)',
615             '00 3E 80 A0 38 3F 00 02' => 'Tamron SP AF 200-500mm f/5-6.3 Di LD (IF) (A08)',
616             '00 3F 80 A0 38 3F 00 02' => 'Tamron SP AF 200-500mm f/5-6.3 Di (A08)',
617             #
618             '00 40 2B 2B 2C 2C 00 02' => 'Tokina AT-X 17 AF PRO (AF 17mm f/3.5)',
619             '00 47 44 44 24 24 00 06' => 'Tokina AT-X M35 PRO DX (AF 35mm f/2.8 Macro)',
620             '8D 54 68 68 24 24 87 02' => 'Tokina AT-X PRO 100mm F2.8 D Macro', #30
621             '00 54 68 68 24 24 00 02' => 'Tokina AT-X M100 AF PRO D (AF 100mm f/2.8 Macro)',
622             '27 48 8E 8E 30 30 1D 02' => 'Tokina AT-X 304 AF (AF 300mm f/4.0)',
623             '00 54 8E 8E 24 24 00 02' => 'Tokina AT-X 300 AF PRO (AF 300mm f/2.8)',
624             '12 3B 98 98 3D 3D 09 00' => 'Tokina AT-X 400 AF SD (AF 400mm f/5.6)',
625             '00 40 18 2B 2C 34 00 06' => 'Tokina AT-X 107 AF DX Fisheye (AF 10-17mm f/3.5-4.5)',
626             '00 48 1C 29 24 24 00 06' => 'Tokina AT-X 116 PRO DX (AF 11-16mm f/2.8)',
627             '7A 48 1C 29 24 24 7E 06' => 'Tokina AT-X 116 PRO DX II (AF 11-16mm f/2.8)',
628             '80 48 1C 29 24 24 7A 06' => 'Tokina atx-i 11-16mm F2.8 CF', #exiv2 issue 1078
629             '7A 48 1C 30 24 24 7E 06' => 'Tokina AT-X 11-20 F2.8 PRO DX (AF 11-20mm f/2.8)',
630             '8B 48 1C 30 24 24 85 06' => 'Tokina AT-X 11-20 F2.8 PRO DX (AF 11-20mm f/2.8)', #forum12687
631             '00 3C 1F 37 30 30 00 06' => 'Tokina AT-X 124 AF PRO DX (AF 12-24mm f/4)',
632             '7A 3C 1F 37 30 30 7E 06.2' => 'Tokina AT-X 124 AF PRO DX II (AF 12-24mm f/4)',
633             '7A 3C 1F 3C 30 30 7E 06' => 'Tokina AT-X 12-28 PRO DX (AF 12-28mm f/4)',
634             '00 48 29 3C 24 24 00 06' => 'Tokina AT-X 16-28 AF PRO FX (AF 16-28mm f/2.8)',
635             '00 48 29 50 24 24 00 06' => 'Tokina AT-X 165 PRO DX (AF 16-50mm f/2.8)',
636             '00 40 2A 72 2C 3C 00 06' => 'Tokina AT-X 16.5-135 DX (AF 16.5-135mm F3.5-5.6)',
637             '00 3C 2B 44 30 30 00 06' => 'Tokina AT-X 17-35 F4 PRO FX (AF 17-35mm f/4)',
638             '2F 40 30 44 2C 34 29 02.2' => 'Tokina AF 193 (AF 19-35mm f/3.5-4.5)',
639             '2F 48 30 44 24 24 29 02.2' => 'Tokina AT-X 235 AF PRO (AF 20-35mm f/2.8)',
640             '2F 40 30 44 2C 34 29 02.1' => 'Tokina AF 235 II (AF 20-35mm f/3.5-4.5)',
641             '00 48 37 5C 24 24 00 06' => 'Tokina AT-X 24-70 F2.8 PRO FX (AF 24-70mm f/2.8)',
642             '00 40 37 80 2C 3C 00 02' => 'Tokina AT-X 242 AF (AF 24-200mm f/3.5-5.6)',
643             '25 48 3C 5C 24 24 1B 02.1' => 'Tokina AT-X 270 AF PRO II (AF 28-70mm f/2.6-2.8)',
644             '25 48 3C 5C 24 24 1B 02.2' => 'Tokina AT-X 287 AF PRO SV (AF 28-70mm f/2.8)',
645             '07 48 3C 5C 24 24 03 00' => 'Tokina AT-X 287 AF (AF 28-70mm f/2.8)',
646             '07 47 3C 5C 25 35 03 00' => 'Tokina AF 287 SD (AF 28-70mm f/2.8-4.5)',
647             '07 40 3C 5C 2C 35 03 00' => 'Tokina AF 270 II (AF 28-70mm f/3.5-4.5)',
648             '00 48 3C 60 24 24 00 02' => 'Tokina AT-X 280 AF PRO (AF 28-80mm f/2.8)',
649             '25 44 44 8E 34 42 1B 02' => 'Tokina AF 353 (AF 35-300mm f/4.5-6.7)',
650             '00 48 50 72 24 24 00 06' => 'Tokina AT-X 535 PRO DX (AF 50-135mm f/2.8)',
651             '00 3C 5C 80 30 30 00 0E' => 'Tokina AT-X 70-200 F4 FX VCM-S (AF 70-200mm f/4)',
652             '00 48 5C 80 30 30 00 0E' => 'Tokina AT-X 70-200 F4 FX VCM-S (AF 70-200mm f/4)',
653             '12 44 5E 8E 34 3C 09 00' => 'Tokina AF 730 (AF 75-300mm F4.5-5.6)',
654             '14 54 60 80 24 24 0B 00' => 'Tokina AT-X 828 AF (AF 80-200mm f/2.8)',
655             '24 54 60 80 24 24 1A 02' => 'Tokina AT-X 828 AF PRO (AF 80-200mm f/2.8)',
656             '24 44 60 98 34 3C 1A 02' => 'Tokina AT-X 840 AF-II (AF 80-400mm f/4.5-5.6)',
657             '00 44 60 98 34 3C 00 02' => 'Tokina AT-X 840 D (AF 80-400mm f/4.5-5.6)',
658             '14 48 68 8E 30 30 0B 00' => 'Tokina AT-X 340 AF (AF 100-300mm f/4)',
659             '8C 48 29 3C 24 24 86 06' => 'Tokina opera 16-28mm F2.8 FF', #30
660             #
661             '06 3F 68 68 2C 2C 06 00' => 'Cosina AF 100mm F3.5 Macro',
662             '07 36 3D 5F 2C 3C 03 00' => 'Cosina AF Zoom 28-80mm F3.5-5.6 MC Macro',
663             '07 46 3D 6A 25 2F 03 00' => 'Cosina AF Zoom 28-105mm F2.8-3.8 MC',
664             '12 36 5C 81 35 3D 09 00' => 'Cosina AF Zoom 70-210mm F4.5-5.6 MC Macro',
665             '12 39 5C 8E 34 3D 08 02' => 'Cosina AF Zoom 70-300mm F4.5-5.6 MC Macro',
666             '12 3B 68 8D 3D 43 09 02' => 'Cosina AF Zoom 100-300mm F5.6-6.7 MC Macro',
667             #
668             '12 38 69 97 35 42 09 02' => 'Promaster Spectrum 7 100-400mm F4.5-6.7',
669             #
670             '00 40 31 31 2C 2C 00 00' => 'Voigtlander Color Skopar 20mm F3.5 SLII Aspherical',
671             '00 48 3C 3C 24 24 00 00' => 'Voigtlander Color Skopar 28mm F2.8 SL II',
672             '00 54 48 48 18 18 00 00' => 'Voigtlander Ultron 40mm F2 SLII Aspherical',
673             '00 54 55 55 0C 0C 00 00' => 'Voigtlander Nokton 58mm F1.4 SLII',
674             '00 40 64 64 2C 2C 00 00' => 'Voigtlander APO-Lanthar 90mm F3.5 SLII Close Focus',
675             '07 40 30 45 2D 35 03 02.2' => 'Voigtlander Ultragon 19-35mm F3.5-4.5 VMV', #NJ
676             '71 48 64 64 24 24 00 00' => 'Voigtlander APO-Skopar 90mm F2.8 SL IIs', #30
677             'FD 00 50 50 18 18 DF 00' => 'Voigtlander APO-Lanthar 50mm F2 Aspherical', #35
678             #
679             '00 40 2D 2D 2C 2C 00 00' => 'Carl Zeiss Distagon T* 3.5/18 ZF.2',
680             '00 48 27 27 24 24 00 00' => 'Carl Zeiss Distagon T* 2.8/15 ZF.2', #MykytaKozlov
681             '00 48 32 32 24 24 00 00' => 'Carl Zeiss Distagon T* 2.8/21 ZF.2',
682             '00 54 38 38 18 18 00 00' => 'Carl Zeiss Distagon T* 2/25 ZF.2',
683             '00 54 3C 3C 18 18 00 00' => 'Carl Zeiss Distagon T* 2/28 ZF.2',
684             '00 54 44 44 0C 0C 00 00' => 'Carl Zeiss Distagon T* 1.4/35 ZF.2',
685             '00 54 44 44 18 18 00 00' => 'Carl Zeiss Distagon T* 2/35 ZF.2',
686             '00 54 50 50 0C 0C 00 00' => 'Carl Zeiss Planar T* 1.4/50 ZF.2',
687             '00 54 50 50 18 18 00 00' => 'Carl Zeiss Makro-Planar T* 2/50 ZF.2',
688             '00 54 62 62 0C 0C 00 00' => 'Carl Zeiss Planar T* 1.4/85 ZF.2',
689             '00 54 68 68 18 18 00 00' => 'Carl Zeiss Makro-Planar T* 2/100 ZF.2',
690             '00 54 72 72 18 18 00 00' => 'Carl Zeiss Apo Sonnar T* 2/135 ZF.2',
691             '00 54 53 53 0C 0C 00 00' => 'Zeiss Otus 1.4/55', #IB
692             '01 54 62 62 0C 0C 00 00' => 'Zeiss Otus 1.4/85',
693             '03 54 68 68 0C 0C 00 00' => 'Zeiss Otus 1.4/100', #IB
694             '52 54 44 44 18 18 00 00' => 'Zeiss Milvus 35mm f/2',
695             '53 54 50 50 0C 0C 00 00' => 'Zeiss Milvus 50mm f/1.4', #IB
696             '54 54 50 50 18 18 00 00' => 'Zeiss Milvus 50mm f/2 Macro',
697             '55 54 62 62 0C 0C 00 00' => 'Zeiss Milvus 85mm f/1.4', #IB
698             '56 54 68 68 18 18 00 00' => 'Zeiss Milvus 100mm f/2 Macro',
699             #
700             '00 54 56 56 30 30 00 00' => 'Coastal Optical Systems 60mm 1:4 UV-VIS-IR Macro Apo',
701             #
702             'BF 4E 26 26 1E 1E 01 04' => 'Irix 15mm f/2.4 Firefly', #30
703             'BF 3C 1B 1B 30 30 01 04' => 'Irix 11mm f/4 Firefly', #30
704             #
705             '4A 40 11 11 2C 0C 4D 02' => 'Samyang 8mm f/3.5 Fish-Eye CS',
706             '4A 48 24 24 24 0C 4D 02.1' => 'Samyang 10mm f/2.8 ED AS NCS CS',
707             '4A 48 1E 1E 24 0C 4D 02' => 'Samyang 12mm f/2.8 ED AS NCS Fish-Eye', #Jurgen Sahlberg
708             '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
709             '4A 4C 24 24 1E 6C 4D 06' => 'Samyang 14mm f/2.4 Premium',
710             '4A 54 29 29 18 0C 4D 02' => 'Samyang 16mm f/2.0 ED AS UMC CS', #Jon Bloom (by email)
711             '4A 60 36 36 0C 0C 4D 02' => 'Samyang 24mm f/1.4 ED AS UMC',
712             '4A 60 44 44 0C 0C 4D 02' => 'Samyang 35mm f/1.4 AS UMC',
713             '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
714             #
715             '9A 4C 50 50 14 14 9C 06' => 'Yongnuo YN50mm F1.8N',
716             '9F 48 48 48 24 24 A1 06' => 'Yongnuo YN40mm F2.8N', #30
717             '9F 54 68 68 18 18 A2 06' => 'Yongnuo YN100mm F2N', #30
718             #
719             '02 40 44 5C 2C 34 02 00' => 'Exakta AF 35-70mm 1:3.5-4.5 MC',
720             #
721             '07 3E 30 43 2D 35 03 00' => 'Soligor AF Zoom 19-35mm 1:3.5-4.5 MC',
722             '03 43 5C 81 35 35 02 00' => 'Soligor AF C/D Zoom UMCS 70-210mm 1:4.5',
723             '12 4A 5C 81 31 3D 09 00' => 'Soligor AF C/D Auto Zoom+Macro 70-210mm 1:4-5.6 UMCS',
724             '12 36 69 97 35 42 09 00' => 'Soligor AF Zoom 100-400mm 1:4.5-6.7 MC',
725             #
726             '00 00 00 00 00 00 00 01' => 'Manual Lens No CPU',
727             #
728             '00 00 48 48 53 53 00 01' => 'Loreo 40mm F11-22 3D Lens in a Cap 9005', #PH
729             '00 47 10 10 24 24 00 00' => 'Fisheye Nikkor 8mm f/2.8 AiS',
730             '00 47 3C 3C 24 24 00 00' => 'Nikkor 28mm f/2.8 AiS', #35
731             # '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)
732             '00 57 50 50 14 14 00 00' => 'Nikkor 50mm f/1.8 AI', #35
733             '00 48 50 50 18 18 00 00' => 'Nikkor H 50mm f/2',
734             '00 48 68 68 24 24 00 00' => 'Series E 100mm f/2.8',
735             '00 4C 6A 6A 20 20 00 00' => 'Nikkor 105mm f/2.5 AiS',
736             '00 48 80 80 30 30 00 00' => 'Nikkor 200mm f/4 AiS',
737             '00 40 11 11 2C 2C 00 00' => 'Samyang 8mm f/3.5 Fish-Eye',
738             '00 58 64 64 20 20 00 00' => 'Soligor C/D Macro MC 90mm f/2.5',
739             '4A 58 30 30 14 0C 4D 02' => 'Rokinon 20mm f/1.8 ED AS UMC', #30
740             #
741             'A0 56 44 44 14 14 A2 06' => 'Sony FE 35mm F1.8', #IB (Techart adapter)
742             'A0 37 5C 8E 34 3C A2 06' => 'Sony FE 70-300mm F4.5-5.6 G OSS', #IB (Techart adapter)
743             );
744              
745             # text encoding used in LocationInfo (ref PH)
746             %nikonTextEncoding = (
747             0 => 'n/a',
748             1 => 'UTF8',
749             # UTF16 is a guess here: it could also be Unicode or JIS,
750             # but I chose UTF16 due to the similarity with the QuickTime stringEncoding
751             2 => 'UTF16',
752             );
753              
754             # flash firmware decoding (ref JD)
755             my %flashFirmware = (
756             '0 0' => 'n/a',
757             '1 1' => '1.01 (SB-800 or Metz 58 AF-1)',
758             '1 3' => '1.03 (SB-800)',
759             '2 1' => '2.01 (SB-800)',
760             '2 4' => '2.04 (SB-600)',
761             '2 5' => '2.05 (SB-600)',
762             '3 1' => '3.01 (SU-800 Remote Commander)',
763             '4 1' => '4.01 (SB-400)',
764             '4 2' => '4.02 (SB-400)',
765             '4 4' => '4.04 (SB-400)',
766             '5 1' => '5.01 (SB-900)',
767             '5 2' => '5.02 (SB-900)',
768             '6 1' => '6.01 (SB-700)', #https://exiftool.org/forum/index.php/topic,5034.0.html
769             '7 1' => '7.01 (SB-910)', #PH
770             '14 3' => '14.03 (SB-5000)', #28
771             OTHER => sub {
772             my ($val, $inv) = @_;
773             return sprintf('%d.%.2d (Unknown model)', split(' ', $val)) unless $inv;
774             return "$1 $2" if $val =~ /(\d+)\.(\d+)/;
775             return '0 0';
776             },
777             );
778              
779             # flash Guide Number (GN) distance settings (ref 28)
780             my %flashGNDistance = (
781             0 => 0, 19 => '2.8 m',
782             1 => '0.1 m', 20 => '3.2 m',
783             2 => '0.2 m', 21 => '3.6 m',
784             3 => '0.3 m', 22 => '4.0 m',
785             4 => '0.4 m', 23 => '4.5 m',
786             5 => '0.5 m', 24 => '5.0 m',
787             6 => '0.6 m', 25 => '5.6 m',
788             7 => '0.7 m', 26 => '6.3 m',
789             8 => '0.8 m', 27 => '7.1 m',
790             9 => '0.9 m', 28 => '8.0 m',
791             10 => '1.0 m', 29 => '9.0 m',
792             11 => '1.1 m', 30 => '10.0 m',
793             12 => '1.3 m', 31 => '11.0 m',
794             13 => '1.4 m', 32 => '13.0 m',
795             14 => '1.6 m', 33 => '14.0 m',
796             15 => '1.8 m', 34 => '16.0 m',
797             16 => '2.0 m', 35 => '18.0 m',
798             17 => '2.2 m', 36 => '20.0 m',
799             18 => '2.5 m', 255 => 'n/a',
800             );
801              
802             # flash color filter values (ref 28)
803             my %flashColorFilter = (
804             0x00 => 'None',
805             1 => 'FL-GL1 or SZ-2FL Fluorescent', # (green) (SZ model ref PH)
806             2 => 'FL-GL2',
807             9 => 'TN-A1 or SZ-2TN Incandescent', # (orange) (SZ model ref PH)
808             10 => 'TN-A2',
809             65 => 'Red',
810             66 => 'Blue',
811             67 => 'Yellow',
812             68 => 'Amber',
813             128 => 'Incandescent', #SZ-4TN Incandescent
814             );
815              
816             # flash control mode values (ref JD)
817             my %flashControlMode = (
818             0x00 => 'Off',
819             0x01 => 'iTTL-BL',
820             0x02 => 'iTTL',
821             0x03 => 'Auto Aperture',
822             0x04 => 'Automatic', #28
823             0x05 => 'GN (distance priority)', #28 (Guide Number, but called "GN" in manual)
824             0x06 => 'Manual',
825             0x07 => 'Repeating Flash',
826             );
827              
828             my %activeDLightingZ7 = (
829             0 => 'Off',
830             2 => 'Low',
831             3 => 'Normal',
832             4 => 'High',
833             5 => 'Extra High',
834             );
835              
836             my %aFAreaModeZ9 = (
837             0 => 'Pinpoint',
838             1 => 'Single',
839             2 => 'Dynamic',
840             3 => 'Wide (S)',
841             4 => 'Wide (L)',
842             5 => '3D',
843             6 => 'Auto',
844             11 => 'Subject Tracking',
845             12 => 'Wide (C1)',
846             13 => 'Wide (C2)',
847             );
848              
849             my %banksZ9 = (
850             0 => 'A',
851             1 => 'B',
852             2 => 'C',
853             3 => 'D',
854             );
855              
856             my %bracketIncrementZ9 = (
857             0 => '0.3',
858             #1 => '0.5',
859             2 => '0.7',
860             3 => '1.0',
861             4 => '2.0',
862             5 => '3.0',
863             );
864              
865             my %bracketSetZ9 = (
866             0 => 'AE/Flash',
867             1 => 'AE',
868             2 => 'Flash',
869             3 => 'White Balance',
870             4 => 'Active-D Lighting',
871             );
872              
873             my %bracketProgramZ9 = (
874             0 => 'Disabled',
875             2 => '2F',
876             3 => '3F',
877             4 => '4F',
878             5 => '5F',
879             7 => '7F',
880             9 => '9F',
881             );
882              
883             my %dynamicAfAreaModesZ9 = (
884             0 => 'Small',
885             1 => 'Medium',
886             2 => 'Large',
887             );
888              
889             my %flashControlModeZ7 = (
890             0 => 'TTL',
891             1 => 'Auto External Flash',
892             2 => 'GN (distance priority)',
893             3 => 'Manual',
894             4 => 'Repeating Flash',
895             );
896              
897             my %flashRemoteControlZ7 = (
898             0 => 'Group',
899             1 => 'Quick Wireless',
900             2 => 'Remote Repeating',
901             );
902              
903             my %flashWirelessOptionZ7 = (
904             0 => 'Off',
905             1 => 'Optical AWL',
906             2 => 'Optical/Radio AWL',
907             3 => 'Radio AWL',
908             );
909              
910             my %focusModeZ7 = (
911             0 => 'Manual',
912             1 => 'AF-S',
913             2 => 'AF-C',
914             4 => 'AF-F', # full frame
915             );
916              
917             my %hDMIOutputResolutionZ9 = (
918             0 => 'Auto',
919             1 => '4320p',
920             2 => '2160p',
921             3 => '1080p',
922             #4 => '1080i',
923             5 => '720p',
924             #6 => '576p',
925             #7 => '480p',
926             );
927              
928             my %highFrameRateZ9 = (
929             0 => 'Off',
930             1 => 'CH',
931             3 => 'C30',
932             5 => 'C60',
933             4 => 'C120',
934             );
935              
936             my %imageAreaZ9 = (
937             0 => 'FX',
938             1 => 'DX',
939             4 => '16:9',
940             8 => '1:1',
941             );
942              
943             my %imageAreaZ9b = (
944             0 => 'FX',
945             1 => 'DX',
946             );
947              
948             my %infoZSeries = (
949             Condition => '$$self{Model} =~ /^NIKON Z (5|50|6|6_2|7|7_2|fc|9)\b/i',
950             Notes => 'Z Series cameras thru December 2021',
951             );
952             my %iSOAutoHiLimitZ7 = (
953             0 => 'ISO 64',
954             1 => 'ISO 80',
955             2 => 'ISO 100',
956             3 => 'ISO 125',
957             4 => 'ISO 160',
958             5 => 'ISO 200',
959             6 => 'ISO 250',
960             7 => 'ISO 320',
961             8 => 'ISO 400',
962             9 => 'ISO 500',
963             10 => 'ISO 640',
964             11 => 'ISO 800',
965             12 => 'ISO 1000',
966             13 => 'ISO 1250',
967             14 => 'ISO 1600',
968             15 => 'ISO 2000',
969             16 => 'ISO 2500',
970             17 => 'ISO 3200',
971             18 => 'ISO 4000',
972             19 => 'ISO 5000',
973             20 => 'ISO 6400',
974             21 => 'ISO 8000',
975             22 => 'ISO 10000',
976             23 => 'ISO 12800',
977             24 => 'ISO 16000',
978             25 => 'ISO 20000',
979             26 => 'ISO 25600',
980             27 => 'ISO Hi 0.3',
981             28 => 'ISO Hi 0.7',
982             29 => 'ISO Hi 1.0',
983             32 => 'ISO Hi 2.0',
984             );
985              
986             my %iSOAutoShutterTimeZ9 = (
987             -15 => 'Auto', #z9 firmware 1.00 maps both 'Auto' and '30 s' to -15
988             -12 => '15 s',
989             -9 => '8 s',
990             -6 => '4 s',
991             -3 => '2 s',
992             0 => '1 s',
993             1 => '1/1.3 s',
994             2 => '1/1.6 s',
995             3 => '1/2 s',
996             4 => '1/2.5 s',
997             5 => '1/3 s',
998             6 => '1/4 s',
999             7 => '1/5 s',
1000             8 => '1/6 s',
1001             9 => '1/8 s',
1002             10 => '1/10 s',
1003             11 => '1/13 s',
1004             12 => '1/15 s',
1005             13 => '1/20 s',
1006             14 => '1/25 s',
1007             15 => '1/30 s',
1008             16 => '1/40 s',
1009             17 => '1/50 s',
1010             18 => '1/60 s',
1011             19 => '1/80 s',
1012             20 => '1/100 s',
1013             21 => '1/120 s',
1014             22 => '1/160 s',
1015             23 => '1/200 s',
1016             24 => '1/250 s',
1017             25 => '1/320 s',
1018             26 => '1/400 s',
1019             27 => '1/500 s',
1020             28 => '1/640 s',
1021             29 => '1/800 s',
1022             30 => '1/1000 s',
1023             31 => '1/1250 s',
1024             32 => '1/1600 s',
1025             33 => '1/2000 s',
1026             34 => '1/2500 s',
1027             35 => '1/3200 s',
1028             36 => '1/4000 s',
1029             37 => '1/5000 s',
1030             37.5 => '1/6000 s',
1031             38 => '1/6400 s',
1032             39 => '1/8000 s',
1033             40 => '1/10000 s',
1034             40.5 => '1/12000 s',
1035             41 => '1/13000 s',
1036             42 => '1/16000 s',
1037             );
1038              
1039             my %languageZ9 = (
1040             4 => 'English',
1041             5 => 'Spanish',
1042             7 => 'French',
1043             15 => 'Portuguese'
1044             );
1045              
1046             my %meteringModeZ7 = (
1047             0 => 'Matrix',
1048             1 => 'Center',
1049             2 => 'Spot',
1050             3 => 'Highlight'
1051             );
1052              
1053             my %monitorBrightnessZ9 = (
1054             0 => '-5',
1055             1 => '-4',
1056             2 => '-3',
1057             3 => '-2',
1058             4 => '-1',
1059             5 => '0',
1060             6 => '1',
1061             7 => '2',
1062             8 => '3',
1063             9 => '4',
1064             10 => '5',
1065             14 => 'Hi1',
1066             15 => 'Hi2',
1067             16 => 'Lo2',
1068             17 => 'Lo1',
1069             );
1070              
1071             my %movieFlickerReductionZ9 = (
1072             0 => 'Auto',
1073             1 => '50Hz',
1074             2 => '60Hz',
1075             );
1076              
1077             my %movieFrameRateZ7 = (
1078             0 => '120p',
1079             1 => '100p',
1080             2 => '60p',
1081             3 => '50p',
1082             4 => '30p',
1083             5 => '25p',
1084             6 => '24p',
1085             );
1086              
1087             my %movieFrameSizeZ9 = (
1088             1 => '1920x1080',
1089             2 => '3840x2160',
1090             3 => '7680x4320',
1091             );
1092              
1093             my %movieToneMapZ9 = (
1094             0 => 'SDR',
1095             1 => 'HLG',
1096             2 => 'N-Log',
1097             );
1098              
1099             my %movieTypeZ9 = (
1100             1 => 'H.265 8-bit (MP4)',
1101             2 => 'H.265 8-bit (MOV)',
1102             3 => 'H.265 10-bit (MOV)',
1103             4 => 'ProRes 422 HQ 10-bit (MOV)',
1104             5 => 'ProRes RAW HQ 12-bit (MOV)',
1105             6 => 'NRAW 12-bit (NEV)'
1106             );
1107              
1108             my %multipleExposureModeZ9 = (
1109             0 => 'Off',
1110             1 => 'On',
1111             2 => 'On (Series)',
1112             );
1113              
1114             my %offLowNormalHighZ7 = (
1115             0 => 'Off',
1116             1 => 'Low',
1117             2 => 'Normal',
1118             3 => 'High',
1119             );
1120              
1121             my %releaseModeZ7 = (
1122             0 => 'Continuous Low',
1123             1 => 'Continuous High',
1124             2 => 'Continuous High (Extended)',
1125             4 => 'Timer',
1126             5 => 'Single Frame',
1127             );
1128              
1129             my %secondarySlotFunctionZ9 = (
1130             0 => 'Overflow',
1131             1 => 'Backup',
1132             2 => 'NEF Primary + JPG Secondary',
1133             3 => 'JPG Primary + JPG Secondary',
1134             );
1135              
1136             my %subjectDetectionZ9 = (
1137             0 => 'Off',
1138             1 => 'Auto',
1139             2 => 'People',
1140             3 => 'Animals',
1141             4 => 'Vehicles',
1142             );
1143              
1144             my %timeZoneZ9 = (
1145             3 => '+10:00 (Sydney)',
1146             5 => '+09:00 (Tokyo)',
1147             6 => '+08:00 (Beijing, Honk Kong, Sinapore)',
1148             10 => '+05:45 (Kathmandu)',
1149             11 => '+05:30 (New Dehli)',
1150             12 => '+05:00 (Islamabad)',
1151             13 => '+04:30 (Kabul)',
1152             14 => '+04:00 (Abu Dhabi)',
1153             15 => '+03:30 (Tehran)',
1154             16 => '+03:00 (Moscow, Nairobi)',
1155             17 => '+02:00 (Athens, Helsinki)',
1156             18 => '+01:00 (Madrid, Paris, Berlin)',
1157             19 => '+00:00 (London)',
1158             20 => '-01:00 (Azores)',
1159             21 => '-02:00 (Fernando de Noronha)',
1160             22 => '-03:00 (Buenos Aires, Sao Paulo)',
1161             23 => '-03:30 (Newfoundland)',
1162             24 => '-04:00 (Manaus, Caracas)',
1163             25 => '-05:00 (New York, Toronto, Lima)',
1164             26 => '-06:00 (Chicago, Mexico City)',
1165             27 => '-07:00 (Denver)',
1166             28 => '-08:00 (Los Angeles, Vancouver)',
1167             29 => '-09:00 (Anchorage)',
1168             30 => '-10:00 (Hawaii)',
1169             );
1170              
1171              
1172             my %vRModeZ9 = (
1173             0 => 'Off',
1174             1 => 'Normal',
1175             2 => 'Sport',
1176             );
1177              
1178             my %retouchValues = ( #PH
1179             0 => 'None',
1180             3 => 'B & W',
1181             4 => 'Sepia',
1182             5 => 'Trim',
1183             6 => 'Small Picture',
1184             7 => 'D-Lighting',
1185             8 => 'Red Eye',
1186             9 => 'Cyanotype',
1187             10 => 'Sky Light',
1188             11 => 'Warm Tone',
1189             12 => 'Color Custom',
1190             13 => 'Image Overlay',
1191             14 => 'Red Intensifier',
1192             15 => 'Green Intensifier',
1193             16 => 'Blue Intensifier',
1194             17 => 'Cross Screen',
1195             18 => 'Quick Retouch',
1196             19 => 'NEF Processing',
1197             23 => 'Distortion Control',
1198             25 => 'Fisheye',
1199             26 => 'Straighten',
1200             29 => 'Perspective Control',
1201             30 => 'Color Outline',
1202             31 => 'Soft Filter',
1203             32 => 'Resize', #31
1204             33 => 'Miniature Effect',
1205             34 => 'Skin Softening', # (S9200)
1206             35 => 'Selected Frame', #31 (frame exported from MOV)
1207             37 => 'Color Sketch', #31
1208             38 => 'Selective Color', # (S9200)
1209             39 => 'Glamour', # (S3500)
1210             40 => 'Drawing', # (S9200)
1211             44 => 'Pop', # (S3500)
1212             45 => 'Toy Camera Effect 1', # (S3500)
1213             46 => 'Toy Camera Effect 2', # (S3500)
1214             47 => 'Cross Process (red)', # (S3500)
1215             48 => 'Cross Process (blue)', # (S3500)
1216             49 => 'Cross Process (green)', # (S3500)
1217             50 => 'Cross Process (yellow)', # (S3500)
1218             51 => 'Super Vivid', # (S3500)
1219             52 => 'High-contrast Monochrome', # (S3500)
1220             53 => 'High Key', # (S3500)
1221             54 => 'Low Key', # (S3500)
1222             );
1223              
1224             # AF point indices for models with 51 focus points, eg. D3 (ref JD/PH)
1225             # A1 A2 A3 A4 A5 A6 A7 A8 A9
1226             # B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11
1227             # C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11
1228             # D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11
1229             # E1 E2 E3 E4 E5 E6 E7 E8 E9
1230             my %afPoints51 = (
1231             1 => 'C6', 11 => 'C5', 21 => 'C9', 31 => 'C11',41 => 'A2', 51 => 'D1',
1232             2 => 'B6', 12 => 'B5', 22 => 'B9', 32 => 'B11',42 => 'D3',
1233             3 => 'A5', 13 => 'A4', 23 => 'A8', 33 => 'D11',43 => 'E2',
1234             4 => 'D6', 14 => 'D5', 24 => 'D9', 34 => 'C4', 44 => 'C2',
1235             5 => 'E5', 15 => 'E4', 25 => 'E8', 35 => 'B4', 45 => 'B2',
1236             6 => 'C7', 16 => 'C8', 26 => 'C10',36 => 'A3', 46 => 'A1',
1237             7 => 'B7', 17 => 'B8', 27 => 'B10',37 => 'D4', 47 => 'D2',
1238             8 => 'A6', 18 => 'A7', 28 => 'A9', 38 => 'E3', 48 => 'E1',
1239             9 => 'D7', 19 => 'D8', 29 => 'D10',39 => 'C3', 49 => 'C1',
1240             10 => 'E6', 20 => 'E7', 30 => 'E9', 40 => 'B3', 50 => 'B1',
1241             );
1242              
1243             # AF point indices for models with 39 focus points, eg. D7000 (ref 29)
1244             # A1 A2 A3
1245             # B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11
1246             # C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11
1247             # D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11
1248             # E1 E2 E3
1249             my %afPoints39 = (
1250             1 => 'C6', 11 => 'C5', 21 => 'D9', 31 => 'C3',
1251             2 => 'B6', 12 => 'B5', 22 => 'C10',32 => 'B3',
1252             3 => 'A2', 13 => 'A1', 23 => 'B10',33 => 'D3',
1253             4 => 'D6', 14 => 'D5', 24 => 'D10',34 => 'C2',
1254             5 => 'E2', 15 => 'E1', 25 => 'C11',35 => 'B2',
1255             6 => 'C7', 16 => 'C8', 26 => 'B11',36 => 'D2',
1256             7 => 'B7', 17 => 'B8', 27 => 'D11',37 => 'C1',
1257             8 => 'A3', 18 => 'D8', 28 => 'C4', 38 => 'B1',
1258             9 => 'D7', 19 => 'C9', 29 => 'B4', 39 => 'D1',
1259             10 => 'E3', 20 => 'B9', 30 => 'D4',
1260             );
1261              
1262             # AF point indices for models with 105 focus points, eg. D6 (ref 28)
1263             # - 7 rows (A-G) with 15 columns (1-15), center is D8
1264             my %afPoints105 = (
1265             1 => 'D8', 28 => 'G7', 55 => 'F13', 82 => 'E4',
1266             2 => 'C8', 29 => 'D6', 56 => 'G13', 83 => 'F4',
1267             3 => 'B8', 30 => 'C6', 57 => 'D14', 84 => 'G4',
1268             4 => 'A8', 31 => 'B6', 58 => 'C14', 85 => 'D3',
1269             5 => 'E8', 32 => 'A6', 59 => 'B14', 86 => 'C3',
1270             6 => 'F8', 33 => 'E6', 60 => 'A14', 87 => 'B3',
1271             7 => 'G8', 34 => 'F6', 61 => 'E14', 88 => 'A3',
1272             8 => 'D9', 35 => 'G6', 62 => 'F14', 89 => 'E3',
1273             9 => 'C9', 36 => 'D11', 63 => 'G14', 90 => 'F3',
1274             10 => 'B9', 37 => 'C11', 64 => 'D15', 91 => 'G3',
1275             11 => 'A9', 38 => 'B11', 65 => 'C15', 92 => 'D2',
1276             12 => 'E9', 39 => 'A11', 66 => 'B15', 93 => 'C2',
1277             13 => 'F9', 40 => 'E11', 67 => 'A15', 94 => 'B2',
1278             14 => 'G9', 41 => 'F11', 68 => 'E15', 95 => 'A2',
1279             15 => 'D10', 42 => 'G11', 69 => 'F15', 96 => 'E2',
1280             16 => 'C10', 43 => 'D12', 70 => 'G15', 97 => 'F2',
1281             17 => 'B10', 44 => 'C12', 71 => 'D5', 98 => 'G2',
1282             18 => 'A10', 45 => 'B12', 72 => 'C5', 99 => 'D1',
1283             19 => 'E10', 46 => 'A12', 73 => 'B5', 100 => 'C1',
1284             20 => 'F10', 47 => 'E12', 74 => 'A5', 101 => 'B1',
1285             21 => 'G10', 48 => 'F12', 75 => 'E5', 102 => 'A1',
1286             22 => 'D7', 49 => 'G12', 76 => 'F5', 103 => 'E1',
1287             23 => 'C7', 50 => 'D13', 77 => 'G5', 104 => 'F1',
1288             24 => 'B7', 51 => 'C13', 78 => 'D4', 105 => 'G1',
1289             25 => 'A7', 52 => 'B13', 79 => 'C4',
1290             26 => 'E7', 53 => 'A13', 80 => 'B4',
1291             27 => 'F7', 54 => 'E13', 81 => 'A4',
1292             );
1293              
1294             # AF point indices for models with 135 focus points, eg. 1J1 (ref PH)
1295             # - 9 rows (A-I) with 15 columns (1-15), center is E8
1296             # - odd columns, columns 2 and 14, and the remaining corner points are
1297             # not used in 41-point mode
1298             my %afPoints135 = (
1299             1 => 'E8', 28 => 'E10', 55 => 'E13', 82 => 'E6', 109 => 'E3',
1300             2 => 'D8', 29 => 'D10', 56 => 'D13', 83 => 'D6', 110 => 'D3',
1301             3 => 'C8', 30 => 'C10', 57 => 'C13', 84 => 'C6', 111 => 'C3',
1302             4 => 'B8', 31 => 'B10', 58 => 'B13', 85 => 'B6', 112 => 'B3',
1303             5 => 'A8', 32 => 'A10', 59 => 'A13', 86 => 'A6', 113 => 'A3',
1304             6 => 'F8', 33 => 'F10', 60 => 'F13', 87 => 'F6', 114 => 'F3',
1305             7 => 'G8', 34 => 'G10', 61 => 'G13', 88 => 'G6', 115 => 'G3',
1306             8 => 'H8', 35 => 'H10', 62 => 'H13', 89 => 'H6', 116 => 'H3',
1307             9 => 'I8', 36 => 'I10', 63 => 'I13', 90 => 'I6', 117 => 'I3',
1308             10 => 'E9', 37 => 'E11', 64 => 'E14', 91 => 'E5', 118 => 'E2',
1309             11 => 'D9', 38 => 'D11', 65 => 'D14', 92 => 'D5', 119 => 'D2',
1310             12 => 'C9', 39 => 'C11', 66 => 'C14', 93 => 'C5', 120 => 'C2',
1311             13 => 'B9', 40 => 'B11', 67 => 'B14', 94 => 'B5', 121 => 'B2',
1312             14 => 'A9', 41 => 'A11', 68 => 'A14', 95 => 'A5', 122 => 'A2',
1313             15 => 'F9', 42 => 'F11', 69 => 'F14', 96 => 'F5', 123 => 'F2',
1314             16 => 'G9', 43 => 'G11', 70 => 'G14', 97 => 'G5', 124 => 'G2',
1315             17 => 'H9', 44 => 'H11', 71 => 'H14', 98 => 'H5', 125 => 'H2',
1316             18 => 'I9', 45 => 'I11', 72 => 'I14', 99 => 'I5', 126 => 'I2',
1317             19 => 'E7', 46 => 'E12', 73 => 'E15', 100 => 'E4', 127 => 'E1',
1318             20 => 'D7', 47 => 'D12', 74 => 'D15', 101 => 'D4', 128 => 'D1',
1319             21 => 'C7', 48 => 'C12', 75 => 'C15', 102 => 'C4', 129 => 'C1',
1320             22 => 'B7', 49 => 'B12', 76 => 'B15', 103 => 'B4', 130 => 'B1',
1321             23 => 'A7', 50 => 'A12', 77 => 'A15', 104 => 'A4', 131 => 'A1',
1322             24 => 'F7', 51 => 'F12', 78 => 'F15', 105 => 'F4', 132 => 'F1',
1323             25 => 'G7', 52 => 'G12', 79 => 'G15', 106 => 'G4', 133 => 'G1',
1324             26 => 'H7', 53 => 'H12', 80 => 'H15', 107 => 'H4', 134 => 'H1',
1325             27 => 'I7', 54 => 'I12', 81 => 'I15', 108 => 'I4', 135 => 'I1',
1326             );
1327              
1328             # AF point indices for models with 153 focus points, eg. D5,D500 (ref PH)
1329             # - 9 rows (A-I) with 17 columns (1-17), center is E9
1330             # - 55 of these are selectable cross points (odd rows and columns 1,3,4,6,7,9,11,12,14,15,17)
1331             my %afPoints153 = (
1332             1 => 'E9', 32 => 'A8', 63 => 'I13', 94 => 'B17', 125 => 'H4',
1333             2 => 'D9', 33 => 'F8', 64 => 'E14', 95 => 'A17', 126 => 'I4',
1334             3 => 'C9', 34 => 'G8', 65 => 'D14', 96 => 'F17', 127 => 'E3',
1335             4 => 'B9', 35 => 'H8', 66 => 'C14', 97 => 'G17', 128 => 'D3',
1336             5 => 'A9', 36 => 'I8', 67 => 'B14', 98 => 'H17', 129 => 'C3',
1337             6 => 'F9', 37 => 'E7', 68 => 'A14', 99 => 'I17', 130 => 'B3',
1338             7 => 'G9', 38 => 'D7', 69 => 'F14', 100 => 'E6', 131 => 'A3',
1339             8 => 'H9', 39 => 'C7', 70 => 'G14', 101 => 'D6', 132 => 'F3',
1340             9 => 'I9', 40 => 'B7', 71 => 'H14', 102 => 'C6', 133 => 'G3',
1341             10 => 'E10', 41 => 'A7', 72 => 'I14', 103 => 'B6', 134 => 'H3',
1342             11 => 'D10', 42 => 'F7', 73 => 'E15', 104 => 'A6', 135 => 'I3',
1343             12 => 'C10', 43 => 'G7', 74 => 'D15', 105 => 'F6', 136 => 'E2',
1344             13 => 'B10', 44 => 'H7', 75 => 'C15', 106 => 'G6', 137 => 'D2',
1345             14 => 'A10', 45 => 'I7', 76 => 'B15', 107 => 'H6', 138 => 'C2',
1346             15 => 'F10', 46 => 'E12', 77 => 'A15', 108 => 'I6', 139 => 'B2',
1347             16 => 'G10', 47 => 'D12', 78 => 'F15', 109 => 'E5', 140 => 'A2',
1348             17 => 'H10', 48 => 'C12', 79 => 'G15', 110 => 'D5', 141 => 'F2',
1349             18 => 'I10', 49 => 'B12', 80 => 'H15', 111 => 'C5', 142 => 'G2',
1350             19 => 'E11', 50 => 'A12', 81 => 'I15', 112 => 'B5', 143 => 'H2',
1351             20 => 'D11', 51 => 'F12', 82 => 'E16', 113 => 'A5', 144 => 'I2',
1352             21 => 'C11', 52 => 'G12', 83 => 'D16', 114 => 'F5', 145 => 'E1',
1353             22 => 'B11', 53 => 'H12', 84 => 'C16', 115 => 'G5', 146 => 'D1',
1354             23 => 'A11', 54 => 'I12', 85 => 'B16', 116 => 'H5', 147 => 'C1',
1355             24 => 'F11', 55 => 'E13', 86 => 'A16', 117 => 'I5', 148 => 'B1',
1356             25 => 'G11', 56 => 'D13', 87 => 'F16', 118 => 'E4', 149 => 'A1',
1357             26 => 'H11', 57 => 'C13', 88 => 'G16', 119 => 'D4', 150 => 'F1',
1358             27 => 'I11', 58 => 'B13', 89 => 'H16', 120 => 'C4', 151 => 'G1',
1359             28 => 'E8', 59 => 'A13', 90 => 'I16', 121 => 'B4', 152 => 'H1',
1360             29 => 'D8', 60 => 'F13', 91 => 'E17', 122 => 'A4', 153 => 'I1',
1361             30 => 'C8', 61 => 'G13', 92 => 'D17', 123 => 'F4',
1362             31 => 'B8', 62 => 'H13', 93 => 'C17', 124 => 'G4',
1363             );
1364              
1365             # AF point indices for models with 81 focus points, eg. Z6/Z7/Z50 (ref 38)
1366             # - 9 rows (A-I) with 9 columns (1-9), center is E5
1367             #
1368             # 7 6 5 4 3 2 1 0
1369             # 00 : [H5][G5][F5][A5][B5][C5][D5][E5]
1370             # 01 : [G6][F6][A6][B6][C6][D6][E6][I5]
1371             # 02 : [F4][A4][B4][C4][D4][E4][I6][H6]
1372             # 03 : [A7][B7][C7][D7][E7][I4][H4][G4]
1373             # 04 : [B3][C3][D3][E3][I7][H7][G7][F7]
1374             # 05 : [C8][D8][E8][I3][H3][G3][F3][A3]
1375             # 06 : [D2][E2][I8][H8][G8][F8][A8][B8]
1376             # 07 : [E9][I2][H2][G2][F2][A2][B2][C2]
1377             # 08 : [I9][H9][G9][F9][A9][B9][C9][D9]
1378             # 09 : [H1][G1][F1][A1][B1][C1][D1][E1]
1379             # 0a : [ ][ ][ ][ ][ ][ ][ ][I1]
1380             my %afPoints81 = (
1381             1 => 'E5', 18 => 'I6', 35 => 'H7', 52 => 'G8', 69 => 'F9',
1382             2 => 'D5', 19 => 'E4', 36 => 'I7', 53 => 'H8', 70 => 'G9',
1383             3 => 'C5', 20 => 'D4', 37 => 'E3', 54 => 'I8', 71 => 'H9',
1384             4 => 'B5', 21 => 'C4', 38 => 'D3', 55 => 'E2', 72 => 'I9',
1385             5 => 'A5', 22 => 'B4', 39 => 'C3', 56 => 'D2', 73 => 'E1',
1386             6 => 'F5', 23 => 'A4', 40 => 'B3', 57 => 'C2', 74 => 'D1',
1387             7 => 'G5', 24 => 'F4', 41 => 'A3', 58 => 'B2', 75 => 'C1',
1388             8 => 'H5', 25 => 'G4', 42 => 'F3', 59 => 'A2', 76 => 'B1',
1389             9 => 'I5', 26 => 'H4', 43 => 'G3', 60 => 'F2', 77 => 'A1',
1390             10 => 'E6', 27 => 'I4', 44 => 'H3', 61 => 'G2', 78 => 'F1',
1391             11 => 'D6', 28 => 'E7', 45 => 'I3', 62 => 'H2', 79 => 'G1',
1392             12 => 'C6', 29 => 'D7', 46 => 'E8', 63 => 'I2', 80 => 'H1',
1393             13 => 'B6', 30 => 'C7', 47 => 'D8', 64 => 'E9', 81 => 'I1',
1394             14 => 'A6', 31 => 'B7', 48 => 'C8', 65 => 'D9',
1395             15 => 'F6', 32 => 'A7', 49 => 'B8', 66 => 'C9',
1396             16 => 'G6', 33 => 'F7', 50 => 'A8', 67 => 'B9',
1397             17 => 'H6', 34 => 'G7', 51 => 'F8', 68 => 'A9',
1398             );
1399              
1400             my %cropHiSpeed = ( #IB
1401             0 => 'Off',
1402             1 => '1.3x Crop', # (1.3x Crop, Large)
1403             2 => 'DX Crop', # (1.5x)
1404             3 => '5:4 Crop',
1405             4 => '3:2 Crop', # (1.2x, ref 36)
1406             6 => '16:9 Crop',
1407             8 => '2.7x Crop', #36 (D4/D500)
1408             9 => 'DX Movie Crop', # (DX during movie recording, Large)
1409             10 => '1.3x Movie Crop', #36 (D4/D500)
1410             11 => 'FX Uncropped',
1411             12 => 'DX Uncropped',
1412             13 => '2.8x Movie Crop', #28 (D5/D6) 5584/1936
1413             14 => '1.4x Movie Crop', #28 (D5/D6) 5584/3856
1414             15 => '1.5x Movie Crop', #36 (D4/D500) 5600/3872
1415             17 => '1:1 Crop',
1416             OTHER => sub {
1417             my ($val, $inv, $conv) = @_;
1418             return undef if $inv;
1419             my @a = split ' ', $val;
1420             return "Unknown ($val)" unless @a == 7;
1421             $a[0] = $$conv{$a[0]} || "Unknown ($a[0])";
1422             return "$a[0] ($a[1]x$a[2] cropped to $a[3]x$a[4] at pixel $a[5],$a[6])";
1423             },
1424             );
1425              
1426             my %flashGroupOptionsMode = (
1427             0 => 'TTL',
1428             1 => 'Manual',
1429             2 => 'Auto',
1430             3 => 'Off',
1431             );
1432              
1433             my %nefCompression = ( #28 relocated to MakerNotes_0x51 at offset x'0a (Z9)
1434             1 => 'Lossy (type 1)', # (older models)
1435             2 => 'Uncompressed', #JD - D100 (even though TIFF compression is set!)
1436             3 => 'Lossless',
1437             4 => 'Lossy (type 2)',
1438             5 => 'Striped packed 12 bits', #IB
1439             6 => 'Uncompressed (reduced to 12 bit)', #IB
1440             7 => 'Unpacked 12 bits', #IB (padded to 16)
1441             8 => 'Small', #IB
1442             9 => 'Packed 12 bits', #IB (2 pixels in 3 bytes)
1443             10 => 'Packed 14 bits', #28 (4 pixels in 7 bytes, eg. D6 uncompressed 14 bit)
1444             13 => 'High Efficiency', #28
1445             14 => 'High Efficiency*', #28
1446             );
1447              
1448             my %noYes = ( 0 => 'No' , 1 => 'Yes', );
1449             my %offOn = ( 0 => 'Off', 1 => 'On' );
1450             my %onOff = ( 0 => 'On', 1 => 'Off' );
1451              
1452             # common attributes for writable BinaryData directories
1453             my %binaryDataAttrs = (
1454             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
1455             WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
1456             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
1457             WRITABLE => 1,
1458             FIRST_ENTRY => 0,
1459             );
1460              
1461             my %base64bin = ( ValueConv => 'Image::ExifTool::XMP::DecodeBase64($val)' );
1462             my %base64int32u = ( ValueConv => 'my $val=Image::ExifTool::XMP::DecodeBase64($val); unpack("V",$$val)' );
1463             my %base64bytes = ( ValueConv => 'my $val=Image::ExifTool::XMP::DecodeBase64($val); join(".",unpack("C*",$$val))' );
1464             my %base64double = (
1465             ValueConv => q{
1466             my $val=Image::ExifTool::XMP::DecodeBase64($val);
1467             my $saveOrder = GetByteOrder();
1468             SetByteOrder('II');
1469             $val = GetDouble($val,0);
1470             SetByteOrder($saveOrder);
1471             return $val;
1472             },
1473             );
1474             my %base64coord = (
1475             ValueConv => q{
1476             my $val=Image::ExifTool::XMP::DecodeBase64($val);
1477             my $saveOrder = GetByteOrder();
1478             SetByteOrder('II');
1479             $val = GetDouble($val,0) + GetDouble($val,8)/60 + GetDouble($val,16)/3600;
1480             SetByteOrder($saveOrder);
1481             return $val;
1482             },
1483             PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1)',
1484             );
1485             # Nikon maker note tags
1486             %Image::ExifTool::Nikon::Main = (
1487             PROCESS_PROC => \&Image::ExifTool::Nikon::ProcessNikon,
1488             WRITE_PROC => \&Image::ExifTool::Nikon::ProcessNikon,
1489             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
1490             WRITABLE => 1,
1491             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
1492             PRINT_CONV => \&FormatString,
1493             0x0001 => { #2
1494             # the format differs for different models. for D70, this is a string '0210',
1495             # but for the E775 it is binary: "\x00\x01\x00\x00"
1496             Name => 'MakerNoteVersion',
1497             Writable => 'undef',
1498             Count => 4,
1499             # convert to string if binary
1500             ValueConv => '$_=$val; /^[\x00-\x09]/ and $_=join("",unpack("CCCC",$_)); $_',
1501             ValueConvInv => '$val',
1502             PrintConv => '$_=$val;s/^(\d{2})/$1\./;s/^0//;$_',
1503             PrintConvInv => '$_=$val;s/\.//;"0$_"',
1504             },
1505             0x0002 => {
1506             # this is the ISO actually used by the camera
1507             # (may be different than ISO setting if auto)
1508             Name => 'ISO',
1509             Writable => 'int16u',
1510             Count => 2,
1511             Priority => 0, # the EXIF ISO is more reliable
1512             Groups => { 2 => 'Image' },
1513             # D300 sets this to undef with 4 zero bytes when LO ISO is used - PH
1514             RawConv => '$val eq "\0\0\0\0" ? undef : $val',
1515             # first number is 1 for "Hi ISO" modes (H0.3, H0.7 and H1.0 on D80) - PH
1516             PrintConv => '$_=$val;s/^0 //;s/^1 (\d+)/Hi $1/;$_',
1517             PrintConvInv => '$_=$val;/^\d+/ ? "0 $_" : (s/Hi ?//i ? "1 $_" : $_)',
1518             },
1519             # Note: we attempt to fix the case of these string values (typically written in all caps)
1520             0x0003 => { Name => 'ColorMode', Writable => 'string' },
1521             0x0004 => { Name => 'Quality', Writable => 'string' },
1522             0x0005 => { Name => 'WhiteBalance', Writable => 'string' },
1523             0x0006 => { Name => 'Sharpness', Writable => 'string' },
1524             0x0007 => {
1525             Name => 'FocusMode',
1526             Writable => 'string',
1527             },
1528             # FlashSetting (better named FlashSyncMode, ref 28) values:
1529             # "Normal", "Slow", "Rear Slow", "RED-EYE", "RED-EYE SLOW"
1530             0x0008 => { Name => 'FlashSetting', Writable => 'string' },
1531             # FlashType observed values:
1532             # internal: "Built-in,TTL", "Built-in,RPT", "Comdr.", "NEW_TTL"
1533             # external: "Optional,TTL", "Optional,RPT", "Optional,M", "Comdr."
1534             # both: "Built-in,TTL&Comdr."
1535             # no flash: ""
1536             0x0009 => { Name => 'FlashType', Writable => 'string' }, #2 (count varies by model - PH)
1537             # 0x000a - rational values: 5.6 to 9.33 - found in Coolpix models - PH
1538             # (seems constant for a given camera model, but not correlated with scale factor)
1539             0x000b => { #2
1540             Name => 'WhiteBalanceFineTune',
1541             Writable => 'int16s',
1542             Count => -1, # older models write 1 value, newer DSLR's write 2 - PH
1543             },
1544             0x000c => { # (D1X)
1545             Name => 'WB_RBLevels',
1546             Writable => 'rational64u',
1547             Count => 4, # (not sure what the last 2 values are for)
1548             },
1549             0x000d => { #15
1550             Name => 'ProgramShift',
1551             Writable => 'undef',
1552             Count => 4,
1553             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1554             ValueConvInv => q{
1555             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1556             $a<-128 or $a>127 ? undef : pack("c4",$a,1,6,0);
1557             },
1558             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1559             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1560             },
1561             0x000e => {
1562             Name => 'ExposureDifference',
1563             Writable => 'undef',
1564             Count => 4,
1565             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1566             ValueConvInv => q{
1567             my $a = int($val*12 + ($val>0 ? 0.5 : -0.5));
1568             $a<-128 or $a>127 ? undef : pack("c4",$a,1,12,0);
1569             },
1570             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
1571             PrintConvInv => '$val',
1572             },
1573             0x000f => { Name => 'ISOSelection', Writable => 'string' }, #2
1574             0x0010 => {
1575             Name => 'DataDump',
1576             Writable => 0,
1577             Binary => 1,
1578             },
1579             0x0011 => {
1580             Name => 'PreviewIFD',
1581             Groups => { 1 => 'PreviewIFD', 2 => 'Image' },
1582             Flags => 'SubIFD',
1583             SubDirectory => {
1584             TagTable => 'Image::ExifTool::Nikon::PreviewIFD',
1585             Start => '$val',
1586             },
1587             },
1588             0x0012 => { #2 (camera setting: combination of command dial and menus - PH)
1589             Name => 'FlashExposureComp',
1590             Description => 'Flash Exposure Compensation',
1591             Writable => 'undef',
1592             Count => 4,
1593             # (includes the built-in compensation for FlashType "Built-in,TTL&Comdr.")
1594             Notes => q{
1595             may be set even if flash does not fire. Does not include the effect of
1596             flash bracketing.
1597             },
1598             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1599             ValueConvInv => q{
1600             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1601             $a<-128 or $a>127 ? undef : pack("c4",$a,1,6,0);
1602             },
1603             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1604             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1605             },
1606             # D70 - another ISO tag
1607             0x0013 => { #2
1608             Name => 'ISOSetting',
1609             Writable => 'int16u',
1610             Count => 2,
1611             PrintConv => '$_=$val;s/^0 //;$_',
1612             PrintConvInv => '"0 $val"',
1613             },
1614             0x0014 => [
1615             { #4
1616             Name => 'ColorBalanceA',
1617             Condition => '$format eq "undef" and $count == 2560',
1618             SubDirectory => {
1619             TagTable => 'Image::ExifTool::Nikon::ColorBalanceA',
1620             ByteOrder => 'BigEndian',
1621             },
1622             },
1623             { #IB
1624             Name => 'NRWData',
1625             Condition => '$$valPt =~ /^NRW 0100/',
1626             Drop => 1, # 'Drop' because it is large and not found in JPEG images
1627             SubDirectory => {
1628             TagTable => 'Image::ExifTool::Nikon::ColorBalanceB',
1629             },
1630             },
1631             { #IB
1632             Name => 'NRWData',
1633             Condition => '$$valPt =~ /^NRW /',
1634             Drop => 1, # 'Drop' because it is large and not found in JPEG images
1635             SubDirectory => {
1636             TagTable => 'Image::ExifTool::Nikon::ColorBalanceC',
1637             },
1638             },
1639             ],
1640             # 0x0015 - string[8]: "AUTO "
1641             # D70 Image boundary?? top x,y bot-right x,y
1642             0x0016 => { #2
1643             Name => 'ImageBoundary',
1644             Writable => 'int16u',
1645             Count => 4,
1646             },
1647             0x0017 => { #28
1648             Name => 'ExternalFlashExposureComp', #PH (setting from external flash unit)
1649             Writable => 'undef',
1650             Count => 4,
1651             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1652             ValueConvInv => q{
1653             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1654             $a<-128 or $a>127 ? undef : pack("c4",$a,1,6,0);
1655             },
1656             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1657             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1658             },
1659             0x0018 => { #5
1660             Name => 'FlashExposureBracketValue',
1661             Writable => 'undef',
1662             Count => 4,
1663             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1664             ValueConvInv => q{
1665             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1666             $a<-128 or $a>127 ? undef : pack("c4",$a,1,6,0);
1667             },
1668             PrintConv => 'sprintf("%.1f",$val)',
1669             PrintConvInv => '$val',
1670             },
1671             0x0019 => { #5
1672             Name => 'ExposureBracketValue',
1673             Writable => 'rational64s',
1674             PrintConv => '$val !~ /undef/ ? Image::ExifTool::Exif::PrintFraction($val) : "n/a" ', #undef observed for Z9 jpgs at C30/C60/C90 [data is 0/0 rather than the usual 0/6]
1675             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1676             },
1677             0x001a => { #PH
1678             Name => 'ImageProcessing',
1679             Writable => 'string',
1680             },
1681             0x001b => { #15
1682             Name => 'CropHiSpeed',
1683             Writable => 'int16u',
1684             Count => 7,
1685             PrintConv => \%cropHiSpeed,
1686             },
1687             0x001c => { #28 (D3 "the application of CSb6 to the selected metering mode")
1688             Name => 'ExposureTuning',
1689             Writable => 'undef',
1690             Count => 3,
1691             ValueConv => 'my ($a,$b,$c)=unpack("c3",$val); $c ? $a*($b/$c) : 0',
1692             ValueConvInv => q{
1693             my $a = int($val*6 + ($val>0 ? 0.5 : -0.5));
1694             $a<-128 or $a>127 ? undef : pack("c3",$a,1,6);
1695             },
1696             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
1697             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1698             },
1699             0x001d => { #4
1700             Name => 'SerialNumber',
1701             # Note: this has been known to change even if the serial number on the body
1702             # stays the same if some parts of the camera were replaced by Nikon service
1703             Writable => 'string',
1704             Protected => 1,
1705             Notes => q{
1706             this value is used as a key to decrypt other information -- writing this tag
1707             causes the other information to be re-encrypted with the new key
1708             },
1709             PrintConv => undef, # disable default PRINT_CONV
1710             },
1711             0x001e => { #14
1712             Name => 'ColorSpace',
1713             Writable => 'int16u',
1714             PrintConv => {
1715             1 => 'sRGB',
1716             2 => 'Adobe RGB',
1717             },
1718             },
1719             0x001f => { #PH
1720             Name => 'VRInfo',
1721             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::VRInfo' },
1722             },
1723             0x0020 => { #16
1724             Name => 'ImageAuthentication',
1725             Writable => 'int8u',
1726             PrintConv => \%offOn,
1727             },
1728             0x0021 => { #PH
1729             Name => 'FaceDetect',
1730             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FaceDetect' },
1731             },
1732             0x0022 => { #21
1733             Name => 'ActiveD-Lighting',
1734             Writable => 'int16u',
1735             PrintConv => {
1736             0 => 'Off',
1737             1 => 'Low',
1738             3 => 'Normal',
1739             5 => 'High',
1740             7 => 'Extra High', #10
1741             8 => 'Extra High 1', #PH
1742             9 => 'Extra High 2', #PH
1743             10 => 'Extra High 3', #PH
1744             11 => 'Extra High 4', #PH
1745             0xffff => 'Auto', #10
1746             },
1747             },
1748             0x0023 => [
1749             { #PH (D300, but also found in D3,D3S,D3X,D90,D300S,D700,D3000,D5000)
1750             Name => 'PictureControlData',
1751             Condition => '$$valPt =~ /^01/',
1752             Writable => 'undef',
1753             Permanent => 0,
1754             Flags => [ 'Binary', 'Protected' ],
1755             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl' },
1756             },{ #28
1757             Name => 'PictureControlData',
1758             Condition => '$$valPt =~ /^02/',
1759             Writable => 'undef',
1760             Permanent => 0,
1761             Flags => [ 'Binary', 'Protected' ],
1762             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl2' },
1763             },{
1764             Name => 'PictureControlData',
1765             Condition => '$$valPt =~ /^03/',
1766             Writable => 'undef',
1767             Permanent => 0,
1768             Flags => [ 'Binary', 'Protected' ],
1769             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl3' },
1770             },{
1771             Name => 'PictureControlData',
1772             Writable => 'undef',
1773             Permanent => 0,
1774             Flags => [ 'Binary', 'Protected' ],
1775             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControlUnknown' },
1776             },
1777             ],
1778             0x0024 => { #JD
1779             Name => 'WorldTime',
1780             SubDirectory => {
1781             TagTable => 'Image::ExifTool::Nikon::WorldTime',
1782             # (CaptureNX does flip the byte order of this record)
1783             },
1784             },
1785             0x0025 => { #PH
1786             Name => 'ISOInfo',
1787             SubDirectory => {
1788             TagTable => 'Image::ExifTool::Nikon::ISOInfo',
1789             ByteOrder => 'BigEndian',
1790             },
1791             },
1792             0x002a => { #23 (this tag added with D3 firmware 1.10 -- also written by Nikon utilities)
1793             Name => 'VignetteControl',
1794             Writable => 'int16u',
1795             PrintConv => {
1796             0 => 'Off',
1797             1 => 'Low',
1798             3 => 'Normal',
1799             5 => 'High',
1800             },
1801             },
1802             0x002b => { #PH
1803             Name => 'DistortInfo',
1804             SubDirectory => {
1805             TagTable => 'Image::ExifTool::Nikon::DistortInfo',
1806             },
1807             },
1808             0x002c => { #29 (D7000)
1809             Name => 'UnknownInfo',
1810             SubDirectory => {
1811             TagTable => 'Image::ExifTool::Nikon::UnknownInfo',
1812             ByteOrder => 'BigEndian', #(NC)
1813             },
1814             },
1815             # 0x2d - "512 0 0","512 3 10","512 1 14",...
1816             0x0032 => { #PH
1817             Name => 'UnknownInfo2',
1818             SubDirectory => {
1819             TagTable => 'Image::ExifTool::Nikon::UnknownInfo2',
1820             ByteOrder => 'BigEndian', #(NC)
1821             },
1822             },
1823             0x0034 => { #forum9646
1824             Name => 'ShutterMode',
1825             Writable => 'int16u',
1826             RawConv => '$$self{ShutterMode} = $val',
1827             DataMember => 'ShutterMode',
1828             PrintConv => {
1829             0 => 'Mechanical',
1830             16 => 'Electronic',
1831             # 33 => ? seen for 1J2
1832             48 => 'Electronic Front Curtain',
1833             64 => 'Electronic (Movie)', #JanSkoda (Z6II)
1834             80 => 'Auto (Mechanical)', #JanSkoda (Z6II)
1835             81 => 'Auto (Electronic Front Curtain)', #JanSkoda (Z6II)
1836             96 => 'Electronic (High Speed)', #28 Z9 at C30/C60/C120 frame rates
1837             },
1838             },
1839             0x0035 => [{ #32
1840             Name => 'HDRInfo',
1841             Condition => '$count != 6',
1842             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::HDRInfo' },
1843             },{
1844             Name => 'HDRInfo2',
1845             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::HDRInfo2' },
1846             }],
1847             0x0037 => { #XavierJubier
1848             Name => 'MechanicalShutterCount',
1849             Writable => 'int32u',
1850             },
1851             0x0039 => {
1852             Name => 'LocationInfo',
1853             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LocationInfo' },
1854             },
1855             0x003d => { #IB
1856             Name => 'BlackLevel',
1857             Writable => 'int16u',
1858             Count => 4,
1859             # (may need to divide by 4 for some images, eg. D3300/D5300, 12 bit - ref IB)
1860             },
1861             0x003e => { #28
1862             Name => 'ImageSizeRAW',
1863             PrintConv => {
1864             1 => 'Large',
1865             2 => 'Medium',
1866             3 => 'Small',
1867             },
1868             },
1869             0x003f => { #https://github.com/darktable-org/darktable/issues/12282
1870             Name => 'WhiteBalanceFineTune',
1871             Writable => 'rational64s',
1872             Count => 2,
1873             },
1874             0x0045 => { #IB
1875             Name => 'CropArea',
1876             Notes => 'left, top, width, height',
1877             Writable => 'int16u',
1878             Count => 4,
1879             },
1880             0x004e => { #28
1881             Name => 'NikonSettings',
1882             Writable => 'undef',
1883             Permanent => 0,
1884             Flags => [ 'Binary', 'Protected' ],
1885             SubDirectory => { TagTable => 'Image::ExifTool::NikonSettings::Main' },
1886             },
1887             0x004f => { #IB (D850)
1888             Name => 'ColorTemperatureAuto',
1889             Writable => 'int16u',
1890             },
1891             0x0051 => { #28 (Z9)
1892             Name => 'MakerNotes0x51',
1893             Writable => 'undef',
1894             Hidden => 1,
1895             Permanent => 0,
1896             Flags => [ 'Binary', 'Protected' ],
1897             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::MakerNotes0x51' },
1898             },
1899             #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)
1900             0x0056 => { #28 (Z9)
1901             Name => 'MakerNotes0x56',
1902             Writable => 'undef',
1903             Hidden => 1,
1904             Permanent => 0,
1905             Flags => [ 'Binary', 'Protected' ],
1906             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::MakerNotes0x56' },
1907             },
1908             #0x005e #28 possibly DiffractionCompensation block? Certainly offset 0x04 within block contains tag DiffractionCompensation
1909             0x0080 => { Name => 'ImageAdjustment', Writable => 'string' },
1910             0x0081 => { Name => 'ToneComp', Writable => 'string' }, #2
1911             0x0082 => { Name => 'AuxiliaryLens', Writable => 'string' },
1912             0x0083 => {
1913             Name => 'LensType',
1914             Writable => 'int8u',
1915             # credit to Tom Christiansen (ref 7) for figuring this out...
1916             # (note that older models don't seem to set bits 4-7 (0xf0), so the
1917             # LensType may be different with different models, ref Kenneth Cochran)
1918             PrintConv => q[$_ = $val ? Image::ExifTool::DecodeBits($val,
1919             {
1920             0 => 'MF',
1921             1 => 'D',
1922             2 => 'G',
1923             3 => 'VR',
1924             4 => '1', #PH
1925             5 => 'FT-1', #PH/IB
1926             6 => 'E', #PH (electromagnetic aperture mechanism)
1927             7 => 'AF-P', #PH/IB
1928             }) : 'AF';
1929             # remove commas and change "D G" to just "G"
1930             s/,//g; s/\bD G\b/G/;
1931             s/ E\b// and s/^(G )?/E /; # put "E" at the start instead of "G"
1932             s/ 1// and $_ = "1 $_"; # put "1" at start
1933             s/FT-1 // and $_ .= ' FT-1'; # put "FT-1" at end
1934             return $_;
1935             ],
1936             PrintConvInv => q[
1937             my $bits = 0;
1938             $bits |= 0x01 if $val =~ /\bMF\b/i; # bit 0
1939             $bits |= 0x02 if $val =~ /\bD\b/i; # bit 1
1940             $bits |= 0x06 if $val =~ /\bG\b/i; # bits 1 and 2
1941             $bits |= 0x08 if $val =~ /\bVR\b/i; # bit 3
1942             $bits |= 0x10 if $val =~ /\b1\b/; # bit 4
1943             $bits |= 0x20 if $val =~ /\bFT-1/i; # bit 5
1944             $bits |= 0x80 if $val =~ /\bAF-P/i; # bit 7 (not used by all models)
1945             $bits |= 0x46 if $val =~ /\bE\b/i; # bits 1, 2 and 6
1946             return $bits;
1947             ],
1948             },
1949             0x0084 => { #2
1950             Name => "Lens",
1951             Writable => 'rational64u',
1952             Count => 4,
1953             # short focal, long focal, aperture at short focal, aperture at long focal
1954             PrintConv => \&Image::ExifTool::Exif::PrintLensInfo,
1955             PrintConvInv => \&Image::ExifTool::Exif::ConvertLensInfo,
1956             },
1957             0x0085 => {
1958             Name => 'ManualFocusDistance',
1959             Writable => 'rational64u',
1960             },
1961             0x0086 => {
1962             Name => 'DigitalZoom',
1963             Writable => 'rational64u',
1964             },
1965             0x0087 => { #5
1966             Name => 'FlashMode',
1967             Writable => 'int8u',
1968             PrintConv => {
1969             0 => 'Did Not Fire',
1970             1 => 'Fired, Manual', #14
1971             3 => 'Not Ready', #28
1972             7 => 'Fired, External', #14
1973             8 => 'Fired, Commander Mode',
1974             9 => 'Fired, TTL Mode',
1975             18 => 'LED Light', #G.F. (movie LED light)
1976             },
1977             },
1978             0x0088 => [
1979             {
1980             Name => 'AFInfo',
1981             Condition => '$$self{Model} =~ /^NIKON D/i',
1982             SubDirectory => {
1983             TagTable => 'Image::ExifTool::Nikon::AFInfo',
1984             ByteOrder => 'BigEndian',
1985             },
1986             },
1987             {
1988             Name => 'AFInfo',
1989             SubDirectory => {
1990             TagTable => 'Image::ExifTool::Nikon::AFInfo',
1991             ByteOrder => 'LittleEndian',
1992             },
1993             },
1994             ],
1995             0x0089 => { #5
1996             Name => 'ShootingMode',
1997             Writable => 'int16u',
1998             # the meaning of bit 5 seems to change: For the D200 it indicates "Auto ISO" - PH
1999             Notes => 'for the D70, Bit 5 = Unused LE-NR Slowdown',
2000             # credit to Tom Christiansen (ref 7) for figuring this out...
2001             # The (new?) bit 5 seriously complicates our life here: after firmwareB's
2002             # 1.03, bit 5 turns on when you ask for BUT DO NOT USE the long-range
2003             # noise reduction feature, probably because even not using it, it still
2004             # slows down your drive operation to 50% (1.5fps max not 3fps). But no
2005             # longer does !$val alone indicate single-frame operation. - TC, D70
2006             # The following comments are from Warren Hatch:
2007             # Bits 4,6,8 indicate bracketing mode.
2008             # - all 0's => Bracketing Off
2009             # - bit 4 on with bits 6,8 off => Exposure Bracketing On
2010             # - bits 4,6 on => WB bracketing On
2011             # - 4,8 on => ADL Bracketing On
2012             # Bit 2 gives tethered status: Off=>Not Tethered; On=Tethered.
2013             # - that this simply indicates a camera is connected via a cord to a PC
2014             # (doesn't necessarily mean that the shutter was tripped by the computer)
2015             # Bits 0,1,3,7,9 relate to how the shutter is tripped in concert with the
2016             # Release Mode dial [although I cannot cause bit 7 to flip with any of my gear and
2017             # I suspect it is no longer used for the D500]. Regardless, the ReleaseMode tag
2018             # offers a superior decoding of this information for the D4s, D810 and D500.
2019             # Bit 5 indicates whether or not AutoISO is enabled.
2020             PrintConv => q[
2021             $_ = '';
2022             unless ($val & 0x87) {
2023             return 'Single-Frame' unless $val;
2024             $_ = 'Single-Frame, ';
2025             }
2026             return $_ . Image::ExifTool::DecodeBits($val,
2027             {
2028             0 => 'Continuous',
2029             1 => 'Delay',
2030             2 => 'PC Control',
2031             3 => 'Self-timer', #forum6281 (NC)
2032             4 => 'Exposure Bracketing',
2033             5 => $$self{Model}=~/D70\b/ ? 'Unused LE-NR Slowdown' : 'Auto ISO',
2034             6 => 'White-Balance Bracketing',
2035             7 => 'IR Control',
2036             8 => 'D-Lighting Bracketing', #forum6281 (NC)
2037             11 => 'Pre-capture', #28 Z9 pre-release burst
2038             });
2039             ],
2040             },
2041             # 0x008a - called "AutoBracketRelease" by ref 15 [but this seems wrong]
2042             # values: 0,255 (when writing NEF only), or 1,2 (when writing JPEG or JPEG+NEF)
2043             # --> makes odd, repeating pattern in sequential NEF images (ref 28)
2044             0x008b => { #8
2045             Name => 'LensFStops',
2046             ValueConv => 'my ($a,$b,$c)=unpack("C3",$val); $c ? $a*($b/$c) : 0',
2047             ValueConvInv => 'my $a=int($val*12+0.5);$a<256 ? pack("C4",$a,1,12,0) : undef',
2048             PrintConv => 'sprintf("%.2f", $val)',
2049             PrintConvInv => '$val',
2050             Writable => 'undef',
2051             Count => 4,
2052             },
2053             0x008c => {
2054             Name => 'ContrastCurve', #JD
2055             Writable => 'undef',
2056             Flags => [ 'Binary', 'Protected', 'Drop' ], # (drop because not found in Nikon JPEG's)
2057             },
2058             # ColorHue: MODE1/MODE1a=sRGB, MODE2=Adobe RGB, MODE3a=more saturated sRGB
2059             # --> should really be called ColorSpace or ColorMode, but that would conflict with other tags
2060             0x008d => { Name => 'ColorHue' , Writable => 'string' }, #2
2061             # SceneMode takes on the following values: PORTRAIT, PARTY/INDOOR, NIGHT PORTRAIT,
2062             # BEACH/SNOW, LANDSCAPE, SUNSET, NIGHT SCENE, MUSEUM, FIREWORKS, CLOSE UP, COPY,
2063             # BACK LIGHT, PANORAMA ASSIST, SPORT, DAWN/DUSK
2064             0x008f => { Name => 'SceneMode', Writable => 'string' }, #2
2065             # LightSource shows 3 values COLORED SPEEDLIGHT NATURAL.
2066             # (SPEEDLIGHT when flash goes. Have no idea about difference between other two.)
2067             0x0090 => { Name => 'LightSource', Writable => 'string' }, #2
2068             0x0091 => [ #18
2069             { #PH
2070             Condition => '$$valPt =~ /^0209/',
2071             Name => 'ShotInfoD40',
2072             SubDirectory => {
2073             TagTable => 'Image::ExifTool::Nikon::ShotInfoD40',
2074             DecryptStart => 4,
2075             ByteOrder => 'BigEndian',
2076             },
2077             },
2078             {
2079             Condition => '$$valPt =~ /^0208/',
2080             Name => 'ShotInfoD80',
2081             SubDirectory => {
2082             TagTable => 'Image::ExifTool::Nikon::ShotInfoD80',
2083             DecryptStart => 4,
2084             # (Capture NX can change the makernote byte order, but this stays big-endian)
2085             ByteOrder => 'BigEndian',
2086             },
2087             },
2088             { #PH (D90, firmware 1.00)
2089             Condition => '$$valPt =~ /^0213/',
2090             Name => 'ShotInfoD90',
2091             SubDirectory => {
2092             TagTable => 'Image::ExifTool::Nikon::ShotInfoD90',
2093             DecryptStart => 4,
2094             ByteOrder => 'BigEndian',
2095             },
2096             },
2097             { #PH (D3, firmware 0.37 and 1.00)
2098             Condition => '$$valPt =~ /^0210/ and $count == 5399',
2099             Name => 'ShotInfoD3a',
2100             SubDirectory => {
2101             TagTable => 'Image::ExifTool::Nikon::ShotInfoD3a',
2102             DecryptStart => 4,
2103             ByteOrder => 'BigEndian',
2104             },
2105             },
2106             { #PH (D3, firmware 1.10, 2.00 and 2.01 [count 5408], and 2.02 [count 5412])
2107             Condition => '$$valPt =~ /^0210/ and ($count == 5408 or $count == 5412)',
2108             Name => 'ShotInfoD3b',
2109             SubDirectory => {
2110             TagTable => 'Image::ExifTool::Nikon::ShotInfoD3b',
2111             DecryptStart => 4,
2112             ByteOrder => 'BigEndian',
2113             },
2114             },
2115             { #PH (D3X, firmware 1.00)
2116             Condition => '$$valPt =~ /^0214/ and $count == 5409',
2117             Name => 'ShotInfoD3X',
2118             SubDirectory => {
2119             TagTable => 'Image::ExifTool::Nikon::ShotInfoD3X',
2120             DecryptStart => 4,
2121             ByteOrder => 'BigEndian',
2122             },
2123             },
2124             { #PH (D3S, firmware 0.16 and 1.00)
2125             Condition => '$$valPt =~ /^0218/ and ($count == 5356 or $count == 5388)',
2126             Name => 'ShotInfoD3S',
2127             SubDirectory => {
2128             TagTable => 'Image::ExifTool::Nikon::ShotInfoD3S',
2129             DecryptStart => 4,
2130             ByteOrder => 'BigEndian',
2131             },
2132             },
2133             { #JD (D300, firmware 0.25 and 1.00)
2134             # D3 and D300 use the same version number, but the length is different
2135             Condition => '$$valPt =~ /^0210/ and $count == 5291',
2136             Name => 'ShotInfoD300a',
2137             SubDirectory => {
2138             TagTable => 'Image::ExifTool::Nikon::ShotInfoD300a',
2139             DecryptStart => 4,
2140             ByteOrder => 'BigEndian',
2141             },
2142             },
2143             { #PH (D300, firmware version 1.10)
2144             # yet again the same ShotInfoVersion for different data
2145             Condition => '$$valPt =~ /^0210/ and $count == 5303',
2146             Name => 'ShotInfoD300b',
2147             SubDirectory => {
2148             TagTable => 'Image::ExifTool::Nikon::ShotInfoD300b',
2149             DecryptStart => 4,
2150             ByteOrder => 'BigEndian',
2151             },
2152             },
2153             { #PH (D300S, firmware version 1.00)
2154             # yet again the same ShotInfoVersion for different data
2155             Condition => '$$valPt =~ /^0216/ and $count == 5311',
2156             Name => 'ShotInfoD300S',
2157             SubDirectory => {
2158             TagTable => 'Image::ExifTool::Nikon::ShotInfoD300S',
2159             DecryptStart => 4,
2160             ByteOrder => 'BigEndian',
2161             },
2162             },
2163             # 0225 - D600
2164             { #29 (D700 firmware version 1.02f)
2165             Condition => '$$valPt =~ /^0212/ and $count == 5312',
2166             Name => 'ShotInfoD700',
2167             SubDirectory => {
2168             TagTable => 'Image::ExifTool::Nikon::ShotInfoD700',
2169             DecryptStart => 4,
2170             ByteOrder => 'BigEndian',
2171             },
2172             },
2173             { #28 (D780 firmware version 1.00)
2174             Condition => '$$valPt =~ /^0245/',
2175             Name => 'ShotInfoD780',
2176             SubDirectory => {
2177             TagTable => 'Image::ExifTool::Nikon::ShotInfoD780',
2178             DecryptStart => 4,
2179             ByteOrder => 'LittleEndian',
2180             },
2181             },
2182             { #28 (D7500 firmware version 1.00h)
2183             Condition => '$$valPt =~ /^0242/',
2184             Name => 'ShotInfoD7500',
2185             SubDirectory => {
2186             TagTable => 'Image::ExifTool::Nikon::ShotInfoD7500',
2187             DecryptStart => 4,
2188             ByteOrder => 'LittleEndian',
2189             },
2190             },
2191             { #PH (D800 firmware 1.01a)
2192             Condition => '$$valPt =~ /^0222/',
2193             Name => 'ShotInfoD800',
2194             SubDirectory => {
2195             TagTable => 'Image::ExifTool::Nikon::ShotInfoD800',
2196             DecryptStart => 4,
2197             ByteOrder => 'BigEndian',
2198             },
2199             },
2200             { #28 (D810 firmware 1.01)
2201             Condition => '$$valPt =~ /^0233/',
2202             Name => 'ShotInfoD810',
2203             SubDirectory => {
2204             TagTable => 'Image::ExifTool::Nikon::ShotInfoD810',
2205             DecryptStart => 4,
2206             ByteOrder => 'LittleEndian',
2207             },
2208             },
2209             { #28 (D850 firmware 1.00b)
2210             Condition => '$$valPt =~ /^0243/',
2211             Name => 'ShotInfoD850',
2212             SubDirectory => {
2213             TagTable => 'Image::ExifTool::Nikon::ShotInfoD850',
2214             DecryptStart => 4,
2215             ByteOrder => 'LittleEndian',
2216             },
2217             },
2218             # 0217 - D3000
2219             # 0219 - D3100
2220             # 0224 - D3200
2221             { #PH
2222             Condition => '$$valPt =~ /^0215/ and $count == 6745',
2223             Name => 'ShotInfoD5000',
2224             SubDirectory => {
2225             TagTable => 'Image::ExifTool::Nikon::ShotInfoD5000',
2226             DecryptStart => 4,
2227             ByteOrder => 'BigEndian',
2228             },
2229             },
2230             { #PH
2231             Condition => '$$valPt =~ /^0221/ and $count == 8902',
2232             Name => 'ShotInfoD5100',
2233             SubDirectory => {
2234             TagTable => 'Image::ExifTool::Nikon::ShotInfoD5100',
2235             DecryptStart => 4,
2236             ByteOrder => 'BigEndian',
2237             },
2238             },
2239             { #PH
2240             Condition => '$$valPt =~ /^0226/ and $count == 11587',
2241             Name => 'ShotInfoD5200',
2242             SubDirectory => {
2243             TagTable => 'Image::ExifTool::Nikon::ShotInfoD5200',
2244             DecryptStart => 4,
2245             ByteOrder => 'BigEndian',
2246             },
2247             },
2248             { #29 (D7000 firmware version 1.01b)
2249             Condition => '$$valPt =~ /^0220/',
2250             Name => 'ShotInfoD7000',
2251             SubDirectory => {
2252             TagTable => 'Image::ExifTool::Nikon::ShotInfoD7000',
2253             DecryptStart => 4,
2254             ByteOrder => 'BigEndian',
2255             },
2256             },
2257             { # (D4 firmware version 1.00g)
2258             Condition => '$$valPt =~ /^0223/',
2259             Name => 'ShotInfoD4',
2260             SubDirectory => {
2261             TagTable => 'Image::ExifTool::Nikon::ShotInfoD4',
2262             DecryptStart => 4,
2263             ByteOrder => 'BigEndian',
2264             },
2265             },
2266             { # (D4S firmware version 1.00d and 1.01a)
2267             Condition => '$$valPt =~ /^0231/',
2268             Name => 'ShotInfoD4S',
2269             SubDirectory => {
2270             TagTable => 'Image::ExifTool::Nikon::ShotInfoD4S',
2271             DecryptStart => 4,
2272             ByteOrder => 'LittleEndian',
2273             },
2274             },
2275             { #28 (D500 firmware version 1.00 and D5 firmware version 1.10a)
2276             Condition => '$$valPt =~ /^023[89]/',
2277             Name => 'ShotInfoD500',
2278             SubDirectory => {
2279             TagTable => 'Image::ExifTool::Nikon::ShotInfoD500',
2280             DecryptStart => 4,
2281             ByteOrder => 'LittleEndian',
2282             },
2283             },
2284             { # (D6 firmware version 1.00, ref 28)
2285             Condition => '$$valPt =~ /^0246/',
2286             Name => 'ShotInfoD6',
2287             SubDirectory => {
2288             TagTable => 'Image::ExifTool::Nikon::ShotInfoD6',
2289             DecryptStart => 4,
2290             ByteOrder => 'LittleEndian',
2291             },
2292             },
2293             { # (D610 firmware version 1.00)
2294             Condition => '$$valPt =~ /^0232/',
2295             Name => 'ShotInfoD610',
2296             SubDirectory => {
2297             TagTable => 'Image::ExifTool::Nikon::ShotInfoD610',
2298             DecryptStart => 4,
2299             ByteOrder => 'BigEndian',
2300             },
2301             },
2302             { # (Z6_2 firmware version 1.00 and Z7II firmware versions 1.00 & 1.01, ref 28)
2303             # 0800=Z6/Z7 0801=Z50 0802=Z5 0803=Z6II/Z7II 0804=Zfc
2304             Condition => '$$valPt =~ /^080[01234]/',
2305             Name => 'ShotInfoZ7II',
2306             SubDirectory => {
2307             TagTable => 'Image::ExifTool::Nikon::ShotInfoZ7II',
2308             DecryptStart => 4,
2309             ByteOrder => 'LittleEndian',
2310             },
2311             },
2312             { # (Z9 firmware version 1.00 ref 28)
2313             Condition => '$$valPt =~ /^0805/',
2314             Name => 'ShotInfoZ9',
2315             SubDirectory => {
2316             TagTable => 'Image::ExifTool::Nikon::ShotInfoZ9',
2317             DecryptStart => 4,
2318             ByteOrder => 'LittleEndian',
2319             },
2320             },
2321             { # D7100=0227
2322             Condition => '$$valPt =~ /^0[28]/',
2323             Name => 'ShotInfo02xx',
2324             SubDirectory => {
2325             TagTable => 'Image::ExifTool::Nikon::ShotInfo',
2326             ProcessProc => \&ProcessNikonEncrypted,
2327             WriteProc => \&ProcessNikonEncrypted,
2328             DecryptStart => 4,
2329             ByteOrder => 'BigEndian',
2330             },
2331             },
2332             {
2333             Name => 'ShotInfoUnknown',
2334             Writable => 0,
2335             SubDirectory => {
2336             TagTable => 'Image::ExifTool::Nikon::ShotInfo',
2337             ByteOrder => 'BigEndian',
2338             },
2339             },
2340             ],
2341             0x0092 => { #2
2342             Name => 'HueAdjustment',
2343             Writable => 'int16s',
2344             },
2345             # 0x0093 - ref 15 calls this Saturation, but this is wrong - PH
2346             0x0093 => { #21
2347             Name => 'NEFCompression',
2348             Writable => 'int16u',
2349             SeparateTable => 'NEFCompression',
2350             PrintConv => \%nefCompression,
2351             },
2352             0x0094 => { Name => 'SaturationAdj', Writable => 'int16s' },
2353             0x0095 => { Name => 'NoiseReduction', Writable => 'string' }, # ("Off" or "FPNR"=long exposure NR)
2354             0x0096 => {
2355             Name => 'NEFLinearizationTable', # same table as DNG LinearizationTable (ref JD)
2356             Writable => 'undef',
2357             Flags => [ 'Binary', 'Protected' ],
2358             },
2359             0x0097 => [ #4
2360             # (NOTE: these are byte-swapped by NX when byte order changes)
2361             {
2362             Condition => '$$valPt =~ /^0100/', # (D100 and Coolpix models)
2363             Name => 'ColorBalance0100',
2364             SubDirectory => {
2365             Start => '$valuePtr + 72',
2366             TagTable => 'Image::ExifTool::Nikon::ColorBalance1',
2367             },
2368             },
2369             {
2370             Condition => '$$valPt =~ /^0102/', # (D2H)
2371             Name => 'ColorBalance0102',
2372             SubDirectory => {
2373             Start => '$valuePtr + 10',
2374             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2375             },
2376             },
2377             {
2378             Condition => '$$valPt =~ /^0103/', # (D70/D70s)
2379             Name => 'ColorBalance0103',
2380             # D70: at file offset 'tag-value + base + 20', 4 16 bits numbers,
2381             # v[0]/v[1] , v[2]/v[3] are the red/blue multipliers.
2382             SubDirectory => {
2383             Start => '$valuePtr + 20',
2384             TagTable => 'Image::ExifTool::Nikon::ColorBalance3',
2385             },
2386             },
2387             {
2388             Condition => '$$valPt =~ /^0205/', # (D50)
2389             Name => 'ColorBalance0205',
2390             SubDirectory => {
2391             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2392             ProcessProc => \&ProcessNikonEncrypted,
2393             WriteProc => \&ProcessNikonEncrypted,
2394             DecryptStart => 4,
2395             DirOffset => 14, # (start of directory relative to DecryptStart)
2396             },
2397             },
2398             { # (D3/D3X/D300/D700=0209,D300S=0212,D3S=0214)
2399             Condition => '$$valPt =~ /^02(09|12|14)/',
2400             Name => 'ColorBalance0209',
2401             SubDirectory => {
2402             TagTable => 'Image::ExifTool::Nikon::ColorBalance4',
2403             ProcessProc => \&ProcessNikonEncrypted,
2404             WriteProc => \&ProcessNikonEncrypted,
2405             DecryptStart => 284,
2406             DirOffset => 10,
2407             },
2408             },
2409             { # (D2X/D2Xs=0204,D2Hs=0206,D200=0207,D40/D40X/D80=0208,D60=0210)
2410             Condition => '$$valPt =~ /^02(\d{2})/ and $1 < 11',
2411             Name => 'ColorBalance02',
2412             SubDirectory => {
2413             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2414             ProcessProc => \&ProcessNikonEncrypted,
2415             WriteProc => \&ProcessNikonEncrypted,
2416             DecryptStart => 284,
2417             DirOffset => 6,
2418             },
2419             },
2420             {
2421             Condition => '$$valPt =~ /^0211/', # (D90/D5000)
2422             Name => 'ColorBalance0211',
2423             SubDirectory => {
2424             TagTable => 'Image::ExifTool::Nikon::ColorBalance4',
2425             ProcessProc => \&ProcessNikonEncrypted,
2426             WriteProc => \&ProcessNikonEncrypted,
2427             DecryptStart => 284,
2428             DirOffset => 16,
2429             },
2430             },
2431             {
2432             Condition => '$$valPt =~ /^0213/', # (D3000)
2433             Name => 'ColorBalance0213',
2434             SubDirectory => {
2435             TagTable => 'Image::ExifTool::Nikon::ColorBalance2',
2436             ProcessProc => \&ProcessNikonEncrypted,
2437             WriteProc => \&ProcessNikonEncrypted,
2438             DecryptStart => 284,
2439             DirOffset => 10,
2440             },
2441             },
2442             { # (D3100=0215,D7000/D5100=0216,D4/D600/D800/D800E/D3200=0217)
2443             Condition => '$$valPt =~ /^021[567]/',
2444             Name => 'ColorBalance0215',
2445             SubDirectory => {
2446             TagTable => 'Image::ExifTool::Nikon::ColorBalance4',
2447             ProcessProc => \&ProcessNikonEncrypted,
2448             WriteProc => \&ProcessNikonEncrypted,
2449             DecryptStart => 284,
2450             DirOffset => 4,
2451             },
2452             },
2453             { # (D5200/D7100=0218, D5300=0219, D610/Df=0220, D3300=0221, CoolpixA=0601)
2454             Name => 'ColorBalanceUnknown02',
2455             Condition => '$$valPt =~ /^0[26]/',
2456             SubDirectory => {
2457             TagTable => 'Image::ExifTool::Nikon::ColorBalanceUnknown',
2458             ProcessProc => \&ProcessNikonEncrypted,
2459             WriteProc => \&ProcessNikonEncrypted, # (necessary to recrypt this if serial number changed)
2460             DecryptStart => 284,
2461             },
2462             },
2463             { # (1J1/1J2/1V1=0400, 1V2=0401, 1J3/1S1=0402, 1AW1=0403, Z6/Z7=0800)
2464             Name => 'ColorBalanceUnknown04',
2465             Condition => '$$valPt =~ /^0[48]/',
2466             SubDirectory => {
2467             TagTable => 'Image::ExifTool::Nikon::ColorBalanceUnknown',
2468             ProcessProc => \&ProcessNikonEncrypted,
2469             WriteProc => \&ProcessNikonEncrypted, # (necessary to recrypt this if serial number changed)
2470             DecryptStart => 4,
2471             },
2472             },
2473             {
2474             # (CoolpixP7700/P7800=0500, CoolpixP330/P520=0502)
2475             Name => 'ColorBalanceUnknown',
2476             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::ColorBalanceUnknown' },
2477             },
2478             ],
2479             0x0098 => [
2480             { #8
2481             Condition => '$$valPt =~ /^0100/', # D100, D1X - PH
2482             Name => 'LensData0100',
2483             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LensData00' },
2484             },
2485             { #8
2486             Condition => '$$valPt =~ /^0101/', # D70, D70s - PH
2487             Name => 'LensData0101',
2488             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LensData01' },
2489             },
2490             # note: this information is encrypted if the version is 02xx
2491             { #8
2492             # 0201 - D200, D2Hs, D2X and D2Xs
2493             # 0202 - D40, D40X and D80
2494             # 0203 - D300
2495             Condition => '$$valPt =~ /^020[1-3]/',
2496             Name => 'LensData0201',
2497             SubDirectory => {
2498             TagTable => 'Image::ExifTool::Nikon::LensData01',
2499             ProcessProc => \&ProcessNikonEncrypted,
2500             WriteProc => \&ProcessNikonEncrypted,
2501             DecryptStart => 4,
2502             },
2503             },
2504             { #PH
2505             Condition => '$$valPt =~ /^0204/', # D90, D7000
2506             Name => 'LensData0204',
2507             SubDirectory => {
2508             TagTable => 'Image::ExifTool::Nikon::LensData0204',
2509             ProcessProc => \&ProcessNikonEncrypted,
2510             WriteProc => \&ProcessNikonEncrypted,
2511             DecryptStart => 4,
2512             },
2513             },
2514             {
2515             Condition => '$$valPt =~ /^040[01]/', # 0=1J1/1V1, 1=1J2
2516             Name => 'LensData0400',
2517             SubDirectory => {
2518             TagTable => 'Image::ExifTool::Nikon::LensData0400',
2519             ProcessProc => \&ProcessNikonEncrypted,
2520             WriteProc => \&ProcessNikonEncrypted,
2521             DecryptStart => 4,
2522             },
2523             },
2524             {
2525             Condition => '$$valPt =~ /^0402/', # 1J3/1S1/1V2
2526             Name => 'LensData0402',
2527             SubDirectory => {
2528             TagTable => 'Image::ExifTool::Nikon::LensData0402',
2529             ProcessProc => \&ProcessNikonEncrypted,
2530             WriteProc => \&ProcessNikonEncrypted,
2531             DecryptStart => 4,
2532             },
2533             },
2534             {
2535             Condition => '$$valPt =~ /^0403/', # 1J4,1J5
2536             Name => 'LensData0403',
2537             SubDirectory => {
2538             TagTable => 'Image::ExifTool::Nikon::LensData0403',
2539             ProcessProc => \&ProcessNikonEncrypted,
2540             WriteProc => \&ProcessNikonEncrypted,
2541             DecryptStart => 4,
2542             },
2543             },
2544             {
2545             Condition => '$$valPt =~ /^080[012]/', # Z6/Z7/Z9
2546             Name => 'LensData0800',
2547             SubDirectory => {
2548             TagTable => 'Image::ExifTool::Nikon::LensData0800',
2549             ProcessProc => \&ProcessNikonEncrypted,
2550             WriteProc => \&ProcessNikonEncrypted,
2551             DecryptStart => 4,
2552             ByteOrder => 'LittleEndian',
2553             },
2554             },
2555             {
2556             Name => 'LensDataUnknown',
2557             SubDirectory => {
2558             TagTable => 'Image::ExifTool::Nikon::LensDataUnknown',
2559             ProcessProc => \&ProcessNikonEncrypted,
2560             WriteProc => \&ProcessNikonEncrypted,
2561             DecryptStart => 4,
2562             },
2563             },
2564             ],
2565             0x0099 => { #2/15
2566             Name => 'RawImageCenter',
2567             Writable => 'int16u',
2568             Count => 2,
2569             },
2570             0x009a => { #10
2571             Name => 'SensorPixelSize',
2572             Writable => 'rational64u',
2573             Count => 2,
2574             PrintConv => '$val=~s/ / x /;"$val um"',
2575             PrintConvInv => '$val=~tr/a-zA-Z/ /;$val',
2576             },
2577             0x009c => { #14
2578             # L2/L3 has these modes (from owner's manual): - PH
2579             # Portrait Assist: FACE-PRIORITY AF,PORTRAIT,PORTRAIT LEFT,PORTRAIT RIGHT,
2580             # PORTRAIT CLOSE-UP,PORTRAIT COUPLE,PORTRAIT-FIGURE
2581             # Landscape Assist:LANDSCAPE,SCENIC VIEW,ARCHITECTURE,GROUP RIGHT,GROUP LEFT
2582             # Sports Assist: SPORTS,SPORT SPECTATOR,SPORT COMPOSITE
2583             # P7100 has test modes: - PH
2584             # CREATIVE MONOCHROME,PAINTING,CROSS PROCESS,SOFT,NOSTALGIC SEPIA,
2585             # HIGH KEY,LOW KEY,SELECTIVE COLOR,ZOOM EXPOSURE EXP.,DEFOCUS DURING
2586             Name => 'SceneAssist',
2587             Writable => 'string',
2588             },
2589             0x009d => { #NealKrawetz
2590             Name => 'DateStampMode',
2591             Writable => 'int16u',
2592             Notes => 'feature to imprint date/time on image',
2593             PrintConv => { #PH
2594             0 => 'Off',
2595             1 => 'Date & Time',
2596             2 => 'Date',
2597             3 => 'Date Counter', # (NC) (D3500)
2598             },
2599             },
2600             0x009e => { #JD
2601             Name => 'RetouchHistory',
2602             Writable => 'int16u',
2603             Count => 10,
2604             # trim off extra "None" values
2605             ValueConv => '$val=~s/( 0)+$//; $val',
2606             ValueConvInv => 'my $n=($val=~/ \d+/g);$n < 9 ? $val . " 0" x (9-$n) : $val',
2607             PrintConvColumns => 2,
2608             PrintConv => [
2609             \%retouchValues,
2610             \%retouchValues,
2611             \%retouchValues,
2612             \%retouchValues,
2613             \%retouchValues,
2614             \%retouchValues,
2615             \%retouchValues,
2616             \%retouchValues,
2617             \%retouchValues,
2618             \%retouchValues,
2619             ],
2620             },
2621             0x00a0 => { Name => 'SerialNumber', Writable => 'string' }, #2
2622             0x00a2 => { # size of compressed image data plus EOI segment (ref 10)
2623             Name => 'ImageDataSize',
2624             Writable => 'int32u',
2625             },
2626             # 0x00a3 - int8u: 0 (All DSLR's but D1,D1H,D1X,D100)
2627             # 0x00a4 - version number found only in NEF images from DSLR models except the
2628             # D1,D1X,D2H and D100. Value is "0200" for all available samples except images
2629             # edited by Nikon Capture Editor 4.3.1 W and 4.4.2 which have "0100" - PH
2630             0x00a5 => { #15
2631             Name => 'ImageCount',
2632             Writable => 'int32u',
2633             },
2634             0x00a6 => { #15
2635             Name => 'DeletedImageCount',
2636             Writable => 'int32u',
2637             },
2638             # the sum of 0xa5 and 0xa6 is equal to 0xa7 ShutterCount (D2X,D2Hs,D2H,D200, ref 10)
2639             0x00a7 => { # Number of shots taken by camera so far (ref 2)
2640             Name => 'ShutterCount',
2641             Writable => 'int32u',
2642             Protected => 1,
2643             PrintConv => '$val == 4294965247 ? "n/a" : $val',
2644             PrintConvInv => '$val eq "n/a" ? 4294965247 : $val',
2645             Notes => q{
2646             includes both mechanical and electronic shutter activations for models with
2647             this feature. This value is used as a key to decrypt other information, and
2648             writing this tag causes the other information to be re-encrypted with the
2649             new key
2650             },
2651             },
2652             0x00a8 => [#JD
2653             {
2654             Name => 'FlashInfo0100',
2655             Condition => '$$valPt =~ /^010[01]/',
2656             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0100' },
2657             },
2658             {
2659             Name => 'FlashInfo0102',
2660             Condition => '$$valPt =~ /^0102/',
2661             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0102' },
2662             },
2663             {
2664             Name => 'FlashInfo0103',
2665             # (0104 for D7000, 0105 for D800)
2666             Condition => '$$valPt =~ /^010[345]/',
2667             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0103' },
2668             },
2669             {
2670             Name => 'FlashInfo0106', # (Df, D610, D3300, D5300, D7100, Coolpix A)
2671             Condition => '$$valPt =~ /^0106/',
2672             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0106' },
2673             },
2674             {
2675             Name => 'FlashInfo0107', # (0107 for D4S/D750/D810/D5500/D7200, 0108 for D5/D500/D3400)
2676             Condition => '$$valPt =~ /^010[78]/',
2677             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0107' },
2678             },
2679             {
2680             Name => 'FlashInfo0300', # (Z7II)
2681             Condition => '$$valPt =~ /^030[01]/',
2682             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0300' },
2683             },
2684             {
2685             Name => 'FlashInfoUnknown',
2686             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfoUnknown' },
2687             },
2688             ],
2689             0x00a9 => { Name => 'ImageOptimization',Writable => 'string' },#2
2690             0x00aa => { Name => 'Saturation', Writable => 'string' }, #2
2691             0x00ab => { Name => 'VariProgram', Writable => 'string' }, #2 (scene mode for DSLR's - PH)
2692             0x00ac => { Name => 'ImageStabilization',Writable=> 'string' }, #14
2693             0x00ad => { Name => 'AFResponse', Writable => 'string' }, #14
2694             0x00b0 => [{ #PH
2695             Name => 'MultiExposure',
2696             Condition => '$$valPt =~ /^0100/',
2697             SubDirectory => {
2698             TagTable => 'Image::ExifTool::Nikon::MultiExposure',
2699             # Note: this endianness varies with model, but Nikon software may change
2700             # metadata endianness (although it is unknown how it affects this record),
2701             # so for now don't specify ByteOrder although it may be wrong if the
2702             # file is rewritten by Nikon software --> see comments for FileInfo
2703             },
2704             },{
2705             Name => 'MultiExposure',
2706             Condition => '$$valPt =~ /^0101/',
2707             SubDirectory => {
2708             TagTable => 'Image::ExifTool::Nikon::MultiExposure',
2709             ByteOrder => 'LittleEndian',
2710             },
2711             },{
2712             Name => 'MultiExposure2',
2713             Condition => '$$valPt =~ /^010[23]/', # 0102 is NC (PH)
2714             SubDirectory => {
2715             TagTable => 'Image::ExifTool::Nikon::MultiExposure2',
2716             },
2717             }],
2718             0x00b1 => { #14/PH/JD (D80)
2719             Name => 'HighISONoiseReduction',
2720             Writable => 'int16u',
2721             PrintConv => {
2722             0 => 'Off',
2723             1 => 'Minimal', # for high ISO (>800) when setting is "Off"
2724             2 => 'Low', # Low,Normal,High take effect for ISO > 400
2725             3 => 'Medium Low',
2726             4 => 'Normal',
2727             5 => 'Medium High',
2728             6 => 'High',
2729             },
2730             },
2731             # 0x00b2 (string: "NORMAL ", 0xc3's, 0xff's or 0x20's)
2732             0x00b3 => { #14
2733             Name => 'ToningEffect',
2734             Writable => 'string',
2735             },
2736             0x00b6 => { #PH
2737             Name => 'PowerUpTime',
2738             Groups => { 2 => 'Time' },
2739             Shift => 'Time',
2740             # not clear whether "powered up" means "turned on" or "power applied" - PH
2741             Notes => 'date/time when camera was last powered up',
2742             Writable => 'undef',
2743             # must use RawConv so byte order is correct
2744             RawConv => sub {
2745             my $val = shift;
2746             return $val if length $val < 7;
2747             my $shrt = GetByteOrder() eq 'II' ? 'v' : 'n';
2748             my @date = unpack("${shrt}C5", $val);
2749             return sprintf('%.4d:%.2d:%.2d %.2d:%.2d:%.2d', @date);
2750             },
2751             RawConvInv => sub {
2752             my $val = shift;
2753             my $shrt = GetByteOrder() eq 'II' ? 'v' : 'n';
2754             my @date = ($val =~ /\d+/g);
2755             return pack("${shrt}C6", @date, 0);
2756             },
2757             PrintConv => '$self->ConvertDateTime($val)',
2758             PrintConvInv => '$self->InverseDateTime($val,0)',
2759             },
2760             0x00b7 => [{
2761             Name => 'AFInfo2',
2762             Condition => '$$self{Model} =~ /^NIKON Z 9\b/i', #AFInfo2Version 0400
2763             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2V0400' },
2764             },{ #JD
2765             Name => 'AFInfo2',
2766             # (this structure may be byte swapped when rewritten by CaptureNX)
2767             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2' },
2768             }],
2769             0x00b8 => [{ #PH
2770             Name => 'FileInfo',
2771             # unfortunately, some newer models write this as little-endian
2772             # (and CaptureNX can change the byte order of the maker notes,
2773             # but leaves this structure unchanged)
2774             # - it will be an ongoing pain to keep this list of models up-to-date,
2775             # so if only one ordering yields valid DirectoryNumber and FileNumber values,
2776             # use it, otherwise default to a-priori knowledge of the camera model
2777             # (assume that a valid DirectoryNumber is 100-999, and a valid FileNumber
2778             # is 0000-9999, although I have some samples with a DirectoryNumber of 99)
2779             Condition => q{
2780             if (length($$valPt) >= 0) {
2781             my ($dir, $file) = unpack('x6vv', $$valPt);
2782             my $littleEndian = ($dir >= 100 and $dir <= 999 and $file <= 9999);
2783             ($dir, $file) = unpack('x6nn', $$valPt);
2784             my $bigEndian = ($dir >= 100 and $dir <= 999 and $file <= 9999);
2785             return $littleEndian if $littleEndian xor $bigEndian;
2786             }
2787             return $$self{Model} =~ /^NIKON (D4S|D750|D810|D3300|D5200|D5300|D5500|D7100)$/;
2788             },
2789             SubDirectory => {
2790             TagTable => 'Image::ExifTool::Nikon::FileInfo',
2791             ByteOrder => 'LittleEndian',
2792             },
2793             },{
2794             Name => 'FileInfo',
2795             SubDirectory => {
2796             TagTable => 'Image::ExifTool::Nikon::FileInfo',
2797             ByteOrder => 'BigEndian',
2798             },
2799             }],
2800             0x00b9 => { #28
2801             Name => 'AFTune',
2802             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFTune' },
2803             },
2804             # 0x00ba - custom curve data? (ref 28?) (only in NEF images)
2805             0x00bb => { #forum6281
2806             Name => 'RetouchInfo',
2807             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::RetouchInfo' },
2808             },
2809             # 0x00bc - NEFThumbnail? (forum6281)
2810             0x00bd => { #PH (P6000)
2811             Name => 'PictureControlData',
2812             Writable => 'undef',
2813             Permanent => 0,
2814             Flags => [ 'Binary', 'Protected' ],
2815             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl' },
2816             },
2817             0x00bf => {
2818             Name => 'SilentPhotography',
2819             PrintConv => \%offOn,
2820             },
2821             0x00c3 => {
2822             Name => 'BarometerInfo',
2823             SubDirectory => {
2824             TagTable => 'Image::ExifTool::Nikon::BarometerInfo',
2825             # (little-endian in II EXIF, big-endian in MOV)
2826             },
2827             },
2828             0x0e00 => {
2829             Name => 'PrintIM',
2830             Description => 'Print Image Matching',
2831             Writable => 0,
2832             SubDirectory => {
2833             TagTable => 'Image::ExifTool::PrintIM::Main',
2834             },
2835             },
2836             # 0x0e01 - In D70 NEF files produced by Nikon Capture, the data for this tag extends 4 bytes
2837             # past the end of the maker notes. Very odd. I hope these 4 bytes aren't useful because
2838             # they will get lost by any utility that blindly copies the maker notes (not ExifTool) - PH
2839             0x0e01 => {
2840             Name => 'NikonCaptureData',
2841             Writable => 'undef',
2842             Permanent => 0,
2843             # (Drop because may be too large for JPEG images)
2844             Flags => [ 'Binary', 'Protected', 'Drop' ],
2845             Notes => q{
2846             this data is dropped when copying Nikon MakerNotes since it may be too large
2847             to fit in the EXIF segment of a JPEG image, but it may be copied as a block
2848             into existing Nikon MakerNotes later if desired
2849             },
2850             SubDirectory => {
2851             DirName => 'NikonCapture',
2852             TagTable => 'Image::ExifTool::NikonCapture::Main',
2853             },
2854             },
2855             # 0x0e05 written by Nikon Capture to NEF files, values of 1 and 2 - PH
2856             0x0e09 => { #12
2857             Name => 'NikonCaptureVersion',
2858             Writable => 'string',
2859             Permanent => 0,
2860             PrintConv => undef, # (avoid applying default print conversion to string)
2861             },
2862             # 0x0e0e is in D70 Nikon Capture files (not out-of-the-camera D70 files) - PH
2863             0x0e0e => { #PH
2864             Name => 'NikonCaptureOffsets',
2865             Writable => 'undef',
2866             Permanent => 0,
2867             SubDirectory => {
2868             TagTable => 'Image::ExifTool::Nikon::CaptureOffsets',
2869             Validate => '$val =~ /^0100/',
2870             Start => '$valuePtr + 4',
2871             },
2872             },
2873             0x0e10 => { #17
2874             Name => 'NikonScanIFD',
2875             Groups => { 1 => 'NikonScan', 2 => 'Image' },
2876             Flags => 'SubIFD',
2877             SubDirectory => {
2878             TagTable => 'Image::ExifTool::Nikon::Scan',
2879             Start => '$val',
2880             },
2881             },
2882             0x0e13 => [{ # PH/https://exiftool.org/forum/index.php/topic,2737.0.html
2883             Name => 'NikonCaptureEditVersions',
2884             Condition => '$self->Options("ExtractEmbedded")',
2885             Notes => q{
2886             the L option may be used to decode settings from the stored
2887             edit versions, otherwise this is extracted as a binary data block
2888             },
2889             Writable => 'undef',
2890             Permanent => 0,
2891             Drop => 1, # (may be too large for JPEG images)
2892             SubDirectory => {
2893             DirName => 'NikonCaptureEditVersions',
2894             TagTable => 'Image::ExifTool::NikonCapture::Main',
2895             ProcessProc => \&ProcessNikonCaptureEditVersions,
2896             WriteProc => sub { return undef }, # (writing not yet supported)
2897             },
2898             },{
2899             Name => 'NikonCaptureEditVersions',
2900             Writable => 'undef',
2901             Permanent => 0,
2902             Flags => [ 'Binary', 'Protected', 'Drop' ],
2903             }],
2904             0x0e1d => { #JD
2905             Name => 'NikonICCProfile',
2906             Flags => [ 'Binary', 'Protected' ],
2907             Writable => 'undef', # must be defined here so tag will be extracted if specified
2908             WriteCheck => q{
2909             require Image::ExifTool::ICC_Profile;
2910             return Image::ExifTool::ICC_Profile::ValidateICC(\$val);
2911             },
2912             SubDirectory => {
2913             DirName => 'NikonICCProfile',
2914             TagTable => 'Image::ExifTool::ICC_Profile::Main',
2915             },
2916             },
2917             0x0e1e => { #PH
2918             Name => 'NikonCaptureOutput',
2919             Writable => 'undef',
2920             Permanent => 0,
2921             Flags => [ 'Binary', 'Protected' ],
2922             SubDirectory => {
2923             TagTable => 'Image::ExifTool::Nikon::CaptureOutput',
2924             Validate => '$val =~ /^0100/',
2925             },
2926             },
2927             0x0e22 => { #28
2928             Name => 'NEFBitDepth',
2929             Writable => 'int16u',
2930             Count => 4,
2931             Protected => 1,
2932             PrintConv => {
2933             '0 0 0 0' => 'n/a (JPEG)',
2934             '8 8 8 0' => '8 x 3', # TIFF RGB
2935             '16 16 16 0' => '16 x 3', # TIFF 16-bit RGB
2936             '12 0 0 0' => 12,
2937             '14 0 0 0' => 14,
2938             },
2939             },
2940             );
2941              
2942             # NikonScan IFD entries (ref 17)
2943             %Image::ExifTool::Nikon::Scan = (
2944             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
2945             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
2946             WRITE_GROUP => 'NikonScan',
2947             WRITABLE => 1,
2948             GROUPS => { 0 => 'MakerNotes', 1 => 'NikonScan', 2 => 'Image' },
2949             VARS => { MINOR_ERRORS => 1 }, # this IFD is non-essential and often corrupted
2950             NOTES => 'This information is written by the Nikon Scan software.',
2951             0x02 => { Name => 'FilmType', Writable => 'string', },
2952             0x40 => { Name => 'MultiSample', Writable => 'string' },
2953             0x41 => { Name => 'BitDepth', Writable => 'int16u' },
2954             0x50 => {
2955             Name => 'MasterGain',
2956             Writable => 'rational64s',
2957             PrintConv => 'sprintf("%.2f",$val)',
2958             PrintConvInv => '$val',
2959             },
2960             0x51 => {
2961             Name => 'ColorGain',
2962             Writable => 'rational64s',
2963             Count => 3,
2964             PrintConv => 'sprintf("%.2f %.2f %.2f",split(" ",$val))',
2965             PrintConvInv => '$val',
2966             },
2967             0x60 => {
2968             Name => 'ScanImageEnhancer',
2969             Writable => 'int32u',
2970             PrintConv => \%offOn,
2971             },
2972             0x100 => { Name => 'DigitalICE', Writable => 'string' },
2973             0x110 => {
2974             Name => 'ROCInfo',
2975             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::ROC' },
2976             },
2977             0x120 => {
2978             Name => 'GEMInfo',
2979             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::GEM' },
2980             },
2981             0x200 => { Name => 'DigitalDEEShadowAdj', Writable => 'int32u' },
2982             0x201 => { Name => 'DigitalDEEThreshold', Writable => 'int32u' },
2983             0x202 => { Name => 'DigitalDEEHighlightAdj',Writable => 'int32u' },
2984             );
2985              
2986             # ref 17
2987             %Image::ExifTool::Nikon::ROC = (
2988             %binaryDataAttrs,
2989             FORMAT => 'int32u',
2990             GROUPS => { 0 => 'MakerNotes', 1 => 'NikonScan', 2 => 'Image' },
2991             0 => {
2992             Name => 'DigitalROC',
2993             ValueConv => '$val / 10',
2994             ValueConvInv => 'int($val * 10)',
2995             },
2996             );
2997              
2998             # ref 17
2999             %Image::ExifTool::Nikon::GEM = (
3000             %binaryDataAttrs,
3001             FORMAT => 'int32u',
3002             GROUPS => { 0 => 'MakerNotes', 1 => 'NikonScan', 2 => 'Image' },
3003             0 => {
3004             Name => 'DigitalGEM',
3005             ValueConv => '$val<95 ? $val/20-1 : 4',
3006             ValueConvInv => '$val == 4 ? 95 : int(($val + 1) * 20)',
3007             },
3008             );
3009              
3010             # Vibration Reduction information - PH (D300)
3011             %Image::ExifTool::Nikon::VRInfo = (
3012             %binaryDataAttrs,
3013             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3014             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3015             0 => {
3016             Name => 'VRInfoVersion',
3017             Format => 'undef[4]',
3018             Writable => 0,
3019             },
3020             4 => {
3021             Name => 'VibrationReduction',
3022             PrintConv => {
3023             0 => 'n/a', # (1V1 with a non-VR lens)
3024             1 => 'On',
3025             2 => 'Off',
3026             },
3027             },
3028             # 5 - values: 0, 1 (VR On), 2 (VR Off)
3029             6 => [{
3030             Name => 'VRMode',
3031             PrintConv => {
3032             0 => 'Off',
3033             1 => 'Normal', #39 (was 'Sport')
3034             3 => 'Sport', #39 (was 'Normal')
3035             },
3036             %infoZSeries,
3037             },{
3038             Name => 'VRMode',
3039             PrintConv => {
3040             0 => 'Normal',
3041             1 => 'On (1)', #PH (NC)
3042             2 => 'Active', # (1J1)
3043             3 => 'Sport', #PH (Z7)
3044             },
3045             }],
3046             # 7 - values: 0, 1
3047             8 => { #39
3048             Name => 'VRType',
3049             PrintConv => {
3050             2 => 'In-body', # (IBIS)
3051             3 => 'In-body + Lens', # (IBIS + VR)
3052             },
3053             },
3054             );
3055              
3056             # Face detection information - PH (S8100)
3057             %Image::ExifTool::Nikon::FaceDetect = (
3058             %binaryDataAttrs,
3059             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
3060             FORMAT => 'int16u',
3061             DATAMEMBER => [ 0x03 ],
3062             0x01 => {
3063             Name => 'FaceDetectFrameSize',
3064             Format => 'int16u[2]',
3065             },
3066             0x03 => {
3067             Name => 'FacesDetected',
3068             DataMember => 'FacesDetected',
3069             RawConv => '$$self{FacesDetected} = $val',
3070             },
3071             0x04 => {
3072             Name => 'Face1Position',
3073             Format => 'int16u[4]',
3074             RawConv => '$$self{FacesDetected} < 1 ? undef : $val',
3075             Notes => q{
3076             top, left, width and height of face detect area in coordinates of
3077             FaceDetectFrameSize
3078             },
3079             },
3080             0x08 => {
3081             Name => 'Face2Position',
3082             Format => 'int16u[4]',
3083             RawConv => '$$self{FacesDetected} < 2 ? undef : $val',
3084             },
3085             0x0c => {
3086             Name => 'Face3Position',
3087             Format => 'int16u[4]',
3088             RawConv => '$$self{FacesDetected} < 3 ? undef : $val',
3089             },
3090             0x10 => {
3091             Name => 'Face4Position',
3092             Format => 'int16u[4]',
3093             RawConv => '$$self{FacesDetected} < 4 ? undef : $val',
3094             },
3095             0x14 => {
3096             Name => 'Face5Position',
3097             Format => 'int16u[4]',
3098             RawConv => '$$self{FacesDetected} < 5 ? undef : $val',
3099             },
3100             0x18 => {
3101             Name => 'Face6Position',
3102             Format => 'int16u[4]',
3103             RawConv => '$$self{FacesDetected} < 6 ? undef : $val',
3104             },
3105             0x1c => {
3106             Name => 'Face7Position',
3107             Format => 'int16u[4]',
3108             RawConv => '$$self{FacesDetected} < 7 ? undef : $val',
3109             },
3110             0x20 => {
3111             Name => 'Face8Position',
3112             Format => 'int16u[4]',
3113             RawConv => '$$self{FacesDetected} < 8 ? undef : $val',
3114             },
3115             0x24 => {
3116             Name => 'Face9Position',
3117             Format => 'int16u[4]',
3118             RawConv => '$$self{FacesDetected} < 9 ? undef : $val',
3119             },
3120             0x28 => {
3121             Name => 'Face10Position',
3122             Format => 'int16u[4]',
3123             RawConv => '$$self{FacesDetected} < 10 ? undef : $val',
3124             },
3125             0x2c => {
3126             Name => 'Face11Position',
3127             Format => 'int16u[4]',
3128             RawConv => '$$self{FacesDetected} < 11 ? undef : $val',
3129             },
3130             0x30 => {
3131             Name => 'Face12Position',
3132             Format => 'int16u[4]',
3133             RawConv => '$$self{FacesDetected} < 12 ? undef : $val',
3134             },
3135             );
3136              
3137             # Picture Control information - PH (D300,P6000)
3138             %Image::ExifTool::Nikon::PictureControl = (
3139             %binaryDataAttrs,
3140             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3141             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3142             0 => {
3143             Name => 'PictureControlVersion',
3144             Format => 'undef[4]',
3145             Writable => 0,
3146             },
3147             4 => {
3148             Name => 'PictureControlName',
3149             Format => 'string[20]',
3150             # make lower case with a leading capital for each word
3151             PrintConv => \&FormatString,
3152             PrintConvInv => 'uc($val)',
3153             },
3154             24 => {
3155             Name => 'PictureControlBase',
3156             Format => 'string[20]',
3157             PrintConv => \&FormatString,
3158             PrintConvInv => 'uc($val)',
3159             },
3160             # beginning at byte 44, there is some interesting information.
3161             # here are the observed bytes for each PictureControlMode:
3162             # 44 45 46 47 48 49 50 51 52 53 54 55 56 57
3163             # STANDARD 00 01 00 00 00 80 83 80 80 80 80 ff ff ff
3164             # NEUTRAL 03 c2 00 00 00 ff 82 80 80 80 80 ff ff ff
3165             # VIVID 00 c3 00 00 00 80 84 80 80 80 80 ff ff ff
3166             # MONOCHROME 06 4d 00 01 02 ff 82 80 80 ff ff 80 80 ff
3167             # Neutral2 03 c2 01 00 02 ff 80 7f 81 00 7f ff ff ff (custom)
3168             # (note that up to 9 different custom picture controls can be stored)
3169             # --> bytes 44 and 45 are swapped if CaptureNX changes the byte order
3170             #
3171             48 => { #21
3172             Name => 'PictureControlAdjust',
3173             PrintConv => {
3174             0 => 'Default Settings',
3175             1 => 'Quick Adjust',
3176             2 => 'Full Control',
3177             },
3178             },
3179             49 => {
3180             Name => 'PictureControlQuickAdjust',
3181             # settings: -2 to +2 (n/a for Neutral and Monochrome modes)
3182             DelValue => 0xff,
3183             ValueConv => '$val - 0x80',
3184             ValueConvInv => '$val + 0x80',
3185             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3186             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3187             },
3188             50 => {
3189             Name => 'Sharpness',
3190             # settings: 0 to 9, Auto
3191             ValueConv => '$val - 0x80',
3192             ValueConvInv => '$val + 0x80',
3193             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"No Sharpening","%d")',
3194             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3195             },
3196             51 => {
3197             Name => 'Contrast',
3198             # settings: -3 to +3, Auto
3199             ValueConv => '$val - 0x80',
3200             ValueConvInv => '$val + 0x80',
3201             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3202             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3203             },
3204             52 => {
3205             Name => 'Brightness',
3206             # settings: -1 to +1
3207             ValueConv => '$val - 0x80',
3208             ValueConvInv => '$val + 0x80',
3209             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3210             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3211             },
3212             53 => {
3213             Name => 'Saturation',
3214             # settings: -3 to +3, Auto (n/a for Monochrome mode)
3215             DelValue => 0xff,
3216             ValueConv => '$val - 0x80',
3217             ValueConvInv => '$val + 0x80',
3218             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3219             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3220             },
3221             54 => {
3222             Name => 'HueAdjustment',
3223             # settings: -3 to +3 (n/a for Monochrome mode)
3224             DelValue => 0xff,
3225             ValueConv => '$val - 0x80',
3226             ValueConvInv => '$val + 0x80',
3227             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None")',
3228             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3229             },
3230             55 => {
3231             Name => 'FilterEffect',
3232             # settings: Off,Yellow,Orange,Red,Green (n/a for color modes)
3233             DelValue => 0xff,
3234             PrintHex => 1,
3235             PrintConv => {
3236             0x80 => 'Off',
3237             0x81 => 'Yellow',
3238             0x82 => 'Orange',
3239             0x83 => 'Red',
3240             0x84 => 'Green',
3241             0xff => 'n/a',
3242             },
3243             },
3244             56 => {
3245             Name => 'ToningEffect',
3246             # settings: B&W,Sepia,Cyanotype,Red,Yellow,Green,Blue-Green,Blue,
3247             # Purple-Blue,Red-Purple (n/a for color modes)
3248             DelValue => 0xff,
3249             PrintHex => 1,
3250             PrintConvColumns => 2,
3251             PrintConv => {
3252             0x80 => 'B&W',
3253             0x81 => 'Sepia',
3254             0x82 => 'Cyanotype',
3255             0x83 => 'Red',
3256             0x84 => 'Yellow',
3257             0x85 => 'Green',
3258             0x86 => 'Blue-green',
3259             0x87 => 'Blue',
3260             0x88 => 'Purple-blue',
3261             0x89 => 'Red-purple',
3262             0xff => 'n/a',
3263             # 0x04 - seen for D810 (PH)
3264             },
3265             },
3266             57 => { #21
3267             Name => 'ToningSaturation',
3268             # settings: B&W,Sepia,Cyanotype,Red,Yellow,Green,Blue-Green,Blue,
3269             # Purple-Blue,Red-Purple (n/a unless ToningEffect is used)
3270             DelValue => 0xff,
3271             ValueConv => '$val - 0x80',
3272             ValueConvInv => '$val + 0x80',
3273             PrintConv => '$val==0x7f ? "n/a" : $val',
3274             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3275             },
3276             );
3277              
3278             # Picture Control information V2 (ref 28)
3279             %Image::ExifTool::Nikon::PictureControl2 = (
3280             %binaryDataAttrs,
3281             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3282             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3283             0 => {
3284             Name => 'PictureControlVersion',
3285             Format => 'undef[4]',
3286             Writable => 0,
3287             },
3288             4 => {
3289             Name => 'PictureControlName',
3290             Format => 'string[20]',
3291             # make lower case with a leading capital for each word
3292             PrintConv => \&FormatString,
3293             PrintConvInv => 'uc($val)',
3294             },
3295             24 => {
3296             Name => 'PictureControlBase',
3297             Format => 'string[20]',
3298             PrintConv => \&FormatString,
3299             PrintConvInv => 'uc($val)',
3300             },
3301             # beginning at byte 44, there is some interesting information.
3302             # here are the observed bytes for each PictureControlMode:
3303             # 44 45 46 47 48 49 50 51 52 53 54 55 56 57
3304             # STANDARD 00 01 00 00 00 80 83 80 80 80 80 ff ff ff
3305             # NEUTRAL 03 c2 00 00 00 ff 82 80 80 80 80 ff ff ff
3306             # VIVID 00 c3 00 00 00 80 84 80 80 80 80 ff ff ff
3307             # MONOCHROME 06 4d 00 01 02 ff 82 80 80 ff ff 80 80 ff
3308             # Neutral2 03 c2 01 00 02 ff 80 7f 81 00 7f ff ff ff (custom)
3309             # (note that up to 9 different custom picture controls can be stored)
3310             # --> bytes 44 and 45 are swapped if CaptureNX changes the byte order
3311             #
3312             48 => { #21
3313             Name => 'PictureControlAdjust',
3314             PrintConv => {
3315             0 => 'Default Settings',
3316             1 => 'Quick Adjust',
3317             2 => 'Full Control',
3318             },
3319             },
3320             49 => {
3321             Name => 'PictureControlQuickAdjust',
3322             # settings: -2 to +2 (n/a for Neutral and Monochrome modes)
3323             DelValue => 0xff,
3324             ValueConv => '$val - 0x80',
3325             ValueConvInv => '$val + 0x80',
3326             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3327             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3328             },
3329             51 => {
3330             Name => 'Sharpness',
3331             DelValue => 0xff,
3332             ValueConv => '$val - 0x80',
3333             ValueConvInv => '$val + 0x80',
3334             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3335             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3336             },
3337             53 => {
3338             Name => 'Clarity',
3339             DelValue => 0xff,
3340             ValueConv => '$val - 0x80',
3341             ValueConvInv => '$val + 0x80',
3342             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3343             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv2($val,4)',
3344             },
3345             55 => {
3346             Name => 'Contrast',
3347             DelValue => 0xff,
3348             ValueConv => '$val - 0x80',
3349             ValueConvInv => '$val + 0x80',
3350             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3351             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3352             },
3353             57 => { #21
3354             Name => 'Brightness',
3355             # settings: -1 to +1
3356             ValueConv => '$val - 0x80',
3357             ValueConvInv => '$val + 0x80',
3358             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,undef,"%.2f",4)',
3359             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3360             },
3361             59 => {
3362             Name => 'Saturation',
3363             DelValue => 0xff,
3364             ValueConv => '$val - 0x80',
3365             ValueConvInv => '$val + 0x80',
3366             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3367             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3368             },
3369             61 => {
3370             Name => 'Hue',
3371             DelValue => 0xff,
3372             ValueConv => '$val - 0x80',
3373             ValueConvInv => '$val + 0x80',
3374             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3375             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3376             },
3377             63 => {
3378             Name => 'FilterEffect',
3379             # settings: Off,Yellow,Orange,Red,Green (n/a for color modes)
3380             DelValue => 0xff,
3381             PrintHex => 1,
3382             PrintConv => {
3383             0x80 => 'Off',
3384             0x81 => 'Yellow',
3385             0x82 => 'Orange',
3386             0x83 => 'Red',
3387             0x84 => 'Green',
3388             0xff => 'n/a',
3389             },
3390             },
3391             64 => {
3392             Name => 'ToningEffect',
3393             # settings: B&W,Sepia,Cyanotype,Red,Yellow,Green,Blue-Green,Blue,
3394             # Purple-Blue,Red-Purple (n/a for color modes)
3395             DelValue => 0xff,
3396             PrintHex => 1,
3397             PrintConvColumns => 2,
3398             PrintConv => {
3399             0x80 => 'B&W',
3400             0x81 => 'Sepia',
3401             0x82 => 'Cyanotype',
3402             0x83 => 'Red',
3403             0x84 => 'Yellow',
3404             0x85 => 'Green',
3405             0x86 => 'Blue-green',
3406             0x87 => 'Blue',
3407             0x88 => 'Purple-blue',
3408             0x89 => 'Red-purple',
3409             0xff => 'n/a',
3410             },
3411             },
3412             65 => {
3413             Name => 'ToningSaturation',
3414             DelValue => 0xff,
3415             ValueConv => '$val - 0x80', #$val == 0x7f (n/a) for "B&W"
3416             ValueConvInv => '$val + 0x80',
3417             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3418             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3419              
3420             },
3421             );
3422              
3423             # Picture Control information V3 (ref PH, Z7)
3424             %Image::ExifTool::Nikon::PictureControl3 = (
3425             %binaryDataAttrs,
3426             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3427             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3428             0 => {
3429             Name => 'PictureControlVersion',
3430             Format => 'undef[4]',
3431             Writable => 0,
3432             },
3433             8 => {
3434             Name => 'PictureControlName',
3435             Format => 'string[20]',
3436             # make lower case with a leading capital for each word
3437             PrintConv => \&FormatString,
3438             PrintConvInv => 'uc($val)',
3439             },
3440             # 48 - looks like PictureControl2 byte 45
3441             28 => {
3442             Name => 'PictureControlBase',
3443             Format => 'string[20]',
3444             PrintConv => \&FormatString,
3445             PrintConvInv => 'uc($val)',
3446             },
3447             54 => { # (NC)
3448             Name => 'PictureControlAdjust',
3449             PrintConv => {
3450             0 => 'Default Settings',
3451             1 => 'Quick Adjust',
3452             2 => 'Full Control',
3453             },
3454             },
3455             55 => { # (NC)
3456             Name => 'PictureControlQuickAdjust',
3457             DelValue => 0xff,
3458             ValueConv => '$val - 0x80',
3459             ValueConvInv => '$val + 0x80',
3460             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val)',
3461             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3462             },
3463             57 => {
3464             Name => 'Sharpness',
3465             DelValue => 0xff,
3466             ValueConv => '$val - 0x80',
3467             ValueConvInv => '$val + 0x80',
3468             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3469             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3470             },
3471             59 => {
3472             Name => 'MidRangeSharpness',
3473             DelValue => 0xff,
3474             ValueConv => '$val - 0x80',
3475             ValueConvInv => '$val + 0x80',
3476             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3477             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3478             },
3479             61 => {
3480             Name => 'Clarity',
3481             DelValue => 0xff,
3482             ValueConv => '$val - 0x80',
3483             ValueConvInv => '$val + 0x80',
3484             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3485             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv2($val,4)',
3486             },
3487             63 => {
3488             Name => 'Contrast',
3489             DelValue => 0xff,
3490             ValueConv => '$val - 0x80',
3491             ValueConvInv => '$val + 0x80',
3492             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3493             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3494             },
3495             65 => { #21
3496             Name => 'Brightness',
3497             ValueConv => '$val - 0x80',
3498             ValueConvInv => '$val + 0x80',
3499             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,undef,"%.2f",4)',
3500             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3501             },
3502             67 => {
3503             Name => 'Saturation',
3504             DelValue => 0xff,
3505             ValueConv => '$val - 0x80',
3506             ValueConvInv => '$val + 0x80',
3507             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3508             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3509             },
3510             69 => {
3511             Name => 'Hue',
3512             DelValue => 0xff,
3513             ValueConv => '$val - 0x80',
3514             ValueConvInv => '$val + 0x80',
3515             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3516             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val)',
3517             },
3518             71 => { # (NC)
3519             Name => 'FilterEffect',
3520             DelValue => 0xff,
3521             PrintHex => 1,
3522             PrintConv => {
3523             0x80 => 'Off',
3524             0x81 => 'Yellow',
3525             0x82 => 'Orange',
3526             0x83 => 'Red',
3527             0x84 => 'Green',
3528             0xff => 'n/a',
3529             },
3530             },
3531             72 => { # (NC)
3532             Name => 'ToningEffect',
3533             DelValue => 0xff,
3534             PrintHex => 1,
3535             PrintConvColumns => 2,
3536             PrintConv => {
3537             0x80 => 'B&W',
3538             0x81 => 'Sepia',
3539             0x82 => 'Cyanotype',
3540             0x83 => 'Red',
3541             0x84 => 'Yellow',
3542             0x85 => 'Green',
3543             0x86 => 'Blue-green',
3544             0x87 => 'Blue',
3545             0x88 => 'Purple-blue',
3546             0x89 => 'Red-purple',
3547             0xff => 'n/a',
3548             },
3549             },
3550             73 => { # (NC)
3551             Name => 'ToningSaturation',
3552             DelValue => 0xff,
3553             ValueConv => '$val - 0x80',
3554             ValueConvInv => '$val + 0x80',
3555             PrintConv => 'Image::ExifTool::Nikon::PrintPC($val,"None","%.2f",4)',
3556             PrintConvInv => 'Image::ExifTool::Nikon::PrintPCInv($val,4)',
3557              
3558             },
3559             );
3560              
3561             # Unknown Picture Control information
3562             %Image::ExifTool::Nikon::PictureControlUnknown = (
3563             %binaryDataAttrs,
3564             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3565             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3566             0 => {
3567             Name => 'PictureControlVersion',
3568             Format => 'undef[4]',
3569             Writable => 0,
3570             },
3571             );
3572              
3573             # World Time information - JD (D300)
3574             %Image::ExifTool::Nikon::WorldTime = (
3575             %binaryDataAttrs,
3576             GROUPS => { 0 => 'MakerNotes', 2 => 'Time' },
3577             0 => {
3578             Name => 'TimeZone',
3579             Format => 'int16s',
3580             PrintConv => q{
3581             my $sign = $val < 0 ? '-' : '+';
3582             my $h = int(abs($val) / 60);
3583             sprintf("%s%.2d:%.2d", $sign, $h, abs($val)-60*$h);
3584             },
3585             PrintConvInv => q{
3586             $val =~ /Z$/ and return 0;
3587             $val =~ /([-+])(\d{1,2}):?(\d{2})$/ and return $1 . ($2 * 60 + $3);
3588             $val =~ /^(\d{2})(\d{2})$/ and return $1 * 60 + $2;
3589             return undef;
3590             },
3591             },
3592             2 => {
3593             Name => 'DaylightSavings',
3594             PrintConv => { 0 => 'No', 1 => 'Yes' },
3595             },
3596             3 => {
3597             Name => 'DateDisplayFormat',
3598             PrintConv => {
3599             0 => 'Y/M/D',
3600             1 => 'M/D/Y',
3601             2 => 'D/M/Y',
3602             },
3603             },
3604             );
3605              
3606             # ISO information - PH (D300)
3607             %Image::ExifTool::Nikon::ISOInfo = (
3608             %binaryDataAttrs,
3609             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3610             0 => {
3611             Name => 'ISO',
3612             Notes => 'val = 100 * 2**(raw/12-5)',
3613             Priority => 0, # because people like to see rounded-off values if they exist
3614             ValueConv => '100*exp(($val/12-5)*log(2))',
3615             ValueConvInv => '(log($val/100)/log(2)+5)*12',
3616             PrintConv => 'int($val + 0.5)',
3617             PrintConvInv => '$val',
3618             },
3619             # 1 - 0x01
3620             # 2 - 0x0c (probably the ISO divisor above)
3621             # 3 - 0x00
3622             4 => {
3623             Name => 'ISOExpansion',
3624             Format => 'int16u',
3625             PrintHex => 1,
3626             PrintConvColumns => 2,
3627             PrintConv => {
3628             0x000 => 'Off',
3629             0x101 => 'Hi 0.3',
3630             0x102 => 'Hi 0.5',
3631             0x103 => 'Hi 0.7',
3632             0x104 => 'Hi 1.0',
3633             0x105 => 'Hi 1.3', # (Hi 1.3-1.7 may be possible with future models)
3634             0x106 => 'Hi 1.5',
3635             0x107 => 'Hi 1.7',
3636             0x108 => 'Hi 2.0', #(NC) - D3 should have this mode
3637             0x109 => 'Hi 2.3', #IB
3638             0x10a => 'Hi 2.5', #IB
3639             0x10b => 'Hi 2.7', #IB
3640             0x10c => 'Hi 3.0', #IB
3641             0x10d => 'Hi 3.3', #IB
3642             0x10e => 'Hi 3.5', #IB
3643             0x10f => 'Hi 3.7', #IB
3644             0x110 => 'Hi 4.0', #IB
3645             0x111 => 'Hi 4.3', #IB
3646             0x112 => 'Hi 4.5', #IB
3647             0x113 => 'Hi 4.7', #IB
3648             0x114 => 'Hi 5.0', #IB
3649             0x201 => 'Lo 0.3',
3650             0x202 => 'Lo 0.5',
3651             0x203 => 'Lo 0.7',
3652             0x204 => 'Lo 1.0',
3653             },
3654             },
3655             # bytes 6-11 same as 0-4 in my samples (why is this duplicated?)
3656             6 => {
3657             Name => 'ISO2',
3658             Notes => 'val = 100 * 2**(raw/12-5)',
3659             ValueConv => '100*exp(($val/12-5)*log(2))',
3660             ValueConvInv => '(log($val/100)/log(2)+5)*12',
3661             PrintConv => 'int($val + 0.5)',
3662             PrintConvInv => '$val',
3663             },
3664             # 7 - 0x01
3665             # 8 - 0x0c (probably the ISO divisor above)
3666             # 9 - 0x00
3667             10 => {
3668             Name => 'ISOExpansion2',
3669             Format => 'int16u',
3670             PrintHex => 1,
3671             PrintConvColumns => 2,
3672             PrintConv => {
3673             0x000 => 'Off',
3674             0x101 => 'Hi 0.3',
3675             0x102 => 'Hi 0.5',
3676             0x103 => 'Hi 0.7',
3677             0x104 => 'Hi 1.0',
3678             0x105 => 'Hi 1.3', # (Hi 1.3-1.7 may be possible with future models)
3679             0x106 => 'Hi 1.5',
3680             0x107 => 'Hi 1.7',
3681             0x108 => 'Hi 2.0', #(NC) - D3 should have this mode
3682             0x201 => 'Lo 0.3',
3683             0x202 => 'Lo 0.5',
3684             0x203 => 'Lo 0.7',
3685             0x204 => 'Lo 1.0',
3686             },
3687             },
3688             # bytes 12-13: 00 00
3689             );
3690              
3691             # distortion information - PH (D5000)
3692             %Image::ExifTool::Nikon::DistortInfo = (
3693             %binaryDataAttrs,
3694             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3695             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
3696             0 => {
3697             Name => 'DistortionVersion',
3698             Format => 'undef[4]',
3699             Writable => 0,
3700             Unknown => 1,
3701             },
3702             4 => {
3703             Name => 'AutoDistortionControl',
3704             PrintConv => {
3705             0 => 'Off',
3706             1 => 'On',
3707             2 => 'On (underwater)', # (1AW1)
3708             },
3709             },
3710             );
3711              
3712             # unknown information - PH (D7000)
3713             %Image::ExifTool::Nikon::UnknownInfo = (
3714             %binaryDataAttrs,
3715             FORMAT => 'int32u',
3716             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3717             0 => {
3718             Name => 'UnknownInfoVersion',
3719             Condition => '$$valPt =~ /^\d{4}/',
3720             Format => 'undef[4]',
3721             Writable => 0,
3722             Unknown => 1,
3723             },
3724             # (bytes 6/7 and 8/9 are swapped if CaptureNX changes the byte order)
3725             );
3726              
3727             # more unknown information - PH (D7000)
3728             %Image::ExifTool::Nikon::UnknownInfo2 = (
3729             %binaryDataAttrs,
3730             FORMAT => 'int32u',
3731             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3732             0 => {
3733             Name => 'UnknownInfo2Version',
3734             Condition => '$$valPt =~ /^\d{4}/',
3735             Format => 'undef[4]',
3736             Writable => 0,
3737             Unknown => 1,
3738             },
3739             # (byte 4 may be changed from 1 to 0 when rewritten by CaptureNX)
3740             );
3741              
3742             # Nikon AF information (ref 13)
3743             %Image::ExifTool::Nikon::AFInfo = (
3744             %binaryDataAttrs,
3745             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3746             0 => {
3747             Name => 'AFAreaMode',
3748             PrintConv => {
3749             0 => 'Single Area',
3750             1 => 'Dynamic Area',
3751             2 => 'Dynamic Area (closest subject)',
3752             3 => 'Group Dynamic',
3753             4 => 'Single Area (wide)',
3754             5 => 'Dynamic Area (wide)',
3755             },
3756             },
3757             1 => {
3758             Name => 'AFPoint',
3759             Notes => 'in some focus modes this value is not meaningful',
3760             PrintConvColumns => 2,
3761             PrintConv => {
3762             0 => 'Center',
3763             1 => 'Top',
3764             2 => 'Bottom',
3765             3 => 'Mid-left',
3766             4 => 'Mid-right',
3767             5 => 'Upper-left',
3768             6 => 'Upper-right',
3769             7 => 'Lower-left',
3770             8 => 'Lower-right',
3771             9 => 'Far Left',
3772             10 => 'Far Right',
3773             # (have also seen values of 11 and 12 when AFPointsInFocus is "(none)" - PH S3500)
3774             },
3775             },
3776             2 => {
3777             Name => 'AFPointsInFocus',
3778             Format => 'int16u',
3779             PrintConvColumns => 2,
3780             PrintConv => {
3781             0 => '(none)',
3782             0x7ff => 'All 11 Points',
3783             BITMASK => {
3784             0 => 'Center',
3785             1 => 'Top',
3786             2 => 'Bottom',
3787             3 => 'Mid-left',
3788             4 => 'Mid-right',
3789             5 => 'Upper-left',
3790             6 => 'Upper-right',
3791             7 => 'Lower-left',
3792             8 => 'Lower-right',
3793             9 => 'Far Left',
3794             10 => 'Far Right',
3795             },
3796             },
3797             },
3798             );
3799              
3800             # Nikon AF information for D3 and D300 (ref JD)
3801             %Image::ExifTool::Nikon::AFInfo2 = (
3802             %binaryDataAttrs,
3803             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3804             DATAMEMBER => [ 0, 4, 6 ],
3805             NOTES => "These tags are written by Nikon DSLR's which have the live view feature.",
3806             0 => {
3807             Name => 'AFInfo2Version',
3808             Format => 'undef[4]',
3809             Writable => 0,
3810             RawConv => '$$self{AFInfo2Version} = $val',
3811             },
3812             4 => { #PH
3813             Name => 'ContrastDetectAF',
3814             RawConv => '$$self{ContrastDetectAF} = $val',
3815             PrintConv => {
3816             %offOn,
3817             2 => 'On (2)', #PH (Z7)
3818             },
3819             Notes => 'this is Off for the hybrid AF used in Nikon 1 models',
3820             },
3821             5 => [
3822             {
3823             Name => 'AFAreaMode',
3824             Condition => 'not $$self{ContrastDetectAF}',
3825             Notes => 'ContrastDetectAF Off',
3826             PrintConv => {
3827             0 => 'Single Area', # (called "Single Point" in manual - PH)
3828             1 => 'Dynamic Area', #PH
3829             2 => 'Dynamic Area (closest subject)', #PH
3830             3 => 'Group Dynamic', #PH
3831             4 => 'Dynamic Area (9 points)', #JD/28
3832             5 => 'Dynamic Area (21 points)', #28
3833             6 => 'Dynamic Area (51 points)', #28
3834             7 => 'Dynamic Area (51 points, 3D-tracking)', #PH/28
3835             8 => 'Auto-area',
3836             9 => 'Dynamic Area (3D-tracking)', #PH (D5000 "3D-tracking (11 points)")
3837             10 => 'Single Area (wide)', #PH
3838             11 => 'Dynamic Area (wide)', #PH
3839             12 => 'Dynamic Area (wide, 3D-tracking)', #PH
3840             13 => 'Group Area', #PH
3841             14 => 'Dynamic Area (25 points)', #PH
3842             15 => 'Dynamic Area (72 points)', #PH
3843             16 => 'Group Area (HL)', #28
3844             17 => 'Group Area (VL)', #28
3845             18 => 'Dynamic Area (49 points)', #28
3846             128 => 'Single', #PH (1J1,1J2,1J3,1J4,1S1,1S2,1V2,1V3)
3847             129 => 'Auto (41 points)', #PH (1J1,1J2,1J3,1J4,1S1,1S2,1V1,1V2,1V3,AW1)
3848             130 => 'Subject Tracking (41 points)', #PH (1J1,1J4,1J3)
3849             131 => 'Face Priority (41 points)', #PH (1J1,1J3,1S1,1V2,AW1)
3850             # 134 - seen for 1V1[PhaseDetectAF=0] (PH)
3851             # 135 - seen for 1J2[PhaseDetectAF=4] (PH)
3852             192 => 'Pinpoint', #PH (NC)
3853             193 => 'Single', #PH (NC)
3854             195 => 'Wide (S)', #PH (NC)
3855             196 => 'Wide (L)', #PH (NC)
3856             197 => 'Auto', #PH (NC)
3857             },
3858             },
3859             { #PH (D3/D90/D5000)
3860             Name => 'AFAreaMode',
3861             Notes => 'ContrastDetectAF On',
3862             PrintConv => {
3863             0 => 'Contrast-detect', # (D3)
3864             1 => 'Contrast-detect (normal area)', # (D90/D5000)
3865             # (D90 and D5000 give value of 2 when set to 'Face Priority' and
3866             # 'Subject Tracking', but I didn't have a face to shoot at or a
3867             # moving subject to track so perhaps this value changes dynamically)
3868             2 => 'Contrast-detect (wide area)', # (D90/D5000)
3869             3 => 'Contrast-detect (face priority)', # (ViewNX)
3870             4 => 'Contrast-detect (subject tracking)', # (ViewNX)
3871             128 => 'Single', #PH (1V3)
3872             129 => 'Auto (41 points)', #PH (NC)
3873             130 => 'Subject Tracking (41 points)', #PH (NC)
3874             131 => 'Face Priority (41 points)', #PH (NC)
3875             192 => 'Pinpoint', #PH (Z7)
3876             193 => 'Single', #PH (Z7)
3877             194 => 'Dynamic', #PH (Z7)
3878             195 => 'Wide (S)', #PH (Z7)
3879             196 => 'Wide (L)', #PH (Z7)
3880             197 => 'Auto', #PH (Z7)
3881             198 => 'Auto (People)', #28 (Z7) #if no faces are detected, will record as 'Auto'. Camera setting recorded in AFAreaMode field in the MakerNotes area
3882             199 => 'Auto (Animal)', #28 (Z7) #if no animals are detected, will record as 'Auto'. Camera setting recorded in AFAreaMode field in the MakerNotes area
3883             200 => 'Normal-area AF', #28 (D6)
3884             201 => 'Wide-area AF', #28 (D6)
3885             202 => 'Face-priority AF', #28 (D6)
3886             203 => 'Subject-tracking AF', #28 (D6)
3887             204 => 'Dynamic Area (S)', #28 (Z9)
3888             205 => 'Dynamic Area (M)', #28 (Z9)
3889             206 => 'Dynamic Area (L)', #28 (Z9)
3890             207 => '3D-tracking', #28 (Z9)
3891             },
3892             },
3893             ],
3894             6 => {
3895             Name => 'PhaseDetectAF', #JD(AutoFocus), PH(PhaseDetectAF)
3896             Notes => 'PrimaryAFPoint and AFPointsUsed below are only valid when this is On',
3897             RawConv => '$$self{PhaseDetectAF} = $val',
3898             PrintConv => {
3899             # [observed AFAreaMode values in square brackets for each PhaseDetectAF value]
3900             0 => 'Off',
3901             1 => 'On (51-point)', #PH
3902             2 => 'On (11-point)', #PH
3903             3 => 'On (39-point)', #29 (D7000)
3904             4 => 'On (73-point)', #PH (1J1[128/129],1J2[128/129/135],1J3/1S1/1V2[128/129/131],1V1[129],AW1[129/131])
3905             5 => 'On (5)', #PH (1S2[128/129], 1J4/1V3[129])
3906             6 => 'On (105-point)', #PH (1J4/1V3[128/130])
3907             7 => 'On (153-point)', #PH (D5/D500/D850)
3908             8 => 'On (81-point)', #38
3909             9 => 'On (105-point)', #28 (D6)
3910             },
3911             },
3912             7 => [
3913             { #PH/JD
3914             Name => 'PrimaryAFPoint',
3915             # PrimaryAFPoint may only be valid for PhaseDetect - certainly true on the D6, possibly other bodies? (ref 28)
3916             Condition => '$$self{PhaseDetectAF} < 2 and $$self{AFInfo2Version} !~ /^03/',
3917             Notes => q{
3918             models with 51-point AF -- 5 rows (A-E) and 11 columns (1-11): D3, D3S, D3X,
3919             D4, D4S, D300, D300S, D700, D800, D800e and D810
3920             },
3921             PrintConvColumns => 5,
3922             PrintConv => {
3923             0 => '(none)',
3924             %afPoints51,
3925             1 => 'C6 (Center)', # (add " (Center)" to central point)
3926             },
3927             },
3928             { #10
3929             Name => 'PrimaryAFPoint',
3930             Notes => 'models with 11-point AF: D90, D3000, D3100, D5000 and D5100',
3931             Condition => '$$self{PhaseDetectAF} == 2',
3932             PrintConvColumns => 2,
3933             PrintConv => {
3934             0 => '(none)',
3935             1 => 'Center',
3936             2 => 'Top',
3937             3 => 'Bottom',
3938             4 => 'Mid-left',
3939             5 => 'Upper-left',
3940             6 => 'Lower-left',
3941             7 => 'Far Left',
3942             8 => 'Mid-right',
3943             9 => 'Upper-right',
3944             10 => 'Lower-right',
3945             11 => 'Far Right',
3946             },
3947             },
3948             { #29
3949             Name => 'PrimaryAFPoint',
3950             Condition => '$$self{PhaseDetectAF} == 3',
3951             Notes => 'models with 39-point AF: D600 and D7000',
3952             PrintConvColumns => 5,
3953             PrintConv => {
3954             0 => '(none)',
3955             %afPoints39,
3956             1 => 'C6 (Center)', # (add " (Center)" to central point)
3957             },
3958             },
3959             { #PH
3960             Name => 'PrimaryAFPoint',
3961             Condition => '$$self{PhaseDetectAF} == 4',
3962             Notes => 'Nikon 1 models with older 135-point AF and 73-point phase-detect AF',
3963             PrintConvColumns => 5,
3964             PrintConv => {
3965             0 => '(none)',
3966             %afPoints135,
3967             1 => 'E8 (Center)', # (add " (Center)" to central point)
3968             },
3969             },
3970             { #PH (NC)
3971             Name => 'PrimaryAFPoint',
3972             Condition => '$$self{PhaseDetectAF} == 5',
3973             Notes => q{
3974             Nikon 1 models with newer 135-point AF and 73-point phase-detect AF -- 9
3975             rows (B-J) and 15 columns (1-15), inside a grid of 11 rows by 15 columns.
3976             The points are numbered sequentially, with F8 at the center
3977             },
3978             PrintConv => {
3979             0 => '(none)',
3980             82 => 'F8 (Center)',
3981             OTHER => sub {
3982             my ($val, $inv) = @_;
3983             return GetAFPointGrid($val, 15, $inv);
3984             },
3985             },
3986             },
3987             { #PH
3988             Name => 'PrimaryAFPoint',
3989             Condition => '$$self{PhaseDetectAF} == 6',
3990             Notes => q{
3991             Nikon 1 models with 171-point AF and 105-point phase-detect AF -- 9 rows
3992             (B-J) and 19 columns (2-20), inside a grid of 11 rows by 21 columns. The
3993             points are numbered sequentially, with F11 at the center
3994             },
3995             PrintConv => {
3996             0 => '(none)',
3997             #22 => 'B2 (Top-left)',
3998             #40 => 'B20 (Top-right)',
3999             115 => 'F11 (Center)',
4000             #190 => 'J2 (Bottom-left)',
4001             #208 => 'J20 (Bottom-right)',
4002             OTHER => sub {
4003             my ($val, $inv) = @_;
4004             return GetAFPointGrid($val, 21, $inv);
4005             },
4006             },
4007             },
4008             { #PH
4009             Name => 'PrimaryAFPoint',
4010             Condition => '$$self{PhaseDetectAF} == 7 and $$self{AFInfo2Version} eq "0100"',
4011             Notes => q{
4012             Nikon models with 153-point AF -- 9 rows (A-I) and 17 columns (1-17): D5,
4013             D500 and D850
4014             },
4015             PrintConvColumns => 5,
4016             PrintConv => {
4017             0 => '(none)',
4018             %afPoints153,
4019             1 => 'E9 (Center)',
4020             },
4021             },
4022             {
4023             Name => 'PrimaryAFPoint',
4024             Condition => '$$self{AFInfo2Version} eq "0100"',
4025             Notes => 'future models?...',
4026             PrintConv => {
4027             0 => '(none)',
4028             1 => 'Center',
4029             },
4030             },
4031             ],
4032             8 => [
4033             { #JD/PH
4034             Name => 'AFPointsUsed',
4035             Condition => '$$self{PhaseDetectAF} < 2 and $$self{AFInfo2Version} !~ /^03/',
4036             Notes => q{
4037             models with 51-point AF -- 5 rows: A1-9, B1-11, C1-11, D1-11, E1-9. Center
4038             point is C6
4039             },
4040             Format => 'undef[7]',
4041             ValueConv => 'join(" ", unpack("H2"x7, $val))',
4042             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4043             PrintConv => sub { PrintAFPoints(shift, \%afPoints51); },
4044             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints51); },
4045             },
4046             { #10
4047             Name => 'AFPointsUsed',
4048             Condition => '$$self{PhaseDetectAF} == 2',
4049             Notes => 'models with 11-point AF',
4050             # read as int16u in little-endian byte order
4051             Format => 'undef[2]',
4052             ValueConv => 'unpack("v",$val)',
4053             ValueConvInv => 'pack("v",$val)',
4054             PrintConvColumns => 2,
4055             PrintConv => {
4056             0 => '(none)',
4057             0x7ff => 'All 11 Points',
4058             BITMASK => {
4059             0 => 'Center',
4060             1 => 'Top',
4061             2 => 'Bottom',
4062             3 => 'Mid-left',
4063             4 => 'Upper-left',
4064             5 => 'Lower-left',
4065             6 => 'Far Left',
4066             7 => 'Mid-right',
4067             8 => 'Upper-right',
4068             9 => 'Lower-right',
4069             10 => 'Far Right',
4070             },
4071             },
4072             },
4073             { #29/PH
4074             Name => 'AFPointsUsed',
4075             Condition => '$$self{PhaseDetectAF} == 3',
4076             Notes => q{
4077             models with 39-point AF -- 5 rows: A1-3, B1-11, C1-11, D1-11, E1-3. Center
4078             point is C6
4079             },
4080             Format => 'undef[5]',
4081             ValueConv => 'join(" ", unpack("H2"x5, $val))',
4082             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4083             PrintConv => sub { PrintAFPoints(shift, \%afPoints39); },
4084             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints39); },
4085             },
4086             { #PH (1AW1,1J1,1J2,1J3,1S1,1V1,1V2)
4087             Name => 'AFPointsUsed',
4088             Condition => '$$self{PhaseDetectAF} == 4',
4089             Notes => q{
4090             older models with 135-point AF -- 9 rows (A-I) and 15 columns (1-15).
4091             Center point is E8. The odd-numbered columns, columns 2 and 14, and the
4092             remaining corner points are not used for 41-point AF mode
4093             },
4094             Format => 'undef[17]',
4095             ValueConv => 'join(" ", unpack("H2"x17, $val))',
4096             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4097             PrintConv => sub { PrintAFPoints(shift, \%afPoints135); },
4098             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints135); },
4099             },
4100             { #PH (1S2)
4101             Name => 'AFPointsUsed',
4102             Condition => '$$self{PhaseDetectAF} == 5',
4103             Notes => q{
4104             newer models with 135-point AF -- 9 rows (B-J) and 15 columns (1-15). Center
4105             point is F8
4106             },
4107             Format => 'undef[21]',
4108             ValueConv => 'join(" ", unpack("H2"x21, $val))',
4109             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4110             PrintConv => sub { PrintAFPointsGrid(shift, 15); },
4111             PrintConvInv => sub { PrintAFPointsGridInv(shift, 15, 21); },
4112             },
4113             { #PH (1J4,1V3)
4114             Name => 'AFPointsUsed',
4115             Condition => '$$self{PhaseDetectAF} == 6',
4116             Notes => q{
4117             models with 171-point AF -- 9 rows (B-J) and 19 columns (2-20). Center
4118             point is F10
4119             },
4120             Format => 'undef[29]',
4121             ValueConv => 'join(" ", unpack("H2"x29, $val))',
4122             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4123             PrintConv => sub { PrintAFPointsGrid(shift, 21); },
4124             PrintConvInv => sub { PrintAFPointsGridInv(shift, 21, 29); },
4125             },
4126             { #PH (D5,D500)
4127             Name => 'AFPointsUsed',
4128             Condition => '$$self{PhaseDetectAF} == 7',
4129             Notes => q{
4130             models with 153-point AF -- 9 rows (A-I) and 17 columns (1-17). Center
4131             point is E9
4132             },
4133             Format => 'undef[20]',
4134             ValueConv => 'join(" ", unpack("H2"x20, $val))',
4135             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4136             PrintConv => sub { PrintAFPoints(shift, \%afPoints153); },
4137             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints153); },
4138             },
4139             { #PH
4140             Name => 'AFPointsUsed',
4141             # version 301 uses a separate field at offset 0x0a for this tag (ref 28)
4142             Condition => '$$self{AFInfo2Version} !~ /^03/',
4143             Format => 'undef[7]',
4144             ValueConv => 'join(" ", unpack("H2"x7, $val))',
4145             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4146             PrintConv => '"Unknown ($val)"',
4147             PrintConvInv => '$val=~s/Unknown \\((.*)\\)/$1/; $val',
4148             },
4149             { #PH
4150             Name => 'PrimaryAFPoint',
4151             Condition => '$$self{PhaseDetectAF} == 1 and $$self{AFInfo2Version} =~ /^03/',
4152             Notes => 'newer models with 51-point AF',
4153             PrintConvColumns => 5,
4154             PrintConv => {
4155             0 => '(none)',
4156             %afPoints51,
4157             1 => 'C6 (Center)', # (add " (Center)" to central point)
4158             },
4159             },
4160             { #PH (Z7)
4161             Name => 'PrimaryAFPoint',
4162             Condition => '$$self{PhaseDetectAF} == 8 and $$self{AFInfo2Version} =~ /^03/',
4163             PrintConv => {
4164             0 => '(none)',
4165             %afPoints81,
4166             1 => 'E5 (Center)', # (add " (Center)" to central point)
4167             },
4168             },
4169             # this was wrong, but keep the code as a comment in case it may be useful later
4170             #{ #PH (Z7) (NC)
4171             # Name => 'PrimaryAFPoint',
4172             # Condition => '$$self{PhaseDetectAF} == 8 and $$self{AFInfo2Version} =~ /^03/',
4173             # Notes => q{
4174             # Nikon models with 493-point AF -- 17 rows (A-Q) and 29 columns (1-29), I15
4175             # at the center
4176             # },
4177             # PrintConv => {
4178             # 0 => '(none)',
4179             # 246 => 'I15 (Center)',
4180             # OTHER => sub {
4181             # my ($val, $inv) = @_;
4182             # return GetAFPointGrid($val, 29, $inv);
4183             # },
4184             # },
4185             #},
4186             ],
4187             0x0a => [{ #PH (D780)
4188             Name => 'AFPointsUsed',
4189             Condition => '$$self{PhaseDetectAF} == 1 and $$self{AFInfo2Version} =~ /^03/',
4190             Notes => 'newer models with 51-point AF',
4191             Format => 'undef[7]',
4192             ValueConv => 'join(" ", unpack("H2"x7, $val))',
4193             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4194             PrintConv => sub { PrintAFPoints(shift, \%afPoints51); },
4195             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints51); },
4196             },{ #38 (Z6/Z7/Z50)
4197             Name => 'AFPointsUsed',
4198             Condition => '$$self{PhaseDetectAF} == 8 and $$self{AFInfo2Version} =~ /^03/',
4199             Notes => q{
4200             models with 81-selectable point AF -- 9 rows (A-I) and 9 columns (1-9) for
4201             phase detect AF points. Center point is E5
4202             },
4203             Format => 'undef[11]',
4204             ValueConv => 'join(" ", unpack("H2"x11, $val))',
4205             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4206             PrintConv => sub { PrintAFPoints(shift, \%afPoints81); },
4207             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints81); },
4208             },{ #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
4209             Name => 'AFPointsUsed',
4210             Condition => '$$self{PhaseDetectAF} == 9 and $$self{AFInfo2Version} =~ /^03/',
4211             Notes => q{
4212             models with 105-point AF -- 7 rows (A-G) and 15 columns (1-15). Center
4213             point is D8
4214             },
4215             Format => 'undef[14]',
4216             ValueConv => 'join(" ", unpack("H2"x14, $val))',
4217             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4218             PrintConv => sub { PrintAFPoints(shift, \%afPoints105); },
4219             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints105); },
4220             }],
4221             0x10 => { #PH (D90 and D5000)
4222             Name => 'AFImageWidth',
4223             Condition => '$$self{AFInfo2Version} eq "0100"',
4224             Format => 'int16u',
4225             RawConv => '$val ? $val : undef',
4226             Notes => 'this and the following tags are valid only for contrast-detect AF',
4227             },
4228             0x12 => { #PH
4229             Name => 'AFImageHeight',
4230             Condition => '$$self{AFInfo2Version} eq "0100"',
4231             Format => 'int16u',
4232             RawConv => '$val ? $val : undef',
4233             },
4234             0x14 => { #PH
4235             Name => 'AFAreaXPosition',
4236             Condition => '$$self{AFInfo2Version} eq "0100"',
4237             Notes => 'center of AF area in AFImage coordinates',
4238             Format => 'int16u',
4239             RawConv => '$val ? $val : undef',
4240             },
4241             0x16 => { #PH
4242             Name => 'AFAreaYPosition',
4243             Condition => '$$self{AFInfo2Version} eq "0100"',
4244             Format => 'int16u',
4245             RawConv => '$val ? $val : undef',
4246             },
4247             # AFAreaWidth/Height for the D90 and D5000:
4248             # 352x288 (AF normal area),
4249             # 704x576 (AF face priority, wide area, subject tracking)
4250             0x18 => { #PH
4251             Name => 'AFAreaWidth',
4252             Condition => '$$self{AFInfo2Version} eq "0100"',
4253             Format => 'int16u',
4254             Notes => 'size of AF area in AFImage coordinates',
4255             RawConv => '$val ? $val : undef',
4256             },
4257             0x1a => { #PH
4258             Name => 'AFAreaHeight',
4259             Condition => '$$self{AFInfo2Version} eq "0100"',
4260             Format => 'int16u',
4261             RawConv => '$val ? $val : undef',
4262             },
4263             0x1c => [
4264             { #PH
4265             Name => 'ContrastDetectAFInFocus',
4266             Condition => '$$self{AFInfo2Version} eq "0100"',
4267             PrintConv => { 0 => 'No', 1 => 'Yes' },
4268             },{ #PH (D500, see forum11190)
4269             Name => 'AFPointsSelected',
4270             Condition => '$$self{AFInfo2Version} eq "0101" and $$self{PhaseDetectAF} == 7',
4271             Format => 'undef[20]',
4272             ValueConv => 'join(" ", unpack("H2"x20, $val))',
4273             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4274             PrintConv => sub { PrintAFPoints(shift, \%afPoints153); },
4275             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints153); },
4276             },
4277             ],
4278             # 0x1d - always zero (with or without live view)
4279             0x2a => { #PH (Z7)
4280             Name => 'AFImageWidth',
4281             Condition => '$$self{AFInfo2Version} =~ /^03/',
4282             Format => 'int16u',
4283             RawConv => '$val ? $val : undef',
4284             },
4285             0x2c => { #PH (Z7)
4286             Name => 'AFImageHeight',
4287             Condition => '$$self{AFInfo2Version} =~ /^03/',
4288             Format => 'int16u',
4289             RawConv => '$val ? $val : undef',
4290             },
4291             0x2e => { #PH (Z7)
4292             Name => 'AFAreaXPosition',
4293             Condition => q{
4294             $$self{ContrastDetectAF} == 2 and $$self{AFInfo2Version} =~ /^03/ or
4295             $$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} =~ /^0301/
4296             },
4297             Format => 'int16u', # (decodes same byte as 0x2f)
4298             },
4299             0x2f => { #28 (Z7) Still photography range 1-17 for the 493 point Z7 (arranged in a 29x17 grid. Center at x=16, y=10).
4300             Name => 'FocusPositionHorizontal',
4301             Condition => q{
4302             $$self{ContrastDetectAF} == 2 and $$self{AFInfo2Version} =~ /^03/ or
4303             $$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} =~ /^0301/
4304             },
4305             PrintConv => sub { my ($val) = @_; PrintAFPointsLeftRight($val, 29 ); },
4306             },
4307             0x30 => [
4308             { #PH (Z7)
4309             Name => 'AFAreaYPosition',
4310             Condition => q{
4311             $$self{ContrastDetectAF} == 2 and $$self{AFInfo2Version} =~ /^03/ or
4312             $$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} =~ /^0301/
4313             },
4314             Format => 'int16u', # (decodes same byte as 0x31)
4315             },{ #PH (D500, see forum11190)
4316             Name => 'AFPointsInFocus',
4317             Condition => '$$self{AFInfo2Version} eq "0101" and $$self{PhaseDetectAF} == 7',
4318             Notes => 'AF points in focus at the time time image was captured',
4319             Format => 'undef[20]',
4320             ValueConv => 'join(" ", unpack("H2"x20, $val))',
4321             ValueConvInv => '$val=~tr/ //d; pack("H*",$val)',
4322             PrintConv => sub { PrintAFPoints(shift, \%afPoints153); },
4323             PrintConvInv => sub { PrintAFPointsInv(shift, \%afPoints153); },
4324             },
4325             ],
4326             0x31 => { #28 (Z7)
4327             Name => 'FocusPositionVertical',
4328             Condition => q{
4329             $$self{ContrastDetectAF} == 2 and $$self{AFInfo2Version} =~ /^03/ or
4330             $$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} =~ /^0301/
4331             },
4332             PrintConv => sub { my ($val) = @_; PrintAFPointsUpDown($val, 17 ); },
4333             },
4334             0x32 => { #PH (Z7)
4335             Name => 'AFAreaWidth',
4336             Condition => '$$self{AFInfo2Version} =~ /^03/',
4337             Format => 'int16u',
4338             RawConv => '$val ? $val : undef',
4339             },
4340             0x34 => { #PH (Z7)
4341             Name => 'AFAreaHeight',
4342             Condition => '$$self{AFInfo2Version} =~ /^03/',
4343             Format => 'int16u',
4344             RawConv => '$val ? $val : undef',
4345             },
4346             0x38 => { #28
4347             Name => 'PrimaryAFPoint',
4348             Condition => '$$self{PhaseDetectAF} == 9 and $$self{AFInfo2Version} =~ /^03/',
4349             Notes => q{
4350             Nikon models with 105-point AF -- 7 rows (A-G) and 15 columns (1-15): D6
4351             },
4352             PrintConvColumns => 5,
4353             PrintConv => {
4354             0 => '(none)',
4355             %afPoints105,
4356             1 => 'D8 (Center)',
4357             },
4358             },
4359             0x44 => [
4360             {
4361             Name => 'PrimaryAFPoint',
4362             Condition => '$$self{PhaseDetectAF} == 7 and $$self{AFInfo2Version} eq "0101"',
4363             PrintConvColumns => 5,
4364             PrintConv => {
4365             0 => '(none)',
4366             %afPoints153,
4367             1 => 'E9 (Center)',
4368             },
4369             },
4370             { #PH
4371             Name => 'PrimaryAFPoint',
4372             Notes => 'D3500',
4373             Condition => '$$self{PhaseDetectAF} == 2 and $$self{AFInfo2Version} eq "0101"',
4374             PrintConvColumns => 2,
4375             PrintConv => {
4376             0 => '(none)',
4377             1 => 'Center',
4378             2 => 'Top',
4379             3 => 'Bottom',
4380             4 => 'Mid-left',
4381             5 => 'Upper-left',
4382             6 => 'Lower-left',
4383             7 => 'Far Left',
4384             8 => 'Mid-right',
4385             9 => 'Upper-right',
4386             10 => 'Lower-right',
4387             11 => 'Far Right',
4388             },
4389             },
4390             {
4391             Name => 'PrimaryAFPoint',
4392             Condition => '$$self{AFInfo2Version} eq "0101"',
4393             Notes => 'future models?...',
4394             Priority => 0,
4395             PrintConv => {
4396             0 => '(none)',
4397             1 => 'Center',
4398             },
4399             },
4400             ],
4401             0x46 => {
4402             Name => 'AFImageWidth',
4403             Condition => '$$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} eq "0101"',
4404             Format => 'int16u',
4405             RawConv => '$val ? $val : undef',
4406             Notes => 'this and the following tags are valid only for contrast-detect AF',
4407             },
4408             0x48 => {
4409             Name => 'AFImageHeight',
4410             Condition => '$$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} eq "0101"',
4411             Format => 'int16u',
4412             RawConv => '$val ? $val : undef',
4413             },
4414             0x4a => {
4415             Name => 'AFAreaXPosition',
4416             Condition => '$$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} eq "0101"',
4417             Notes => 'center of AF area in AFImage coordinates',
4418             Format => 'int16u',
4419             RawConv => '$val ? $val : undef',
4420             },
4421             0x4c => {
4422             Name => 'AFAreaYPosition',
4423             Condition => '$$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} eq "0101"',
4424             Format => 'int16u',
4425             RawConv => '$val ? $val : undef',
4426             },
4427             0x4e => {
4428             Name => 'AFAreaWidth',
4429             Condition => '$$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} eq "0101"',
4430             Format => 'int16u',
4431             Notes => 'size of AF area in AFImage coordinates',
4432             RawConv => '$val ? $val : undef',
4433             },
4434             0x50 => {
4435             Name => 'AFAreaHeight',
4436             Condition => '$$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} eq "0101"',
4437             Format => 'int16u',
4438             RawConv => '$val ? $val : undef',
4439             },
4440             0x52 => {
4441             Name => 'ContrastDetectAFInFocus',
4442             Condition => '$$self{ContrastDetectAF} == 1 and $$self{AFInfo2Version} eq "0101"',
4443             PrintConv => { 0 => 'No', 1 => 'Yes' },
4444             },
4445             );
4446              
4447             %Image::ExifTool::Nikon::AFInfo2V0400 = ( #V0400 related fields begin at x'3c' (Z9)
4448             %binaryDataAttrs,
4449             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4450             DATAMEMBER => [ 0 ],
4451             0 => {
4452             Name => 'AFInfo2Version',
4453             Format => 'undef[4]',
4454             Writable => 0,
4455             RawConv => '$$self{AFInfo2Version} = $val',
4456             },
4457             5 => { #28
4458             Name => 'AFAreaMode', #reflects the mode active when the shutter is tripped, not the position of the Focus Mode button (which is recorded in MenuSettingsZ9 tag also named AfAreaMode)
4459             PrintConv => {
4460             192 => 'Pinpoint',
4461             193 => 'Single',
4462             195 => 'Wide (S)',
4463             196 => 'Wide (L)',
4464             197 => 'Auto',
4465             204 => 'Dynamic Area (S)',
4466             205 => 'Dynamic Area (M)',
4467             206 => 'Dynamic Area (L)',
4468             207 => '3D-tracking',
4469             208 => 'Wide (C1/C2)',
4470             },
4471             },
4472             0x3e => {
4473             Name => 'AFImageWidth',
4474             Format => 'int16u',
4475             },
4476             0x40 => {
4477             Name => 'AFImageHeight',
4478             Format => 'int16u',
4479             },
4480             0x42 => { #28
4481             Name => 'AFAreaXPosition', #top left image corner is the origin
4482             Format => 'int16u', # (decodes same byte as 0x43)
4483             RawConv => '$val ? $val : undef',
4484             },
4485             0x43 => {
4486             Name => 'FocusPositionHorizontal',
4487             Notes => q{
4488             the focus points form a 29x17 grid, but the X,Y coordinate values run from 1,1
4489             to 30,19. The horizontal coordinate 11R (5) and the vertical coordinates 6U
4490             (4) and 2D (12) are not used for some reason
4491             },
4492             # 493 focus points for Z9 fall in a 30x19 grid
4493             # (the 11R (5) position is not used, for a total of 29 columns, ref AlbertShan email)
4494             PrintConv => sub { my ($val) = @_; PrintAFPointsLeftRight($val, 29); },
4495             },
4496             0x44 => { #28
4497             Name => 'AFAreaYPosition',
4498             Format => 'int16u', # (decodes same byte as 0x45)
4499             RawConv => '$val ? $val : undef',
4500             },
4501             0x45 => {
4502             Name => 'FocusPositionVertical',
4503             # (the 6U (4) and 2D (12) are not used, for a total of 17 rows, ref AlbertShan email)
4504             PrintConv => sub { my ($val) = @_; PrintAFPointsUpDown($val, 17); },
4505             },
4506             0x46 => {
4507             Name => 'AFAreaWidth',
4508             Format => 'int16u',
4509             Notes => 'size of AF area in AFImage pixels',
4510             RawConv => '$val ? $val : undef',
4511             },
4512             0x48 => {
4513             Name => 'AFAreaHeight',
4514             Format => 'int16u',
4515             RawConv => '$val ? $val : undef',
4516             },
4517             0x4a => {
4518             Name => 'FocusResult',
4519             # in Manual Foucs mode, reflects the state of viewfinder focus indicator.
4520             # In AF-C or AF-S, reflects the result of the last AF operation.
4521             PrintConv => { 0=> "Out of Focus", 1=>"Focus"},
4522             },
4523             );
4524              
4525             # Nikon AF fine-tune information (ref 28)
4526             %Image::ExifTool::Nikon::AFTune = (
4527             %binaryDataAttrs,
4528             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4529             0 => {
4530             Name => 'AFFineTune',
4531             PrintConv => {
4532             0 => 'Off',
4533             # (don't know what the difference between 1 and 2 is)
4534             1 => 'On (1)',
4535             2 => 'On (2)',
4536             3 => 'On (Zoom)', #28
4537             },
4538             },
4539             1 => {
4540             Name => 'AFFineTuneIndex',
4541             Notes => 'index of saved lens',
4542             PrintConv => '$val == 255 ? "n/a" : $val',
4543             PrintConvInv => '$val eq "n/a" ? 255 : $val',
4544             },
4545             2 => {
4546             # when AFFineTune = 3 (indicating a zoom lens), this Tag stores the tuning adjustment for the wide end of the zoom range (ref 28)
4547             Name => 'AFFineTuneAdj',
4548             Priority => 0, # so other value takes priority if it exists
4549             Notes => 'may only be valid for saved lenses',
4550             Format => 'int8s',
4551             PrintConv => '$val > 0 ? "+$val" : $val',
4552             PrintConvInv => '$val',
4553             },
4554             3 => {
4555             Name => 'AFFineTuneAdjTele',
4556             # should probably insert a Condition that restricts this to AFFineTune = 3 (ref 28)
4557             Notes => 'only valid for zoom lenses (ie, AFTune=3)',
4558             Format => 'int8s',
4559             PrintConv => '$val > 0 ? "+$val" : $val',
4560             PrintConvInv => '$val',
4561             },
4562             );
4563              
4564             # Nikon NEF processing information (ref forum6281)
4565             %Image::ExifTool::Nikon::RetouchInfo = (
4566             %binaryDataAttrs,
4567             FORMAT => 'int8s',
4568             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4569             DATAMEMBER => [ 0 ],
4570             0 => {
4571             Name => 'RetouchInfoVersion',
4572             Format => 'undef[4]',
4573             Writable => 0,
4574             RawConv => '$$self{RetouchInfoVersion} = $val',
4575             },
4576             # 4 - RetouchExposureComp (+$val/6 or -$val/6?)
4577             5 => {
4578             Name => 'RetouchNEFProcessing',
4579             Condition => '$$self{RetouchInfoVersion} ge "0200"',
4580             PrintConv => {
4581             -1 => 'Off',
4582             1 => 'On',
4583             },
4584             },
4585             );
4586              
4587             # Nikon File information - D60, D3 and D300 (ref PH)
4588             %Image::ExifTool::Nikon::FileInfo = (
4589             %binaryDataAttrs,
4590             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
4591             FORMAT => 'int16u',
4592             0 => {
4593             Name => 'FileInfoVersion',
4594             Format => 'undef[4]',
4595             Writable => 0,
4596             },
4597             2 => 'MemoryCardNumber',
4598             3 => {
4599             Name => 'DirectoryNumber',
4600             PrintConv => 'sprintf("%.3d", $val)',
4601             PrintConvInv => '$val',
4602             },
4603             4 => {
4604             Name => 'FileNumber',
4605             PrintConv => 'sprintf("%.4d", $val)',
4606             PrintConvInv => '$val',
4607             },
4608             );
4609              
4610             # ref PH
4611             %Image::ExifTool::Nikon::BarometerInfo = (
4612             %binaryDataAttrs,
4613             GROUPS => { 0 => 'MakerNotes', 2 => 'Location' },
4614             0 => {
4615             Name => 'BarometerInfoVersion',
4616             Format => 'undef[4]',
4617             Writable => 0,
4618             },
4619             6 => {
4620             Name => 'Altitude',
4621             Format => 'int32s',
4622             PrintConv => '"$val m"', # (always stored as metres)
4623             PrintConvInv => '$val=~s/\s*m$//; $val',
4624             },
4625             # 10: int16u - values: 0 (display in metres?), 18 (display in feet?)
4626             );
4627              
4628             # ref PH
4629             %Image::ExifTool::Nikon::CaptureOffsets = (
4630             PROCESS_PROC => \&ProcessNikonCaptureOffsets,
4631             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4632             # (note that these are duplicates of offsets in the normal TIFF structure,
4633             # and that these offsets are not updated when ExifTool rewrites the file)
4634             1 => 'IFD0_Offset',
4635             2 => 'PreviewIFD_Offset',
4636             3 => 'SubIFD_Offset',
4637             );
4638              
4639             # ref PH (Written by capture NX)
4640             %Image::ExifTool::Nikon::CaptureOutput = (
4641             %binaryDataAttrs,
4642             FORMAT => 'int32u',
4643             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
4644             # 1 = 1
4645             2 => 'OutputImageWidth',
4646             3 => 'OutputImageHeight',
4647             4 => 'OutputResolution',
4648             # 5 = 1
4649             );
4650              
4651             # ref IB
4652             %Image::ExifTool::Nikon::ColorBalanceA = (
4653             %binaryDataAttrs,
4654             FORMAT => 'int16u',
4655             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4656             624 => { #4
4657             Name => 'WB_RBLevels',
4658             Notes => 'as shot', #IB
4659             Format => 'int16u[2]',
4660             Protected => 1,
4661             },
4662             626 => {
4663             Name => 'WB_RBLevelsAuto',
4664             Format => 'int16u[2]',
4665             Protected => 1,
4666             },
4667             628 => {
4668             Name => 'WB_RBLevelsDaylight',
4669             Notes => 'red/blue levels for 0,+3,+2,+1,-1,-2,-3',
4670             Format => 'int16u[14]',
4671             Protected => 1,
4672             },
4673             642 => {
4674             Name => 'WB_RBLevelsIncandescent',
4675             Format => 'int16u[14]',
4676             Protected => 1,
4677             },
4678             656 => {
4679             Name => 'WB_RBLevelsFluorescent',
4680             Format => 'int16u[6]',
4681             Notes => 'red/blue levels for fluorescent W,N,D',
4682             Protected => 1,
4683             },
4684             662 => {
4685             Name => 'WB_RBLevelsCloudy',
4686             Format => 'int16u[14]',
4687             Protected => 1,
4688             },
4689             676 => {
4690             Name => 'WB_RBLevelsFlash',
4691             Format => 'int16u[14]',
4692             Protected => 1,
4693             },
4694             690 => {
4695             Name => 'WB_RBLevelsShade',
4696             Condition => '$$self{Model} ne "E8700"',
4697             Notes => 'not valid for E8700',
4698             Format => 'int16u[14]',
4699             Protected => 1,
4700             },
4701             );
4702              
4703             my %nrwLevels = (
4704             Format => 'int32u[4]',
4705             Protected => 1,
4706             ValueConv => 'my @a=split " ",$val;$a[0]*=2;$a[3]*=2;"@a"',
4707             ValueConvInv => 'my @a=split " ",$val;$a[0]/=2;$a[3]/=2;"@a"',
4708             );
4709              
4710             # (ref IB)
4711             %Image::ExifTool::Nikon::ColorBalanceB = (
4712             %binaryDataAttrs,
4713             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4714             NOTES => 'Color balance tags used by the P6000.',
4715             0x0004 => {
4716             Name => 'ColorBalanceVersion',
4717             Format => 'undef[4]',
4718             },
4719             0x13e8 => { Name => 'WB_RGGBLevels', %nrwLevels },
4720             0x13f8 => { Name => 'WB_RGGBLevelsDaylight', %nrwLevels },
4721             0x1408 => { Name => 'WB_RGGBLevelsCloudy', %nrwLevels },
4722             0x1428 => { Name => 'WB_RGGBLevelsTungsten', %nrwLevels },
4723             0x1438 => { Name => 'WB_RGGBLevelsFluorescentW',%nrwLevels },
4724             0x1448 => { Name => 'WB_RGGBLevelsFlash', %nrwLevels },
4725             0x1468 => { Name => 'WB_RGGBLevelsCustom', %nrwLevels, Notes => 'all zero if preset WB not used' },
4726             0x1478 => { Name => 'WB_RGGBLevelsAuto', %nrwLevels },
4727             );
4728              
4729             # (ref IB)
4730             %Image::ExifTool::Nikon::ColorBalanceC = (
4731             %binaryDataAttrs,
4732             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4733             DATAMEMBER => [ 4 ],
4734             NOTES => 'Color balance tags used by the P1000, P7000, P7100 and B700.',
4735             0x0004 => {
4736             Name => 'ColorBalanceVersion',
4737             Format => 'undef[4]',
4738             RawConv => '$$self{ColorBalanceVersion} = $val',
4739             },
4740             0x0020 => { Name => 'BlackLevel', Format => 'int16u' },
4741             0x0038 => { Name => 'WB_RGGBLevels', %nrwLevels },
4742             0x004c => { Name => 'WB_RGGBLevelsDaylight', %nrwLevels },
4743             0x0060 => { Name => 'WB_RGGBLevelsCloudy', %nrwLevels },
4744             0x0074 => {
4745             Name => 'WB_RGGBLevelsShade',
4746             Condition => '$$self{ColorBalanceVersion} ge "0104"',
4747             Notes => 'valid only for some models',
4748             %nrwLevels,
4749             },
4750             0x0088 => { Name => 'WB_RGGBLevelsTungsten', %nrwLevels },
4751             0x009c => { Name => 'WB_RGGBLevelsFluorescentW',%nrwLevels },
4752             0x00b0 => { Name => 'WB_RGGBLevelsFluorescentN',%nrwLevels },
4753             0x00c4 => { Name => 'WB_RGGBLevelsFluorescentD',%nrwLevels },
4754             0x00d8 => { Name => 'WB_RGGBLevelsHTMercury', %nrwLevels },
4755             0x0100 => { Name => 'WB_RGGBLevelsCustom', %nrwLevels, Notes => 'all zero if preset WB not used' },
4756             0x0114 => { Name => 'WB_RGGBLevelsAuto', %nrwLevels },
4757             );
4758              
4759             # ref 4
4760             %Image::ExifTool::Nikon::ColorBalance1 = (
4761             %binaryDataAttrs,
4762             FORMAT => 'int16u',
4763             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4764             0 => {
4765             Name => 'WB_RBGGLevels',
4766             Format => 'int16u[4]',
4767             Protected => 1,
4768             },
4769             );
4770              
4771             # ref 4
4772             %Image::ExifTool::Nikon::ColorBalance2 = (
4773             %binaryDataAttrs,
4774             FORMAT => 'int16u',
4775             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4776             NOTES => 'This information is encrypted for most camera models.',
4777             0 => {
4778             Name => 'WB_RGGBLevels',
4779             Format => 'int16u[4]',
4780             Protected => 1,
4781             },
4782             );
4783              
4784             # ref 4
4785             %Image::ExifTool::Nikon::ColorBalance3 = (
4786             %binaryDataAttrs,
4787             FORMAT => 'int16u',
4788             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4789             0 => {
4790             Name => 'WB_RGBGLevels',
4791             Format => 'int16u[4]',
4792             Protected => 1,
4793             },
4794             );
4795              
4796             # ref 4
4797             %Image::ExifTool::Nikon::ColorBalance4 = (
4798             %binaryDataAttrs,
4799             FORMAT => 'int16u',
4800             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4801             0 => {
4802             Name => 'WB_GRBGLevels',
4803             Format => 'int16u[4]',
4804             Protected => 1,
4805             },
4806             );
4807              
4808             %Image::ExifTool::Nikon::ColorBalanceUnknown = (
4809             %binaryDataAttrs,
4810             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4811             0 => {
4812             Name => 'ColorBalanceVersion',
4813             Format => 'undef[4]',
4814             },
4815             );
4816              
4817             %Image::ExifTool::Nikon::Type2 = (
4818             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
4819             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
4820             WRITABLE => 1,
4821             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4822             0x0003 => 'Quality',
4823             0x0004 => 'ColorMode',
4824             0x0005 => 'ImageAdjustment',
4825             0x0006 => 'CCDSensitivity',
4826             0x0007 => 'WhiteBalance',
4827             0x0008 => 'Focus',
4828             0x000A => 'DigitalZoom',
4829             0x000B => 'Converter',
4830             );
4831              
4832             # these are standard EXIF tags, but they are duplicated here so we can
4833             # set the family 0 group to 'MakerNotes' and set the MINOR_ERRORS flag
4834             %Image::ExifTool::Nikon::PreviewIFD = (
4835             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
4836             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
4837             GROUPS => { 0 => 'MakerNotes', 1 => 'PreviewIFD', 2 => 'Image'},
4838             VARS => { MINOR_ERRORS => 1 }, # this IFD is non-essential and often corrupted
4839             # (these tags are priority 0 by default because PreviewIFD is flagged in LOW_PRIORITY_DIR)
4840             0xfe => { # (not used by Nikon, but SRW images also use this table)
4841             Name => 'SubfileType',
4842             DataMember => 'SubfileType',
4843             RawConv => '$$self{SubfileType} = $val',
4844             PrintConv => \%Image::ExifTool::Exif::subfileType,
4845             },
4846             0x103 => {
4847             Name => 'Compression',
4848             SeparateTable => 'EXIF Compression',
4849             PrintConv => \%Image::ExifTool::Exif::compression,
4850             },
4851             0x11a => 'XResolution',
4852             0x11b => 'YResolution',
4853             0x128 => {
4854             Name => 'ResolutionUnit',
4855             PrintConv => {
4856             1 => 'None',
4857             2 => 'inches',
4858             3 => 'cm',
4859             },
4860             },
4861             0x201 => {
4862             Name => 'PreviewImageStart',
4863             Flags => [ 'IsOffset', 'Permanent' ],
4864             OffsetPair => 0x202,
4865             DataTag => 'PreviewImage',
4866             Writable => 'int32u',
4867             WriteGroup => 'MakerNotes',
4868             Protected => 2,
4869             },
4870             0x202 => {
4871             Name => 'PreviewImageLength',
4872             Flags => 'Permanent' ,
4873             OffsetPair => 0x201,
4874             DataTag => 'PreviewImage',
4875             Writable => 'int32u',
4876             WriteGroup => 'MakerNotes',
4877             Protected => 2,
4878             },
4879             0x213 => {
4880             Name => 'YCbCrPositioning',
4881             PrintConv => {
4882             1 => 'Centered',
4883             2 => 'Co-sited',
4884             },
4885             },
4886             );
4887              
4888             # these are duplicated enough times to make it worthwhile to define them centrally
4889             my %nikonApertureConversions = (
4890             ValueConv => '2**($val/24)',
4891             ValueConvInv => '$val>0 ? 24*log($val)/log(2) : 0',
4892             PrintConv => 'sprintf("%.1f",$val)',
4893             PrintConvInv => '$val',
4894             );
4895              
4896             my %nikonFocalConversions = (
4897             ValueConv => '5 * 2**($val/24)',
4898             ValueConvInv => '$val>0 ? 24*log($val/5)/log(2) : 0',
4899             PrintConv => 'sprintf("%.1f mm",$val)',
4900             PrintConvInv => '$val=~s/\s*mm$//;$val',
4901             );
4902              
4903             # Version 100 Nikon lens data
4904             %Image::ExifTool::Nikon::LensData00 = (
4905             %binaryDataAttrs,
4906             NOTES => 'This structure is used by the D100, and D1X with firmware version 1.1.',
4907             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4908             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
4909             0x00 => {
4910             Name => 'LensDataVersion',
4911             Format => 'undef[4]',
4912             Writable => 0,
4913             },
4914             0x06 => { #8
4915             Name => 'LensIDNumber',
4916             Notes => 'see LensID values below',
4917             },
4918             0x07 => { #8
4919             Name => 'LensFStops',
4920             ValueConv => '$val / 12',
4921             ValueConvInv => '$val * 12',
4922             PrintConv => 'sprintf("%.2f", $val)',
4923             PrintConvInv => '$val',
4924             },
4925             0x08 => { #8/9
4926             Name => 'MinFocalLength',
4927             %nikonFocalConversions,
4928             },
4929             0x09 => { #8/9
4930             Name => 'MaxFocalLength',
4931             %nikonFocalConversions,
4932             },
4933             0x0a => { #8
4934             Name => 'MaxApertureAtMinFocal',
4935             %nikonApertureConversions,
4936             },
4937             0x0b => { #8
4938             Name => 'MaxApertureAtMaxFocal',
4939             %nikonApertureConversions,
4940             },
4941             0x0c => 'MCUVersion', #8 (MCU = Micro Controller Unit)
4942             );
4943              
4944             # Nikon lens data (note: needs decrypting if LensDataVersion is 020x)
4945             %Image::ExifTool::Nikon::LensData01 = (
4946             %binaryDataAttrs,
4947             NOTES => q{
4948             Nikon encrypts the LensData information below if LensDataVersion is 0201 or
4949             higher, but the decryption algorithm is known so the information can be
4950             extracted.
4951             },
4952             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4953             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
4954             0x00 => {
4955             Name => 'LensDataVersion',
4956             Format => 'string[4]',
4957             Writable => 0,
4958             },
4959             0x04 => { #8
4960             Name => 'ExitPupilPosition',
4961             ValueConv => '$val ? 2048 / $val : $val',
4962             ValueConvInv => '$val ? 2048 / $val : $val',
4963             PrintConv => 'sprintf("%.1f mm",$val)',
4964             PrintConvInv => '$val=~s/\s*mm$//; $val',
4965             },
4966             0x05 => { #8
4967             Name => 'AFAperture',
4968             %nikonApertureConversions,
4969             },
4970             0x08 => { #8
4971             # this seems to be 2 values: the upper nibble gives the far focus
4972             # range and the lower nibble gives the near focus range. The values
4973             # are in the range 1-N, where N is lens-dependent. A value of 0 for
4974             # the far focus range indicates infinity. (ref JD)
4975             Name => 'FocusPosition',
4976             PrintConv => 'sprintf("0x%02x", $val)',
4977             PrintConvInv => '$val',
4978             },
4979             0x09 => { #8/9
4980             # With older AF lenses this does not work... (ref 13)
4981             # eg) AF Nikkor 50mm f/1.4 => 48 (0x30)
4982             # AF Zoom-Nikkor 35-105mm f/3.5-4.5 => @35mm => 15 (0x0f), @105mm => 141 (0x8d)
4983             Notes => 'this focus distance is approximate, and not very accurate for some lenses',
4984             Name => 'FocusDistance',
4985             ValueConv => '0.01 * 10**($val/40)', # in m
4986             ValueConvInv => '$val>0 ? 40*log($val*100)/log(10) : 0',
4987             PrintConv => '$val ? sprintf("%.2f m",$val) : "inf"',
4988             PrintConvInv => '$val eq "inf" ? 0 : $val =~ s/\s*m$//, $val',
4989             },
4990             0x0a => { #8/9
4991             Name => 'FocalLength',
4992             Priority => 0,
4993             %nikonFocalConversions,
4994             },
4995             0x0b => { #8
4996             Name => 'LensIDNumber',
4997             Notes => 'see LensID values below',
4998             },
4999             0x0c => { #8
5000             Name => 'LensFStops',
5001             ValueConv => '$val / 12',
5002             ValueConvInv => '$val * 12',
5003             PrintConv => 'sprintf("%.2f", $val)',
5004             PrintConvInv => '$val',
5005             },
5006             0x0d => { #8/9
5007             Name => 'MinFocalLength',
5008             %nikonFocalConversions,
5009             },
5010             0x0e => { #8/9
5011             Name => 'MaxFocalLength',
5012             %nikonFocalConversions,
5013             },
5014             0x0f => { #8
5015             Name => 'MaxApertureAtMinFocal',
5016             %nikonApertureConversions,
5017             },
5018             0x10 => { #8
5019             Name => 'MaxApertureAtMaxFocal',
5020             %nikonApertureConversions,
5021             },
5022             0x11 => 'MCUVersion', #8 (MCU = Micro Controller Unit)
5023             0x12 => { #8
5024             Name => 'EffectiveMaxAperture',
5025             %nikonApertureConversions,
5026             },
5027             );
5028              
5029             # Nikon lens data (note: needs decrypting)
5030             %Image::ExifTool::Nikon::LensData0204 = (
5031             %binaryDataAttrs,
5032             NOTES => q{
5033             Nikon encrypts the LensData information below if LensDataVersion is 0201 or
5034             higher, but the decryption algorithm is known so the information can be
5035             extracted.
5036             },
5037             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5038             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
5039             0x00 => {
5040             Name => 'LensDataVersion',
5041             Format => 'string[4]',
5042             Writable => 0,
5043             },
5044             0x04 => { #8
5045             Name => 'ExitPupilPosition',
5046             ValueConv => '$val ? 2048 / $val : $val',
5047             ValueConvInv => '$val ? 2048 / $val : $val',
5048             PrintConv => 'sprintf("%.1f mm",$val)',
5049             PrintConvInv => '$val=~s/\s*mm$//; $val',
5050             },
5051             0x05 => { #8
5052             Name => 'AFAperture',
5053             %nikonApertureConversions,
5054             },
5055             0x08 => { #8
5056             # this seems to be 2 values: the upper nibble gives the far focus
5057             # range and the lower nibble gives the near focus range. The values
5058             # are in the range 1-N, where N is lens-dependent. A value of 0 for
5059             # the far focus range indicates infinity. (ref JD)
5060             Name => 'FocusPosition',
5061             PrintConv => 'sprintf("0x%02x", $val)',
5062             PrintConvInv => '$val',
5063             },
5064             # --> extra byte at position 0x09 in this version of LensData (PH)
5065             0x0a => { #8/9
5066             # With older AF lenses this does not work... (ref 13)
5067             # eg) AF Nikkor 50mm f/1.4 => 48 (0x30)
5068             # AF Zoom-Nikkor 35-105mm f/3.5-4.5 => @35mm => 15 (0x0f), @105mm => 141 (0x8d)
5069             Notes => 'this focus distance is approximate, and not very accurate for some lenses',
5070             Name => 'FocusDistance',
5071             ValueConv => '0.01 * 10**($val/40)', # in m
5072             ValueConvInv => '$val>0 ? 40*log($val*100)/log(10) : 0',
5073             PrintConv => '$val ? sprintf("%.2f m",$val) : "inf"',
5074             PrintConvInv => '$val eq "inf" ? 0 : $val =~ s/\s*m$//, $val',
5075             },
5076             0x0b => { #8/9
5077             Name => 'FocalLength',
5078             Priority => 0,
5079             %nikonFocalConversions,
5080             },
5081             0x0c => { #8
5082             Name => 'LensIDNumber',
5083             Notes => 'see LensID values below',
5084             },
5085             0x0d => { #8
5086             Name => 'LensFStops',
5087             ValueConv => '$val / 12',
5088             ValueConvInv => '$val * 12',
5089             PrintConv => 'sprintf("%.2f", $val)',
5090             PrintConvInv => '$val',
5091             },
5092             0x0e => { #8/9
5093             Name => 'MinFocalLength',
5094             %nikonFocalConversions,
5095             },
5096             0x0f => { #8/9
5097             Name => 'MaxFocalLength',
5098             %nikonFocalConversions,
5099             },
5100             0x10 => { #8
5101             Name => 'MaxApertureAtMinFocal',
5102             %nikonApertureConversions,
5103             },
5104             0x11 => { #8
5105             Name => 'MaxApertureAtMaxFocal',
5106             %nikonApertureConversions,
5107             },
5108             0x12 => 'MCUVersion', #8 (MCU = Micro Controller Unit)
5109             0x13 => { #8
5110             Name => 'EffectiveMaxAperture',
5111             %nikonApertureConversions,
5112             },
5113             );
5114              
5115             # Nikon lens data version 0400 (note: needs decrypting) (ref PH)
5116             %Image::ExifTool::Nikon::LensData0400 = (
5117             %binaryDataAttrs,
5118             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5119             NOTES => 'Tags extracted from the encrypted lens data of the Nikon 1J1/1V1/1J2.',
5120             0x00 => {
5121             Name => 'LensDataVersion',
5122             Format => 'string[4]',
5123             Writable => 0,
5124             },
5125             0x18a => { #PH
5126             Name => 'LensModel',
5127             Format => 'string[64]',
5128             },
5129             );
5130              
5131             # Nikon lens data version 0402 (note: needs decrypting) (ref PH)
5132             %Image::ExifTool::Nikon::LensData0402 = (
5133             %binaryDataAttrs,
5134             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5135             NOTES => 'Tags extracted from the encrypted lens data of the Nikon 1J3/1S1/1V2.',
5136             0x00 => {
5137             Name => 'LensDataVersion',
5138             Format => 'string[4]',
5139             Writable => 0,
5140             },
5141             0x18b => { #PH
5142             Name => 'LensModel',
5143             Format => 'string[64]',
5144             },
5145             );
5146              
5147             # Nikon lens data version 0403 (note: needs decrypting) (ref PH)
5148             %Image::ExifTool::Nikon::LensData0403 = (
5149             %binaryDataAttrs,
5150             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5151             NOTES => 'Tags extracted from the encrypted lens data of the Nikon 1J4/1J5.',
5152             0x00 => {
5153             Name => 'LensDataVersion',
5154             Format => 'string[4]',
5155             Writable => 0,
5156             },
5157             0x2ac => { #PH
5158             Name => 'LensModel',
5159             Format => 'string[64]',
5160             },
5161             );
5162              
5163             # Nikon Z lens data (note: needs decrypting) (ref PH, based on LensData0204)
5164             %Image::ExifTool::Nikon::LensData0800 = (
5165             %binaryDataAttrs,
5166             NOTES => 'Tags found in the encrypted LensData from cameras such as the Z6 and Z7.',
5167             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5168             DATAMEMBER => [ 0x03, 0x2f, 0x35, 0x4c, 0x56 ],
5169             0x00 => {
5170             Name => 'LensDataVersion',
5171             Format => 'string[4]',
5172             Writable => 0,
5173             },
5174             0x03 => { # look forward to see if new old data exists...
5175             Name => 'OldLensData',
5176             Format => 'undef[17]',
5177             RawConv => '$$self{OldLensData} = 1 unless $val =~ /^.\0+$/s; undef',
5178             Hidden => 1,
5179             },
5180             0x04 => {
5181             Name => 'ExitPupilPosition',
5182             Condition => '$$self{OldLensData}',
5183             ValueConv => '$val ? 2048 / $val : $val',
5184             ValueConvInv => '$val ? 2048 / $val : $val',
5185             PrintConv => 'sprintf("%.1f mm",$val)',
5186             PrintConvInv => '$val=~s/\s*mm$//; $val',
5187             },
5188             0x05 => {
5189             Name => 'AFAperture',
5190             Condition => '$$self{OldLensData}',
5191             %nikonApertureConversions,
5192             },
5193             # --> another extra byte at position 0x08 in this version of LensData (PH)
5194             #0x09 => {
5195             # Name => 'FocusPosition', #28 - this appears to be copied from an older version of LensData and is no longer valid. Text with Z9 and Z7_2 with a variety of lenses
5196             # Condition => '$$self{OldLensData}',
5197             # PrintConv => 'sprintf("0x%02x", $val)',
5198             # PrintConvInv => '$val',
5199             #},
5200             0x0b => {
5201             Notes => 'this focus distance is approximate, and not very accurate for some lenses',
5202             Name => 'FocusDistance',
5203             Condition => '$$self{OldLensData}',
5204             ValueConv => '0.01 * 10**($val/40)', # in m
5205             ValueConvInv => '$val>0 ? 40*log($val*100)/log(10) : 0',
5206             PrintConv => '$val ? sprintf("%.2f m",$val) : "inf"',
5207             PrintConvInv => '$val eq "inf" ? 0 : $val =~ s/\s*m$//, $val',
5208             },
5209             0x0c => {
5210             Name => 'FocalLength',
5211             Condition => '$$self{OldLensData}',
5212             Priority => 0,
5213             %nikonFocalConversions,
5214             },
5215             0x0d => {
5216             Name => 'LensIDNumber',
5217             Condition => '$$self{OldLensData}',
5218             Notes => 'see LensID values below',
5219             },
5220             0x0e => {
5221             Name => 'LensFStops',
5222             Condition => '$$self{OldLensData}',
5223             ValueConv => '$val / 12',
5224             ValueConvInv => '$val * 12',
5225             PrintConv => 'sprintf("%.2f", $val)',
5226             PrintConvInv => '$val',
5227             },
5228             0x0f => {
5229             Name => 'MinFocalLength',
5230             Condition => '$$self{OldLensData}',
5231             %nikonFocalConversions,
5232             },
5233             0x10 => {
5234             Name => 'MaxFocalLength',
5235             Condition => '$$self{OldLensData}',
5236             %nikonFocalConversions,
5237             },
5238             0x11 => {
5239             Name => 'MaxApertureAtMinFocal',
5240             Condition => '$$self{OldLensData}',
5241             %nikonApertureConversions,
5242             },
5243             0x12 => {
5244             Name => 'MaxApertureAtMaxFocal',
5245             Condition => '$$self{OldLensData}',
5246             %nikonApertureConversions,
5247             },
5248             0x13 => {
5249             Name => 'MCUVersion',
5250             Condition => '$$self{OldLensData}',
5251             },
5252             0x14 => {
5253             Name => 'EffectiveMaxAperture',
5254             Condition => '$$self{OldLensData}',
5255             %nikonApertureConversions,
5256             },
5257             #
5258             # ---- new LensData tags used by Nikkor Z cameras (ref PH/28). ----
5259             # (some fields are strictly for Z-series lenses, others apply to legacy F-mount as well, ref 28)
5260             #
5261             0x2f => { # look forward to see if new lens data exists...
5262             Name => 'NewLensData',
5263             Format => 'undef[17]',
5264             RawConv => '$$self{NewLensData} = 1 unless $val =~ /^.\0+$/s; undef',
5265             #Hidden => 1,
5266             },
5267             0x30 => { #PH
5268             Name => 'LensID',
5269             Condition => '$$self{NewLensData}',
5270             Notes => 'tags from here onward used for Nikkor Z lenses only',
5271             Format => 'int16u',
5272             PrintConv => {
5273             1 => 'Nikkor Z 24-70mm f/4 S',
5274             2 => 'Nikkor Z 14-30mm f/4 S',
5275             4 => 'Nikkor Z 35mm f/1.8 S',
5276             8 => 'Nikkor Z 58mm f/0.95 S Noct', #IB
5277             9 => 'Nikkor Z 50mm f/1.8 S',
5278             11 => 'Nikkor Z DX 16-50mm f/3.5-6.3 VR',
5279             12 => 'Nikkor Z DX 50-250mm f/4.5-6.3 VR',
5280             13 => 'Nikkor Z 24-70mm f/2.8 S',
5281             14 => 'Nikkor Z 85mm f/1.8 S',
5282             15 => 'Nikkor Z 24mm f/1.8 S', #IB
5283             16 => 'Nikkor Z 70-200mm f/2.8 VR S', #IB
5284             17 => 'Nikkor Z 20mm f/1.8 S', #IB
5285             18 => 'Nikkor Z 24-200mm f/4-6.3 VR', #IB
5286             21 => 'Nikkor Z 50mm f/1.2 S', #IB
5287             22 => 'Nikkor Z 24-50mm f/4-6.3', #IB
5288             23 => 'Nikkor Z 14-24mm f/2.8 S', #IB
5289             24 => 'Nikkor Z MC 105mm f/2.8 VR S', #IB
5290             25 => 'Nikkor Z 40mm f/2', #28
5291             26 => 'Nikkor Z DX 18-140mm f/3.5-6.3 VR', #IB
5292             27 => 'Nikkor Z MC 50mm f/2.8', #IB
5293             28 => 'Nikkor Z 100-400mm f/4.5-5.6 VR S', #28
5294             29 => 'Nikkor Z 28mm f/2.8', #IB
5295             30 => 'Nikkor Z 400mm f/2.8 TC VR S', #28
5296             31 => 'Nikkor Z 24-120 f/4', #28
5297             32 => 'Nikkor Z 800mm f/6.3 VR S', #28
5298             35 => 'Nikkor Z 28-75mm f/2.8', #IB
5299             36 => 'Nikkor Z 400mm f/4.5 VR S', #IB
5300             37 => 'Nikkor Z 600mm f/4 TC VR S', #28
5301             38 => 'Nikkor Z 85mm f/1.2 S', #28
5302             39 => 'Nikkor Z 17-28mm f/2.8', #IB
5303             32768 => 'Nikkor Z 400mm f/2.8 TC VR S TC-1.4x', #28
5304             32769 => 'Nikkor Z 600mm f/4 TC VR S TC-1.4x', #28
5305             },
5306             },
5307             0x35 => { #28
5308             Name => 'LensMountType',
5309             RawConv => '$$self{LensMountType} = $val', # 0=> DSLR lens via FTZ style adapter; 1=> Native Z lens;
5310             Format => 'int8u',
5311             #Unknown => 1,
5312             PrintConv => {
5313             0 => 'F-mount Lens',
5314             1 => 'Z-mount Lens',
5315             },
5316             },
5317             0x36 => { #PH
5318             Name => 'MaxAperture',
5319             Condition => '$$self{NewLensData}',
5320             Format => 'int16u',
5321             Priority => 0,
5322             ValueConv => '2**($val/384-1)',
5323             ValueConvInv => '384*(log($val)/log(2)+1)',
5324             PrintConv => 'sprintf("%.1f",$val)',
5325             PrintConvInv => '$val',
5326             },
5327             0x38 => { #PH
5328             Name => 'FNumber',
5329             Condition => '$$self{NewLensData}',
5330             Format => 'int16u',
5331             Priority => 0,
5332             ValueConv => '2**($val/384-1)',
5333             ValueConvInv => '384*(log($val)/log(2)+1)',
5334             PrintConv => 'sprintf("%.1f",$val)',
5335             PrintConvInv => '$val',
5336             },
5337             0x3c => { #PH
5338             Name => 'FocalLength',
5339             Condition => '$$self{NewLensData}',
5340             Format => 'int16u',
5341             Priority => 0,
5342             PrintConv => '"$val mm"',
5343             PrintConvInv => '$val=~s/\s*mm$//;$val',
5344             },
5345             0x4c => { #28
5346             Name => 'FocusDistanceRangeWidth', #reflects the number of discrete absolute lens positions that are mapped to the reported FocusDistance. Will be 1 near CFD reflecting very narrow focus distance bands (i.e., quite accurate). Near Infinity will be something like 32. Note: 0 at infinity.
5347             Format => 'int8u',
5348             Condition => '$$self{NewLensData} and $$self{LensMountType} and $$self{LensMountType} == 1',
5349             RawConv => '$$self{FocusDistanceRangeWidth} = $val',
5350             Unknown => 1,
5351             },
5352             0x4e => { #28
5353             Name => 'FocusDistance',
5354             Format => 'int16u',
5355             Condition => '$$self{NewLensData} and $$self{LensMountType} and $$self{LensMountType} == 1',
5356             RawConv => '$val = $val/256', # 1st byte is the fractional component. This byte was not previously considered in the legacy calculation (which only used the 2nd byte). When 2nd byte < 80; distance is < 1 meter
5357             ValueConv => '0.01 * 10**($val/40)', # in m
5358             ValueConvInv => '$val>0 ? 40*log($val*100)/log(10) : 0',
5359             PrintConv => q{
5360             (defined $$self{FocusDistanceRangeWidth} and not $$self{FocusDistanceRangeWidth}) ? "Inf" : $val < 1 ? $val < 0.35 ? sprintf("%.4f m", $val): sprintf("%.3f m", $val): sprintf("%.2f m", $val), #distances less than 35mm are quite accurate with increasingly less precision past 1m
5361             },
5362             },
5363             0x56 => { #28
5364             Name => 'LensDriveEnd', # byte contains: 1 at CFD/MOD; 2 at Infinity; 0 otherwise
5365             Condition => '$$self{NewLensData} and $$self{LensMountType} and $$self{LensMountType} == 1',
5366             Format => 'int8u',
5367             RawConv => 'unless (defined $$self{FocusDistanceRangeWidth} and not $$self{FocusDistanceRangeWidth}) { if ($val == 0 ) {$$self{LensDriveEnd} = "No"} else { $$self{LensDriveEnd} = "CFD"}; } else{ $$self{LensDriveEnd} = "Inf"}',
5368             Unknown => 1,
5369             },
5370             0x5a => { #28
5371             Name => 'LensPositionAbsolute', # <=0 at infinity. Typical value at CFD might be 58000. Only valid for Z-mount lenses.
5372             Condition => '$$self{NewLensData} and $$self{LensMountType} and $$self{LensMountType} == 1',
5373             Format => 'int32s',
5374             #Unknown => 1,
5375             },
5376             );
5377              
5378             # Unknown Nikon lens data (note: data may need decrypting after byte 4)
5379             %Image::ExifTool::Nikon::LensDataUnknown = (
5380             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
5381             FIRST_ENTRY => 0,
5382             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5383             0x00 => {
5384             Name => 'LensDataVersion',
5385             Format => 'string[4]',
5386             },
5387             );
5388              
5389             # shot information (encrypted in some cameras) - ref 18
5390             %Image::ExifTool::Nikon::ShotInfo = (
5391             %binaryDataAttrs,
5392             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5393             DATAMEMBER => [ 0 ],
5394             NOTES => q{
5395             This information is encrypted for ShotInfoVersion 02xx, and some tags are
5396             only valid for specific models.
5397             },
5398             0x00 => {
5399             Name => 'ShotInfoVersion',
5400             Format => 'string[4]',
5401             Writable => 0,
5402             RawConv => '$$self{ShotInfoVersion} = $val; $val =~ /^\d+$/ ? $val : undef',
5403             },
5404             0x04 => {
5405             Name => 'FirmwareVersion',
5406             Format => 'string[5]',
5407             Writable => 0,
5408             RawConv => '$val =~ /^\d\.\d+.$/ ? $val : undef',
5409             },
5410             0x10 => {
5411             Name => 'DistortionControl',
5412             Condition => '$$self{Model} =~ /P6000\b/',
5413             Notes => 'P6000',
5414             PrintConv => \%offOn,
5415             },
5416             0x66 => {
5417             Name => 'VR_0x66',
5418             Condition => '$$self{ShotInfoVersion} eq "0204"',
5419             Format => 'int8u',
5420             Unknown => 1,
5421             Notes => 'D2X, D2Xs (unverified)',
5422             PrintConv => {
5423             0 => 'Off',
5424             1 => 'On (normal)',
5425             2 => 'On (active)',
5426             },
5427             },
5428             # 6a, 6e not correct for 0103 (D70), 0207 (D200)
5429             0x6a => {
5430             Name => 'ShutterCount',
5431             Condition => '$$self{ShotInfoVersion} eq "0204"',
5432             Format => 'int32u',
5433             Priority => 0,
5434             Notes => 'D2X, D2Xs',
5435             },
5436             0x6e => {
5437             Name => 'DeletedImageCount',
5438             Condition => '$$self{ShotInfoVersion} eq "0204"',
5439             Format => 'int32u',
5440             Priority => 0,
5441             Notes => 'D2X, D2Xs',
5442             },
5443             0x75 => { #JD
5444             Name => 'VibrationReduction',
5445             Condition => '$$self{ShotInfoVersion} eq "0207"',
5446             Format => 'int8u',
5447             Notes => 'D200',
5448             PrintConv => {
5449             0 => 'Off',
5450             # (not sure what the different values represent, but values
5451             # of 1 and 2 have even been observed for non-VR lenses!)
5452             1 => 'On (1)', #PH
5453             2 => 'On (2)', #PH
5454             3 => 'On (3)', #PH (rare -- only seen once)
5455             },
5456             },
5457             0x82 => { # educated guess, needs verification
5458             Name => 'VibrationReduction',
5459             Condition => '$$self{ShotInfoVersion} eq "0204"',
5460             Format => 'int8u',
5461             Notes => 'D2X, D2Xs',
5462             PrintConv => {
5463             0 => 'Off',
5464             1 => 'On',
5465             },
5466             },
5467             # 0xac - int16u[600] TiffMeteringImage1: 30x20 image (ShotInfoVersion 0800, ref JR)
5468             0x157 => { #JD
5469             Name => 'ShutterCount',
5470             Condition => '$$self{ShotInfoVersion} eq "0205"',
5471             Format => 'undef[2]',
5472             Priority => 0,
5473             Notes => 'D50',
5474             # treat as a 2-byte big-endian integer
5475             ValueConv => 'unpack("n", $val)',
5476             ValueConvInv => 'pack("n",$val)',
5477             },
5478             0x1ae => { #JD
5479             Name => 'VibrationReduction',
5480             Condition => '$$self{ShotInfoVersion} eq "0205"',
5481             Format => 'int8u',
5482             Notes => 'D50',
5483             PrintHex => 1,
5484             PrintConv => {
5485             0x00 => 'n/a',
5486             0x0c => 'Off',
5487             0x0f => 'On',
5488             },
5489             },
5490             0x24d => { #PH
5491             Name => 'ShutterCount',
5492             Condition => '$$self{ShotInfoVersion} eq "0211"',
5493             Notes => 'D60',
5494             Format => 'int32u',
5495             Priority => 0,
5496             },
5497             # 0x55c - int16u[2400] TiffMeteringImage2: 60x40 image (ShotInfoVersion 0800, ref JR)
5498             # 0x181c - int16u[1200] TiffMeteringImage?: 60x20 image for some NEF's (ShotInfoVersion 0800, ref JR)
5499             # 0x217c - int16u[2400] TiffMeteringImage3: 60x40 image (ShotInfoVersion 0800, ref JR)
5500             # 0x3d9c - int16u[2400] TiffMeteringImage4: 60x40 image (ShotInfoVersion 0800, ref JR)
5501             # 0x59c0 - TiffMeteringImageWidth (ShotInfoVersion 0800, ref JR)
5502             # 0x59c2 - TiffMeteringImageHeight (ShotInfoVersion 0800, ref JR)
5503             # 0x59c4 - int16u[1800] TiffMeteringImage5: 30x20 RGB image (ShotInfoVersion 0800, ref JR)
5504             );
5505              
5506             # shot information for D40 and D40X (encrypted) - ref PH
5507             %Image::ExifTool::Nikon::ShotInfoD40 = (
5508             PROCESS_PROC => \&ProcessNikonEncrypted,
5509             WRITE_PROC => \&ProcessNikonEncrypted,
5510             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5511             VARS => { ID_LABEL => 'Index' },
5512             IS_SUBDIR => [ 729 ],
5513             WRITABLE => 1,
5514             FIRST_ENTRY => 0,
5515             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5516             NOTES => 'These tags are extracted from encrypted data in D40 and D40X images.',
5517             0x00 => {
5518             Name => 'ShotInfoVersion',
5519             Format => 'string[4]',
5520             Writable => 0,
5521             },
5522             582 => {
5523             Name => 'ShutterCount',
5524             Format => 'int32u',
5525             Priority => 0,
5526             },
5527             586.1 => { #JD
5528             Name => 'VibrationReduction',
5529             Mask => 0x08,
5530             PrintConv => { 0 => 'Off', 1 => 'On' },
5531             },
5532             729 => { #JD
5533             Name => 'CustomSettingsD40',
5534             Format => 'undef[12]',
5535             SubDirectory => {
5536             TagTable => 'Image::ExifTool::NikonCustom::SettingsD40',
5537             },
5538             },
5539             );
5540              
5541             # shot information for D80 (encrypted) - ref JD
5542             %Image::ExifTool::Nikon::ShotInfoD80 = (
5543             PROCESS_PROC => \&ProcessNikonEncrypted,
5544             WRITE_PROC => \&ProcessNikonEncrypted,
5545             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5546             VARS => { ID_LABEL => 'Index' },
5547             IS_SUBDIR => [ 748 ],
5548             WRITABLE => 1,
5549             FIRST_ENTRY => 0,
5550             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5551             NOTES => 'These tags are extracted from encrypted data in D80 images.',
5552             0x00 => {
5553             Name => 'ShotInfoVersion',
5554             Format => 'string[4]',
5555             Writable => 0,
5556             },
5557             586 => {
5558             Name => 'ShutterCount',
5559             Format => 'int32u',
5560             Priority => 0,
5561             },
5562             # split 590 into a few different tags
5563             590.1 => {
5564             Name => 'Rotation',
5565             Mask => 0x07,
5566             PrintConv => {
5567             0 => 'Horizontal',
5568             1 => 'Rotate 270 CW',
5569             2 => 'Rotate 90 CW',
5570             3 => 'Rotate 180',
5571             },
5572             },
5573             590.2 => {
5574             Name => 'VibrationReduction',
5575             Mask => 0x18,
5576             PrintConv => {
5577             0 => 'Off',
5578             3 => 'On',
5579             },
5580             },
5581             590.3 => {
5582             Name => 'FlashFired',
5583             Mask => 0xe0,
5584             PrintConv => { BITMASK => {
5585             1 => 'Internal',
5586             2 => 'External',
5587             }},
5588             },
5589             708 => {
5590             Name => 'NikonImageSize',
5591             Mask => 0xf0,
5592             PrintConv => {
5593             0 => 'Large (10.0 M)',
5594             1 => 'Medium (5.6 M)',
5595             2 => 'Small (2.5 M)',
5596             },
5597             },
5598             708.1 => {
5599             Name => 'ImageQuality',
5600             Mask => 0x0f,
5601             PrintConv => {
5602             0 => 'NEF (RAW)',
5603             1 => 'JPEG Fine',
5604             2 => 'JPEG Normal',
5605             3 => 'JPEG Basic',
5606             4 => 'NEF (RAW) + JPEG Fine',
5607             5 => 'NEF (RAW) + JPEG Normal',
5608             6 => 'NEF (RAW) + JPEG Basic',
5609             },
5610             },
5611             748 => { #JD
5612             Name => 'CustomSettingsD80',
5613             Format => 'undef[17]',
5614             SubDirectory => {
5615             TagTable => 'Image::ExifTool::NikonCustom::SettingsD80',
5616             },
5617             },
5618             );
5619              
5620             # shot information for D90 (encrypted) - ref PH
5621             %Image::ExifTool::Nikon::ShotInfoD90 = (
5622             PROCESS_PROC => \&ProcessNikonEncrypted,
5623             WRITE_PROC => \&ProcessNikonEncrypted,
5624             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5625             VARS => { ID_LABEL => 'Index' },
5626             IS_SUBDIR => [ 0x374 ],
5627             WRITABLE => 1,
5628             FIRST_ENTRY => 0,
5629             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5630             NOTES => q{
5631             These tags are extracted from encrypted data in images from the D90 with
5632             firmware 1.00.
5633             },
5634             0x00 => {
5635             Name => 'ShotInfoVersion',
5636             Format => 'string[4]',
5637             Writable => 0,
5638             },
5639             0x04 => {
5640             Name => 'FirmwareVersion',
5641             Format => 'string[5]',
5642             Writable => 0,
5643             },
5644             0x2b5 => { #JD (same value found at offset 0x39, 0x2bf, 0x346)
5645             Name => 'ISO2',
5646             ValueConv => '100*exp(($val/12-5)*log(2))',
5647             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5648             PrintConv => 'int($val + 0.5)',
5649             PrintConvInv => '$val',
5650             },
5651             0x2d5 => {
5652             Name => 'ShutterCount',
5653             Format => 'int32u',
5654             Priority => 0,
5655             },
5656             0x374 => {
5657             Name => 'CustomSettingsD90',
5658             Format => 'undef[36]',
5659             SubDirectory => {
5660             TagTable => 'Image::ExifTool::NikonCustom::SettingsD90',
5661             },
5662             },
5663             );
5664              
5665             # shot information for the D3 firmware 0.37 and 1.00 (encrypted) - ref PH
5666             %Image::ExifTool::Nikon::ShotInfoD3a = (
5667             PROCESS_PROC => \&ProcessNikonEncrypted,
5668             WRITE_PROC => \&ProcessNikonEncrypted,
5669             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5670             VARS => { ID_LABEL => 'Index' },
5671             IS_SUBDIR => [ 0x301 ],
5672             WRITABLE => 1,
5673             FIRST_ENTRY => 0,
5674             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5675             NOTES => q{
5676             These tags are extracted from encrypted data in images from the D3 with
5677             firmware 1.00 and earlier.
5678             },
5679             0x00 => {
5680             Name => 'ShotInfoVersion',
5681             Format => 'string[4]',
5682             Writable => 0,
5683             },
5684             0x256 => { #JD (same value found at offset 0x26b)
5685             Name => 'ISO2',
5686             ValueConv => '100*exp(($val/12-5)*log(2))',
5687             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5688             PrintConv => 'int($val + 0.5)',
5689             PrintConvInv => '$val',
5690             },
5691             0x276 => { #JD
5692             Name => 'ShutterCount',
5693             Format => 'int32u',
5694             Priority => 0,
5695             },
5696             723.1 => {
5697             Name => 'NikonImageSize',
5698             Mask => 0x18,
5699             PrintConv => {
5700             0 => 'Large',
5701             1 => 'Medium',
5702             2 => 'Small',
5703             },
5704             },
5705             723.2 => {
5706             Name => 'ImageQuality',
5707             Mask => 0x07,
5708             PrintConv => {
5709             0 => 'NEF (RAW) + JPEG Fine',
5710             1 => 'NEF (RAW) + JPEG Norm',
5711             2 => 'NEF (RAW) + JPEG Basic',
5712             3 => 'NEF (RAW)',
5713             4 => 'TIF (RGB)',
5714             5 => 'JPEG Fine',
5715             6 => 'JPEG Normal',
5716             7 => 'JPEG Basic',
5717             },
5718             },
5719             0x301 => { #(NC)
5720             Name => 'CustomSettingsD3',
5721             Format => 'undef[24]',
5722             SubDirectory => {
5723             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
5724             },
5725             },
5726             );
5727              
5728             # shot information for the D3 firmware 1.10, 2.00 and 2.01 (encrypted) - ref PH
5729             %Image::ExifTool::Nikon::ShotInfoD3b = (
5730             PROCESS_PROC => \&ProcessNikonEncrypted,
5731             WRITE_PROC => \&ProcessNikonEncrypted,
5732             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5733             VARS => { ID_LABEL => 'Index' },
5734             IS_SUBDIR => [ 0x30a ],
5735             WRITABLE => 1,
5736             FIRST_ENTRY => 0,
5737             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5738             DATAMEMBER => [ 4 ],
5739             NOTES => q{
5740             These tags are extracted from encrypted data in images from the D3 with
5741             firmware 1.10, 2.00, 2.01 and 2.02.
5742             },
5743             0x00 => {
5744             Name => 'ShotInfoVersion',
5745             Format => 'string[4]',
5746             Writable => 0,
5747             },
5748             0x04 => {
5749             Name => 'FirmwareVersion',
5750             Format => 'string[5]',
5751             Writable => 0,
5752             RawConv => '$$self{FirmwareVersion} = $val',
5753             },
5754             0x10 => { #28
5755             Name => 'ImageArea',
5756             PrintConv => {
5757             0 => 'FX (36.0 x 23.9 mm)',
5758             1 => 'DX (23.5 x 15.6 mm)',
5759             2 => '5:4 (30.0 x 23.9 mm)',
5760             },
5761             },
5762             0x25d => {
5763             Name => 'ISO2',
5764             ValueConv => '100*exp(($val/12-5)*log(2))',
5765             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5766             PrintConv => 'int($val + 0.5)',
5767             PrintConvInv => '$val',
5768             },
5769             0x27d => {
5770             Name => 'ShutterCount',
5771             Condition => '$$self{FirmwareVersion} =~ /^1\.01/',
5772             Notes => 'firmware 1.10',
5773             Format => 'int32u',
5774             Priority => 0,
5775             },
5776             0x27f => {
5777             Name => 'ShutterCount',
5778             Condition => '$$self{FirmwareVersion} =~ /^2\.0/',
5779             Notes => 'firmware 2.00, 2.01 and 2.02',
5780             Format => 'int32u',
5781             Priority => 0,
5782             },
5783             732.1 => { #28
5784             Name => 'NikonImageSize',
5785             Mask => 0x18,
5786             PrintConv => {
5787             0 => 'Large',
5788             1 => 'Medium',
5789             2 => 'Small',
5790             },
5791             },
5792             732.2 => { #28
5793             Name => 'ImageQuality',
5794             Mask => 0x07,
5795             PrintConv => {
5796             0 => 'NEF (RAW) + JPEG Fine',
5797             1 => 'NEF (RAW) + JPEG Norm',
5798             2 => 'NEF (RAW) + JPEG Basic',
5799             3 => 'NEF (RAW)',
5800             4 => 'TIF (RGB)',
5801             5 => 'JPEG Fine',
5802             6 => 'JPEG Normal',
5803             7 => 'JPEG Basic',
5804             },
5805             },
5806             0x28a => { #28
5807             Name => 'PreFlashReturnStrength',
5808             Notes => 'valid in TTL and TTL-BL flash control modes',
5809             # this is used to set the flash power using this relationship
5810             # for the SB-800 and SB-900:
5811             # $val < 140 ? 2**(0.08372*$val-12.352) : $val
5812             },
5813             0x30a => { # tested with firmware 2.00
5814             Name => 'CustomSettingsD3',
5815             Format => 'undef[24]',
5816             SubDirectory => {
5817             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
5818             },
5819             },
5820             );
5821              
5822             # shot information for the D3X firmware 1.00 (encrypted) - ref PH
5823             %Image::ExifTool::Nikon::ShotInfoD3X = (
5824             PROCESS_PROC => \&ProcessNikonEncrypted,
5825             WRITE_PROC => \&ProcessNikonEncrypted,
5826             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5827             VARS => { ID_LABEL => 'Index' },
5828             IS_SUBDIR => [ 0x30b ],
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 D3X 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             0x25d => {
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             0x280 => {
5854             Name => 'ShutterCount',
5855             Format => 'int32u',
5856             Priority => 0,
5857             },
5858             0x30b => { #(NC)
5859             Name => 'CustomSettingsD3X',
5860             Format => 'undef[24]',
5861             SubDirectory => {
5862             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
5863             },
5864             },
5865             );
5866              
5867             # shot information for the D3S firmware 0.16 and 1.00 (encrypted) - ref PH
5868             %Image::ExifTool::Nikon::ShotInfoD3S = (
5869             PROCESS_PROC => \&ProcessNikonEncrypted,
5870             WRITE_PROC => \&ProcessNikonEncrypted,
5871             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5872             VARS => { ID_LABEL => 'Index' },
5873             IS_SUBDIR => [ 0x2ce ],
5874             WRITABLE => 1,
5875             FIRST_ENTRY => 0,
5876             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5877             NOTES => q{
5878             These tags are extracted from encrypted data in images from the D3S with
5879             firmware 1.00 and earlier.
5880             },
5881             0x00 => {
5882             Name => 'ShotInfoVersion',
5883             Format => 'string[4]',
5884             Writable => 0,
5885             },
5886             0x04 => {
5887             Name => 'FirmwareVersion',
5888             Format => 'string[5]',
5889             Writable => 0,
5890             },
5891             0x10 => { #28
5892             Name => 'ImageArea',
5893             PrintConv => {
5894             0 => 'FX (36x24)',
5895             1 => 'DX (24x16)',
5896             2 => '5:4 (30x24)',
5897             3 => '1.2x (30x20)',
5898             },
5899             },
5900             0x221 => {
5901             Name => 'ISO2',
5902             ValueConv => '100*exp(($val/12-5)*log(2))',
5903             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5904             PrintConv => 'int($val + 0.5)',
5905             PrintConvInv => '$val',
5906             },
5907             0x242 => {
5908             Name => 'ShutterCount',
5909             Format => 'int32u',
5910             Priority => 0,
5911             },
5912             0x2ce => { #(NC)
5913             Name => 'CustomSettingsD3S',
5914             Format => 'undef[27]',
5915             SubDirectory => {
5916             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
5917             },
5918             },
5919             );
5920              
5921             # shot information for the D300 firmware 1.00 (encrypted) - ref JD
5922             %Image::ExifTool::Nikon::ShotInfoD300a = (
5923             PROCESS_PROC => \&ProcessNikonEncrypted,
5924             WRITE_PROC => \&ProcessNikonEncrypted,
5925             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
5926             VARS => { ID_LABEL => 'Index' },
5927             IS_SUBDIR => [ 790 ],
5928             WRITABLE => 1,
5929             FIRST_ENTRY => 0,
5930             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5931             NOTES => q{
5932             These tags are extracted from encrypted data in images from the D300 with
5933             firmware 1.00 and earlier.
5934             },
5935             0x00 => {
5936             Name => 'ShotInfoVersion',
5937             Format => 'string[4]',
5938             Writable => 0,
5939             },
5940             604 => {
5941             Name => 'ISO2',
5942             ValueConv => '100*exp(($val/12-5)*log(2))',
5943             ValueConvInv => '(log($val/100)/log(2)+5)*12',
5944             PrintConv => 'int($val + 0.5)',
5945             PrintConvInv => '$val',
5946             },
5947             633 => {
5948             Name => 'ShutterCount',
5949             Format => 'int32u',
5950             Priority => 0,
5951             },
5952             721 => { #PH
5953             Name => 'AFFineTuneAdj',
5954             Format => 'int16u',
5955             PrintHex => 1,
5956             PrintConvColumns => 3,
5957             # thanks to Neil Nappe for the samples to decode this!...
5958             # (have seen various unknown values here when flash is enabled, but
5959             # these are yet to be decoded: 0x2e,0x619,0xd0d,0x103a,0x2029 - PH)
5960             PrintConv => {
5961             0x403e => '+20',
5962             0x303e => '+19',
5963             0x203e => '+18',
5964             0x103e => '+17',
5965             0x003e => '+16',
5966             0xe03d => '+15',
5967             0xc03d => '+14',
5968             0xa03d => '+13',
5969             0x803d => '+12',
5970             0x603d => '+11',
5971             0x403d => '+10',
5972             0x203d => '+9',
5973             0x003d => '+8',
5974             0xc03c => '+7',
5975             0x803c => '+6',
5976             0x403c => '+5',
5977             0x003c => '+4',
5978             0x803b => '+3',
5979             0x003b => '+2',
5980             0x003a => '+1',
5981             0x0000 => '0',
5982             0x00c6 => '-1',
5983             0x00c5 => '-2',
5984             0x80c5 => '-3',
5985             0x00c4 => '-4',
5986             0x40c4 => '-5',
5987             0x80c4 => '-6',
5988             0xc0c4 => '-7',
5989             0x00c3 => '-8',
5990             0x20c3 => '-9',
5991             0x40c3 => '-10',
5992             0x60c3 => '-11',
5993             0x80c3 => '-12',
5994             0xa0c3 => '-13',
5995             0xc0c3 => '-14',
5996             0xe0c3 => '-15',
5997             0x00c2 => '-16',
5998             0x10c2 => '-17',
5999             0x20c2 => '-18',
6000             0x30c2 => '-19',
6001             0x40c2 => '-20',
6002             },
6003             },
6004             790 => {
6005             Name => 'CustomSettingsD300',
6006             Format => 'undef[24]',
6007             SubDirectory => {
6008             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
6009             },
6010             },
6011             );
6012              
6013             # shot information for the D300 firmware 1.10 (encrypted) - ref PH
6014             %Image::ExifTool::Nikon::ShotInfoD300b = (
6015             PROCESS_PROC => \&ProcessNikonEncrypted,
6016             WRITE_PROC => \&ProcessNikonEncrypted,
6017             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6018             VARS => { ID_LABEL => 'Index' },
6019             DATAMEMBER => [ 4 ],
6020             IS_SUBDIR => [ 802 ],
6021             WRITABLE => 1,
6022             FIRST_ENTRY => 0,
6023             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6024             NOTES => q{
6025             These tags are extracted from encrypted data in images from the D300 with
6026             firmware 1.10.
6027             },
6028             0x00 => {
6029             Name => 'ShotInfoVersion',
6030             Format => 'string[4]',
6031             Writable => 0,
6032             },
6033             0x04 => { #PH
6034             Name => 'FirmwareVersion',
6035             DataMember => 'FirmwareVersion',
6036             Format => 'string[5]',
6037             Writable => 0,
6038             RawConv => '$$self{FirmwareVersion} = $val',
6039             },
6040             613 => {
6041             Name => 'ISO2',
6042             ValueConv => '100*exp(($val/12-5)*log(2))',
6043             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6044             PrintConv => 'int($val + 0.5)',
6045             PrintConvInv => '$val',
6046             },
6047             644 => {
6048             Name => 'ShutterCount',
6049             Format => 'int32u',
6050             Priority => 0,
6051             },
6052             732 => [{
6053             Name => 'AFFineTuneAdj',
6054             Condition => '$$self{FirmwareVersion} eq "1.10B"',
6055             Notes => 'firmware version 1.10B',
6056             Format => 'int16u',
6057             PrintHex => 1,
6058             PrintConvColumns => 3,
6059             # thanks to Michael Tapes for the samples to decode this!...
6060             PrintConv => {
6061             0xe03e => '+20',
6062             0xc83e => '+19',
6063             0xb03e => '+18',
6064             0x983e => '+17',
6065             0x803e => '+16',
6066             0x683e => '+15',
6067             0x503e => '+14',
6068             0x383e => '+13',
6069             0x203e => '+12',
6070             0x083e => '+11',
6071             0xe03d => '+10',
6072             0xb03d => '+9',
6073             0x803d => '+8',
6074             0x503d => '+7',
6075             0x203d => '+6',
6076             0xe03c => '+5',
6077             0x803c => '+4',
6078             0x203c => '+3',
6079             0x803b => '+2',
6080             0x803a => '+1',
6081             0x0000 => '0',
6082             0x80c6 => '-1',
6083             0x80c5 => '-2',
6084             0x20c4 => '-3',
6085             0x80c4 => '-4',
6086             0xe0c4 => '-5',
6087             0x20c3 => '-6',
6088             0x50c3 => '-7',
6089             0x80c3 => '-8',
6090             0xb0c3 => '-9',
6091             0xe0c3 => '-10',
6092             0x08c2 => '-11',
6093             0x20c2 => '-12',
6094             0x38c2 => '-13',
6095             0x50c2 => '-14',
6096             0x68c2 => '-15',
6097             0x80c2 => '-16',
6098             0x98c2 => '-17',
6099             0xb0c2 => '-18',
6100             0xc8c2 => '-19',
6101             0xe0c2 => '-20',
6102             },
6103             },{
6104             Name => 'AFFineTuneAdj',
6105             Notes => 'other versions',
6106             Format => 'int16u',
6107             PrintHex => 1,
6108             PrintConvColumns => 3,
6109             # thanks to Stuart Solomon for the samples to decode this!...
6110             PrintConv => {
6111             0x903e => '+20',
6112             0x7c3e => '+19',
6113             0x683e => '+18',
6114             0x543e => '+17',
6115             0x403e => '+16',
6116             0x2c3e => '+15',
6117             0x183e => '+14',
6118             0x043e => '+13',
6119             0xe03d => '+12',
6120             0xb83d => '+11',
6121             0x903d => '+10',
6122             0x683d => '+9',
6123             0x403d => '+8',
6124             0x183d => '+7',
6125             0xe03c => '+6',
6126             0x903c => '+5',
6127             0x403c => '+4',
6128             0xe03b => '+3',
6129             0x403b => '+2',
6130             0x403a => '+1',
6131             0x0000 => '0',
6132             0x40c6 => '-1',
6133             0x40c5 => '-2',
6134             0xe0c5 => '-3',
6135             0x40c4 => '-4',
6136             0x90c4 => '-5',
6137             0xe0c4 => '-6',
6138             0x18c3 => '-7',
6139             0x40c3 => '-8',
6140             0x68c3 => '-9',
6141             0x90c3 => '-10',
6142             0xb8c3 => '-11',
6143             0xe0c3 => '-12',
6144             0x04c2 => '-13',
6145             0x18c2 => '-14',
6146             0x2cc2 => '-15',
6147             0x40c2 => '-16',
6148             0x54c2 => '-17',
6149             0x68c2 => '-18',
6150             0x7cc2 => '-19',
6151             0x90c2 => '-20',
6152             },
6153             }],
6154             802 => {
6155             Name => 'CustomSettingsD300',
6156             Format => 'undef[24]',
6157             SubDirectory => {
6158             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
6159             },
6160             },
6161             );
6162              
6163             # shot information for the D300S firmware 1.00 (encrypted) - ref PH
6164             %Image::ExifTool::Nikon::ShotInfoD300S = (
6165             PROCESS_PROC => \&ProcessNikonEncrypted,
6166             WRITE_PROC => \&ProcessNikonEncrypted,
6167             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6168             VARS => { ID_LABEL => 'Index' },
6169             IS_SUBDIR => [ 804 ],
6170             WRITABLE => 1,
6171             FIRST_ENTRY => 0,
6172             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6173             NOTES => q{
6174             These tags are extracted from encrypted data in images from the D300S with
6175             firmware 1.00.
6176             },
6177             0x00 => {
6178             Name => 'ShotInfoVersion',
6179             Format => 'string[4]',
6180             Writable => 0,
6181             },
6182             0x04 => {
6183             Name => 'FirmwareVersion',
6184             Format => 'string[5]',
6185             Writable => 0,
6186             },
6187             613 => {
6188             Name => 'ISO2',
6189             ValueConv => '100*exp(($val/12-5)*log(2))',
6190             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6191             PrintConv => 'int($val + 0.5)',
6192             PrintConvInv => '$val',
6193             },
6194             646 => {
6195             Name => 'ShutterCount',
6196             Format => 'int32u',
6197             Priority => 0,
6198             },
6199             804 => { #(NC)
6200             Name => 'CustomSettingsD300S',
6201             Format => 'undef[24]',
6202             SubDirectory => {
6203             TagTable => 'Image::ExifTool::NikonCustom::SettingsD3',
6204             },
6205             },
6206             );
6207              
6208             # shot information for the D700 firmware 1.02f (encrypted) - ref 29
6209             %Image::ExifTool::Nikon::ShotInfoD700 = (
6210             PROCESS_PROC => \&ProcessNikonEncrypted,
6211             WRITE_PROC => \&ProcessNikonEncrypted,
6212             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6213             VARS => { ID_LABEL => 'Index' },
6214             IS_SUBDIR => [ 804 ],
6215             WRITABLE => 1,
6216             FIRST_ENTRY => 0,
6217             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6218             NOTES => q{
6219             These tags are extracted from encrypted data in images from the D700 with
6220             firmware 1.02f.
6221             },
6222             0x00 => {
6223             Name => 'ShotInfoVersion',
6224             Format => 'string[4]',
6225             Writable => 0,
6226             },
6227             0x04 => {
6228             Name => 'FirmwareVersion',
6229             Format => 'string[5]',
6230             Writable => 0,
6231             },
6232             613 => { # 0x265
6233             Name => 'ISO2',
6234             ValueConv => '100*exp(($val/12-5)*log(2))',
6235             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6236             PrintConv => 'int($val + 0.5)',
6237             PrintConvInv => '$val',
6238             },
6239             0x287 => {
6240             Name => 'ShutterCount',
6241             Format => 'int32u',
6242             Priority => 0,
6243             },
6244             804 => { # 0x324 (NC)
6245             Name => 'CustomSettingsD700',
6246             Format => 'undef[48]',
6247             SubDirectory => {
6248             TagTable => 'Image::ExifTool::NikonCustom::SettingsD700',
6249             },
6250             },
6251             );
6252              
6253             # shot information for the D780 - ref #28
6254             %Image::ExifTool::Nikon::ShotInfoD780 = (
6255             PROCESS_PROC => \&ProcessNikonEncrypted,
6256             WRITE_PROC => \&ProcessNikonEncrypted,
6257             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6258             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x24 },
6259             DATAMEMBER => [ 0x04 ],
6260             IS_SUBDIR => [ 0x9c ],
6261             WRITABLE => 1,
6262             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6263             NOTES => 'These tags are extracted from encrypted data in images from the D780.',
6264             0x00 => {
6265             Name => 'ShotInfoVersion',
6266             Format => 'string[4]',
6267             Writable => 0,
6268             },
6269             0x04 => {
6270             Name => 'FirmwareVersion',
6271             DataMember => 'FirmwareVersion',
6272             Format => 'string[5]',
6273             Writable => 0,
6274             RawConv => '$$self{FirmwareVersion} = $val',
6275             },
6276             0x9c => {
6277             Name => 'OrientOffset',
6278             Format => 'int32u',
6279             SubDirectory => {
6280             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
6281             Start => '$val',
6282             },
6283             },
6284             );
6285              
6286             # shot information for the D5000 firmware 1.00 (encrypted) - ref PH
6287             %Image::ExifTool::Nikon::ShotInfoD5000 = (
6288             PROCESS_PROC => \&ProcessNikonEncrypted,
6289             WRITE_PROC => \&ProcessNikonEncrypted,
6290             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6291             VARS => { ID_LABEL => 'Index' },
6292             IS_SUBDIR => [ 0x378 ],
6293             WRITABLE => 1,
6294             FIRST_ENTRY => 0,
6295             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6296             NOTES => q{
6297             These tags are extracted from encrypted data in images from the D5000 with
6298             firmware 1.00.
6299             },
6300             0x00 => {
6301             Name => 'ShotInfoVersion',
6302             Format => 'string[4]',
6303             Writable => 0,
6304             },
6305             0x04 => {
6306             Name => 'FirmwareVersion',
6307             Format => 'string[5]',
6308             Writable => 0,
6309             },
6310             0x2b5 => { # (also found at 0x2c0)
6311             Name => 'ISO2',
6312             ValueConv => '100*exp(($val/12-5)*log(2))',
6313             ValueConvInv => '(log($val/100)/log(2)+5)*12',
6314             PrintConv => 'int($val + 0.5)',
6315             PrintConvInv => '$val',
6316             },
6317             0x2d6 => {
6318             Name => 'ShutterCount',
6319             Format => 'int32u',
6320             Priority => 0,
6321             },
6322             0x378 => {
6323             Name => 'CustomSettingsD5000',
6324             Format => 'undef[34]',
6325             SubDirectory => {
6326             TagTable => 'Image::ExifTool::NikonCustom::SettingsD5000',
6327             },
6328             },
6329             );
6330              
6331             # shot information for the D5100 firmware 1.00f (encrypted) - ref PH
6332             %Image::ExifTool::Nikon::ShotInfoD5100 = (
6333             PROCESS_PROC => \&ProcessNikonEncrypted,
6334             WRITE_PROC => \&ProcessNikonEncrypted,
6335             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6336             VARS => { ID_LABEL => 'Index' },
6337             IS_SUBDIR => [ 0x407 ],
6338             WRITABLE => 1,
6339             FIRST_ENTRY => 0,
6340             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6341             0x00 => {
6342             Name => 'ShotInfoVersion',
6343             Format => 'string[4]',
6344             Writable => 0,
6345             },
6346             0x04 => {
6347             Name => 'FirmwareVersion',
6348             Format => 'string[5]',
6349             Writable => 0,
6350             },
6351             0x321 => {
6352             Name => 'ShutterCount',
6353             Format => 'int32u',
6354             Priority => 0,
6355             },
6356             0x407 => {
6357             Name => 'CustomSettingsD5100',
6358             Format => 'undef[34]',
6359             SubDirectory => {
6360             TagTable => 'Image::ExifTool::NikonCustom::SettingsD5100',
6361             },
6362             },
6363             );
6364              
6365             # shot information for the D5200 firmware 1.00 (encrypted) - ref PH
6366             %Image::ExifTool::Nikon::ShotInfoD5200 = (
6367             PROCESS_PROC => \&ProcessNikonEncrypted,
6368             WRITE_PROC => \&ProcessNikonEncrypted,
6369             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6370             VARS => { ID_LABEL => 'Index' },
6371             IS_SUBDIR => [ 0xcd5 ],
6372             WRITABLE => 1,
6373             FIRST_ENTRY => 0,
6374             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6375             0x00 => {
6376             Name => 'ShotInfoVersion',
6377             Format => 'string[4]',
6378             Writable => 0,
6379             },
6380             0x04 => {
6381             Name => 'FirmwareVersion',
6382             Format => 'string[5]',
6383             Writable => 0,
6384             },
6385             # 0x101 - 2=VR Off, 3=VR On
6386             # 0x13d - 0=VR On, 1=VR Off
6387             0xbd8 => {
6388             Name => 'ShutterCount',
6389             Format => 'int32u',
6390             Priority => 0,
6391             },
6392             # 0xcd2 - 12=VR Off, 15=VR On
6393             0xcd5 => {
6394             Name => 'CustomSettingsD5200',
6395             Format => 'undef[34]',
6396             SubDirectory => {
6397             TagTable => 'Image::ExifTool::NikonCustom::SettingsD5200',
6398             },
6399             },
6400             );
6401              
6402             # shot information for the D7000 firmware 1.01d (encrypted) - ref 29
6403             %Image::ExifTool::Nikon::ShotInfoD7000 = (
6404             PROCESS_PROC => \&ProcessNikonEncrypted,
6405             WRITE_PROC => \&ProcessNikonEncrypted,
6406             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6407             VARS => { ID_LABEL => 'Index' },
6408             IS_SUBDIR => [ 1028 ],
6409             WRITABLE => 1,
6410             FIRST_ENTRY => 0,
6411             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6412             NOTES => q{
6413             These tags are extracted from encrypted data in images from the D7000 with
6414             firmware 1.01b.
6415             },
6416             0x00 => {
6417             Name => 'ShotInfoVersion',
6418             Format => 'string[4]',
6419             Writable => 0,
6420             },
6421             0x04 => {
6422             Name => 'FirmwareVersion',
6423             Format => 'string[5]',
6424             Writable => 0,
6425             },
6426             #613 => {
6427             # Name => 'ISO2',
6428             # ValueConv => '100*exp(($val/12-5)*log(2))',
6429             # ValueConvInv => '(log($val/100)/log(2)+5)*12',
6430             # PrintConv => 'int($val + 0.5)',
6431             # PrintConvInv => '$val',
6432             #},
6433             0x320 => { # 800
6434             Name => 'ShutterCount',
6435             Format => 'int32u',
6436             Priority => 0,
6437             },
6438             0x404 => { # 1028 (NC)
6439             Name => 'CustomSettingsD7000',
6440             Format => 'undef[48]',
6441             SubDirectory => {
6442             TagTable => 'Image::ExifTool::NikonCustom::SettingsD7000',
6443             },
6444             },
6445             );
6446              
6447             # shot information for the D7500 - ref #28
6448             %Image::ExifTool::Nikon::ShotInfoD7500 = (
6449             PROCESS_PROC => \&ProcessNikonEncrypted,
6450             WRITE_PROC => \&ProcessNikonEncrypted,
6451             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6452             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x0c },
6453             DATAMEMBER => [ 0x04 ],
6454             IS_SUBDIR => [ 0xa0 ],
6455             WRITABLE => 1,
6456             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6457             NOTES => 'These tags are extracted from encrypted data in images from the D7500.',
6458             0x00 => {
6459             Name => 'ShotInfoVersion',
6460             Format => 'string[4]',
6461             Writable => 0,
6462             },
6463             0x04 => {
6464             Name => 'FirmwareVersion',
6465             DataMember => 'FirmwareVersion',
6466             Format => 'string[5]',
6467             Writable => 0,
6468             RawConv => '$$self{FirmwareVersion} = $val',
6469             },
6470             0xa0 => {
6471             Name => 'OrientOffset',
6472             Format => 'int32u',
6473             SubDirectory => {
6474             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
6475             Start => '$val',
6476             },
6477             },
6478             );
6479              
6480             # shot information for the D800 firmware 1.01a (encrypted) - ref PH
6481             %Image::ExifTool::Nikon::ShotInfoD800 = (
6482             PROCESS_PROC => \&ProcessNikonEncrypted,
6483             WRITE_PROC => \&ProcessNikonEncrypted,
6484             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6485             VARS => { ID_LABEL => 'Index' },
6486             IS_SUBDIR => [ 0x6ec ],
6487             WRITABLE => 1,
6488             FIRST_ENTRY => 0,
6489             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6490             NOTES => 'These tags are extracted from encrypted data in images from the D800.',
6491             0x00 => {
6492             Name => 'ShotInfoVersion',
6493             Format => 'string[4]',
6494             Writable => 0,
6495             },
6496             0x04 => {
6497             Name => 'FirmwareVersion',
6498             Format => 'string[5]',
6499             Writable => 0,
6500             },
6501             0x4c0 => {
6502             Name => 'RepeatingFlashOutputExternal',
6503             ValueConv => '2 ** (-$val/6)',
6504             ValueConvInv => '$val > 0 ? -6*log($val)/log(2) : 0',
6505             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
6506             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
6507             },
6508             0x4c2 => {
6509             Name => 'RepeatingFlashRateExternal',
6510             DelValue => 0,
6511             RawConv => '$val || undef',
6512             PrintConv => '"$val Hz"',
6513             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
6514             },
6515             0x4c3 => {
6516             Name => 'RepeatingFlashCountExternal',
6517             DelValue => 0,
6518             RawConv => '$val || undef',
6519             },
6520             0x4d2 => {
6521             Name => 'FlashExposureComp2',
6522             Notes => 'includes the effect of flash bracketing',
6523             Format => 'int8s',
6524             ValueConv => '-$val/6',
6525             ValueConvInv => '-6 * $val',
6526             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
6527             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
6528             },
6529             # 0x4d4 - FEC again, doesn't include bracketing this time (internal?)
6530             # (not fully decoded, and duplicated in custom settings)
6531             # 0x4d9 => {
6532             # Name => 'FlashControlBuilt-in',
6533             # PrintConv => {
6534             # 1 => 'TTL',
6535             # 6 => 'Manual',
6536             # 7 => 'Repeating Flash',
6537             # },
6538             # },
6539             0x4da => {
6540             Name => 'RepeatingFlashRateBuilt-in',
6541             DelValue => 0,
6542             RawConv => '$val || undef',
6543             PrintConv => '"$val Hz"',
6544             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
6545             },
6546             0x4db => {
6547             Name => 'RepeatingFlashCountBuilt-in',
6548             DelValue => 0,
6549             RawConv => '$val || undef',
6550             },
6551             # 1294.1 => { # (0x4dc)
6552             # Name => 'FlashModeBuilt-in',
6553             # Mask => 0x0f,
6554             # PrintConv => {
6555             # 0 => 'Front-curtain Sync',
6556             # 1 => 'Red-eye Reduction',
6557             # 2 => 'Redy-eye Reduction with Slow Sync',
6558             # 3 => 'Slow Sync',
6559             # 4 => 'Rear-curtain Sync',
6560             # 5 => 'Rear-curtain Sync 2', # got this in P exposure mode
6561             # },
6562             # },
6563             # 1294.2 => { # (0x4dc)
6564             # Name => 'ExposureMode2',
6565             # Mask => 0xf0,
6566             # PrintConv => {
6567             # 0 => 'Program',
6568             # 1 => 'Aperture Priority',
6569             # 3 => 'Manual',
6570             # },
6571             # },
6572             # 0x511 - related to FlashSyncSpeed
6573             0x51c => 'SequenceNumber',
6574             # 0x4ba+0x63 - interesting
6575             # 0x4ba+0x68 - general downward trend
6576             # 0x4ba+0x7b - FlashControlBuilt-in: 8=TTL, 72=Manual
6577             # (not reliable)
6578             # 1346.1 => { # (0x542)
6579             # Name => 'RepeatingFlashOutputBuilt-in',
6580             # DelValue => 112,
6581             # Mask => 0xfc,
6582             # RawConv => '$val == 0x1c ? undef : 2 ** ($val/3-7)',
6583             # ValueConvInv => '$val > 0 ? (log($val)/log(2)+7)*3 : 0',
6584             # PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
6585             # PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
6586             # },
6587             0x5fb => {
6588             Name => 'ShutterCount',
6589             Format => 'int32u',
6590             },
6591             0x6ec => {
6592             Name => 'CustomSettingsD800',
6593             Format => 'undef[48]',
6594             SubDirectory => {
6595             TagTable => 'Image::ExifTool::NikonCustom::SettingsD800',
6596             },
6597             },
6598             );
6599              
6600             # shot information for the D5 firmware 1.10a and D500 firmware 1.01 (encrypted) - ref 28
6601             %Image::ExifTool::Nikon::ShotInfoD500 = (
6602             PROCESS_PROC => \&ProcessNikonEncrypted,
6603             WRITE_PROC => \&ProcessNikonEncrypted,
6604             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
6605             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x0c },
6606             DATAMEMBER => [ 0x04 ],
6607             IS_SUBDIR => [ 0x10, 0x14, 0x2c, 0x50, 0x58, 0xa0, 0xa8 ],
6608             WRITABLE => 1,
6609             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6610             NOTES => 'These tags are extracted from encrypted data in images from the D5 and D500.',
6611             0x00 => {
6612             Name => 'ShotInfoVersion',
6613             Format => 'string[4]',
6614             Writable => 0,
6615             },
6616             0x04 => {
6617             Name => 'FirmwareVersion',
6618             DataMember => 'FirmwareVersion',
6619             Format => 'string[5]',
6620             Writable => 0,
6621             RawConv => '$$self{FirmwareVersion} = $val',
6622             },
6623             0x10 => {
6624             Name => 'RotationInfoOffset',
6625             Format => 'int32u',
6626             SubDirectory => {
6627             TagTable => 'Image::ExifTool::Nikon::RotationInfoD500',
6628             Start => '$val',
6629             }
6630             },
6631             0x14 => {
6632             Name => 'JPGInfoOffset',
6633             Format => 'int32u',
6634             SubDirectory => {
6635             TagTable => 'Image::ExifTool::Nikon::JPGInfoD500',
6636             Start => '$val',
6637             }
6638             },
6639             0x2c => {
6640             Name => 'BracketingOffset',
6641             Format => 'int32u',
6642             SubDirectory => {
6643             TagTable => 'Image::ExifTool::Nikon::BracketingInfoD500',
6644             Start => '$val',
6645             }
6646             },
6647             0x50 => {
6648             Name => 'ShootingMenuOffset',
6649             Format => 'int32u',
6650             SubDirectory => {
6651             TagTable => 'Image::ExifTool::Nikon::ShootingMenuD500',
6652             Start => '$val',
6653             }
6654             },
6655             0x58 => {
6656             Name => 'CustomSettingsOffset',
6657             Format => 'int32u',
6658             SubDirectory => {
6659             TagTable => 'Image::ExifTool::Nikon::CustomSettingsD500',
6660             Start => '$val',
6661             }
6662             },
6663             0xa0 => {
6664             Name => 'OrientationOffset',
6665             Format => 'int32u',
6666             SubDirectory => {
6667             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
6668             Start => '$val',
6669             }
6670             },
6671             0xa8 => {
6672             Name => 'OtherOffset',
6673             Format => 'int32u',
6674             SubDirectory => {
6675             TagTable => 'Image::ExifTool::Nikon::OtherInfoD500',
6676             Start => '$val',
6677             }
6678             },
6679             );
6680              
6681             %Image::ExifTool::Nikon::RotationInfoD500 = (
6682             %binaryDataAttrs,
6683             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6684             0x1a => {
6685             Name => 'Rotation',
6686             Mask => 0x03,
6687             PrintConv => {
6688             0 => 'Horizontal',
6689             1 => 'Rotate 270 CW',
6690             2 => 'Rotate 90 CW',
6691             3 => 'Rotate 180',
6692             },
6693             },
6694             0x20 => {
6695             Name => 'Interval',
6696             # prior version of the d% firmware do not support this tag, nor does the D500 (at least thru firmware 1.3)
6697             Condition => '$$self{Model} eq "NIKON D5" and $$self{FirmwareVersion} ge "1.40"',
6698             PrintConv => '$val > 0 ? sprintf("%.0f", $val) : ""',
6699             },
6700             0x24 => {
6701             Name => 'IntervalFrame',
6702             # prior version of the d% firmware do not support this tag, nor does the D500 (at least thru firmware 1.3)
6703             Condition => '$$self{Model} eq "NIKON D5" and $$self{FirmwareVersion} ge "1.40"',
6704             PrintConv => '$val > 0 ? sprintf("%.0f", $val) : ""',
6705             },
6706             0x0532 => {
6707             Name => 'FlickerReductionIndicator',
6708             Mask => 0x01,
6709             PrintConv => { 0 => 'On', 1 => 'Off' },
6710             },
6711             );
6712              
6713             %Image::ExifTool::Nikon::JPGInfoD500 = (
6714             %binaryDataAttrs,
6715             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6716             0x24 => {
6717             Name => 'JPGCompression',
6718             Mask => 0x01,
6719             PrintConv => {
6720             0 => 'Size Priority',
6721             1 => 'Optimal Quality',
6722             },
6723             },
6724             );
6725              
6726             %Image::ExifTool::Nikon::BracketingInfoD500 = (
6727             %binaryDataAttrs,
6728             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6729             0x0f => {
6730             Name => 'AEBracketingSteps',
6731             Condition => '$$self{FILE_TYPE} ne "TIFF"', # (covers NEF and TIFF)
6732             Mask => 0xff,
6733             PrintHex => 1,
6734             PrintConvColumns => 2,
6735             PrintConv => {
6736             0x00 => 'AE Bracketing Disabled',
6737             0x20 => 'AE Bracketing Disabled',
6738             0x30 => 'AE Bracketing Disabled',
6739             0x40 => 'AE Bracketing Disabled',
6740             0x50 => 'AE Bracketing Disabled',
6741             0x81 => '+3F0.3',
6742             0x82 => '-3F0.3',
6743             0x83 => '+2F0.3',
6744             0x84 => '-2F0.3',
6745             0x85 => '3F0.3',
6746             0x86 => '5F0.3',
6747             0x87 => '7F0.3',
6748             0x88 => '9F0.3',
6749             0x91 => '+3F0.5',
6750             0x92 => '-3F0.5',
6751             0x93 => '+2F0.5',
6752             0x94 => '-2F0.5',
6753             0x95 => '3F0.5',
6754             0x96 => '5F0.5',
6755             0x97 => '7F0.5',
6756             0x98 => '9F0.5',
6757             0xa1 => '+3F0.7',
6758             0xa2 => '-3F0.7',
6759             0xa3 => '+2F0.7',
6760             0xa4 => '-2F0.7',
6761             0xa5 => '3F0.7',
6762             0xa6 => '5F0.7',
6763             0xa7 => '7F0.7',
6764             0xa8 => '9F0.7',
6765             0xb1 => '+3F1',
6766             0xb2 => '-3F1',
6767             0xb3 => '+2F1',
6768             0xb4 => '-2F1',
6769             0xb5 => '3F1',
6770             0xb6 => '5F1',
6771             0xb7 => '7F1',
6772             0xb8 => '9F1',
6773             0xc1 => '+3F2',
6774             0xc2 => '-3F2',
6775             0xc3 => '+2F2',
6776             0xc4 => '-2F2',
6777             0xc5 => '3F2',
6778             0xc6 => '5F2',
6779             0xd1 => '+3F3',
6780             0xd2 => '-3F3',
6781             0xd3 => '+2F3',
6782             0xd4 => '-2F3',
6783             0xd5 => '3F3',
6784             0xd6 => '5F3',
6785             },
6786             },
6787             0x10 => {
6788             Name => 'WBBracketingSteps',
6789             Condition => '$$self{FILE_TYPE} ne "TIFF"', # (covers NEF and TIFF)
6790             Mask => 0xff,
6791             PrintHex => 1,
6792             PrintConvColumns => 2,
6793             PrintConv => {
6794             0x00 => 'WB Bracketing Disabled',
6795             0x01 => 'b3F 1',
6796             0x02 => 'A3F 1',
6797             0x03 => 'b2F 1',
6798             0x04 => 'A2F 1',
6799             0x05 => '3F 1',
6800             0x06 => '5F 1',
6801             0x07 => '7F 1',
6802             0x08 => '9F 1',
6803             0x10 => '0F 2',
6804             0x11 => 'b3F 2',
6805             0x12 => 'A3F 2',
6806             0x13 => 'b2F 2',
6807             0x14 => 'A2F 2',
6808             0x15 => '3F 2',
6809             0x16 => '5F 2',
6810             0x17 => '7F 2',
6811             0x18 => '9F 2',
6812             0x20 => '0F 3',
6813             0x21 => 'b3F 3',
6814             0x22 => 'A3F 3',
6815             0x23 => 'b2F 3',
6816             0x24 => 'A2F 3',
6817             0x25 => '3F 3',
6818             0x26 => '5F 3',
6819             0x27 => '7F 3',
6820             0x28 => '9F 3',
6821             0x22 => 'A3F 3',
6822             0x23 => 'b2F 3',
6823             0x24 => 'A2F 3',
6824             0x25 => '3F 3',
6825             0x26 => '5F 3',
6826             0x27 => '7F 3',
6827             0x28 => '9F 3',
6828             },
6829             },
6830             0x17 => {
6831             Name => 'ADLBracketingStep',
6832             Mask => 0xf0,
6833             PrintConv => {
6834             0 => 'Off',
6835             1 => 'Low',
6836             2 => 'Normal',
6837             3 => 'High',
6838             4 => 'Extra High',
6839             8 => 'Auto',
6840             },
6841             },
6842             0x18 => {
6843             Name => 'ADLBracketingType',
6844             Mask => 0x0f,
6845             PrintConv => {
6846             0 => 'Off',
6847             1 => '2 Shots',
6848             2 => '3 Shots',
6849             3 => '4 Shots',
6850             4 => '5 Shots',
6851             },
6852             },
6853             );
6854              
6855             %Image::ExifTool::Nikon::ShootingMenuD500 = (
6856             %binaryDataAttrs,
6857             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6858             0x00 => {
6859             Name => 'PhotoShootingMenuBank',
6860             Mask => 0x03,
6861             PrintConv => {
6862             0 => 'A',
6863             1 => 'B',
6864             2 => 'C',
6865             3 => 'D',
6866             },
6867             },
6868             0x02 => {
6869             Name => 'PrimarySlot',
6870             Condition => '$$self{Model} =~ /\bD500\b/',
6871             Notes => 'D500 only',
6872             Mask => 0x80,
6873             PrintConv => {
6874             0 => 'XQD Card',
6875             1 => 'SD Card',
6876             },
6877             },
6878             0x04 => {
6879             Name => 'ISOAutoShutterTime',
6880             Mask => 0x3f,
6881             PrintConv => {
6882             0 => '1/4000 s',
6883             1 => '1/3200 s',
6884             2 => '1/2500 s',
6885             3 => '1/2000 s',
6886             4 => '1/1600 s',
6887             5 => '1/1250 s',
6888             6 => '1/1000 s',
6889             7 => '1/800 s',
6890             8 => '1/640 s',
6891             9 => '1/500 s',
6892             10 => '1/400 s',
6893             11 => '1/320 s',
6894             12 => '1/250 s',
6895             13 => '1/200 s',
6896             14 => '1/160 s',
6897             15 => '1/125 s',
6898             16 => '1/100 s',
6899             17 => '1/80 s',
6900             18 => '1/60 s',
6901             19 => '1/50 s',
6902             20 => '1/40 s',
6903             21 => '1/30 s',
6904             22 => '1/15 s',
6905             23 => '1/8 s',
6906             24 => '1/4 s',
6907             25 => '1/2 s',
6908             26 => '1 s',
6909             27 => '2 s',
6910             28 => '4 s',
6911             29 => '8 s',
6912             30 => '15 s',
6913             31 => '30 s',
6914             32 => 'Auto (Slowest)',
6915             33 => 'Auto (Slower)',
6916             34 => 'Auto',
6917             35 => 'Auto (Faster)',
6918             36 => 'Auto (Fastest)',
6919             },
6920             },
6921             0x05 => {
6922             Name => 'ISOAutoHiLimit',
6923             Mask => 0xff,
6924             PrintHex => 1,
6925             PrintConv => {
6926             0x24 => 'ISO 200',
6927             0x26 => 'ISO 250',
6928             0x27 => 'ISO 280',
6929             0x28 => 'ISO 320',
6930             0x2a => 'ISO 400',
6931             0x2c => 'ISO 500',
6932             0x2d => 'ISO 560',
6933             0x2e => 'ISO 640',
6934             0x30 => 'ISO 800',
6935             0x32 => 'ISO 1000',
6936             0x33 => 'ISO 1100',
6937             0x34 => 'ISO 1250',
6938             0x36 => 'ISO 1600',
6939             0x38 => 'ISO 2000',
6940             0x39 => 'ISO 2200',
6941             0x3a => 'ISO 2500',
6942             0x3c => 'ISO 3200',
6943             0x3e => 'ISO 4000',
6944             0x3f => 'ISO 4500',
6945             0x40 => 'ISO 5000',
6946             0x42 => 'ISO 6400',
6947             0x44 => 'ISO 8000',
6948             0x45 => 'ISO 9000',
6949             0x46 => 'ISO 10000',
6950             0x48 => 'ISO 12800',
6951             0x4a => 'ISO 16000',
6952             0x4b => 'ISO 18000',
6953             0x4c => 'ISO 20000',
6954             0x4e => 'ISO 25600',
6955             0x50 => 'ISO 32000',
6956             0x51 => 'ISO 36000',
6957             0x52 => 'ISO 40000',
6958             0x54 => 'ISO 51200',
6959             0x56 => 'ISO Hi 0.3',
6960             0x57 => 'ISO Hi 0.5',
6961             0x58 => 'ISO Hi 0.7',
6962             0x5a => 'ISO Hi 1.0',
6963             0x60 => 'ISO Hi 2.0',
6964             0x66 => 'ISO Hi 3.0',
6965             0x6c => 'ISO Hi 4.0',
6966             0x72 => 'ISO Hi 5.0',
6967             },
6968             },
6969             0x07 => {
6970             Name => 'FlickerReduction',
6971             Mask => 0x20,
6972             PrintConv => {
6973             0 => 'Enable',
6974             1 => 'Disable',
6975             },
6976             },
6977             7.1 => {
6978             Name => 'PhotoShootingMenuBankImageArea',
6979             Mask => 0x07,
6980             PrintConv => {
6981             0 => 'FX (36x24)',
6982             1 => 'DX (24x16)',
6983             2 => '5:4 (30x24)',
6984             3 => '1.2x (30x20)',
6985             4 => '1.3x (18x12)',
6986             },
6987             },
6988             );
6989              
6990             %Image::ExifTool::Nikon::CustomSettingsD500 = (
6991             %binaryDataAttrs,
6992             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6993             IS_SUBDIR => [ 0x00 ],
6994             VARS => { ALLOW_REPROCESS => 1 }, # (necessary because subdirectory is at offset 0)
6995             0x00 => [{
6996             Name => 'CustomSettingsD5',
6997             Condition => '$$self{Model} =~ /\bD5\b/',
6998             Format => 'undef[90]',
6999             SubDirectory => {
7000             TagTable => 'Image::ExifTool::NikonCustom::SettingsD5',
7001             },
7002             },{
7003             Name => 'CustomSettingsD500',
7004             Format => 'undef[90]',
7005             SubDirectory => {
7006             TagTable => 'Image::ExifTool::NikonCustom::SettingsD500',
7007             },
7008             }],
7009             # 0x7d => { #this decode works, but involves more bits than should be necessary
7010             # Name => 'ShutterTrigger',
7011             # Mask => 0xff,
7012             # PrintConv => {
7013             # 0 => 'Timer',
7014             # 15 => 'Cable Release/Remote',
7015             # 195 => 'Shutter Button',
7016             # },
7017             # },
7018             );
7019              
7020             %Image::ExifTool::Nikon::OtherInfoD500 = (
7021             %binaryDataAttrs,
7022             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7023             # (needs testing)
7024             #0x22 => {
7025             # Name => 'ExtendedPhotoShootingBanks',
7026             # Mask => 0x01,
7027             # PrintConv => {
7028             # 0 => 'On',
7029             # 1 => 'Off',
7030             # },
7031             #},
7032             # (may not be reliable and is found elsewhere)
7033             #0x212 => {
7034             # Name => 'Rotation',
7035             # Condition => '$$self{Model} =~ /\bD500\b/',
7036             # Notes => 'D500 firmware 1.1x',
7037             # Mask => 0x30,
7038             # PrintConv => {
7039             # 0 => 'Horizontal',
7040             # 1 => 'Rotate 270 CW',
7041             # 2 => 'Rotate 90 CW',
7042             # 3 => 'Rotate 180',
7043             # },
7044             #},
7045             0x214 => { #PH
7046             Name => 'NikonMeteringMode',
7047             Condition => '$$self{Model} =~ /\bD500\b/', # (didn't seem to work for D5, but I need more samples)
7048             Notes => 'D500 only',
7049             Mask => 0x03,
7050             PrintConv => {
7051             0 => 'Matrix',
7052             1 => 'Center',
7053             2 => 'Spot',
7054             3 => 'Highlight'
7055             },
7056             },
7057             );
7058              
7059             # shot information for the D6 firmware 1.00 (encrypted) - ref 28
7060             %Image::ExifTool::Nikon::ShotInfoD6 = (
7061             PROCESS_PROC => \&ProcessNikonEncrypted,
7062             WRITE_PROC => \&ProcessNikonEncrypted,
7063             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7064             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x24 },
7065             IS_SUBDIR => [ 0x30, 0x9c, 0xa4 ],
7066             WRITABLE => 1,
7067             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7068             NOTES => 'These tags are extracted from encrypted data in images from the D6.',
7069             0x00 => {
7070             Name => 'ShotInfoVersion',
7071             Format => 'string[4]',
7072             Writable => 0,
7073             },
7074             0x04 => {
7075             Name => 'FirmwareVersion',
7076             Format => 'string[8]',
7077             Writable => 0,
7078             },
7079             0x24 => {
7080             Name => 'NumberOffsets', # (number of entries in offset table. offsets are from start of ShotInfo data)
7081             Format => 'int32u',
7082             Writable => 0,
7083             Hidden => 1,
7084             },
7085             0x30 => {
7086             Name => 'SequenceOffset',
7087             Format => 'int32u',
7088             SubDirectory => {
7089             TagTable => 'Image::ExifTool::Nikon::SeqInfoD6',
7090             Start => '$val',
7091             },
7092             },
7093             0x9c => {
7094             Name => 'OrientationOffset',
7095             Format => 'int32u',
7096             SubDirectory => {
7097             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
7098             Start => '$val',
7099             },
7100             },
7101             0xa4 => {
7102             Name => 'IntervalOffset',
7103             Format => 'int32u',
7104             SubDirectory => {
7105             TagTable => 'Image::ExifTool::Nikon::IntervalInfoD6',
7106             Start => '$val',
7107             }
7108             },
7109             );
7110              
7111             %Image::ExifTool::Nikon::SeqInfoD6 = (
7112             %binaryDataAttrs,
7113             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7114             DATAMEMBER => [ 0x24, 0x28 ],
7115             0x24 => {
7116             Name => 'IntervalShooting',
7117             RawConv => '$$self{IntervalShooting} = $val',
7118             Format => 'int16u',
7119             PrintConv => q{
7120             return 'Off' if $val == 0 ;
7121             my $i = sprintf("Interval %.0f of %.0f",$val, $$self{IntervalShootingIntervals}||0); #something like "Interval 1 of 3"
7122             my $f = ($$self{IntervalShootingShotsPerInterval}||0) > 1 ? sprintf(" Frame %.0f of %.0f",$$self{IntervalFrame}||0, $$self{IntervalShootingShotsPerInterval}||0): '' ; #something like "Frame 1 of 3" or blank
7123             return "On: $i$f"
7124             #$val == 0 ? 'Off' : sprintf("On: Interval %.0f of %.0f Frame %.0f of %.0f",$val, $$self{IntervalShootingIntervals}||0, $$self{IntervalFrame}||0, $$self{IntervalShootingShotsPerInterval}||0),
7125             },
7126             },
7127             0x28 => {
7128             Name => 'IntervalFrame',
7129             RawConv => '$$self{IntervalFrame} = $val',
7130             Condition => '$$self{IntervalShooting} > 0',
7131             Format => 'int16u',
7132             Hidden => 1,
7133             },
7134             );
7135              
7136             %Image::ExifTool::Nikon::IntervalInfoD6 = (
7137             %binaryDataAttrs,
7138             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7139             DATAMEMBER => [ 0x17c, 0x180, 0x214, 0x22c ],
7140             0x17c => {
7141             Name => 'Intervals',
7142             Format => 'int32u',
7143             RawConv => '$$self{IntervalShootingIntervals} = $val',
7144             Condition => '$$self{IntervalShooting} > 0',
7145             },
7146             0x180 => {
7147             Name => 'ShotsPerInterval',
7148             Format => 'int32u',
7149             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
7150             Condition => '$$self{IntervalShooting} > 0',
7151             },
7152             0x184 => {
7153             Name => 'IntervalExposureSmoothing',
7154             Condition => '$$self{IntervalShooting} > 0',
7155             Format => 'int8u',
7156             PrintConv => \%offOn,
7157             },
7158             0x186 => {
7159             Name => 'IntervalPriority',
7160             Condition => '$$self{IntervalShooting} > 0',
7161             Format => 'int8u',
7162             PrintConv => \%offOn,
7163             },
7164             0x1a8 => {
7165             Name => 'FocusShiftNumberShots',
7166             },
7167             0x1ac => {
7168             Name => 'FocusShiftStepWidth',
7169             },
7170             0x1b0 => {
7171             Name => 'FocusShiftInterval',
7172             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
7173             },
7174             0x1b4 => {
7175             Name => 'FocusShiftExposureLock',
7176             PrintConv => \%offOn,
7177             },
7178             #0x20a => HighISONoiseReduction
7179             0x20e => {
7180             Name => 'DiffractionCompensation',
7181             Format => 'int8u',
7182             PrintConv => \%offOn,
7183             },
7184             #0x20f => {Name => 'FlickerReductionShooting',}, #redundant with tag in NikonSettings
7185             0x214 => {
7186             Name => 'FlashControlMode', #this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
7187             RawConv => '$$self{FlashControlMode} = $val',
7188             PrintConv => {
7189             0 => 'TTL',
7190             1 => 'Auto External Flash',
7191             2 => 'GN (distance priority)',
7192             3 => 'Manual',
7193             4 => 'Repeating Flash',
7194             },
7195             },
7196             0x21a => {
7197             Name => 'FlashGNDistance',
7198             Condition => '$$self{FlashControlMode} == 2',
7199             Unknown => 1,
7200             ValueConv => '$val + 3',
7201             PrintConv => \%flashGNDistance,
7202             },
7203             0x21e => {
7204             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)
7205             Condition => '$$self{FlashControlMode} >= 3',
7206             Unknown => 1,
7207             ValueConv => '2 ** (-$val/3)',
7208             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
7209             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
7210             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
7211             },
7212             0x228 => {
7213             Name => 'FlashRemoteControl',
7214             Unknown => 1,
7215             PrintConv => {
7216             0 => 'Group',
7217             1 => 'Quick Wireless',
7218             2 => 'Remote Repeating',
7219             },
7220             },
7221             0x22c => {
7222             Name => 'FlashMasterControlMode', #tag name chosen for compatibility with those found in FlashInfo0102 & FlashInfo0103
7223             RawConv => '$$self{FlashGroupOptionsMasterMode} = $val',
7224             PrintConv => \%flashGroupOptionsMode,
7225             },
7226             0x22e => {
7227             Name => 'FlashMasterCompensation',
7228             Unknown => 1,
7229             Format => 'int8s',
7230             Condition => '$$self{FlashGroupOptionsMasterMode} != 3', #other than 'Off'
7231             ValueConv => '$val/6',
7232             ValueConvInv => '6 * $val',
7233             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
7234             PrintConvInv => '$val',
7235             },
7236             0x232 => {
7237             Name => 'FlashMasterOutput',
7238             Unknown => 1,
7239             Condition => '$$self{FlashGroupOptionsMasterMode} == 1', #only for Mode=M
7240             ValueConv => '2 ** (-$val/3)',
7241             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
7242             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
7243             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
7244             },
7245             0x234 => {
7246             Name => 'FlashWirelessOption',
7247             Unknown => 1,
7248             PrintConv => {
7249             0 => 'Optical AWL',
7250             1 => 'Off',
7251             },
7252             },
7253             0x2ca => {
7254             Name => 'MovieType',
7255             Unknown => 1,
7256             PrintConv => {
7257             0 => 'MOV',
7258             1 => 'MP4',
7259             },
7260             },
7261             );
7262              
7263             # shot information for the D610 firmware 1.00 (encrypted) - ref PH
7264             %Image::ExifTool::Nikon::ShotInfoD610 = (
7265             PROCESS_PROC => \&ProcessNikonEncrypted,
7266             WRITE_PROC => \&ProcessNikonEncrypted,
7267             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7268             VARS => { ID_LABEL => 'Index' },
7269             IS_SUBDIR => [ 0x07cf ],
7270             WRITABLE => 1,
7271             FIRST_ENTRY => 0,
7272             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7273             NOTES => 'These tags are extracted from encrypted data in images from the D610.',
7274             0x00 => {
7275             Name => 'ShotInfoVersion',
7276             Format => 'string[4]',
7277             Writable => 0,
7278             },
7279             0x04 => {
7280             Name => 'FirmwareVersion',
7281             Format => 'string[5]',
7282             Writable => 0,
7283             },
7284             0x07cf => {
7285             Name => 'CustomSettingsD610',
7286             Format => 'undef[48]',
7287             SubDirectory => {
7288             TagTable => 'Image::ExifTool::NikonCustom::SettingsD610',
7289             },
7290             },
7291             );
7292              
7293             # shot information for the D810 firmware 1.00(PH)/1.01 (encrypted) - ref 28
7294             %Image::ExifTool::Nikon::ShotInfoD810 = (
7295             PROCESS_PROC => \&ProcessNikonEncrypted,
7296             WRITE_PROC => \&ProcessNikonEncrypted,
7297             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7298             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x0c },
7299             DATAMEMBER => [ 0x04 ],
7300             IS_SUBDIR => [ 0x10, 0x24, 0x38, 0x40, 0x84 ],
7301             WRITABLE => 1,
7302             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7303             NOTES => 'These tags are extracted from encrypted data in images from the D810.',
7304             0x00 => {
7305             Name => 'ShotInfoVersion',
7306             Format => 'string[4]',
7307             Writable => 0,
7308             },
7309             0x04 => {
7310             Name => 'FirmwareVersion',
7311             DataMember => 'FirmwareVersion',
7312             Format => 'string[5]',
7313             Writable => 0,
7314             RawConv => '$$self{FirmwareVersion} = $val',
7315             },
7316             # 0x0c - number of entries in offset table (= 0x21)
7317             # 0x10 - int32u[val 0x0c]: offset table
7318             0x10 => {
7319             Name => 'SettingsOffset',
7320             Format => 'int32u',
7321             SubDirectory => {
7322             TagTable => 'Image::ExifTool::Nikon::SettingsInfoD810',
7323             Start => '$val',
7324             },
7325             },
7326             0x24 => {
7327             Name => 'BracketingOffset',
7328             Format => 'int32u',
7329             SubDirectory => {
7330             TagTable => 'Image::ExifTool::Nikon::BracketingInfoD810',
7331             Start => '$val',
7332             },
7333             },
7334             0x38 => {
7335             Name => 'ISOAutoOffset',
7336             Format => 'int32u',
7337             SubDirectory => {
7338             TagTable => 'Image::ExifTool::Nikon::ISOAutoInfoD810',
7339             Start => '$val',
7340             },
7341             },
7342             0x40 => {
7343             Name => 'CustomSettingsOffset', # (relative offset from start of ShotInfo data)
7344             Format => 'int32u',
7345             SubDirectory => {
7346             TagTable => 'Image::ExifTool::NikonCustom::SettingsD810',
7347             Start => '$val',
7348             },
7349             },
7350             0x84 => {
7351             Name => 'OrientationOffset',
7352             Format => 'int32u',
7353             SubDirectory => {
7354             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
7355             Start => '$val',
7356             }
7357             },
7358             # (moves around too much and doesn't fit cleanly in the offset table)
7359             #0x38be => {
7360             # Name => 'Rotation',
7361             # Condition => '$$self{FirmwareVersion} =~ /^1\.0/',
7362             # Mask => 0x30,
7363             # PrintConv => {
7364             # 0 => 'Horizontal',
7365             # 1 => 'Rotate 270 CW',
7366             # 2 => 'Rotate 90 CW',
7367             # 3 => 'Rotate 180',
7368             # },
7369             #},
7370             );
7371              
7372             %Image::ExifTool::Nikon::SettingsInfoD810 = (
7373             %binaryDataAttrs,
7374             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7375             0x13c => {
7376             Name => 'SecondarySlotFunction',
7377             Mask => 0x03,
7378             PrintConv => {
7379             0 => 'Overflow',
7380             2 => 'Backup',
7381             3 => 'NEF Primary + JPG Secondary',
7382             },
7383             },
7384             );
7385              
7386             %Image::ExifTool::Nikon::BracketingInfoD810 = (
7387             %binaryDataAttrs,
7388             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7389             0x0f => {
7390             Name => 'AEBracketingSteps',
7391             Mask => 0xff,
7392             PrintHex => 1,
7393             PrintConvColumns => 2,
7394             PrintConv => {
7395             0x00 => 'AE Bracketing Disabled',
7396             0x20 => 'AE Bracketing Disabled',
7397             0x30 => 'AE Bracketing Disabled',
7398             0x40 => 'AE Bracketing Disabled',
7399             0x50 => 'AE Bracketing Disabled',
7400             0x81 => '+3F0.3',
7401             0x82 => '-3F0.3',
7402             0x83 => '+2F0.3',
7403             0x84 => '-2F0.3',
7404             0x85 => '3F0.3',
7405             0x86 => '5F0.3',
7406             0x87 => '7F0.3',
7407             0x88 => '9F0.3',
7408             0x91 => '+3F0.5',
7409             0x92 => '-3F0.5',
7410             0x93 => '+2F0.5',
7411             0x94 => '-2F0.5',
7412             0x95 => '3F0.5',
7413             0x96 => '5F0.5',
7414             0x97 => '7F0.5',
7415             0x98 => '9F0.5',
7416             0xa1 => '+3F0.7',
7417             0xa2 => '-3F0.7',
7418             0xa3 => '+2F0.7',
7419             0xa4 => '-2F0.7',
7420             0xa5 => '3F0.7',
7421             0xa6 => '5F0.7',
7422             0xa7 => '7F0.7',
7423             0xa8 => '9F0.7',
7424             0xb1 => '+3F1',
7425             0xb2 => '-3F1',
7426             0xb3 => '+2F1',
7427             0xb4 => '-2F1',
7428             0xb5 => '3F1',
7429             0xb6 => '5F1',
7430             0xb7 => '7F1',
7431             0xb8 => '9F1',
7432             0xc1 => '+3F2',
7433             0xc2 => '-3F2',
7434             0xc3 => '+2F2',
7435             0xc4 => '-2F2',
7436             0xc5 => '3F2',
7437             0xc6 => '5F2',
7438             0xd1 => '+3F3',
7439             0xd2 => '-3F3',
7440             0xd3 => '+2F3',
7441             0xd4 => '-2F3',
7442             0xd5 => '3F3',
7443             0xd6 => '5F3',
7444             },
7445             },
7446             0x10 => {
7447             Name => 'WBBracketingSteps',
7448             Condition => '$$self{FILE_TYPE} ne "TIFF"', # (covers NEF and TIFF)
7449             Mask => 0xff,
7450             PrintHex => 1,
7451             PrintConvColumns => 2,
7452             PrintConv => {
7453             0x00 => 'WB Bracketing Disabled',
7454             0x01 => 'b3F 1',
7455             0x02 => 'A3F 1',
7456             0x03 => 'b2F 1',
7457             0x04 => 'A2F 1',
7458             0x05 => '3F 1',
7459             0x06 => '5F 1',
7460             0x07 => '7F 1',
7461             0x08 => '9F 1',
7462             0x10 => '0F 2',
7463             0x11 => 'b3F 2',
7464             0x12 => 'A3F 2',
7465             0x13 => 'b2F 2',
7466             0x14 => 'A2F 2',
7467             0x15 => '3F 2',
7468             0x16 => '5F 2',
7469             0x17 => '7F 2',
7470             0x18 => '9F 2',
7471             0x20 => '0F 3',
7472             0x21 => 'b3F 3',
7473             0x22 => 'A3F 3',
7474             0x23 => 'b2F 3',
7475             0x24 => 'A2F 3',
7476             0x25 => '3F 3',
7477             0x26 => '5F 3',
7478             0x27 => '7F 3',
7479             0x28 => '9F 3',
7480             0x22 => 'A3F 3',
7481             0x23 => 'b2F 3',
7482             0x24 => 'A2F 3',
7483             0x25 => '3F 3',
7484             0x26 => '5F 3',
7485             0x27 => '7F 3',
7486             0x28 => '9F 3',
7487             },
7488             },
7489             0x17 => {
7490             Name => 'NikonMeteringMode',
7491             Mask => 0x03,
7492             PrintConv => {
7493             0 => 'Matrix',
7494             1 => 'Center',
7495             2 => 'Spot',
7496             3 => 'Highlight'
7497             },
7498             },
7499             );
7500              
7501             %Image::ExifTool::Nikon::ISOAutoInfoD810 = (
7502             %binaryDataAttrs,
7503             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7504             0x04 => {
7505             Name => 'ISOAutoShutterTime',
7506             Mask => 0x3f,
7507             PrintConv => {
7508             0 => '1/4000 s',
7509             1 => '1/3200 s',
7510             2 => '1/2500 s',
7511             3 => '1/2000 s',
7512             4 => '1/1600 s',
7513             5 => '1/1250 s',
7514             6 => '1/1000 s',
7515             7 => '1/800 s',
7516             8 => '1/640 s',
7517             9 => '1/500 s',
7518             10 => '1/400 s',
7519             11 => '1/320 s',
7520             12 => '1/250 s',
7521             13 => '1/200 s',
7522             14 => '1/160 s',
7523             15 => '1/125 s',
7524             16 => '1/100 s',
7525             17 => '1/80 s',
7526             18 => '1/60 s',
7527             19 => '1/50 s',
7528             20 => '1/40 s',
7529             21 => '1/30 s',
7530             22 => '1/15 s',
7531             23 => '1/8 s',
7532             24 => '1/4 s',
7533             25 => '1/2 s',
7534             26 => '1 s',
7535             27 => '2 s',
7536             28 => '4 s',
7537             29 => '8 s',
7538             30 => '15 s',
7539             31 => '30 s',
7540             32 => 'Auto (Slowest)',
7541             33 => 'Auto (Slower)',
7542             34 => 'Auto',
7543             35 => 'Auto (Faster)',
7544             36 => 'Auto (Fastest)',
7545             },
7546             },
7547             0x05 => {
7548             Name => 'ISOAutoHiLimit',
7549             Mask => 0xff,
7550             PrintHex => 1,
7551             PrintConv => {
7552             0x24 => 'ISO 200',
7553             0x26 => 'ISO 250',
7554             0x27 => 'ISO 280',
7555             0x28 => 'ISO 320',
7556             0x2a => 'ISO 400',
7557             0x2c => 'ISO 500',
7558             0x2d => 'ISO 560',
7559             0x2e => 'ISO 640',
7560             0x30 => 'ISO 800',
7561             0x32 => 'ISO 1000',
7562             0x33 => 'ISO 1100',
7563             0x34 => 'ISO 1250',
7564             0x36 => 'ISO 1600',
7565             0x38 => 'ISO 2000',
7566             0x39 => 'ISO 2200',
7567             0x3a => 'ISO 2500',
7568             0x3c => 'ISO 3200',
7569             0x3e => 'ISO 4000',
7570             0x3f => 'ISO 4500',
7571             0x40 => 'ISO 5000',
7572             0x42 => 'ISO 6400',
7573             0x44 => 'ISO 8000',
7574             0x45 => 'ISO 9000',
7575             0x46 => 'ISO 10000',
7576             0x48 => 'ISO 12800',
7577             0x4a => 'ISO 16000',
7578             0x4b => 'ISO 18000',
7579             0x4c => 'ISO 20000',
7580             0x4e => 'ISO 25600',
7581             0x50 => 'ISO 32000',
7582             0x51 => 'ISO 36000',
7583             0x52 => 'ISO 40000',
7584             0x54 => 'ISO 51200',
7585             0x56 => 'ISO Hi 0.3',
7586             0x57 => 'ISO Hi 0.5',
7587             0x58 => 'ISO Hi 0.7',
7588             0x5a => 'ISO Hi 1.0',
7589             0x60 => 'ISO Hi 2.0',
7590             0x66 => 'ISO Hi 3.0',
7591             0x6c => 'ISO Hi 4.0',
7592             0x72 => 'ISO Hi 5.0',
7593             },
7594             },
7595             );
7596              
7597             # shot information for the D850 firmware 1.00b (encrypted) - ref 28
7598             %Image::ExifTool::Nikon::ShotInfoD850 = (
7599             PROCESS_PROC => \&ProcessNikonEncrypted,
7600             WRITE_PROC => \&ProcessNikonEncrypted,
7601             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7602             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x0c },
7603             DATAMEMBER => [ 0x04 ],
7604             IS_SUBDIR => [ 0x10, 0x4c, 0x58, 0xa0 ],
7605             WRITABLE => 1,
7606             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7607             NOTES => 'These tags are extracted from encrypted data in images from the D850.',
7608             0x00 => {
7609             Name => 'ShotInfoVersion',
7610             Format => 'string[4]',
7611             Writable => 0,
7612             },
7613             0x04 => {
7614             Name => 'FirmwareVersion',
7615             DataMember => 'FirmwareVersion',
7616             Format => 'string[5]',
7617             Writable => 0,
7618             RawConv => '$$self{FirmwareVersion} = $val',
7619             },
7620             0x10 => {
7621             Name => 'MenuSettingsOffset',
7622             Format => 'int32u',
7623             SubDirectory => {
7624             TagTable => 'Image::ExifTool::Nikon::MenuSettingsD850',
7625             Start => '$val',
7626             },
7627             },
7628             0x4c => {
7629             Name => 'MoreSettingsOffset',
7630             Format => 'int32u',
7631             SubDirectory => {
7632             TagTable => 'Image::ExifTool::Nikon::MoreSettingsD850',
7633             Start => '$val',
7634             },
7635             },
7636             0x58 => {
7637             Name => 'CustomSettingsOffset',
7638             Format => 'int32u',
7639             SubDirectory => {
7640             TagTable => 'Image::ExifTool::NikonCustom::SettingsD850',
7641             Start => '$val',
7642             },
7643             },
7644             0xa0 => {
7645             Name => 'OrientationOffset',
7646             Format => 'int32u',
7647             SubDirectory => {
7648             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
7649             Start => '$val',
7650             },
7651             },
7652             );
7653              
7654             %Image::ExifTool::Nikon::MenuSettingsD850 = (
7655             %binaryDataAttrs,
7656             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7657             0x06dd => {
7658             Name => 'PhotoShootingMenuBankImageArea',
7659             Mask => 0x07,
7660             PrintConv => {
7661             0 => 'FX (36x24)',
7662             1 => 'DX (24x16)',
7663             2 => '5:4 (30x24)',
7664             3 => '1.2x (30x20)',
7665             4 => '1:1 (24x24)',
7666             },
7667             },
7668             );
7669              
7670             %Image::ExifTool::Nikon::MoreSettingsD850 = (
7671             %binaryDataAttrs,
7672             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7673             0x24 => {
7674             Name => 'PhotoShootingMenuBank',
7675             Condition => '$$self{FILE_TYPE} eq "JPEG"',
7676             Notes => 'valid for JPEG images only',
7677             Mask => 0x03,
7678             PrintConv => {
7679             0 => 'A',
7680             1 => 'B',
7681             2 => 'C',
7682             3 => 'D',
7683             },
7684             },
7685             0x25 => {
7686             Name => 'PrimarySlot',
7687             Mask => 0x80,
7688             PrintConv => {
7689             0 => 'XQD Card',
7690             1 => 'SD Card',
7691             },
7692             },
7693             );
7694              
7695             # shot information for the D4 firmware 1.00g (ref PH)
7696             %Image::ExifTool::Nikon::ShotInfoD4 = (
7697             PROCESS_PROC => \&ProcessNikonEncrypted,
7698             WRITE_PROC => \&ProcessNikonEncrypted,
7699             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7700             VARS => { ID_LABEL => 'Index' },
7701             IS_SUBDIR => [ 0x0751 ],
7702             WRITABLE => 1,
7703             FIRST_ENTRY => 0,
7704             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7705             NOTES => q{
7706             These tags are extracted from encrypted data in images from the D4.
7707             },
7708             0x00 => {
7709             Name => 'ShotInfoVersion',
7710             Format => 'string[4]',
7711             Writable => 0,
7712             },
7713             0x04 => {
7714             Name => 'FirmwareVersion',
7715             Format => 'string[5]',
7716             Writable => 0,
7717             },
7718             0x0751 => { #PH (NC)
7719             Name => 'CustomSettingsD4',
7720             # (seems to work for 1.00g and 1.02b)
7721             Format => 'undef[56]',
7722             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsD4' },
7723             },
7724             );
7725              
7726             # shot information for the D4S firmware 1.01a (ref 28, encrypted)
7727             %Image::ExifTool::Nikon::ShotInfoD4S = (
7728             PROCESS_PROC => \&ProcessNikonEncrypted,
7729             WRITE_PROC => \&ProcessNikonEncrypted,
7730             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
7731             VARS => { ID_LABEL => 'Index' },
7732             DATAMEMBER => [ 4 ],
7733             IS_SUBDIR => [ 0x189d, 0x193d, 0x350b ],
7734             WRITABLE => 1,
7735             FIRST_ENTRY => 0,
7736             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
7737             NOTES => 'These tags are extracted from encrypted data in images from the D4S.',
7738             0x00 => {
7739             Name => 'ShotInfoVersion',
7740             Format => 'string[4]',
7741             Writable => 0,
7742             },
7743             0x04 => {
7744             Name => 'FirmwareVersion',
7745             DataMember => 'FirmwareVersion',
7746             Format => 'string[5]',
7747             Writable => 0,
7748             RawConv => '$$self{FirmwareVersion} = $val',
7749             },
7750             0x01d0 => {
7751             Name => 'SecondarySlotFunction',
7752             Mask => 0x03,
7753             PrintConv => {
7754             0 => 'Overflow',
7755             2 => 'Backup',
7756             3 => 'NEF Primary + JPG Secondary',
7757             },
7758             },
7759             0x174c => {
7760             Name => 'AEBracketingSteps',
7761             Mask => 0xff,
7762             PrintHex => 1,
7763             PrintConvColumns => 2,
7764             PrintConv => {
7765             0x00 => 'AE Bracketing Disabled',
7766             0x20 => 'AE Bracketing Disabled',
7767             0x30 => 'AE Bracketing Disabled',
7768             0x40 => 'AE Bracketing Disabled',
7769             0x50 => 'AE Bracketing Disabled',
7770             0x81 => '+3F0.3',
7771             0x82 => '-3F0.3',
7772             0x83 => '+2F0.3',
7773             0x84 => '-2F0.3',
7774             0x85 => '3F0.3',
7775             0x86 => '5F0.3',
7776             0x87 => '7F0.3',
7777             0x88 => '9F0.3',
7778             0x91 => '+3F0.5',
7779             0x92 => '-3F0.5',
7780             0x93 => '+2F0.5',
7781             0x94 => '-2F0.5',
7782             0x95 => '3F0.5',
7783             0x96 => '5F0.5',
7784             0x97 => '7F0.5',
7785             0x98 => '9F0.5',
7786             0xa1 => '+3F0.7',
7787             0xa2 => '-3F0.7',
7788             0xa3 => '+2F0.7',
7789             0xa4 => '-2F0.7',
7790             0xa5 => '3F0.7',
7791             0xa6 => '5F0.7',
7792             0xa7 => '7F0.7',
7793             0xa8 => '9F0.7',
7794             0xb1 => '+3F1',
7795             0xb2 => '-3F1',
7796             0xb3 => '+2F1',
7797             0xb4 => '-2F1',
7798             0xb5 => '3F1',
7799             0xb6 => '5F1',
7800             0xb7 => '7F1',
7801             0xb8 => '9F1',
7802             0xc1 => '+3F2',
7803             0xc2 => '-3F2',
7804             0xc3 => '+2F2',
7805             0xc4 => '-2F2',
7806             0xc5 => '3F2',
7807             0xc6 => '5F2',
7808             0xd1 => '+3F3',
7809             0xd2 => '-3F3',
7810             0xd3 => '+2F3',
7811             0xd4 => '-2F3',
7812             0xd5 => '3F3',
7813             0xd6 => '5F3',
7814             },
7815             },
7816             0x174d => {
7817             Name => 'WBBracketingSteps',
7818             Condition => '$$self{FILE_TYPE} ne "TIFF"', # (covers NEF and TIFF)
7819             Mask => 0xff,
7820             PrintHex => 1,
7821             PrintConvColumns => 2,
7822             PrintConv => {
7823             0x00 => 'WB Bracketing Disabled',
7824             0x01 => 'b3F 1',
7825             0x02 => 'A3F 1',
7826             0x03 => 'b2F 1',
7827             0x04 => 'A2F 1',
7828             0x05 => '3F 1',
7829             0x06 => '5F 1',
7830             0x07 => '7F 1',
7831             0x08 => '9F 1',
7832             0x10 => '0F 2',
7833             0x11 => 'b3F 2',
7834             0x12 => 'A3F 2',
7835             0x13 => 'b2F 2',
7836             0x14 => 'A2F 2',
7837             0x15 => '3F 2',
7838             0x16 => '5F 2',
7839             0x17 => '7F 2',
7840             0x18 => '9F 2',
7841             0x20 => '0F 3',
7842             0x21 => 'b3F 3',
7843             0x22 => 'A3F 3',
7844             0x23 => 'b2F 3',
7845             0x24 => 'A2F 3',
7846             0x25 => '3F 3',
7847             0x26 => '5F 3',
7848             0x27 => '7F 3',
7849             0x28 => '9F 3',
7850             0x22 => 'A3F 3',
7851             0x23 => 'b2F 3',
7852             0x24 => 'A2F 3',
7853             0x25 => '3F 3',
7854             0x26 => '5F 3',
7855             0x27 => '7F 3',
7856             0x28 => '9F 3',
7857             },
7858             },
7859             0x184d => {
7860             Name => 'ReleaseMode',
7861             Mask => 0xff,
7862             PrintConv => {
7863             0 => 'Single Frame',
7864             1 => 'Continuous High Speed',
7865             3 => 'Continuous Low Speed',
7866             4 => 'Timer',
7867             32 => 'Mirror-Up',
7868             64 => 'Quiet',
7869             },
7870             },
7871             0x189d => { #PH (NC)
7872             Name => 'CustomSettingsD4S',
7873             Condition => '$$self{FirmwareVersion} =~ /^1\.00/',
7874             Notes => 'firmware version 1.00',
7875             Format => 'undef[56]',
7876             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsD4' },
7877             },
7878             0x18c2 => { # CSf1-c (no idea why it is so far away from the rest of the settings)
7879             Name => 'MultiSelectorLiveViewMode',
7880             Groups => { 1 => 'NikonCustom' },
7881             Condition => '$$self{FirmwareVersion} !~ /^1\.00/',
7882             Mask => 0xc0,
7883             PrintConv => {
7884             0 => 'Reset',
7885             1 => 'Zoom',
7886             3 => 'None',
7887             },
7888             },
7889             0x18ea => {
7890             Name => 'ISOAutoShutterTime',
7891             Mask => 0x3f,
7892             PrintConv => {
7893             0 => '1/4000 s',
7894             1 => '1/3200 s',
7895             2 => '1/2500 s',
7896             3 => '1/2000 s',
7897             4 => '1/1600 s',
7898             5 => '1/1250 s',
7899             6 => '1/1000 s',
7900             7 => '1/800 s',
7901             8 => '1/640 s',
7902             9 => '1/500 s',
7903             10 => '1/400 s',
7904             11 => '1/320 s',
7905             12 => '1/250 s',
7906             13 => '1/200 s',
7907             14 => '1/160 s',
7908             15 => '1/125 s',
7909             16 => '1/100 s',
7910             17 => '1/80 s',
7911             18 => '1/60 s',
7912             19 => '1/50 s',
7913             20 => '1/40 s',
7914             21 => '1/30 s',
7915             22 => '1/15 s',
7916             23 => '1/8 s',
7917             24 => '1/4 s',
7918             25 => '1/2 s',
7919             26 => '1 s',
7920             27 => '2 s',
7921             28 => '4 s',
7922             29 => '8 s',
7923             30 => '15 s',
7924             31 => '30 s',
7925             32 => 'Auto (Slowest)',
7926             33 => 'Auto (Slower)',
7927             34 => 'Auto',
7928             35 => 'Auto (Faster)',
7929             36 => 'Auto (Fastest)',
7930             },
7931             },
7932             0x18eb => {
7933             Name => 'ISOAutoHiLimit',
7934             Mask => 0xff,
7935             PrintHex => 1,
7936             PrintConv => {
7937             0x24 => 'ISO 200',
7938             0x26 => 'ISO 250',
7939             0x27 => 'ISO 280',
7940             0x28 => 'ISO 320',
7941             0x2a => 'ISO 400',
7942             0x2c => 'ISO 500',
7943             0x2d => 'ISO 560',
7944             0x2e => 'ISO 640',
7945             0x30 => 'ISO 800',
7946             0x32 => 'ISO 1000',
7947             0x33 => 'ISO 1100',
7948             0x34 => 'ISO 1250',
7949             0x36 => 'ISO 1600',
7950             0x38 => 'ISO 2000',
7951             0x39 => 'ISO 2200',
7952             0x3a => 'ISO 2500',
7953             0x3c => 'ISO 3200',
7954             0x3e => 'ISO 4000',
7955             0x3f => 'ISO 4500',
7956             0x40 => 'ISO 5000',
7957             0x42 => 'ISO 6400',
7958             0x44 => 'ISO 8000',
7959             0x45 => 'ISO 9000',
7960             0x46 => 'ISO 10000',
7961             0x48 => 'ISO 12800',
7962             0x4a => 'ISO 16000',
7963             0x4b => 'ISO 18000',
7964             0x4c => 'ISO 20000',
7965             0x4e => 'ISO 25600',
7966             0x50 => 'ISO 32000',
7967             0x51 => 'ISO 36000',
7968             0x52 => 'ISO 40000',
7969             0x54 => 'ISO 51200',
7970             0x56 => 'ISO Hi 0.3',
7971             0x57 => 'ISO Hi 0.5',
7972             0x58 => 'ISO Hi 0.7',
7973             0x5a => 'ISO Hi 1.0',
7974             0x60 => 'ISO Hi 2.0',
7975             0x66 => 'ISO Hi 3.0',
7976             0x6c => 'ISO Hi 4.0',
7977             0x72 => 'ISO Hi 5.0',
7978             },
7979             },
7980             0x193d => {
7981             Name => 'CustomSettingsD4S',
7982             Condition => '$$self{FirmwareVersion} !~ /^1\.00/',
7983             Notes => 'firmware version 1.01',
7984             Format => 'undef[56]',
7985             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsD4' },
7986             },
7987             # 0x1978 => { # this decode works, but involves more bits than should be necessary
7988             # Name => 'ShutterTrigger',
7989             # Mask => 0xff,
7990             # PrintConv => {
7991             # 0 => 'Timer',
7992             # 15 => 'Cable Release/Remote',
7993             # 195 => 'Shutter Button',
7994             # },
7995             # },
7996             0x350b => {
7997             Name => 'OrientationInfo',
7998             Format => 'undef[12]',
7999             SubDirectory => {
8000             # Note: pitch angle may be wrong sign for this model?
8001             # (pitch sign was changed without verification to use same decoding as other models)
8002             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
8003             },
8004             },
8005             0x3693 => {
8006             Name => 'Rotation',
8007             Mask => 0x30,
8008             PrintConv => {
8009             0 => 'Horizontal',
8010             1 => 'Rotate 270 CW',
8011             2 => 'Rotate 90 CW',
8012             3 => 'Rotate 180',
8013             },
8014             },
8015             );
8016              
8017             # shot information for the Z7II firmware 1.00 (encrypted) - ref 28
8018             %Image::ExifTool::Nikon::ShotInfoZ7II = (
8019             PROCESS_PROC => \&ProcessNikonEncrypted,
8020             WRITE_PROC => \&ProcessNikonEncrypted,
8021             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8022             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x24 },
8023             DATAMEMBER => [ 0x04 ],
8024             IS_SUBDIR => [ 0x30, 0x38, 0x98, 0xa0 ],
8025             WRITABLE => 1,
8026             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8027             NOTES => 'These tags are extracted from encrypted data in images from the Z7II.',
8028             0x00 => {
8029             Name => 'ShotInfoVersion',
8030             Format => 'string[4]',
8031             Writable => 0,
8032             },
8033             0x04 => {
8034             Name => 'FirmwareVersion',
8035             DataMember => 'FirmwareVersion',
8036             Format => 'string[8]',
8037             Writable => 0,
8038             RawConv => '$$self{FirmwareVersion} = $val',
8039             },
8040             0x0e => {
8041             Name => 'FirmwareVersion2',
8042             Format => 'string[8]',
8043             Writable => 0,
8044             Hidden => 1,
8045             },
8046             0x18 => {
8047             Name => 'FirmwareVersion3',
8048             Format => 'string[8]',
8049             Writable => 0,
8050             Hidden => 1,
8051             },
8052             0x24 => {
8053             Name => 'NumberOffsets', # number of entries in offset table. offsets are from start of ShotInfo data.
8054             Format => 'int32u',
8055             Writable => 0,
8056             Hidden => 1,
8057             },
8058             0x30 => {
8059             Name => 'IntervalOffset',
8060             Format => 'int32u',
8061             SubDirectory => {
8062             TagTable => 'Image::ExifTool::Nikon::IntervalInfoZ7II',
8063             Start => '$val',
8064             }
8065             },
8066             0x38 => {
8067             Name => 'PortraitOffset',
8068             Format => 'int32u',
8069             SubDirectory => {
8070             TagTable => 'Image::ExifTool::Nikon::PortraitInfoZ7II',
8071             Start => '$val',
8072             }
8073             },
8074             0x98 => {
8075             Name => 'OrientationOffset',
8076             Format => 'int32u',
8077             SubDirectory => {
8078             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
8079             Start => '$val',
8080             }
8081             },
8082             0xa0 => {
8083             Name => 'MenuOffset',
8084             Format => 'int32u',
8085             SubDirectory => {
8086             TagTable => 'Image::ExifTool::Nikon::MenuInfoZ7II',
8087             Start => '$val',
8088             },
8089             },
8090             );
8091              
8092             %Image::ExifTool::Nikon::IntervalInfoZ7II = (
8093             %binaryDataAttrs,
8094             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8095             DATAMEMBER => [ 0x24, 0x28 ],
8096             0x24 => {
8097             Name => 'IntervalShooting',
8098             RawConv => '$$self{IntervalShooting} = $val',
8099             Format => 'int16u',
8100             PrintConv => q{
8101             return 'Off' if $val == 0 ;
8102             my $i = sprintf("Interval %.0f of %.0f",$val, $$self{IntervalShootingIntervals}||0); # something like "Interval 1 of 3"
8103             my $f = ($$self{IntervalShootingShotsPerInterval}||0) > 1 ? sprintf(" Frame %.0f of %.0f",$$self{IntervalFrame}||0, $$self{IntervalShootingShotsPerInterval}||0): '' ; # something like "Frame 1 of 3" or blank
8104             return "On: $i$f"
8105             #$val == 0 ? 'Off' : sprintf("On: Interval %.0f of %.0f Frame %.0f of %.0f",$val, $$self{IntervalShootingIntervals}||0, $$self{IntervalFrame}||0, $$self{IntervalShootingShotsPerInterval}||0),
8106             },
8107             },
8108             0x28 => {
8109             Name => 'IntervalFrame',
8110             RawConv => '$$self{IntervalFrame} = $val',
8111             Condition => '$$self{IntervalShooting} > 0',
8112             Format => 'int16u',
8113             Hidden => 1,
8114             },
8115             );
8116              
8117             %Image::ExifTool::Nikon::PortraitInfoZ7II = (
8118             %binaryDataAttrs,
8119             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8120             0xa0 => { #28
8121             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
8122             # offset5+160; 128 is neutral; >128 increases Yellow; <128 increases Magenta; increments of 4 result from 1 full unit adjustment on the camera
8123             # offset5+161 128 is neutral; >128 increases Brightness; <128 decreases Brightness
8124             # 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]
8125             Format => 'int8u[2]',
8126             Condition => '$$self{FirmwareVersion} ge "01.30"',
8127             PrintConv => q{
8128             return 'Off' if $val eq '0 0' or $val eq '255 255';
8129             my @v = split ' ', $val;
8130             my $brightness = $v[1]==128 ? 'Brightness: Neutral' : sprintf('Brightness: %+.1f',($v[1]-128)/4);
8131             my $color = $v[0]==128 ? 'Color: Neutral' : sprintf('%s: %.1f', $v[0]>128 ? 'Yellow' : 'Magenta', abs($v[0]-128)/4);
8132             # will return something like: 'Magenta: 1.0 Brightness: Neutral'
8133             return "$color $brightness"
8134             },
8135             },
8136             );
8137              
8138             %Image::ExifTool::Nikon::MenuInfoZ7II = (
8139             %binaryDataAttrs,
8140             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8141             IS_SUBDIR => [ 0x10 ],
8142             0x10 => {
8143             Name => 'MenuSettingsOffsetZ7II',
8144             Format => 'int32u',
8145             SubDirectory => {
8146             TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ7II',
8147             Start => '$dirStart + $val',
8148             },
8149             },
8150             );
8151              
8152             # shot information for the Z9 firmware 1.00 (encrypted) - ref 28
8153             %Image::ExifTool::Nikon::ShotInfoZ9 = (
8154             PROCESS_PROC => \&ProcessNikonEncrypted,
8155             WRITE_PROC => \&ProcessNikonEncrypted,
8156             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
8157             VARS => { ID_LABEL => 'Index', NIKON_OFFSETS => 0x24 },
8158             DATAMEMBER => [ 0x04 ],
8159             IS_SUBDIR => [ 0x30, 0x58, 0x84, 0x8c ],
8160             WRITABLE => 1,
8161             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8162             NOTES => 'These tags are extracted from encrypted data in images from the Z9.',
8163             0x00 => {
8164             Name => 'ShotInfoVersion',
8165             Format => 'string[4]',
8166             Writable => 0,
8167             },
8168             0x04 => {
8169             Name => 'FirmwareVersion',
8170             DataMember => 'FirmwareVersion',
8171             Format => 'string[8]',
8172             Writable => 0,
8173             RawConv => '$$self{FirmwareVersion} = $val',
8174             },
8175             0x0e => {
8176             Name => 'FirmwareVersion2',
8177             Format => 'string[8]',
8178             Writable => 0,
8179             Hidden => 1,
8180             },
8181             0x18 => {
8182             Name => 'FirmwareVersion3',
8183             Format => 'string[8]',
8184             Writable => 0,
8185             Hidden => 1,
8186             },
8187             0x24 => {
8188             Name => 'NumberOffsets', # number of entries in offset table. offsets are from start of ShotInfo data.
8189             Format => 'int32u',
8190             Writable => 0,
8191             Hidden => 1,
8192             },
8193             # subdirectories, referenced by offsets (not processed if offset is zero)
8194             0x30 => {
8195             Name => 'SequenceOffset',
8196             Format => 'int32u',
8197             SubDirectory => {
8198             TagTable => 'Image::ExifTool::Nikon::SeqInfoZ9',
8199             Start => '$val',
8200             },
8201             },
8202             0x58 => {
8203             Name => 'Offset13', #offset13 - length x'8f80 (Z9 firmware 3.01 NEF), using currently for a few foucs related tags. Might be premature to give the offset a more meaningful name at this point.
8204             Condition => '$$self{FirmwareVersion} and $$self{FirmwareVersion} ge "03.01"',
8205             Format => 'int32u',
8206             SubDirectory => {
8207             TagTable => 'Image::ExifTool::Nikon::Offset13InfoZ9',
8208             Start => '$val',
8209             },
8210             },
8211             0x84 => {
8212             Name => 'OrientOffset',
8213             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96', #not valid for C30/C60/C120
8214             Format => 'int32u',
8215             SubDirectory => {
8216             TagTable => 'Image::ExifTool::Nikon::OrientationInfo',
8217             Start => '$val',
8218             },
8219             },
8220             0x8c => {
8221             Name => 'MenuOffset',
8222             Format => 'int32u',
8223             SubDirectory => {
8224             TagTable => 'Image::ExifTool::Nikon::MenuInfoZ9',
8225             Start => '$val',
8226             },
8227             },
8228             );
8229              
8230             # ref 28
8231             %Image::ExifTool::Nikon::SeqInfoZ9 = (
8232             %binaryDataAttrs,
8233             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8234             DATAMEMBER => [ 0x20, 0x28, 0x2a ],
8235             0x0020 => {
8236             Name => 'FocusShiftShooting',
8237             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96', #not valid for C30/C60/C120
8238             RawConv => '$$self{FocusShiftShooting} = $val',
8239             PrintConv => q{
8240             return 'Off' if $val == 0 ;
8241             my $i = sprintf("Frame %.0f of %.0f",$val, $$self{FocusShiftNumberShots}); # something like Frame 1 of 100"
8242             return "On: $i"
8243             },
8244             },
8245             0x0028 => {
8246             Name => 'IntervalShooting',
8247             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96', #not valid for C30/C60/C120
8248             RawConv => '$$self{IntervalShooting} = $val',
8249             Format => 'int16u',
8250             PrintConv => q{
8251             return 'Off' if $val == 0 ;
8252             my $i = sprintf("Interval %.0f of %.0f",$val, $$self{IntervalShootingIntervals}||0); # something like "Interval 1 of 3"
8253             my $f = ($$self{IntervalShootingShotsPerInterval}||0) > 1 ? sprintf(" Frame %.0f of %.0f",$$self{IntervalFrame}||0, $$self{IntervalShootingShotsPerInterval}||0): '' ; # something like "Frame 1 of 3" or blank
8254             return "On: $i$f"
8255             #$val == 0 ? 'Off' : sprintf("On: Interval %.0f of %.0f Frame %.0f of %.0f",$val, $$self{IntervalShootingIntervals}||0, $$self{IntervalFrame}||0, $$self{IntervalShootingShotsPerInterval}||0),
8256             },
8257             },
8258             0x002a => {
8259             Name => 'IntervalFrame',
8260             RawConv => '$$self{IntervalFrame} = $val',
8261             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
8262             Format => 'int16u',
8263             Hidden => 1,
8264             },
8265             );
8266              
8267             # ref 28
8268             %Image::ExifTool::Nikon::Offset13InfoZ9 = (
8269             %binaryDataAttrs,
8270             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8271             DATAMEMBER => [ 0x0bea, 0x0beb ],
8272             0x0be8 => {
8273             Name => 'AFAreaInitialXPosition', #stored as a representation of the horizontal position of the center of the portion of the focus box positioned top left when in Wide Area (L/S/C1/C2) focus modes (before subject detection potentially refines focus)
8274             Condition => '$$self{ShutterMode} ne 96 and $$self{AFAreaMode} < 2 ', #not valid for C30/C60/C120 or for Area Modes 1:1 and 16:19
8275             Format => 'int8s',
8276             PrintConv => q{
8277             #in FX mode and Single-point, the 29 horizontal focus points are spaced 259 pixels apart starting at pixel 502 and ending at 7754. Spacing is the same for Wide(L/C1/C2) with different start points.
8278             #in FX mode and Dynamic(L), the 27 horizontal focus points are spaced 259 pixels apart starting at pixel 761 and ending at 7495
8279             #in FX mode and Dynamic(M), the 29 horizontal focus points are spaced 259 pixels apart starting at pixel 502 and ending at 7754
8280             #in DX mode and Single-point, the 19 horizontal focus points are spaced 388 pixels apart starting at pixel 636 and ending at 7620. [These correspond to FX positions and match the corresponding values in AFAreaMode tag AFAreaXPosition].
8281             #in DX mode and Wide(S), the 17 horizontal focus points are spaced 393 pixels apart starting at pixel 591 and ending at 7272.
8282             #in DX mode and Dynamic(L), the 17 horizontal focus points are spaced 388 pixels apart starting at pixel 1024 and ending at 7232
8283             #in DX mode and Dynamic(M), the 19 horizontal focus points are spaced 388 pixels apart starting at pixel 636 and ending at 7620
8284              
8285             my $areaMode = $$self{VALUE}{PhotoShootingMenuBankImageArea};
8286             my $afAreaMode = $$self{VALUE}{AFAreaMode};
8287             my $dynamicAFAreaSize = $$self{VALUE}{DynamicAFAreaSize};
8288              
8289             my $FX = 0;
8290             my $DX = 1;
8291              
8292             my $Single = 1;
8293             my $Dynamic = 2;
8294             my $WideS = 3;
8295             my $WideL = 4;
8296             my $ThreeD = 5;
8297             my $Auto = 6;
8298             my $WideC1 = 12;
8299              
8300             my $DynamicS = 0;
8301             my $DynamicM = 1;
8302             my $DynamicL = 2;
8303              
8304             my $start = 502; #FX - all flavors
8305             $start = 636 if $areaMode == $DX and ($afAreaMode == $Dynamic or $afAreaMode == $WideL or $afAreaMode == $ThreeD or $afAreaMode == $Auto or $afAreaMode >= $WideC1); #DX Wide(L/C1/C2) + Dynamic (L/M/S) + 3D + Auto
8306             $start = 591 if $areaMode == $DX and $afAreaMode == $WideS ; #DX Wide(S)
8307              
8308             my $increment = 259; #FX - all flavors
8309             $increment = 388 if $areaMode == $DX and ($afAreaMode == $Dynamic or $afAreaMode == $WideL or $afAreaMode == $ThreeD or $afAreaMode == $Auto or $afAreaMode >= $WideC1); #DX Wide(L/C1/C2) + Dynamic (L/M/S) + 3D + Auto
8310             $increment = 393 if $areaMode == $DX and $afAreaMode == $WideS ; #DX Wide(S)
8311              
8312             my $divisor = 4;
8313             $divisor = 6 if $areaMode == $DX ;
8314              
8315             my $offsetVal = 0;
8316             $offsetVal = 12 if $areaMode == $FX and $afAreaMode == $Dynamic ; #FX Dynamic (L/M) - force positive values so perl rounding toward zero isn't an issue
8317             $offsetVal = 18 if $areaMode == $DX and $afAreaMode == $Dynamic ; #DX Dynamic (L/M)
8318              
8319             my $offsetSum = -1;
8320             $offsetSum = -4 if $afAreaMode == $Dynamic ; # Dynamic (L/M)
8321              
8322             my $ncol = $$self{AFAreaInitialWidth};
8323             $ncol = int($ncol * 2 / 3) if $areaMode == $DX ; #DX
8324              
8325             #some sample mappings:
8326             #FX Wide(S/L/C1/C2) [6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101, 105, 109, 113, 117] to 502, 761, 1020, 1279, 1538, 1797, 2056, 2315, 2574, 2833, 3092, 3351, 3610, 3869, 4128, 4387, 4646, 4905, 5164, 5423, 5682, 5941, 6200, 6459, 6718, 6977, 7236, 7495, 7754]
8327             #DX Wide(L/C1/C2) map for Wide(L)/C1/C2 [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 67, 73, 79, 85, 91, 97, 103, 109, 115] to [636, 1024, 1412, 1800, 2188, 2576, 2964, 3352, 3740, 4128, 4516, 4904, 5292, 5680, 6068, 6456, 6844, 7232, 7620]
8328             #DX Wide(S) for Wide(S) [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 67, 73, 79, 85, 91, 97, 103] to [984, 1377, 1770, 2163, 2556, 2949, 3342, 3735, 4128, 4521, 4914, 5307, 5700, 6093, 6486, 6879, 7272]
8329             #FX Dynamic (L) map [-9, -5, -1, 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93] to [761, 1020, 1279, 1538, 1797, 2056, 2315, 2574, 2833, 3092, 3351, 3610, 3869, 4128, 4387, 4646, 4905, 5164, 5423, 5682, 5941, 6200, 6459, 6718, 6977, 7236, 7495]
8330              
8331             return $start + $increment * (int(($val + $offsetVal) / $divisor) + int($ncol / 2) + $offsetSum) ; #do not use simple int() becuase it rounds negative fractions toward zero resulting in duplicate values - instead use the 10xdivisor to force positive values
8332             },
8333             },
8334             0x0be9 => {
8335             Name =>'AFAreaInitialYPosition', #stored as a representation of the vertical position of the center of the portion of the focus box positioned top left when in Wide Area (L/S/C1/C2) focus modes (before subject detection potentially refines focus)
8336             Condition => '$$self{ShutterMode} ne 96 and $$self{AFAreaMode} < 2', #not valid for C30/C60/C120 or for Area Modes 1:1 and 16:19
8337             Format => 'int8s',
8338             PrintConv => q{
8339             #in FX mode and Single-point, the 17 vertical focus points are spaced 291 pixels apart starting at pixel 424 and ending at 5080. Spacing is the same for Wide(L/C1/C2)
8340             #in FX mode and Dynamic(L), the 15 vertical focus points are spaced 291 pixels apart starting at pixel 715 and ending at 4789
8341             #in FX mode and Dynamic(M), the 17 vertical l focus points are spaced 291 pixels apart starting at pixel 424 and ending at 5080
8342             #in DX mode and Single-point, the 11 vertical focus points are spaced 436 pixels apart starting at pixel 572 and ending at 4932. [These correspond to FX positions and match the corresponding values in AFAreaMode tag AFAreaYPosition].
8343             #in DX Mode and Wide(S) the 9 vertical focus points are spaced 442 pixels apart starting at pixel 542 and ending at 4520
8344             #in DX mode and Dynamic(L), the 9 vertical focus points are spaced 436 pixels apart starting at pixel 1008 and ending at 4496
8345              
8346             my $areaMode = $$self{VALUE}{PhotoShootingMenuBankImageArea};
8347             my $afAreaMode = $$self{VALUE}{AFAreaMode};
8348             my $dynamicAFAreaSize = $$self{VALUE}{DynamicAFAreaSize};
8349              
8350             my $FX = 0;
8351             my $DX = 1;
8352              
8353             my $Single = 1;
8354             my $Dynamic = 2;
8355             my $WideS = 3;
8356             my $WideL = 4;
8357             my $ThreeD = 5;
8358             my $Auto = 6;
8359             my $WideC1 = 12;
8360              
8361             my $DynamicS = 0;
8362             my $DynamicM = 1;
8363             my $DynamicL = 2;
8364              
8365             my $start = 424; #FX - all flavors
8366             $start = 572 if $areaMode == $DX and ($afAreaMode == $Dynamic or $afAreaMode == $WideL or $afAreaMode == $ThreeD or $afAreaMode == $Auto or $afAreaMode >= $WideC1); #DX Wide(L/C1/C2) + Dynamic(L/M/S) + 3D + Auto
8367             $start = 542 if $areaMode == $DX and $afAreaMode == 3 ; #DX Wide(S)
8368              
8369             my $increment = 291; #FX - all flavors
8370             $increment = 436 if $areaMode == $DX and ($afAreaMode == $Dynamic or $afAreaMode == $WideL or $afAreaMode == $ThreeD or $afAreaMode == $Auto or $afAreaMode >= $WideC1); #DX Wide(L/C1/C2) + Dynamic (L/M/S) +3D + Auto
8371             $increment = 442 if $areaMode == $DX and $afAreaMode == 3 ; #DX Wide(S)
8372              
8373             my $divisor = 7;
8374             $divisor = 10 if $areaMode == $DX ; #DX
8375              
8376             my $offsetVal = -1;
8377             $offsetVal = 39 if $afAreaMode == $Dynamic and ( $dynamicAFAreaSize == $DynamicL ) ; #Dynamic (L) - force positive values so perl rounding toward zero isn't an issue
8378             $offsetVal = 40 if $afAreaMode == $Dynamic and $dynamicAFAreaSize == $DynamicM ; #Dynamic (M)
8379             $offsetVal = 40 if $areaMode == $FX and (($afAreaMode == $Dynamic and $dynamicAFAreaSize == $DynamicS) or $afAreaMode == $ThreeD) ; #FX Dynamic (S) or 3D
8380             $offsetVal = 38 if $areaMode == $DX and ($afAreaMode == $Dynamic and $dynamicAFAreaSize == $DynamicS ) ; #DX Dynamic (S)or 3D
8381              
8382             my $offsetSum = 0;
8383             $offsetSum = -6 if $areaMode == $FX and ($afAreaMode == $Dynamic or $afAreaMode == $ThreeD); #FX Dynamic (L/M/S) or 3D
8384             $offsetSum = -4 if $areaMode == $DX and ($afAreaMode == $Dynamic or $afAreaMode == $ThreeD ); #DX Dynamic (L/M/S) or 3D
8385              
8386             my $nrow = $$self{AFAreaInitialHeight};
8387             $nrow = int($nrow * 2 / 3) if $areaMode == $DX; #DX
8388              
8389             #some sample mappings:
8390             #FX Wide(S/L/C1/C2) map [7, 13, 20, 27, 33, 40, 47, 53, 60, 67, 74, 80, 87, 94, 100, 107, 114] to [424, 715, 1006, 1297, 1588, 1879, 2170, 2461, 2752, 3043, 3334, 3625, 3916, 4207, 4498, 4789, 5080]
8391             #DX Wide(L/C1/C2) map [7, 17, 28, 38, 48, 58, 69, 79, 89, 100, 110] to [572, 1008, 1444, 1880, 2316, 2752, 3188, 3624, 4060, 4496, 4932]
8392             #DX Wide(S) map for Wide(S) [7, 17, 28, 38, 48, 58, 69, 79, 89] to [984, 1426, 1868, 2310, 2752, 3194, 3636, 4078, 4520]
8393             #FX Dynamic (L) map [-19, -13, -6, 0, 7, 13, 20, 27, 33, 40, 47, 53, 60, 67, 74] to [715, 1006, 1297, 1588, 1879, 2170, 2461, 2752, 3043, 3334, 3625, 3916, 4207, 4498, 4789]
8394              
8395             return $start + $increment * (int(($val + $offsetVal) / $divisor) + int($nrow / 2) + $offsetSum) ;;
8396             },
8397             },
8398             0x0bea => {
8399             Name => 'AFAreaInitialWidth',
8400             Condition => '$$self{ShutterMode} ne 96', #not valid for C30/C60/C120
8401             ValueConv => '$$self{VALUE}{PhotoShootingMenuBankImageArea} eq 0 ? $val : int($val * 2 / 3)', #DX mode requires scaling down TODO: add support ImageAreas 1:1 and 16:9
8402             RawConv => '$$self{AFAreaInitialWidth} = 1 + int ($val / 4)', #convert from [3, 11, 19, 35, 51, 75] to [1, 3, 5, 9 13, 19] to match camera options for C1/C2 focus modes .. input/output of 11/3 is for Wide(S)
8403             },
8404             0x0beb => {
8405             Name => 'AFAreaInitialHeight',
8406             Condition => '$$self{ShutterMode} ne 96', #not valid for C30/C60/C120
8407             ValueConv => '$$self{VALUE}{PhotoShootingMenuBankImageArea} eq 0 ? $val : int($val * 2 / 3)', #DX mode requires scaling down TODO: add support ImageAreas 1:1 and 16:9
8408             RawConv => '$$self{AFAreaInitialHeight} = 1 + int ($val / 7) ', #convert from [6, 20, 33, 46, 73] to [1, 3, 5, 7, 11] to match camera options for C1/C2 focus modes .. input/output of 33/5 is for Wide(L)
8409             },
8410             );
8411              
8412             %Image::ExifTool::Nikon::MenuInfoZ9 = (
8413             %binaryDataAttrs,
8414             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8415             IS_SUBDIR => [ 0x10 ],
8416             # 0x00 - int32u size of this directory
8417             0x10 => [
8418             {
8419             Name => 'MenuSettingsOffsetZ9',
8420             Condition => '$$self{FirmwareVersion} and $$self{FirmwareVersion} lt "03.00"',
8421             Format => 'int32u',
8422             Notes => 'Firmware versions 2.11 and earlier',
8423             SubDirectory => {
8424             TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ9',
8425             Start => '$dirStart + $val',
8426             },
8427             },
8428             {
8429             Name => 'MenuSettingsOffsetZ9v3',
8430             Notes => 'Firmware versions 3.0 and later',
8431             Format => 'int32u',
8432             SubDirectory => {
8433             TagTable => 'Image::ExifTool::Nikon::MenuSettingsZ9v3',
8434             Start => '$dirStart + $val',
8435             },
8436             },
8437             ],
8438             );
8439              
8440             %Image::ExifTool::Nikon::OrientationInfo = (
8441             %binaryDataAttrs,
8442             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8443             0 => {
8444             Name => 'RollAngle',
8445             Format => 'fixed32u',
8446             Notes => 'converted to degrees of clockwise camera roll',
8447             ValueConv => '$val <= 180 ? $val : $val - 360',
8448             ValueConvInv => '$val >= 0 ? $val : $val + 360',
8449             PrintConv => 'sprintf("%.1f", $val)',
8450             PrintConvInv => '$val',
8451             },
8452             4 => {
8453             Name => 'PitchAngle',
8454             Format => 'fixed32u',
8455             Notes => 'converted to degrees of upward camera tilt',
8456             ValueConv => '$val <= 180 ? $val : $val - 360',
8457             ValueConvInv => '$val >= 0 ? $val : $val + 360',
8458             PrintConv => 'sprintf("%.1f", $val)',
8459             PrintConvInv => '$val',
8460             },
8461             8 => {
8462             Name => 'YawAngle',
8463             Format => 'fixed32u',
8464             Notes => 'the camera yaw angle when shooting in portrait orientation',
8465             ValueConv => '$val <= 180 ? $val : $val - 360',
8466             ValueConvInv => '$val >= 0 ? $val : $val + 360',
8467             PrintConv => 'sprintf("%.1f", $val)',
8468             PrintConvInv => '$val',
8469             },
8470             );
8471              
8472             %Image::ExifTool::Nikon::MenuSettingsZ7II = (
8473             %binaryDataAttrs,
8474             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8475             DATAMEMBER => [ 90, 176, 180, 328, 352, 858 ],
8476             NOTES => 'These tags are used by the Z5, Z6, Z7, Z6II, Z7II, Z50 and Zfc.',
8477             #48 SelfTimer' #0=> no 1=> yes works for Z7II firmware 1.40, but not 1.30. Follow-up required.
8478             90 => {
8479             Name => 'SingleFrame', #0=> Single Frame 1=> one of the continuous modes
8480             Hidden => 1,
8481             RawConv => '$$self{SingleFrame} = $val',
8482             },
8483             92 => {
8484             Name => 'ReleaseMode',
8485             #ValueConv => '$$self{SelfTimer} == 1 ? 4 : $$self{SingleFrame} == 0 ? 5 : $val', #map single frame and timer to a unique values for PrintConv. Activate when SelfTimer tag is clarified for cameras other than Z7II fw 1.40
8486             ValueConv => '$$self{SingleFrame} == 0 ? 5 : $val', #map single frame to a unique value for PrintConv
8487             PrintConv => \%releaseModeZ7,
8488             },
8489             160 => {
8490             Name => 'IntervalDurationHours',
8491             Format => 'int32u',
8492             #Condition => '$$self{IntervalShooting} > 0',
8493             },
8494             164 => {
8495             Name => 'IntervalDurationMinutes',
8496             Format => 'int32u',
8497             #Condition => '$$self{IntervalShooting} > 0',
8498             },
8499             168 => {
8500             Name => 'IntervalDurationSeconds',
8501             Format => 'int32u',
8502             #Condition => '$$self{IntervalShooting} > 0',
8503             },
8504             176 => {
8505             Name => 'Intervals',
8506             Format => 'int32u',
8507             RawConv => '$$self{IntervalShootingIntervals} = $val',
8508             #Condition => '$$self{IntervalShooting} > 0',
8509             },
8510             180 => {
8511             Name => 'ShotsPerInterval',
8512             Format => 'int32u',
8513             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
8514             #Condition => '$$self{IntervalShooting} > 0',
8515             },
8516             184 => {
8517             Name => 'IntervalExposureSmoothing',
8518             #Condition => '$$self{IntervalShooting} > 0',
8519             Format => 'int8u',
8520             PrintConv => \%offOn,
8521             },
8522             186 => {
8523             Name => 'IntervalPriority',
8524             #Condition => '$$self{IntervalShooting} > 0',
8525             Format => 'int8u',
8526             PrintConv => \%offOn,
8527             },
8528             220 => {
8529             Name => 'FocusShiftNumberShots',
8530             },
8531             224 => {
8532             Name => 'FocusShiftStepWidth',
8533             },
8534             228 => {
8535             Name => 'FocusShiftInterval',
8536             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
8537             },
8538             232 => {
8539             Name => 'FocusShiftExposureLock',
8540             PrintConv => \%offOn,
8541             },
8542             #304 => White Balance - Kelvin Temp
8543             #312 => ColorSpace
8544             #314 => ActiveD-Lighting
8545             #318 => HighISONoiseReduction
8546             322 => {
8547             Name => 'DiffractionCompensation',
8548             Format => 'int8u',
8549             PrintConv => \%offOn,
8550             },
8551             323 => {
8552             Name => 'AutoDistortionControl',
8553             Format => 'int8u',
8554             PrintConv => \%offOn,
8555             },
8556             #324 => {Name => 'FlickerReductionShooting',}, # redundant with tag in NikonSettings
8557             326 => {
8558             Name => 'NikonMeteringMode',
8559             Unknown => 1,
8560             PrintConv => {
8561             0 => 'Matrix',
8562             1 => 'Center',
8563             2 => 'Spot',
8564             3 => 'Highlight'
8565             },
8566             },
8567             326 => { Name => 'NikonMeteringMode', PrintConv => \%meteringModeZ7},
8568             328 => {
8569             Name => 'FlashControlMode', # this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
8570             RawConv => '$$self{FlashControlMode} = $val',
8571             PrintConv => \%flashControlModeZ7,
8572             },
8573             334 => {
8574             Name => 'FlashGNDistance',
8575             Condition => '$$self{FlashControlMode} == 2',
8576             Unknown => 1,
8577             ValueConv => '$val + 3',
8578             PrintConv => \%flashGNDistance,
8579             },
8580             338 => {
8581             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)
8582             Condition => '$$self{FlashControlMode} >= 3',
8583             Unknown => 1,
8584             ValueConv => '2 ** (-$val/3)',
8585             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
8586             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
8587             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
8588             },
8589             346 => { Name => 'FlashWirelessOption', PrintConv => \%flashWirelessOptionZ7, Unknown => 1 },
8590             348 => { Name => 'FlashRemoteControl', PrintConv => \%flashRemoteControlZ7, Unknown => 1 },
8591             352 => {
8592             Name => 'FlashMasterControlMode', # tag name chosen for compatibility with those found in FlashInfo0102 & FlashInfo0103
8593             RawConv => '$$self{FlashGroupOptionsMasterMode} = $val',
8594             PrintConv => \%flashGroupOptionsMode,
8595             },
8596             354 => {
8597             Name => 'FlashMasterCompensation',
8598             Format => 'int8s',
8599             Condition => '$$self{FlashGroupOptionsMasterMode} != 3', # other than 'Off'
8600             Unknown => 1,
8601             ValueConv => '$val/6',
8602             ValueConvInv => '6 * $val',
8603             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
8604             PrintConvInv => '$val',
8605             },
8606             358 => {
8607             Name => 'FlashMasterOutput',
8608             Unknown => 1,
8609             Condition => '$$self{FlashGroupOptionsMasterMode} == 1', # only for Mode=M
8610             ValueConv => '2 ** (-$val/3)',
8611             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
8612             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
8613             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
8614             },
8615             #360 => { Name => 'FlashGroupAControlMode' }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupACompensation at 362 and FlashGroupAOutput at 368
8616             #368 => { Name => 'FlashGroupBControlMode' }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupBCompensation at 370 and FlashGroupBOutput at 374
8617             #376 => { Name => 'FlashGroupCControlMode' }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupCCompensation at 378 and FlashGroupCOutput at 382
8618             #384 => { Name => 'FlashGroupDControlMode' }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupDCompensation at 386 and FlashGroupDOutput at 390
8619             #392 => { Name => 'FlashGroupEControlMode' }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupECompensation at 394 and FlashGroupEOutput at 398
8620             #400 => { Name => 'FlashGroupFControlMode' }, # commented out to reduce output volume - mapping follows FlashMasterControlMode with FlashGroupFCompensation at 402 and FlashGroupFOutput at 406
8621             #434 => FocusMode
8622             #436 => AFAreaMode
8623             #438 => VibrationReduction
8624             #442 => BracketSet
8625             #444 => BracketProgram
8626             #446 => BracketIncrement
8627             #463 => SilentPhotography
8628             502 => { Name => 'MovieFrameSize', PrintConv => \%movieFrameSizeZ9, Unknown => 1 },
8629             504 => { Name => 'MovieFrameRate', PrintConv => \%movieFrameRateZ7, Unknown => 1 },
8630             506 => {
8631             Name => 'MovieSlowMotion',
8632             Unknown => 1,
8633             PrintConv => {
8634             0 => 'Off',
8635             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]
8636             2 => 'On (5x)', # 120p recording with playback @ 24p [1920 x 1080; 20p x 5]
8637             },
8638             },
8639             510 => {
8640             Name => 'MovieType',
8641             Unknown => 1,
8642             PrintConv => {
8643             0 => 'MOV',
8644             1 => 'MP4',
8645             },
8646             },
8647             #512 => MovieISOAutoHiLimit
8648             516 => {
8649             Name => 'MovieISOAutoManualMode',
8650             Condition => '$$self{Model} =~ /^NIKON 7/', #ISO ranges vary by model. These mappings are for the Z7 and Z7II
8651             Format => 'int16u',
8652             Unknown => 1,
8653             ValueConv => '($val-104)/8',
8654             ValueConvInv => '8 * ($val + 104)',
8655             PrintConv => \%iSOAutoHiLimitZ7,
8656             },
8657             #520 => MovieWhiteBalanceSameAsPhoto
8658             568 => { Name => 'MovieActiveD-Lighting', PrintConv => \%activeDLightingZ7, Unknown => 1 },
8659             572 => { Name => 'MovieHighISONoiseReduction', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
8660             574 => { Name => 'MovieVignetteControl', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
8661             576 => {
8662             Name => 'MovieVignetteControlSameAsPhoto',
8663             Unknown => 1,
8664             PrintConv => \%noYes
8665             },
8666             577 => {
8667             Name => 'MovieDiffractionCompensation',
8668             Unknown => 1,
8669             PrintConv => \%offOn
8670             },
8671             578 => {
8672             Name => 'MovieAutoDistortionControl',
8673             Unknown => 1,
8674             PrintConv => \%offOn
8675             },
8676             584 => { Name => 'MovieFocusMode', PrintConv => \%focusModeZ7, Unknown => 1 },
8677             #586 => MovieAFAreaMode
8678             590 => {
8679             Name => 'MovieVibrationReduction',
8680             Unknown => 1,
8681             PrintConv => {
8682             0 => 'Off',
8683             1 => 'On (Normal)',
8684             2 => 'On (Sport)',
8685             },
8686             },
8687             591 => {
8688             Name => 'MovieVibrationReductionSameAsPhoto',
8689             Unknown => 1,
8690             PrintConv => \%noYes
8691             },
8692             #848 => HDMIOutputResolution
8693             #850 => HDMIOutputRange
8694             #854 => HDMIExternalRecorder
8695             #856 => HDMIBitDepth
8696             858 => {
8697             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
8698             Condition => '$$self{HDMIBitDepth} and $$self{HDMIBitDepth} == 2', # only for 10 bit
8699             RawConv => '$$self{HDMIOutputNLog} = $val',
8700             Unknown => 1,
8701             PrintConv => \%offOn,
8702             },
8703             #859 => HDMIViewAssist
8704             );
8705              
8706             %Image::ExifTool::Nikon::MenuSettingsZ9 = (
8707             %binaryDataAttrs,
8708             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8709             DATAMEMBER => [ 140, 188, 192, 232, 424, 534, 576 ],
8710             IS_SUBDIR => [ 799 ],
8711             NOTES => 'These tags are used by the Z9.',
8712             #90 ISO
8713             140 => {
8714             Name => 'MultipleExposureMode',
8715             RawConv => '$$self{MultipleExposureMode} = $val',
8716             PrintConv => \%multipleExposureModeZ9,
8717             },
8718             142 => {Name => 'MultiExposureShots', Condition => '$$self{MultipleExposureMode} != 0' }, #range 2-9
8719             188 => {
8720             Name => 'Intervals',
8721             Format => 'int32u',
8722             RawConv => '$$self{IntervalShootingIntervals} = $val',
8723             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
8724             },
8725             192 => {
8726             Name => 'ShotsPerInterval',
8727             Format => 'int32u',
8728             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
8729             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
8730             },
8731             #220 NEFCompression 0=> 'Lossless' 1=> 'High Efficiency*' 4=> 'High Efficientcy'
8732             232 => {
8733             Name => 'FocusShiftNumberShots', #1-300
8734             RawConv => '$$self{FocusShiftNumberShots} = $val',
8735             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
8736             },
8737             236 => {
8738             Name => 'FocusShiftStepWidth', #1(Narrow) to 10 (Wide)
8739             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
8740             },
8741             240 => {
8742             Name => 'FocusShiftInterval',
8743             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
8744             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
8745             },
8746             244 => {
8747             Name => 'FocusShiftExposureLock',
8748             Unknown => 1,
8749             PrintConv => \%offOn,
8750             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
8751             },
8752             274 => { Name => 'PhotoShootingMenuBank', PrintConv => \%banksZ9 },
8753             276 => { Name => 'ExtendedMenuBanks', PrintConv => \%offOn }, #single tag from both Photo & Video menus
8754             308 => { Name => 'PhotoShootingMenuBankImageArea', PrintConv => \%imageAreaZ9 },
8755             #310 ImageQuality
8756             322 => { Name => 'AutoISO', PrintConv => \%offOn },
8757             324 => {
8758             Name => 'ISOAutoHiLimit',
8759             Format => 'int16u',
8760             Unknown => 1,
8761             ValueConv => '($val-104)/8',
8762             ValueConvInv => '8 * ($val + 104)',
8763             PrintConv => \%iSOAutoHiLimitZ7,
8764             },
8765             326 => {
8766             Name => 'ISOAutoFlashLimit',
8767             Format => 'int16u',
8768             Unknown => 1,
8769             ValueConv => '($val-104)/8',
8770             ValueConvInv => '8 * ($val + 104)',
8771             PrintConv => \%iSOAutoHiLimitZ7,
8772             },
8773             #332 ISOAutoShutterTime - Auto setting 0=> 'Auto (Slowest)', 1 => 'Auto (Slower)', 2=> 'Auto', 3=> 'Auto (Faster)', 4=> 'Auto (Fastest)'
8774             334 => {
8775             Name => 'ISOAutoShutterTime', #shutter speed is 2 ** (-$val/24)
8776             ValueConv => '$val / 8',
8777             Format => 'int16s',
8778             PrintConv => \%iSOAutoShutterTimeZ9,
8779             },
8780             #336 WhiteBalance
8781             #406 PictureControl
8782             #408 ColorSpace
8783             #410 ActiveD-Lighting
8784             #412 => { Name => 'NoiseReduction', PrintConv => \%offOn }, #Long Exposure Noise Reduction
8785             #414 HighISONoiseReduction
8786             #414 VignetteControl
8787             416 => { Name => 'MovieVignetteControl', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
8788             418 => { Name => 'DiffractionCompensation', PrintConv => \%offOn }, #value can be set from both the Photo Shoot Menu and the Video Shooting Menu
8789             #419 AutoDistortionControl #value can be set from both the Photo Shoot Menu and the Video Shooting Menu
8790             420 => { Name => 'FlickerReductionShooting', PrintConv => \%offOn },
8791             #422 MeteringMode
8792             424 => {
8793             Name => 'FlashControlMode', # this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
8794             RawConv => '$$self{FlashControlMode} = $val',
8795             PrintConv => \%flashControlModeZ7,
8796             },
8797             426 => {
8798             Name => 'FlashMasterCompensation',
8799             Format => 'int8s',
8800             Unknown => 1,
8801             ValueConv => '$val/6',
8802             ValueConvInv => '6 * $val',
8803             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
8804             PrintConvInv => '$val',
8805             },
8806             430 => {
8807             Name => 'FlashGNDistance',
8808             Condition => '$$self{FlashControlMode} == 2',
8809             Unknown => 1,
8810             ValueConv => '$val + 3',
8811             PrintConv => \%flashGNDistance,
8812             },
8813             434 => {
8814             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)
8815             Condition => '$$self{FlashControlMode} >= 3',
8816             Unknown => 1,
8817             ValueConv => '2 ** (-$val/3)',
8818             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
8819             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
8820             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
8821             },
8822             #442 flash wirelss control 0=> 'Off' 1=> 'CMD'
8823             444 => { Name => 'FlashRemoteControl', PrintConv => \%flashRemoteControlZ7, Unknown => 1 },
8824             456 => { Name => 'FlashWirelessOption', PrintConv => \%flashWirelessOptionZ7, Unknown => 1 },
8825             #526 FocusMode
8826             528 => { Name => 'AFAreaMode',PrintConv => \%aFAreaModeZ9 },
8827             530 => { Name => 'VRMode', PrintConv => \%vRModeZ9 },
8828             534 => {
8829             Name => 'BracketSet',
8830             RawConv => '$$self{BracketSet} = $val',
8831             PrintConv => \%bracketSetZ9,
8832             },
8833             536 => {
8834             Name => 'BracketProgram',
8835             Condition => '$$self{BracketSet} < 3',
8836             Notes => 'AE and/or Flash Bracketing',
8837             PrintConv => \%bracketProgramZ9,
8838             },
8839             538 => {
8840             Name => 'BracketIncrement',
8841             Condition => '$$self{BracketSet} < 3',
8842             Notes => 'AE and/or Flash Bracketing',
8843             PrintConv => \%bracketIncrementZ9,
8844             },
8845             #544 BracketProgram for ADL
8846             556 => { Name => 'SecondarySlotFunction', PrintConv => \%secondarySlotFunctionZ9 },
8847             572 => { Name => 'DXCropAlert', PrintConv => \%offOn },
8848             574 => { Name => 'SubjectDetection', PrintConv => \%subjectDetectionZ9 },
8849             576 => {
8850             Name => 'DynamicAFAreaSize',
8851             Condition => '$$self{AFAraMode} = 2',
8852             RawConv => '$$self{DynamicAFAreaSize} = $val',
8853             PrintConv => \%dynamicAfAreaModesZ9,
8854             },
8855             604 => {
8856             Name => 'MovieImageArea',
8857             Unknown => 1,
8858             Mask => 0x01, # without the mask 4 => 'FX', 5 => DX. only the 2nd Z-series field encountered with a mask
8859             PrintConv => \%imageAreaZ9b,
8860             },
8861             614 => { Name => 'MovieType', PrintConv => \%movieTypeZ9, Unknown => 1 },
8862             616 => {
8863             Name => 'MovieISOAutoHiLimit',
8864             Format => 'int16u',
8865             Unknown => 1,
8866             ValueConv => '($val-104)/8',
8867             ValueConvInv => '8 * ($val + 104)',
8868             PrintConv => \%iSOAutoHiLimitZ7,
8869             },
8870             618 => { Name => 'MovieISOAutoControlManualMode', PrintConv => \%offOn, Unknown => 1 },
8871             620 => {
8872             Name => 'MovieISOAutoManualMode',
8873             Format => 'int16u',
8874             Unknown => 1,
8875             ValueConv => '($val-104)/8',
8876             ValueConvInv => '8 * ($val + 104)',
8877             PrintConv => \%iSOAutoHiLimitZ7,
8878             },
8879             696 => { Name => 'MovieActiveD-Lighting', PrintConv => \%activeDLightingZ7, Unknown => 1 },
8880             698 => { Name => 'MovieHighISONoiseReduction', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
8881             704 => { Name => 'MovieFlickerReduction', PrintConv => \%movieFlickerReductionZ9 },
8882             706 => { Name => 'MovieMeteringMode', PrintConv => \%meteringModeZ7, Unknown => 1 },
8883             708 => { Name => 'MovieFocusMode', PrintConv => \%focusModeZ7, Unknown => 1 },
8884             710 => { Name => 'MovieAFAreaMode', PrintConv => \%aFAreaModeZ9 },
8885             712 => { Name => 'MovieVRMode', PrintConv => \%vRModeZ9, Unknown => 1 },
8886             716 => { Name => 'MovieElectronicVR', PrintConv => \%offOn, Unknown => 1 }, #distinct from MoveieVRMode
8887             718 => { Name => 'MovieSoundRecording', PrintConv => { 0 => 'Off', 1 => 'Auto', 2 => 'Manual' }, Unknown => 1 },
8888             720 => { Name => 'MicrophoneSensitivity', Unknown => 1 }, #1-20
8889             722 => { Name => 'MicrophoneAttenuator', PrintConv => \%offOn, Unknown => 1 }, #distinct from MoveieVRMode
8890             724 => { Name => 'MicrophoneFrequencyResponse', PrintConv => { 0 => 'Wide Range', 1 => 'Vocal Range' }, Unknown => 1 },
8891             726 => { Name => 'WindNoiseReduction', PrintConv => \%offOn, Unknown => 1 },
8892             748 => { Name => 'MovieToneMap', PrintConv => \%movieToneMapZ9, Unknown => 1 },
8893             754 => { Name => 'MovieFrameSize', PrintConv => \%movieFrameSizeZ9, Unknown => 1 },
8894             756 => { Name => 'MovieFrameRate', PrintConv => \%movieFrameRateZ7, Unknown => 1 },
8895             762 => { Name => 'MicrophoneJackPower', PrintConv => \%offOn, Unknown => 1 },
8896             763 => { Name => 'MovieDXCropAlert', PrintConv => \%offOn, Unknown => 1 },
8897             764 => { Name => 'MovieSubjectDetection', PrintConv => \%subjectDetectionZ9, Unknown => 1 },
8898             799 => {
8899             Name => 'CustomSettingsZ9',
8900             Format => 'undef[608]',
8901             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsZ9' },
8902             },
8903             1426 => { Name => 'Language', PrintConv => \%languageZ9, Unknown => 1 },
8904             1428 => { Name => 'TimeZone', PrintConv => \%timeZoneZ9 },
8905             1434 => { Name => 'MonitorBrightness', ValueConv => '$val - 5', Unknown => 1 }, # settings: -5 to +5
8906             1456 => { Name => 'AFFineTune', PrintConv => \%offOn, Unknown => 1 },
8907             1552 => { Name => 'HDMIOutputResolution', PrintConv => \%hDMIOutputResolutionZ9 },
8908             1565 => { Name => 'SetClockFromLocationData', PrintConv => \%offOn, Unknown => 1 },
8909             1572 => { Name => 'AirplaneMode', PrintConv => \%offOn, Unknown => 1 },
8910             1573 => { Name => 'EmptySlotRelease', PrintConv => { 0 => 'Disable Release', 1 => 'Enable Release' }, Unknown => 1 },
8911             1608 => { Name => 'EnergySavingMode', PrintConv => \%offOn, Unknown => 1 },
8912             1632 => { Name => 'RecordLocationData', PrintConv => \%offOn, Unknown => 1 },
8913             1636 => { Name => 'USBPowerDelivery', PrintConv => \%offOn, Unknown => 1 },
8914             1645 => { Name => 'SensorShield', PrintConv => { 0 => 'Stays Open', 1 => 'Closes' }, Unknown => 1 },
8915             );
8916              
8917             %Image::ExifTool::Nikon::MenuSettingsZ9v3 = (
8918             %binaryDataAttrs,
8919             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
8920             DATAMEMBER => [ 154, 204, 208, 248, 444, 554, 596 ],
8921             IS_SUBDIR => [ 847 ],
8922             NOTES => 'These tags are used by the Z9 firmware 3.00.',
8923             72 => {
8924             Name => 'HighFrameRate', #CH and C30/C60/C120 but not CL
8925             PrintConv => \%highFrameRateZ9,
8926             },
8927             154 => {
8928             Name => 'MultipleExposureMode',
8929             RawConv => '$$self{MultipleExposureMode} = $val',
8930             PrintConv => \%multipleExposureModeZ9,
8931             },
8932             156 => {Name => 'MultiExposureShots', Condition => '$$self{MultipleExposureMode} != 0'}, #range 2-9
8933             204 => {
8934             Name => 'Intervals',
8935             Format => 'int32u',
8936             RawConv => '$$self{IntervalShootingIntervals} = $val',
8937             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
8938             },
8939             208 => {
8940             Name => 'ShotsPerInterval',
8941             Format => 'int32u',
8942             RawConv => '$$self{IntervalShootingShotsPerInterval} = $val',
8943             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
8944             },
8945             248 => {
8946             Name => 'FocusShiftNumberShots', #1-300
8947             RawConv => '$$self{FocusShiftNumberShots} = $val',
8948             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
8949             },
8950             252 => {
8951             Name => 'FocusShiftStepWidth', #1(Narrow) to 10 (Wide)
8952             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
8953             },
8954             256 => {
8955             Name => 'FocusShiftInterval',
8956             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
8957             PrintConv => '$val == 1? "1 Second" : sprintf("%.0f Seconds",$val)',
8958             },
8959             260 => {
8960             Name => 'FocusShiftExposureLock',
8961             Unknown => 1,
8962             PrintConv => \%offOn,
8963             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
8964             },
8965             290 => { Name => 'PhotoShootingMenuBank', PrintConv => \%banksZ9 },
8966             292 => { Name => 'ExtendedMenuBanks', PrintConv => \%offOn }, # single tag from both Photo & Video menus
8967             328 => { Name => 'PhotoShootingMenuBankImageArea', PrintConv => \%imageAreaZ9 },
8968             342 => { Name => 'AutoISO', PrintConv => \%offOn },
8969             344 => {
8970             Name => 'ISOAutoHiLimit',
8971             Format => 'int16u',
8972             Unknown => 1,
8973             ValueConv => '($val-104)/8',
8974             ValueConvInv => '8 * ($val + 104)',
8975             PrintConv => \%iSOAutoHiLimitZ7,
8976             },
8977             346 => {
8978             Name => 'ISOAutoFlashLimit',
8979             Format => 'int16u',
8980             Unknown => 1,
8981             ValueConv => '($val-104)/8',
8982             ValueConvInv => '8 * ($val + 104)',
8983             PrintConv => \%iSOAutoHiLimitZ7,
8984             },
8985             354 => {
8986             Name => 'ISOAutoShutterTime', # shutter speed is 2 ** (-$val/24)
8987             ValueConv => '$val / 8',
8988             Format => 'int16s',
8989             PrintConv => \%iSOAutoShutterTimeZ9,
8990             },
8991             436 => { Name => 'MovieVignetteControl', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
8992             438 => { Name => 'DiffractionCompensation', PrintConv => \%offOn }, # value can be set from both the Photo Shoot Menu and the Video Shooting Menu
8993             440 => { Name => 'FlickerReductionShooting',PrintConv => \%offOn },
8994             444 => {
8995             Name => 'FlashControlMode', # this and nearby tag values for flash may be set from either the Photo Shooting Menu or using the Flash unit menu
8996             RawConv => '$$self{FlashControlMode} = $val',
8997             PrintConv => \%flashControlModeZ7,
8998             },
8999             446 => {
9000             Name => 'FlashMasterCompensation',
9001             Format => 'int8s',
9002             Unknown => 1,
9003             ValueConv => '$val/6',
9004             ValueConvInv => '6 * $val',
9005             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9006             PrintConvInv => '$val',
9007             },
9008             450 => {
9009             Name => 'FlashGNDistance',
9010             Condition => '$$self{FlashControlMode} == 2',
9011             Unknown => 1,
9012             ValueConv => '$val + 3',
9013             PrintConv => \%flashGNDistance,
9014             },
9015             454 => {
9016             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)
9017             Condition => '$$self{FlashControlMode} >= 3',
9018             Unknown => 1,
9019             ValueConv => '2 ** (-$val/3)',
9020             ValueConvInv => '$val>0 ? -3*log($val)/log(2) : 0',
9021             PrintConv => '$val>0.99 ? "Full" : sprintf("%.1f%%",$val*100)',
9022             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9023             },
9024             #462 flash wireless control 0=> 'Off' 1=> 'Optical AWL'
9025             #464 => { Name => 'FlashRemoteControl', PrintConv => \%flashRemoteControlZ7, Unknown => 1 },
9026             #476 => { Name => 'FlashWirelessOption', PrintConv => \%flashWirelessOptionZ7, Unknown => 1 },
9027             548 => { Name => 'AFAreaMode', PrintConv => \%aFAreaModeZ9},
9028             550 => { Name => 'VRMode', PrintConv => \%vRModeZ9},
9029             554 => {
9030             Name => 'BracketSet',
9031             RawConv => '$$self{BracketSet} = $val',
9032             PrintConv => \%bracketSetZ9,
9033             },
9034             556 => {
9035             Name => 'BracketProgram',
9036             Condition => '$$self{BracketSet} < 3',
9037             Notes => 'AE and/or Flash Bracketing',
9038             PrintConv => \%bracketProgramZ9,
9039             },
9040             558 => {
9041             Name => 'BracketIncrement',
9042             Condition => '$$self{BracketSet} < 3',
9043             Notes => 'AE and/or Flash Bracketing',
9044             PrintConv => \%bracketIncrementZ9,
9045             },
9046             576 => { Name => 'SecondarySlotFunction', PrintConv => \%secondarySlotFunctionZ9 },
9047             592 => { Name => 'DXCropAlert', PrintConv => \%offOn },
9048             594 => { Name => 'SubjectDetection', PrintConv => \%subjectDetectionZ9 },
9049             596 => {
9050             Name => 'DynamicAFAreaSize',
9051             Condition => '$$self{AFAraMode} = 2',
9052             RawConv => '$$self{DynamicAFAreaSize} = $val',
9053             PrintConv => \%dynamicAfAreaModesZ9,
9054             },
9055             636 => { Name => 'HighFrequencyFlickerReductionShooting', PrintConv => \%offOn, Unknown => 1 }, # new with firmware 3.0
9056             646 => {
9057             Name => 'MovieImageArea',
9058             Unknown => 1,
9059             Mask => 0x01, # without the mask 4 => 'FX' 5 => DX only the 2nd Z-series field encountered with a mask.
9060             PrintConv => \%imageAreaZ9b,
9061             },
9062             656 => { Name => 'MovieType', PrintConv => \%movieTypeZ9, Unknown => 1 },
9063             658 => {
9064             Name => 'MovieISOAutoHiLimit',
9065             Format => 'int16u',
9066             Unknown => 1,
9067             ValueConv => '($val-104)/8',
9068             ValueConvInv => '8 * ($val + 104)',
9069             PrintConv => \%iSOAutoHiLimitZ7,
9070             },
9071             660 => { Name => 'MovieISOAutoControlManualMode', PrintConv => \%offOn, Unknown => 1 },
9072             662 => {
9073             Name => 'MovieISOAutoManualMode',
9074             Format => 'int16u',
9075             Unknown => 1,
9076             ValueConv => '($val-104)/8',
9077             ValueConvInv => '8 * ($val + 104)',
9078             PrintConv => \%iSOAutoHiLimitZ7,
9079             },
9080             736 => { Name => 'MovieActiveD-Lighting', PrintConv => \%activeDLightingZ7, Unknown => 1 },
9081             738 => { Name => 'MovieHighISONoiseReduction', PrintConv => \%offLowNormalHighZ7, Unknown => 1 },
9082             744 => { Name => 'MovieFlickerReduction', PrintConv => \%movieFlickerReductionZ9 },
9083             746 => { Name => 'MovieMeteringMode', PrintConv => \%meteringModeZ7, Unknown => 1 },
9084             748 => { Name => 'MovieFocusMode', PrintConv => \%focusModeZ7, Unknown => 1 },
9085             750 => { Name => 'MovieAFAreaMode', PrintConv => \%aFAreaModeZ9 },
9086             752 => { Name => 'MovieVRMode', PrintConv => \%vRModeZ9, Unknown => 1 },
9087             756 => { Name => 'MovieElectronicVR', PrintConv => \%offOn, Unknown => 1 }, # distinct from MoveieVRMode
9088             758 => { Name => 'MovieSoundRecording', PrintConv => { 0 => 'Off', 1 => 'Auto', 2 => 'Manual' }, Unknown => 1 },
9089             760 => { Name => 'MicrophoneSensitivity', Unknown => 1 }, # 1-20
9090             762 => { Name => 'MicrophoneAttenuator', PrintConv => \%offOn, Unknown => 1 }, # distinct from MoveieVRMode
9091             764 => { Name => 'MicrophoneFrequencyResponse',PrintConv => { 0 => 'Wide Range', 1 => 'Vocal Range' }, Unknown => 1 },
9092             766 => { Name => 'WindNoiseReduction', PrintConv => \%offOn, Unknown => 1 },
9093             788 => { Name => 'MovieToneMap', PrintConv => \%movieToneMapZ9, Unknown => 1 },
9094             794 => { Name => 'MovieFrameSize', PrintConv => \%movieFrameSizeZ9, Unknown => 1 },
9095             796 => { Name => 'MovieFrameRate', PrintConv => \%movieFrameRateZ7, Unknown => 1 },
9096             802 => { Name => 'MicrophoneJackPower', PrintConv => \%offOn, Unknown => 1 },
9097             803 => { Name => 'MovieDXCropAlert', PrintConv => \%offOn, Unknown => 1 },
9098             804 => { Name => 'MovieSubjectDetection', PrintConv => \%subjectDetectionZ9, Unknown => 1 },
9099             812 => { Name => 'MovieHighResZoom', PrintConv => \%offOn, Unknown => 1 },
9100             847 => {
9101             Name => 'CustomSettingsZ9',
9102             Format => 'undef[608]',
9103             SubDirectory => { TagTable => 'Image::ExifTool::NikonCustom::SettingsZ9' },
9104             },
9105             1474 => { Name => 'Language', PrintConv => \%languageZ9, Unknown => 1 },
9106             1476 => { Name => 'TimeZone', PrintConv => \%timeZoneZ9 },
9107             1482 => { Name => 'MonitorBrightness', PrintConv => \%monitorBrightnessZ9, Unknown => 1 }, # settings: -5 to +5. Added with firmware 3.0: Lo1, Lo2, Hi1, Hi2
9108             1504 => { Name => 'AFFineTune', PrintConv => \%offOn, Unknown => 1 },
9109             1600 => { Name => 'HDMIOutputResolution', PrintConv => \%hDMIOutputResolutionZ9 },
9110             1613 => { Name => 'SetClockFromLocationData', PrintConv => \%offOn, Unknown => 1 },
9111             1620 => { Name => 'AirplaneMode', PrintConv => \%offOn, Unknown => 1 },
9112             1621 => { Name => 'EmptySlotRelease', PrintConv => { 0 => 'Disable Release', 1 => 'Enable Release' }, Unknown => 1 },
9113             1656 => { Name => 'EnergySavingMode', PrintConv => \%offOn, Unknown => 1 },
9114             1680 => { Name => 'RecordLocationData', PrintConv => \%offOn, Unknown => 1 },
9115             1684 => { Name => 'USBPowerDelivery', PrintConv => \%offOn, Unknown => 1 },
9116             1693 => { Name => 'SensorShield', PrintConv => { 0 => 'Stays Open', 1 => 'Closes' }, Unknown => 1 },
9117             1754 => {
9118             Name => 'FocusShiftAutoReset',
9119             Unknown => 1,
9120             PrintConv => \%offOn,
9121             Condition => '$$self{ShutterMode} and $$self{ShutterMode} ne 96 and $$self{FocusShiftShooting} > 0', #not valid for C30/C60/C120
9122             },
9123             1810 => { #CSd4-a
9124             Name => 'PreReleaseBurstLength',
9125             PrintConv => {
9126             0 => 'None',
9127             1 => '0.3 Sec',
9128             2 => '0.5 Sec',
9129             3 => '1 Sec',
9130             },
9131             },
9132             1812 => { #CSd4-b
9133             Name => 'PostReleaseBurstLength',
9134             PrintConv => {
9135             0 => '1 Sec',
9136             1 => '2 Sec',
9137             2 => '3 Sec',
9138             3 => 'Max',
9139             },
9140             },
9141             #1824 ReleaseTimingIndicatorTypeADelay CSd14-b 0 => '1/200' ... 15 => '1/6'
9142             #1826 VerticalISOButton CSf2
9143             #1828 ExposureCompensationButton CSf2
9144             #1830 ISOButton CSf2
9145             #1890 ViewModeShowEffectsOfSettings CSd9-a 0=>'Always', 1=> 'Only When Flash Not Used'
9146             #1892 DispButton CSf2
9147             #1936 FocusPointDisplayOption3DTrackingColor CSa11-d 0=> 'White', 1= => 'Red'
9148             );
9149              
9150             # Flash information (ref JD)
9151             %Image::ExifTool::Nikon::FlashInfo0100 = (
9152             %binaryDataAttrs,
9153             DATAMEMBER => [ 9.2, 15, 16 ],
9154             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9155             NOTES => q{
9156             These tags are used by the D2H, D2Hs, D2X, D2Xs, D50, D70, D70s, D80 and
9157             D200.
9158             },
9159             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
9160             0 => {
9161             Name => 'FlashInfoVersion',
9162             Format => 'string[4]',
9163             Writable => 0,
9164             },
9165             4 => { #PH
9166             Name => 'FlashSource',
9167             PrintConv => {
9168             0 => 'None',
9169             1 => 'External',
9170             2 => 'Internal',
9171             },
9172             },
9173             # 5 - values: 46,48,50,54,78
9174             6 => {
9175             Format => 'int8u[2]',
9176             Name => 'ExternalFlashFirmware',
9177             SeparateTable => 'FlashFirmware',
9178             PrintConv => \%flashFirmware,
9179             },
9180             8 => {
9181             Name => 'ExternalFlashFlags',
9182             PrintConv => { 0 => '(none)',
9183             BITMASK => {
9184             0 => 'Fired', #28
9185             2 => 'Bounce Flash', #PH
9186             4 => 'Wide Flash Adapter',
9187             5 => 'Dome Diffuser', #28
9188             },
9189             },
9190             },
9191             9.1 => {
9192             Name => 'FlashCommanderMode',
9193             Mask => 0x80,
9194             PrintConv => { 0 => 'Off', 1 => 'On' },
9195             },
9196             9.2 => {
9197             Name => 'FlashControlMode',
9198             Mask => 0x7f,
9199             DataMember => 'FlashControlMode',
9200             RawConv => '$$self{FlashControlMode} = $val',
9201             PrintConv => \%flashControlMode,
9202             SeparateTable => 'FlashControlMode',
9203             },
9204             10 => [
9205             {
9206             Name => 'FlashOutput',
9207             Condition => '$$self{FlashControlMode} >= 0x06',
9208             ValueConv => '2 ** (-$val/6)',
9209             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9210             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9211             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9212             },
9213             {
9214             Name => 'FlashCompensation',
9215             Format => 'int8s',
9216             Priority => 0,
9217             ValueConv => '-$val/6',
9218             ValueConvInv => '-6 * $val',
9219             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9220             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9221             },
9222             ],
9223             11 => {
9224             Name => 'FlashFocalLength',
9225             RawConv => '$val ? $val : undef',
9226             PrintConv => '"$val mm"',
9227             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9228             },
9229             12 => {
9230             Name => 'RepeatingFlashRate',
9231             RawConv => '$val ? $val : undef',
9232             PrintConv => '"$val Hz"',
9233             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9234             },
9235             13 => {
9236             Name => 'RepeatingFlashCount',
9237             RawConv => '$val ? $val : undef',
9238             },
9239             14 => { #PH
9240             Name => 'FlashGNDistance',
9241             SeparateTable => 1,
9242             PrintConv => \%flashGNDistance,
9243             },
9244             15 => {
9245             Name => 'FlashGroupAControlMode',
9246             Mask => 0x0f,
9247             DataMember => 'FlashGroupAControlMode',
9248             RawConv => '$$self{FlashGroupAControlMode} = $val',
9249             PrintConv => \%flashControlMode,
9250             SeparateTable => 'FlashControlMode',
9251             },
9252             16 => {
9253             Name => 'FlashGroupBControlMode',
9254             Mask => 0x0f,
9255             DataMember => 'FlashGroupBControlMode',
9256             RawConv => '$$self{FlashGroupBControlMode} = $val',
9257             PrintConv => \%flashControlMode,
9258             SeparateTable => 'FlashControlMode',
9259             },
9260             17 => [
9261             {
9262             Name => 'FlashGroupAOutput',
9263             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
9264             ValueConv => '2 ** (-$val/6)',
9265             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9266             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9267             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9268             },
9269             {
9270             Name => 'FlashGroupACompensation',
9271             Format => 'int8s',
9272             ValueConv => '-$val/6',
9273             ValueConvInv => '-6 * $val',
9274             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9275             PrintConvInv => '$val',
9276             },
9277             ],
9278             18 => [
9279             {
9280             Name => 'FlashGroupBOutput',
9281             Condition => '$$self{FlashGroupBControlMode} >= 0x06',
9282             ValueConv => '2 ** (-$val/6)',
9283             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9284             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9285             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9286             },
9287             {
9288             Name => 'FlashGroupBCompensation',
9289             Format => 'int8s',
9290             ValueConv => '-$val/6',
9291             ValueConvInv => '-6 * $val',
9292             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9293             PrintConvInv => '$val',
9294             },
9295             ],
9296             );
9297              
9298             # Flash information for D40, D40x, D3 and D300 (ref JD)
9299             %Image::ExifTool::Nikon::FlashInfo0102 = (
9300             %binaryDataAttrs,
9301             DATAMEMBER => [ 9.2, 16.1, 17.1, 17.2 ],
9302             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9303             NOTES => q{
9304             These tags are used by the D3 (firmware 1.x), D40, D40X, D60 and D300
9305             (firmware 1.00).
9306             },
9307             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
9308             0 => {
9309             Name => 'FlashInfoVersion',
9310             Format => 'string[4]',
9311             Writable => 0,
9312             },
9313             4 => { #PH
9314             Name => 'FlashSource',
9315             PrintConv => {
9316             0 => 'None',
9317             1 => 'External',
9318             2 => 'Internal',
9319             },
9320             },
9321             # 5 - values: 46,48,50,54,78
9322             6 => {
9323             Format => 'int8u[2]',
9324             Name => 'ExternalFlashFirmware',
9325             SeparateTable => 'FlashFirmware',
9326             PrintConv => \%flashFirmware,
9327             },
9328             8 => {
9329             Name => 'ExternalFlashFlags',
9330             PrintConv => { BITMASK => {
9331             0 => 'Fired', #28
9332             2 => 'Bounce Flash', #PH
9333             4 => 'Wide Flash Adapter',
9334             5 => 'Dome Diffuser', #28
9335             }},
9336             },
9337             9.1 => {
9338             Name => 'FlashCommanderMode',
9339             Mask => 0x80,
9340             PrintConv => { 0 => 'Off', 1 => 'On' },
9341             },
9342             9.2 => {
9343             Name => 'FlashControlMode',
9344             Mask => 0x7f,
9345             DataMember => 'FlashControlMode',
9346             RawConv => '$$self{FlashControlMode} = $val',
9347             PrintConv => \%flashControlMode,
9348             SeparateTable => 'FlashControlMode',
9349             },
9350             10 => [
9351             {
9352             Name => 'FlashOutput',
9353             Condition => '$$self{FlashControlMode} >= 0x06',
9354             ValueConv => '2 ** (-$val/6)',
9355             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9356             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9357             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9358             },
9359             {
9360             Name => 'FlashCompensation',
9361             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
9362             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
9363             Format => 'int8s',
9364             Priority => 0,
9365             ValueConv => '-$val/6',
9366             ValueConvInv => '-6 * $val',
9367             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9368             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9369             },
9370             ],
9371             12 => {
9372             Name => 'FlashFocalLength',
9373             RawConv => '$val ? $val : undef',
9374             PrintConv => '"$val mm"',
9375             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9376             },
9377             13 => {
9378             Name => 'RepeatingFlashRate',
9379             RawConv => '$val ? $val : undef',
9380             PrintConv => '"$val Hz"',
9381             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9382             },
9383             14 => {
9384             Name => 'RepeatingFlashCount',
9385             RawConv => '$val ? $val : undef',
9386             },
9387             15 => { #PH
9388             Name => 'FlashGNDistance',
9389             SeparateTable => 1,
9390             PrintConv => \%flashGNDistance,
9391             },
9392             16.1 => {
9393             Name => 'FlashGroupAControlMode',
9394             Mask => 0x0f,
9395             Notes => 'note: group A tags may apply to the built-in flash settings for some models',
9396             DataMember => 'FlashGroupAControlMode',
9397             RawConv => '$$self{FlashGroupAControlMode} = $val',
9398             PrintConv => \%flashControlMode,
9399             SeparateTable => 'FlashControlMode',
9400             },
9401             17.1 => {
9402             Name => 'FlashGroupBControlMode',
9403             Mask => 0xf0,
9404             Notes => 'note: group B tags may apply to group A settings for some models',
9405             DataMember => 'FlashGroupBControlMode',
9406             RawConv => '$$self{FlashGroupBControlMode} = $val',
9407             PrintConv => \%flashControlMode,
9408             SeparateTable => 'FlashControlMode',
9409             },
9410             17.2 => { #PH
9411             Name => 'FlashGroupCControlMode',
9412             Mask => 0x0f,
9413             Notes => 'note: group C tags may apply to group B settings for some models',
9414             DataMember => 'FlashGroupCControlMode',
9415             RawConv => '$$self{FlashGroupCControlMode} = $val',
9416             PrintConv => \%flashControlMode,
9417             SeparateTable => 'FlashControlMode',
9418             },
9419             18 => [
9420             {
9421             Name => 'FlashGroupAOutput',
9422             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
9423             ValueConv => '2 ** (-$val/6)',
9424             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9425             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9426             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9427             },
9428             {
9429             Name => 'FlashGroupACompensation',
9430             Format => 'int8s',
9431             ValueConv => '-$val/6',
9432             ValueConvInv => '-6 * $val',
9433             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9434             PrintConvInv => '$val',
9435             },
9436             ],
9437             19 => [
9438             {
9439             Name => 'FlashGroupBOutput',
9440             Condition => '$$self{FlashGroupBControlMode} >= 0x60',
9441             ValueConv => '2 ** (-$val/6)',
9442             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9443             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9444             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9445             },
9446             {
9447             Name => 'FlashGroupBCompensation',
9448             Format => 'int8s',
9449             ValueConv => '-$val/6',
9450             ValueConvInv => '-6 * $val',
9451             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9452             PrintConvInv => '$val',
9453             },
9454             ],
9455             20 => [ #PH
9456             {
9457             Name => 'FlashGroupCOutput',
9458             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
9459             ValueConv => '2 ** (-$val/6)',
9460             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9461             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9462             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9463             },
9464             {
9465             Name => 'FlashGroupCCompensation',
9466             Format => 'int8s',
9467             ValueConv => '-$val/6',
9468             ValueConvInv => '-6 * $val',
9469             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9470             PrintConvInv => '$val',
9471             },
9472             ],
9473             );
9474              
9475             # Flash information for D90 and D700 (ref PH)
9476             # - confirmed in detail for D800 (0105) - PH
9477             %Image::ExifTool::Nikon::FlashInfo0103 = (
9478             %binaryDataAttrs,
9479             DATAMEMBER => [ 9.2, 17.1, 18.1, 18.2 ],
9480             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9481             NOTES => q{
9482             These tags are used by the D3 (firmware 2.x), D3X, D3S, D4, D90, D300
9483             (firmware 1.10), D300S, D600, D700, D800, D3000, D3100, D3200, D5000, D5100,
9484             D5200, D7000.
9485             },
9486             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
9487             0 => {
9488             Name => 'FlashInfoVersion',
9489             Format => 'string[4]',
9490             Writable => 0,
9491             },
9492             4 => { #PH
9493             Name => 'FlashSource',
9494             PrintConv => {
9495             0 => 'None',
9496             1 => 'External',
9497             2 => 'Internal',
9498             },
9499             },
9500             # 5 - values: 46,48,50,54,78
9501             6 => {
9502             Format => 'int8u[2]',
9503             Name => 'ExternalFlashFirmware',
9504             SeparateTable => 'FlashFirmware',
9505             PrintConv => \%flashFirmware,
9506             },
9507             8 => {
9508             Name => 'ExternalFlashFlags',
9509             PrintConv => { BITMASK => {
9510             0 => 'Fired', #28
9511             2 => 'Bounce Flash', #PH
9512             4 => 'Wide Flash Adapter',
9513             5 => 'Dome Diffuser', #28
9514             }},
9515             },
9516             9.1 => {
9517             Name => 'FlashCommanderMode',
9518             Mask => 0x80,
9519             PrintConv => { 0 => 'Off', 1 => 'On' },
9520             },
9521             9.2 => {
9522             Name => 'FlashControlMode',
9523             Mask => 0x7f,
9524             DataMember => 'FlashControlMode',
9525             RawConv => '$$self{FlashControlMode} = $val',
9526             PrintConv => \%flashControlMode,
9527             SeparateTable => 'FlashControlMode',
9528             },
9529             10 => [
9530             {
9531             Name => 'FlashOutput',
9532             Condition => '$$self{FlashControlMode} >= 0x06',
9533             ValueConv => '2 ** (-$val/6)',
9534             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9535             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9536             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9537             },
9538             {
9539             Name => 'FlashCompensation',
9540             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
9541             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
9542             Format => 'int8s',
9543             Priority => 0,
9544             ValueConv => '-$val/6',
9545             ValueConvInv => '-6 * $val',
9546             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9547             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9548             },
9549             ],
9550             12 => { #JD
9551             Name => 'FlashFocalLength',
9552             RawConv => '($val and $val != 255) ? $val : undef',
9553             PrintConv => '"$val mm"',
9554             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9555             },
9556             13 => { #JD
9557             Name => 'RepeatingFlashRate',
9558             RawConv => '($val and $val != 255) ? $val : undef',
9559             PrintConv => '"$val Hz"',
9560             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9561             },
9562             14 => { #JD
9563             Name => 'RepeatingFlashCount',
9564             RawConv => '($val and $val != 255) ? $val : undef',
9565             },
9566             15 => { #28
9567             Name => 'FlashGNDistance',
9568             SeparateTable => 1,
9569             PrintConv => \%flashGNDistance,
9570             },
9571             16 => { #28
9572             Name => 'FlashColorFilter',
9573             SeparateTable => 1,
9574             PrintConv => \%flashColorFilter,
9575             },
9576             17.1 => {
9577             Name => 'FlashGroupAControlMode',
9578             Mask => 0x0f,
9579             Notes => 'note: group A tags may apply to the built-in flash settings for some models',
9580             DataMember => 'FlashGroupAControlMode',
9581             RawConv => '$$self{FlashGroupAControlMode} = $val',
9582             PrintConv => \%flashControlMode,
9583             SeparateTable => 'FlashControlMode',
9584             },
9585             18.1 => {
9586             Name => 'FlashGroupBControlMode',
9587             Mask => 0xf0,
9588             Notes => 'note: group B tags may apply to group A settings for some models',
9589             DataMember => 'FlashGroupBControlMode',
9590             RawConv => '$$self{FlashGroupBControlMode} = $val',
9591             PrintConv => \%flashControlMode,
9592             SeparateTable => 'FlashControlMode',
9593             },
9594             18.2 => { #PH
9595             Name => 'FlashGroupCControlMode',
9596             Mask => 0x0f,
9597             Notes => 'note: group C tags may apply to group B settings for some models',
9598             DataMember => 'FlashGroupCControlMode',
9599             RawConv => '$$self{FlashGroupCControlMode} = $val',
9600             PrintConv => \%flashControlMode,
9601             SeparateTable => 'FlashControlMode',
9602             },
9603             0x13 => [
9604             {
9605             Name => 'FlashGroupAOutput',
9606             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
9607             ValueConv => '2 ** (-$val/6)',
9608             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9609             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9610             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9611             },
9612             {
9613             Name => 'FlashGroupACompensation',
9614             Format => 'int8s',
9615             ValueConv => '-$val/6',
9616             ValueConvInv => '-6 * $val',
9617             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9618             PrintConvInv => '$val',
9619             },
9620             ],
9621             0x14 => [
9622             {
9623             Name => 'FlashGroupBOutput',
9624             Condition => '$$self{FlashGroupBControlMode} >= 0x60',
9625             ValueConv => '2 ** (-$val/6)',
9626             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9627             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9628             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9629             },
9630             {
9631             Name => 'FlashGroupBCompensation',
9632             Format => 'int8s',
9633             ValueConv => '-$val/6',
9634             ValueConvInv => '-6 * $val',
9635             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9636             PrintConvInv => '$val',
9637             },
9638             ],
9639             0x15 => [ #PH
9640             {
9641             Name => 'FlashGroupCOutput',
9642             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
9643             ValueConv => '2 ** (-$val/6)',
9644             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9645             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9646             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9647             },
9648             {
9649             Name => 'FlashGroupCCompensation',
9650             Format => 'int8s',
9651             ValueConv => '-$val/6',
9652             ValueConvInv => '-6 * $val',
9653             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9654             PrintConvInv => '$val',
9655             },
9656             ],
9657             0x1b => { #PH
9658             Name => 'ExternalFlashCompensation',
9659             Format => 'int8s',
9660             Priority => 0,
9661             ValueConv => '-$val/6',
9662             ValueConvInv => '-6 * $val',
9663             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9664             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9665             },
9666             0x1d => { #PH
9667             Name => 'FlashExposureComp3',
9668             Format => 'int8s',
9669             # (does not include the built-in compensation for FlashType "Built-in,TTL&Comdr.")
9670             Notes => 'does not include the effect of flash bracketing',
9671             Priority => 0,
9672             ValueConv => '-$val/6',
9673             ValueConvInv => '-6 * $val',
9674             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9675             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9676             },
9677             0x27 => { #PH (same as ShotInfoD800 0x4d2 but also valid for repeating flash)
9678             Name => 'FlashExposureComp4',
9679             Format => 'int8s',
9680             Notes => 'includes the effect of flash bracketing. Valid for repeating flash',
9681             Priority => 0,
9682             ValueConv => '-$val/6',
9683             ValueConvInv => '-6 * $val',
9684             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9685             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9686             },
9687             # 0x2b - related to flash power (PH, D800, 96=full,62=1/4,2=1/128)
9688             );
9689              
9690             # Flash information for the D7100 (ref PH)
9691             # (this is VERY similar to FlashInfo0107, but there are a few differences that
9692             # would need to be resolved if these two definitions were to be combined)
9693             %Image::ExifTool::Nikon::FlashInfo0106 = (
9694             %binaryDataAttrs,
9695             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9696             DATAMEMBER => [ 9.2, 17.1, 18.1, 18.2 ],
9697             NOTES => 'These tags are used by the Df, D610, D3300, D5300, D7100 and Coolpix A.',
9698             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
9699             0 => {
9700             Name => 'FlashInfoVersion',
9701             Format => 'string[4]',
9702             Writable => 0,
9703             },
9704             4 => {
9705             Name => 'FlashSource',
9706             PrintConv => {
9707             0 => 'None',
9708             1 => 'External',
9709             2 => 'Internal',
9710             },
9711             },
9712             6 => {
9713             Format => 'int8u[2]',
9714             Name => 'ExternalFlashFirmware',
9715             SeparateTable => 'FlashFirmware',
9716             PrintConv => \%flashFirmware,
9717             },
9718             8 => {
9719             Name => 'ExternalFlashFlags',
9720             PrintConv => { BITMASK => {
9721             0 => 'Fired',
9722             2 => 'Bounce Flash',
9723             4 => 'Wide Flash Adapter',
9724             5 => 'Dome Diffuser', # (NC, not true for the SB-910 anyway)
9725             # 7 - ? (set for SB-910 when an advanced option is used, eg. diff pattern)
9726             }},
9727             },
9728             9.1 => { # (NC)
9729             Name => 'FlashCommanderMode',
9730             Mask => 0x80,
9731             PrintConv => { 0 => 'Off', 1 => 'On' },
9732             },
9733             9.2 => {
9734             Name => 'FlashControlMode',
9735             Mask => 0x7f,
9736             DataMember => 'FlashControlMode',
9737             RawConv => '$$self{FlashControlMode} = $val',
9738             PrintConv => \%flashControlMode,
9739             SeparateTable => 'FlashControlMode',
9740             },
9741             # 10 - similar to 0x27 but zero sometimes when I don't think it should be
9742             12 => {
9743             Name => 'FlashFocalLength',
9744             Notes => 'only valid if flash pattern is "Standard Illumination"',
9745             RawConv => '($val and $val != 255) ? $val : undef',
9746             PrintConv => '"$val mm"',
9747             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9748             },
9749             13 => {
9750             Name => 'RepeatingFlashRate',
9751             RawConv => '($val and $val != 255) ? $val : undef',
9752             PrintConv => '"$val Hz"',
9753             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9754             },
9755             14 => {
9756             Name => 'RepeatingFlashCount',
9757             RawConv => '($val and $val != 255) ? $val : undef',
9758             },
9759             15 => { # (NC)
9760             Name => 'FlashGNDistance',
9761             SeparateTable => 1,
9762             PrintConv => \%flashGNDistance,
9763             },
9764             16 => {
9765             Name => 'FlashColorFilter',
9766             SeparateTable => 1,
9767             PrintConv => \%flashColorFilter,
9768             },
9769             17.1 => {
9770             Name => 'FlashGroupAControlMode',
9771             Mask => 0x0f,
9772             DataMember => 'FlashGroupAControlMode',
9773             RawConv => '$$self{FlashGroupAControlMode} = $val',
9774             PrintConv => \%flashControlMode,
9775             SeparateTable => 'FlashControlMode',
9776             },
9777             18.1 => {
9778             Name => 'FlashGroupBControlMode',
9779             Mask => 0xf0,
9780             DataMember => 'FlashGroupBControlMode',
9781             RawConv => '$$self{FlashGroupBControlMode} = $val',
9782             PrintConv => \%flashControlMode,
9783             SeparateTable => 'FlashControlMode',
9784             },
9785             18.2 => {
9786             Name => 'FlashGroupCControlMode',
9787             Mask => 0x0f,
9788             DataMember => 'FlashGroupCControlMode',
9789             RawConv => '$$self{FlashGroupCControlMode} = $val',
9790             PrintConv => \%flashControlMode,
9791             SeparateTable => 'FlashControlMode',
9792             },
9793             # 0x13 - same as 0x28 but not zero when flash group A is Off
9794             # 0x14 - same as 0x29 but not zero when flash group B is Off
9795             # 0x15 - same as 0x2a but not zero when flash group B is Off
9796             # 0x1a - changes with illumination pattern (0=normal,1=narrow,2=wide), but other values seen
9797             # 0x26 - changes when diffuser is used
9798             0x27 => [
9799             {
9800             Name => 'FlashOutput',
9801             Condition => '$$self{FlashControlMode} >= 0x06',
9802             ValueConv => '2 ** (-$val/6)',
9803             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9804             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9805             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9806             },
9807             {
9808             Name => 'FlashCompensation',
9809             Format => 'int8s',
9810             Priority => 0,
9811             ValueConv => '-$val/6',
9812             ValueConvInv => '-6 * $val',
9813             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9814             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9815             },
9816             ],
9817             0x28 => [
9818             {
9819             Name => 'FlashGroupAOutput',
9820             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
9821             ValueConv => '2 ** (-$val/6)',
9822             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9823             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9824             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9825             },
9826             {
9827             Name => 'FlashGroupACompensation',
9828             Format => 'int8s',
9829             ValueConv => '-$val/6',
9830             ValueConvInv => '-6 * $val',
9831             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9832             PrintConvInv => '$val',
9833             },
9834             ],
9835             0x29 => [
9836             {
9837             Name => 'FlashGroupBOutput',
9838             Condition => '$$self{FlashGroupBControlMode} >= 0x60',
9839             ValueConv => '2 ** (-$val/6)',
9840             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9841             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9842             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9843             },
9844             {
9845             Name => 'FlashGroupBCompensation',
9846             Format => 'int8s',
9847             ValueConv => '-$val/6',
9848             ValueConvInv => '-6 * $val',
9849             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9850             PrintConvInv => '$val',
9851             },
9852             ],
9853             0x2a => [
9854             {
9855             Name => 'FlashGroupCOutput',
9856             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
9857             ValueConv => '2 ** (-$val/6)',
9858             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9859             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9860             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9861             },
9862             {
9863             Name => 'FlashGroupCCompensation',
9864             Format => 'int8s',
9865             ValueConv => '-$val/6',
9866             ValueConvInv => '-6 * $val',
9867             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
9868             PrintConvInv => '$val',
9869             },
9870             ],
9871             );
9872              
9873             # Flash information for the D4S/D750/D810/D5500/D7200 (0107)
9874             # and D5/D500/D850/D3400 (0108) (ref 28)
9875             %Image::ExifTool::Nikon::FlashInfo0107 = (
9876             %binaryDataAttrs,
9877             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
9878             DATAMEMBER => [ 17.1, 18.1, 18.2 ],
9879             NOTES => q{
9880             These tags are used by the D4S, D750, D810, D5500, D7200 (FlashInfoVersion
9881             0107) and the D5, D500, D850 and D3400 (FlashInfoVersion 0108).
9882             },
9883             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
9884             0 => {
9885             Name => 'FlashInfoVersion',
9886             Format => 'string[4]',
9887             Writable => 0,
9888             },
9889             4 => {
9890             Name => 'FlashSource',
9891             PrintConv => {
9892             0 => 'None',
9893             1 => 'External',
9894             2 => 'Internal',
9895             },
9896             },
9897             6 => {
9898             Format => 'int8u[2]',
9899             Name => 'ExternalFlashFirmware',
9900             SeparateTable => 'FlashFirmware',
9901             PrintConv => \%flashFirmware,
9902             },
9903             8.1 => {
9904             Name => 'ExternalFlashZoomOverride',
9905             Mask => 0x80,
9906             Notes => 'indicates that the user has overridden the flash zoom distance',
9907             PrintConv => { 0 => 'No', 1 => 'Yes' },
9908             },
9909             8.2 => {
9910             Name => 'ExternalFlashStatus',
9911             Mask => 0x01,
9912             PrintConv => {
9913             0 => 'Flash Not Attached',
9914             1 => 'Flash Attached',
9915             },
9916             },
9917             9.1 => {
9918             Name => 'ExternalFlashReadyState',
9919             Mask => 0x07,
9920             PrintConv => {
9921             0 => 'n/a',
9922             1 => 'Ready',
9923             6 => 'Not Ready',
9924             },
9925             },
9926             10 => {
9927             Name => 'FlashCompensation',
9928             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
9929             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
9930             Format => 'int8s',
9931             Priority => 0,
9932             ValueConv => '-$val/6',
9933             ValueConvInv => '-6 * $val',
9934             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
9935             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
9936             },
9937             12 => {
9938             Name => 'FlashFocalLength',
9939             Notes => 'only valid if flash pattern is "Standard Illumination"', #illumination pattern no no supported starting with the SB-910
9940             RawConv => '($val and $val != 255) ? $val : undef',
9941             PrintConv => '"$val mm"',
9942             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9943             },
9944             13 => {
9945             Name => 'RepeatingFlashRate',
9946             RawConv => '($val and $val != 255) ? $val : undef',
9947             PrintConv => '"$val Hz"',
9948             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
9949             },
9950             14 => {
9951             Name => 'RepeatingFlashCount',
9952             RawConv => '($val and $val != 255) ? $val : undef',
9953             },
9954             15 => {
9955             Name => 'FlashGNDistance',
9956             SeparateTable => 1,
9957             PrintConv => \%flashGNDistance,
9958             },
9959             17.1 => { #PH
9960             Name => 'FlashGroupAControlMode',
9961             Mask => 0x0f,
9962             Notes => 'note: group A tags may apply to the built-in flash settings for some models',
9963             DataMember => 'FlashGroupAControlMode',
9964             RawConv => '$$self{FlashGroupAControlMode} = $val',
9965             PrintConv => \%flashControlMode,
9966             SeparateTable => 'FlashControlMode',
9967             },
9968             18.1 => { #PH
9969             Name => 'FlashGroupBControlMode',
9970             Mask => 0xf0,
9971             Notes => 'note: group B tags may apply to group A settings for some models',
9972             DataMember => 'FlashGroupBControlMode',
9973             RawConv => '$$self{FlashGroupBControlMode} = $val',
9974             PrintConv => \%flashControlMode,
9975             SeparateTable => 'FlashControlMode',
9976             },
9977             18.2 => { #PH
9978             Name => 'FlashGroupCControlMode',
9979             Mask => 0x0f,
9980             Notes => 'note: group C tags may apply to group B settings for some models',
9981             DataMember => 'FlashGroupCControlMode',
9982             RawConv => '$$self{FlashGroupCControlMode} = $val',
9983             PrintConv => \%flashControlMode,
9984             SeparateTable => 'FlashControlMode',
9985             },
9986             # 0x13 - very similar to 0x28
9987             # 0x18 or 0x19 may indicate flash illumination pattern (Standard, Center-weighted, Even)
9988             0x28 => [ #PH
9989             {
9990             Name => 'FlashGroupAOutput',
9991             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
9992             ValueConv => '2 ** (-$val/6)',
9993             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
9994             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
9995             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
9996             },
9997             {
9998             Name => 'FlashGroupACompensation',
9999             Format => 'int8s',
10000             ValueConv => '-$val/6',
10001             ValueConvInv => '-6 * $val',
10002             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
10003             PrintConvInv => '$val',
10004             },
10005             ],
10006             0x29 => [ #PH
10007             {
10008             Name => 'FlashGroupBOutput',
10009             Condition => '$$self{FlashGroupBControlMode} >= 0x06',
10010             ValueConv => '2 ** (-$val/6)',
10011             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
10012             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
10013             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
10014             },
10015             {
10016             Name => 'FlashGroupBCompensation',
10017             Format => 'int8s',
10018             ValueConv => '-$val/6',
10019             ValueConvInv => '-6 * $val',
10020             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
10021             PrintConvInv => '$val',
10022             },
10023             ],
10024             0x2a => [ #PH
10025             {
10026             Name => 'FlashGroupCOutput',
10027             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
10028             ValueConv => '2 ** (-$val/6)',
10029             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
10030             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
10031             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
10032             },
10033             {
10034             Name => 'FlashGroupCCompensation',
10035             Format => 'int8s',
10036             ValueConv => '-$val/6',
10037             ValueConvInv => '-6 * $val',
10038             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
10039             PrintConvInv => '$val',
10040             },
10041             ],
10042             );
10043              
10044             # Flash information for the Z7II (ref 28)
10045             # (likey similar to FlashInfo010 and FlashInfo0108 with addition of support for radio controlled units such as the SB-5000?
10046             %Image::ExifTool::Nikon::FlashInfo0300 = (
10047             %binaryDataAttrs,
10048             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10049             DATAMEMBER => [ 9.2, 17.1, 18.1, 18.2 ],
10050             0 => {
10051             Name => 'FlashInfoVersion',
10052             Format => 'string[4]',
10053             Writable => 0,
10054             },
10055             4 => {
10056             Name => 'FlashSource',
10057             PrintConv => {
10058             0 => 'None',
10059             1 => 'External',
10060             2 => 'Internal',
10061             },
10062             },
10063             6 => {
10064             Name => 'ExternalFlashFirmware',
10065             Format => 'int8u[2]',
10066             SeparateTable => 'FlashFirmware',
10067             PrintConv => \%flashFirmware,
10068             },
10069             8 => {
10070             Name => 'ExternalFlashFlags',
10071             PrintConv => { BITMASK => {
10072             0 => 'Flash Ready', #flash status is 'Not Ready' when this bit is off and FlashSource is non-zero
10073             # 1 - ? (observed with SB-900)
10074             2 => 'Bounce Flash',
10075             4 => 'Wide Flash Adapter',
10076             7 => 'Zoom Override', #override takes place when the Wide Flash Adapter is dropped in place and/or the zoom level is overriden on via flash menu
10077             }},
10078             },
10079             9.1 => {
10080             Name => 'FlashCommanderMode',
10081             Mask => 0x80,
10082             PrintConv => { 0 => 'Off', 1 => 'On' },
10083             },
10084             9.2 => {
10085             Name => 'FlashControlMode',
10086             Mask => 0x7f,
10087             DataMember => 'FlashControlMode',
10088             RawConv => '$$self{FlashControlMode} = $val',
10089             PrintConv => \%flashControlMode,
10090             SeparateTable => 'FlashControlMode',
10091             },
10092             10 => {
10093             Name => 'FlashCompensation',
10094             # this is the compensation from the camera (0x0012) for "Built-in" FlashType, or
10095             # the compensation from the external unit (0x0017) for "Optional" FlashType - PH
10096             Condition => '$$self{FlashControlMode} == 0x01 or $$self{FlashControlMode} == 0x02', #only valid for TTL and TTL-BL modes
10097             Format => 'int8s',
10098             Priority => 0,
10099             ValueConv => '-$val/6',
10100             ValueConvInv => '-6 * $val',
10101             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
10102             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
10103             },
10104             13 => {
10105             Name => 'RepeatingFlashRate',
10106             RawConv => '($val and $val != 255) ? $val : undef',
10107             PrintConv => '"$val Hz"',
10108             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
10109             },
10110             14 => {
10111             Name => 'RepeatingFlashCount',
10112             RawConv => '($val and $val != 255) ? $val : undef',
10113             },
10114             15 => {
10115             Name => 'FlashGNDistance',
10116             SeparateTable => 1,
10117             PrintConv => \%flashGNDistance,
10118             },
10119             16 => {
10120             Name => 'FlashColorFilter',
10121             SeparateTable => 1,
10122             PrintConv => \%flashColorFilter,
10123             },
10124             17.1 => { #PH
10125             Name => 'FlashGroupAControlMode',
10126             Mask => 0x0f,
10127             Notes => 'note: group A tags may apply to the built-in flash settings for some models',
10128             DataMember => 'FlashGroupAControlMode',
10129             RawConv => '$$self{FlashGroupAControlMode} = $val',
10130             PrintConv => \%flashControlMode,
10131             SeparateTable => 'FlashControlMode',
10132             },
10133             18.1 => { #PH
10134             Name => 'FlashGroupBControlMode',
10135             Mask => 0xf0,
10136             Notes => 'note: group B tags may apply to group A settings for some models',
10137             DataMember => 'FlashGroupBControlMode',
10138             RawConv => '$$self{FlashGroupBControlMode} = $val',
10139             PrintConv => \%flashControlMode,
10140             SeparateTable => 'FlashControlMode',
10141             },
10142             18.2 => { #PH
10143             Name => 'FlashGroupCControlMode',
10144             Mask => 0x0f,
10145             Notes => 'note: group C tags may apply to group B settings for some models',
10146             DataMember => 'FlashGroupCControlMode',
10147             RawConv => '$$self{FlashGroupCControlMode} = $val',
10148             PrintConv => \%flashControlMode,
10149             SeparateTable => 'FlashControlMode',
10150             },
10151             33 => {
10152             Name => 'FlashOutput',
10153             Condition => '$$self{FlashControlMode} >= 0x06', #only valid for M mode
10154             ValueConv => '2 ** (-$val/6)',
10155             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
10156             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
10157             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
10158             },
10159             37 => {
10160             Name => 'FlashIlluminationPattern',
10161             PrintConv => {
10162             0 => 'Standard',
10163             1 => 'Center-weighted',
10164             2 => 'Even',
10165             },
10166             },
10167             38 => {
10168             Name => 'FlashFocalLength',
10169             Notes => 'only valid if flash pattern is "Standard Illumination"',
10170             RawConv => '($val and $val != 255) ? $val : undef',
10171             PrintConv => '"$val mm"',
10172             PrintConvInv => '$val=~/(\d+)/; $1 || 0',
10173             },
10174             40 => [ #PH
10175             {
10176             Name => 'FlashGroupAOutput',
10177             Condition => '$$self{FlashGroupAControlMode} >= 0x06',
10178             ValueConv => '2 ** (-$val/6)',
10179             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
10180             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
10181             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
10182             },
10183             {
10184             Name => 'FlashGroupACompensation',
10185             Format => 'int8s',
10186             ValueConv => '-($val-2)/6',
10187             ValueConvInv => '-6 * $val + 2',
10188             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
10189             PrintConvInv => '$val',
10190             },
10191             ],
10192             41 => [ #PH
10193             {
10194             Name => 'FlashGroupBOutput',
10195             Condition => '$$self{FlashGroupBControlMode} >= 0x06',
10196             ValueConv => '2 ** (-$val/6)',
10197             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
10198             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
10199             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
10200             },
10201             {
10202             Name => 'FlashGroupBCompensation',
10203             Format => 'int8s',
10204             ValueConv => '-($val-2)/6',
10205             ValueConvInv => '-6 * $val + 2',
10206             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
10207             PrintConvInv => '$val',
10208             },
10209             ],
10210             42 => [ #PH
10211             {
10212             Name => 'FlashGroupCOutput',
10213             Condition => '$$self{FlashGroupCControlMode} >= 0x06',
10214             ValueConv => '2 ** (-$val/6)',
10215             ValueConvInv => '$val>0 ? -6*log($val)/log(2) : 0',
10216             PrintConv => '$val>0.99 ? "Full" : sprintf("%.0f%%",$val*100)',
10217             PrintConvInv => '$val=~/(\d+)/ ? $1/100 : 1',
10218             },
10219             {
10220             Name => 'FlashGroupCCompensation',
10221             Format => 'int8s',
10222             ValueConv => '-($val-2)/6',
10223             ValueConvInv => '-6 * $val + 2',
10224             PrintConv => '$val ? sprintf("%+.1f",$val) : 0',
10225             PrintConvInv => '$val',
10226             },
10227             ],
10228             );
10229             # Unknown Flash information
10230             %Image::ExifTool::Nikon::FlashInfoUnknown = (
10231             %binaryDataAttrs,
10232             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10233             0 => {
10234             Name => 'FlashInfoVersion',
10235             Format => 'string[4]',
10236             Writable => 0,
10237             },
10238             );
10239              
10240             # Multi exposure / image overlay information (ref PH)
10241             %Image::ExifTool::Nikon::MultiExposure = (
10242             %binaryDataAttrs,
10243             FORMAT => 'int32u',
10244             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10245             0 => {
10246             Name => 'MultiExposureVersion',
10247             Format => 'string[4]',
10248             Writable => 0,
10249             },
10250             1 => {
10251             Name => 'MultiExposureMode',
10252             PrintConv => {
10253             0 => 'Off',
10254             1 => 'Multiple Exposure',
10255             2 => 'Image Overlay',
10256             3 => 'HDR', #31
10257             },
10258             },
10259             2 => 'MultiExposureShots',
10260             3 => {
10261             Name => 'MultiExposureAutoGain',
10262             PrintConv => \%offOn,
10263             },
10264             );
10265              
10266             # Multi exposure2 / image overlay information (ref 39)
10267             %Image::ExifTool::Nikon::MultiExposure2 = (
10268             %binaryDataAttrs,
10269             FORMAT => 'int32u',
10270             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10271             0 => {
10272             Name => 'MultiExposureVersion',
10273             Format => 'string[4]',
10274             Writable => 0,
10275             },
10276             1 => {
10277             Name => 'MultiExposureMode',
10278             PrintConv => {
10279             0 => 'Off',
10280             1 => 'Multiple Exposure',
10281             3 => 'HDR',
10282             },
10283             },
10284             2 => 'MultiExposureShots',
10285             3 => {
10286             Name => 'MultiExposureOverlayMode',
10287             PrintConv => {
10288             0 => 'Add',
10289             1 => 'Average',
10290             2 => 'Light',
10291             3 => 'Dark',
10292             },
10293             },
10294             );
10295              
10296             # HDR information (ref 32)
10297             %Image::ExifTool::Nikon::HDRInfo = (
10298             %binaryDataAttrs,
10299             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
10300             # NOTE: Must set ByteOrder in SubDirectory if any multi-byte integer tags added
10301             0 => {
10302             Name => 'HDRInfoVersion',
10303             Format => 'string[4]',
10304             Writable => 0,
10305             },
10306             4 => {
10307             Name => 'HDR',
10308             PrintConv => {
10309             0 => 'Off',
10310             1 => 'On (normal)',
10311             48 => 'Auto', #PH (NC)
10312             },
10313             },
10314             5 => {
10315             Name => 'HDRLevel',
10316             PrintConv => {
10317             0 => 'Auto',
10318             1 => '1 EV',
10319             2 => '2 EV',
10320             3 => '3 EV',
10321             # 5 - seen for 1J4
10322             255 => 'n/a', #PH
10323             },
10324             },
10325             6 => {
10326             Name => 'HDRSmoothing',
10327             PrintConv => {
10328             0 => 'Off',
10329             1 => 'Normal',
10330             2 => 'Low',
10331             3 => 'High',
10332             48 => 'Auto', #PH (NC)
10333             255 => 'n/a', #PH
10334             },
10335             },
10336             7 => { #PH (P330, HDRInfoVersion=0101)
10337             Name => 'HDRLevel2',
10338             PrintConv => {
10339             0 => 'Auto',
10340             1 => '1 EV',
10341             2 => '2 EV',
10342             3 => '3 EV',
10343             255 => 'n/a',
10344             },
10345             },
10346             );
10347              
10348             # ref 39 (Z9)
10349             %Image::ExifTool::Nikon::HDRInfo2 = (
10350             %binaryDataAttrs,
10351             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
10352             0 => {
10353             Name => 'HDRInfoVersion', # 0200
10354             Format => 'string[4]',
10355             Writable => 0,
10356             },
10357             4 => {
10358             Name => 'HDR',
10359             PrintConv => {
10360             0 => 'Off',
10361             1 => 'On (normal)',
10362             },
10363             },
10364             5 => {
10365             Name => 'HDRLevel',
10366             PrintConv => {
10367             0 => 'n/a',
10368             1 => 'Normal',
10369             2 => 'Low',
10370             3 => 'High',
10371             4 => 'High+',
10372             5 => 'Auto',
10373             },
10374             },
10375             );
10376              
10377             # location information (ref PH)
10378             %Image::ExifTool::Nikon::LocationInfo = (
10379             %binaryDataAttrs,
10380             DATAMEMBER => [ 4 ],
10381             GROUPS => { 0 => 'MakerNotes', 2 => 'Location' },
10382             NOTES => 'Tags written by some Nikon GPS-equipped cameras like the AW100.',
10383             0 => {
10384             Name => 'LocationInfoVersion',
10385             Format => 'undef[4]',
10386             },
10387             4 => {
10388             Name => 'TextEncoding',
10389             DataMember => 'TextEncoding',
10390             RawConv => q{
10391             $$self{TextEncoding} = $Image::ExifTool::Nikon::nikonTextEncoding{$val} if $val;
10392             return $val;
10393             },
10394             PrintConv => \%Image::ExifTool::Nikon::nikonTextEncoding,
10395             },
10396             # (the CountryCode and Location tag names chosen to correspond with XMP::iptcCore)
10397             5 => {
10398             Name => 'CountryCode',
10399             Format => 'undef[3]',
10400             ValueConv => '$val=~s/\0.*//s; $val', # truncate at null
10401             ValueConvInv => '$val',
10402             },
10403             8 => 'POILevel', #forum5782
10404             9 => {
10405             Name => 'Location',
10406             Format => 'undef[70]',
10407             RawConv => '$$self{TextEncoding} ? $self->Decode($val,$$self{TextEncoding},"MM") : $val',
10408             RawConvInv => '$$self{TextEncoding} ? $self->Encode($val,$$self{TextEncoding},"MM") : $val',
10409             },
10410             );
10411              
10412             # MakerNotes0x51 - compression info for Z9
10413             %Image::ExifTool::Nikon::MakerNotes0x51 = (
10414             %binaryDataAttrs,
10415             DATAMEMBER => [ 0 ],
10416             GROUPS => { 0 => 'MakerNotes' },
10417             0 => {
10418             Name => 'FirmwareVersion',
10419             Format => 'string[8]',
10420             Writable => 0,
10421             RawConv => '$$self{FirmwareVersion} = $val',
10422             },
10423             10 => {
10424             Name => 'NEFCompression',
10425             Writable => 'int16u',
10426             SeparateTable => 'NEFCompression',
10427             PrintConv => \%nefCompression,
10428             },
10429             );
10430              
10431             # MakerNotes0x56 - burst info for Z9
10432             %Image::ExifTool::Nikon::MakerNotes0x56 = (
10433             %binaryDataAttrs,
10434             GROUPS => { 0 => 'MakerNotes' },
10435             0 => {
10436             Name => 'FirmwareVersion',
10437             Format => 'string[4]',
10438             Writable => 0,
10439             },
10440             4 => {
10441             Name => 'BurstGroupID', #all frames shot within a burst (using CL/CH/C30/C60/C120) will share the same BurstGroupID. Value will be > 0 for all images shot in continuous modes. 0 for single-frame.
10442             Format => 'int16u'
10443             },
10444             );
10445              
10446             # extra info found in IFD0 of NEF files (ref PH, Z6/Z7)
10447             %Image::ExifTool::Nikon::NEFInfo = (
10448             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10449             NOTES => q{
10450             As-yet unknown information found in SubIFD1 tag 0xc7d5 of NEF images from
10451             cameras such as the Z6 and Z7, and NRW images from some Coolpix cameras.
10452             },
10453             # 0x01 - undef[12]
10454             # 0x02 - undef[148]
10455             # 0x03 - undef[284]
10456             # 0x04 - undef[148,212]
10457             # 0x05 - undef[84] (barrel distortion params at offsets 0x14,0x1c,0x24, ref 28)
10458             # 0x06 - undef[116] (vignette correction params at offsets 0x24,0x34,0x44, ref 28)
10459             # 0x07 - undef[104]
10460             # 0x08 - undef[24]
10461             # 0x09 - undef[36]
10462             );
10463              
10464             # tags in Nikon QuickTime videos (PH - observations with Coolpix S3)
10465             # (similar information in Kodak,Minolta,Nikon,Olympus,Pentax and Sanyo videos)
10466             %Image::ExifTool::Nikon::MOV = (
10467             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
10468             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10469             FIRST_ENTRY => 0,
10470             NOTES => q{
10471             This information is found in MOV and QT videos from some Nikon cameras.
10472             },
10473             0x00 => {
10474             Name => 'Make',
10475             Format => 'string[24]',
10476             },
10477             0x18 => {
10478             Name => 'Model',
10479             Description => 'Camera Model Name',
10480             Format => 'string[8]',
10481             },
10482             # (01 00 at offset 0x20)
10483             0x26 => {
10484             Name => 'ExposureTime',
10485             Format => 'int32u',
10486             ValueConv => '$val ? 10 / $val : 0',
10487             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
10488             },
10489             0x2a => {
10490             Name => 'FNumber',
10491             Format => 'rational64u',
10492             PrintConv => 'sprintf("%.1f",$val)',
10493             },
10494             0x32 => {
10495             Name => 'ExposureCompensation',
10496             Format => 'rational64s',
10497             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
10498             },
10499             0x44 => {
10500             Name => 'WhiteBalance',
10501             Format => 'int16u',
10502             PrintConv => {
10503             0 => 'Auto',
10504             1 => 'Daylight',
10505             2 => 'Shade',
10506             3 => 'Fluorescent', #2
10507             4 => 'Tungsten',
10508             5 => 'Manual',
10509             },
10510             },
10511             0x48 => {
10512             Name => 'FocalLength',
10513             Format => 'rational64u',
10514             PrintConv => 'sprintf("%.1f mm",$val)',
10515             },
10516             0xaf => {
10517             Name => 'Software',
10518             Format => 'string[16]',
10519             },
10520             0xdf => { # (this is a guess ... could also be offset 0xdb)
10521             Name => 'ISO',
10522             Format => 'int16u',
10523             RawConv => '$val < 50 ? undef : $val', # (not valid for Coolpix L10)
10524             },
10525             );
10526              
10527             # Nikon metadata in AVI videos (PH)
10528             %Image::ExifTool::Nikon::AVI = (
10529             NOTES => 'Nikon-specific RIFF tags found in AVI videos.',
10530             GROUPS => { 0 => 'MakerNotes', 2 => 'Video' },
10531             nctg => {
10532             Name => 'NikonTags',
10533             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AVITags' },
10534             },
10535             ncth => {
10536             Name => 'ThumbnailImage',
10537             Groups => { 2 => 'Preview' },
10538             Binary => 1,
10539             },
10540             ncvr => {
10541             Name => 'NikonVers',
10542             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AVIVers' },
10543             },
10544             ncvw => {
10545             Name => 'PreviewImage',
10546             Groups => { 2 => 'Preview' },
10547             RawConv => 'length($val) ? $val : undef',
10548             Binary => 1,
10549             },
10550             );
10551              
10552             # version information in AVI videos (PH)
10553             %Image::ExifTool::Nikon::AVIVers = (
10554             GROUPS => { 0 => 'MakerNotes', 2 => 'Video' },
10555             PROCESS_PROC => \&ProcessNikonAVI,
10556             FORMAT => 'string',
10557             0x01 => 'MakerNoteType',
10558             0x02 => {
10559             Name => 'MakerNoteVersion',
10560             Format => 'int8u',
10561             ValueConv => 'my @a = reverse split " ", $val; join ".", @a;',
10562             },
10563             );
10564              
10565             # tags in AVI videos (PH)
10566             %Image::ExifTool::Nikon::AVITags = (
10567             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10568             PROCESS_PROC => \&ProcessNikonAVI,
10569             FORMAT => 'string',
10570             NOTES => q{
10571             These tags and the AVIVer tags below are found in proprietary-format records
10572             of Nikon AVI videos.
10573             },
10574             0x03 => 'Make',
10575             0x04 => 'Model',
10576             0x05 => {
10577             Name => 'Software',
10578             Format => 'undef',
10579             ValueConv => '$val =~ tr/\0//d; $val',
10580             },
10581             0x06 => 'Equipment', # "NIKON DIGITAL CAMERA"
10582             0x07 => { # (guess)
10583             Name => 'Orientation',
10584             Format => 'int16u',
10585             Groups => { 2 => 'Image' },
10586             PrintConv => \%Image::ExifTool::Exif::orientation,
10587             },
10588             0x08 => {
10589             Name => 'ExposureTime',
10590             Format => 'rational64u',
10591             Groups => { 2 => 'Image' },
10592             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
10593             },
10594             0x09 => {
10595             Name => 'FNumber',
10596             Format => 'rational64u',
10597             Groups => { 2 => 'Image' },
10598             PrintConv => 'sprintf("%.1f",$val)',
10599             },
10600             0x0a => {
10601             Name => 'ExposureCompensation',
10602             Format => 'rational64s',
10603             Groups => { 2 => 'Image' },
10604             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
10605             },
10606             0x0b => {
10607             Name => 'MaxApertureValue',
10608             Format => 'rational64u',
10609             ValueConv => '2 ** ($val / 2)',
10610             PrintConv => 'sprintf("%.1f",$val)',
10611             },
10612             0x0c => {
10613             Name => 'MeteringMode', # (guess)
10614             Format => 'int16u',
10615             PrintConv => {
10616             0 => 'Unknown',
10617             1 => 'Average',
10618             2 => 'Center-weighted average',
10619             3 => 'Spot',
10620             4 => 'Multi-spot',
10621             5 => 'Multi-segment',
10622             6 => 'Partial',
10623             255 => 'Other',
10624             },
10625             },
10626             0x0d => { # val: 0
10627             Name => 'Nikon_AVITags_0x000d',
10628             Format => 'int16u',
10629             Flags => [ 'Hidden', 'Unknown' ],
10630             },
10631             0x0e => { # val: 0
10632             Name => 'Nikon_AVITags_0x000e',
10633             Format => 'int16u',
10634             Flags => [ 'Hidden', 'Unknown' ],
10635             },
10636             0x0f => {
10637             Name => 'FocalLength',
10638             Format => 'rational64u',
10639             PrintConv => 'sprintf("%.1f mm",$val)',
10640             },
10641             0x10 => {
10642             Name => 'XResolution',
10643             Format => 'rational64u',
10644             Groups => { 2 => 'Image' },
10645             },
10646             0x11 => {
10647             Name => 'YResolution',
10648             Format => 'rational64u',
10649             Groups => { 2 => 'Image' },
10650             },
10651             0x12 => {
10652             Name => 'ResolutionUnit',
10653             Format => 'int16u',
10654             Groups => { 2 => 'Image' },
10655             PrintConv => {
10656             1 => 'None',
10657             2 => 'inches',
10658             3 => 'cm',
10659             },
10660             },
10661             0x13 => {
10662             Name => 'DateTimeOriginal', # (guess)
10663             Description => 'Date/Time Original',
10664             Groups => { 2 => 'Time' },
10665             PrintConv => '$self->ConvertDateTime($val)',
10666             },
10667             0x14 => {
10668             Name => 'CreateDate', # (guess)
10669             Groups => { 2 => 'Time' },
10670             PrintConv => '$self->ConvertDateTime($val)',
10671             },
10672             0x15 => {
10673             Name => 'Nikon_AVITags_0x0015',
10674             Format => 'int16u',
10675             Flags => [ 'Hidden', 'Unknown' ],
10676             },
10677             0x16 => {
10678             Name => 'Duration',
10679             Format => 'rational64u',
10680             PrintConv => '"$val s"',
10681             },
10682             0x17 => { # val: 1
10683             Name => 'Nikon_AVITags_0x0017',
10684             Format => 'int16u',
10685             Flags => [ 'Hidden', 'Unknown' ],
10686             },
10687             0x18 => 'FocusMode',
10688             0x19 => { # vals: -5, -2, 3, 5, 6, 8, 11, 12, 14, 20, 22
10689             Name => 'Nikon_AVITags_0x0019',
10690             Format => 'int32s',
10691             Flags => [ 'Hidden', 'Unknown' ],
10692             },
10693             0x1b => { # vals: 1 (640x480), 1.25 (320x240)
10694             Name => 'DigitalZoom',
10695             Format => 'rational64u',
10696             },
10697             0x1c => { # (same as Nikon_0x000a)
10698             Name => 'Nikon_AVITags_0x001c',
10699             Format => 'rational64u',
10700             Flags => [ 'Hidden', 'Unknown' ],
10701             },
10702             0x1d => 'ColorMode',
10703             0x1e => { # string[8] - val: "AUTO"
10704             Name => 'Sharpness', # (guess, could also be ISOSelection)
10705             },
10706             0x1f => { # string[16] - val: "AUTO"
10707             Name => 'WhiteBalance', # (guess, could also be ImageAdjustment)
10708             },
10709             0x20 => { # string[4] - val: "OFF"
10710             Name => 'NoiseReduction', # (guess)
10711             },
10712             0x801a => { # val: 0 (why is the 0x8000 bit set in the ID?)
10713             Name => 'Nikon_AVITags_0x801a',
10714             Format => 'int32s',
10715             Flags => [ 'Hidden', 'Unknown' ],
10716             }
10717             );
10718              
10719             # Nikon NCDT atoms (ref PH)
10720             %Image::ExifTool::Nikon::NCDT = (
10721             GROUPS => { 0 => 'MakerNotes', 1 => 'Nikon', 2 => 'Video' },
10722             NOTES => q{
10723             Nikon-specific QuickTime tags found in the NCDT atom of MOV videos from
10724             various Nikon models.
10725             },
10726             NCHD => {
10727             Name => 'MakerNoteVersion',
10728             Format => 'undef',
10729             ValueConv => q{
10730             $val =~ s/\0$//; # remove trailing null
10731             $val =~ s/([\0-\x1f])/'.'.ord($1)/ge;
10732             $val =~ s/\./ /; return $val;
10733             },
10734             },
10735             NCTG => {
10736             Name => 'NikonTags',
10737             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::NCTG' },
10738             },
10739             NCTH => {
10740             Name => 'ThumbnailImage',
10741             Groups => { 2 => 'Preview' },
10742             Format => 'undef',
10743             Binary => 1,
10744             },
10745             NCVW => {
10746             Name => 'PreviewImage',
10747             Groups => { 2 => 'Preview' },
10748             Format => 'undef',
10749             Binary => 1,
10750             },
10751             NCDB => { # (often 0 bytes long, or 4 null bytes)
10752             Name => 'NikonNCDB',
10753             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::NCDB' },
10754             },
10755             NCM1 => {
10756             Name => 'PreviewImage1',
10757             Groups => { 2 => 'Preview' },
10758             Format => 'undef',
10759             Binary => 1,
10760             RawConv => 'length $val ? $val : undef',
10761             },
10762             NCM2 => { #PH (guess - have only seen 0 bytes)
10763             Name => 'PreviewImage2',
10764             Groups => { 2 => 'Preview' },
10765             Format => 'undef',
10766             Binary => 1,
10767             RawConv => 'length $val ? $val : undef',
10768             },
10769             );
10770              
10771             # Nikon NCDB tags from MOV videos (ref PH)
10772             %Image::ExifTool::Nikon::NCDB = (
10773             GROUPS => { 0 => 'MakerNotes', 1 => 'Nikon', 2 => 'Video' },
10774             # the following probably contain encrypted data -- look into decryping these!
10775             # OP01 - 320 bytes, starts with "0200" (D600,D610,D810,D3200,D5200)
10776             # - 638 bytes, starts with "0200" (D7100)
10777             # OP02 - 2048 bytes, starts with "0200" (D810)
10778             );
10779              
10780             # Nikon NCTG tags from MOV videos (ref PH)
10781             %Image::ExifTool::Nikon::NCTG = (
10782             PROCESS_PROC => \&ProcessNikonMOV,
10783             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
10784             NOTES => q{
10785             These tags are found in proprietary-format records of the NCTG atom in MOV
10786             videos from some Nikon cameras.
10787             },
10788             0x01 => 'Make',
10789             0x02 => 'Model',
10790             0x03 => 'Software',
10791             0x11 => {
10792             Name => 'CreateDate', #(guess, but matches QuickTime CreateDate)
10793             Groups => { 2 => 'Time' },
10794             PrintConv => '$self->ConvertDateTime($val)',
10795             },
10796             0x12 => {
10797             Name => 'DateTimeOriginal', #(guess, but time is 1 sec before tag 0x11)
10798             Description => 'Date/Time Original',
10799             Groups => { 2 => 'Time' },
10800             PrintConv => '$self->ConvertDateTime($val)',
10801             },
10802             0x13 => {
10803             Name => 'FrameCount',
10804             # int32u[2]: "467 0", "1038 0", "1127 0"
10805             ValueConv => '$val =~ s/ 0$//; $val', # (not sure what the extra "0" is for)
10806             },
10807             # 0x14 - int32u[2]: "0 0"
10808             # 0x15 - int32u[2]: "0 0"
10809             0x16 => {
10810             Name => 'FrameRate',
10811             Groups => { 2 => 'Video' },
10812             PrintConv => 'int($val * 1000 + 0.5) / 1000',
10813             },
10814             # 0x17 - rational62u: same value as FrameRate
10815             # 0x18 - int16u: 1, 2
10816             0x19 => {
10817             Name => 'TimeZone',
10818             Groups => { 2 => 'Time' },
10819             },
10820             # 0x21 - int16u: 1, 2
10821             0x22 => {
10822             Name => 'FrameWidth',
10823             Groups => { 2 => 'Video' },
10824             },
10825             0x23 => {
10826             Name => 'FrameHeight',
10827             Groups => { 2 => 'Video' },
10828             },
10829             # 0x24 - int16u: 1, 2
10830             # 0x31 - int16u: 0, 1, 2
10831             0x32 => { #(guess)
10832             Name => 'AudioChannels',
10833             Groups => { 2 => 'Audio' },
10834             },
10835             0x33 => {
10836             Name => 'AudioBitsPerSample',
10837             Groups => { 2 => 'Audio' },
10838             },
10839             0x34 => {
10840             Name => 'AudioSampleRate',
10841             Groups => { 2 => 'Audio' },
10842             },
10843             # 0x101 - int16u[4]: "160 120 1280 720", "160 120 3840 2160"
10844             # 0x102 - int16u[8]: "640 360 0 0 0 0 0 0", "640 360 1920 1080 0 0 0 0"
10845             # 0x1001 - int16s: 0
10846             0x1002 => {
10847             Name => 'NikonDateTime', #?
10848             Groups => { 2 => 'Time' },
10849             PrintConv => '$self->ConvertDateTime($val)',
10850             },
10851             # 0x1011 - int32u: 0
10852             # 0x1012 - int32u: 0
10853             0x1013 => { #HayoBaan
10854             Name => 'ElectronicVR',
10855             PrintConv => \%offOn,
10856             },
10857             # 0x1014 - int16u: 1
10858             # 0x1021 - int32u[32]: all zeros
10859             #
10860             # 0x110**** tags correspond to 0x**** tags in Exif::Main
10861             #
10862             0x110829a => { #34
10863             Name => 'ExposureTime',
10864             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
10865             },
10866             0x110829d => { #34
10867             Name => 'FNumber',
10868             PrintConv => 'Image::ExifTool::Exif::PrintFNumber($val)',
10869             },
10870             0x1108822 => {
10871             Name => 'ExposureProgram',
10872             PrintConv => {
10873             0 => 'Not Defined',
10874             1 => 'Manual',
10875             2 => 'Program AE',
10876             3 => 'Aperture-priority AE',
10877             4 => 'Shutter speed priority AE',
10878             5 => 'Creative (Slow speed)',
10879             6 => 'Action (High speed)',
10880             7 => 'Portrait',
10881             8 => 'Landscape',
10882             # 9 => 'Bulb', # (non-standard Canon value)
10883             },
10884             },
10885             0x1109204 => {
10886             Name => 'ExposureCompensation',
10887             PrintConv => 'Image::ExifTool::Exif::PrintFraction($val)',
10888             },
10889             0x1109207 => {
10890             Name => 'MeteringMode',
10891             PrintConv => {
10892             0 => 'Unknown',
10893             1 => 'Average',
10894             2 => 'Center-weighted average',
10895             3 => 'Spot',
10896             4 => 'Multi-spot',
10897             5 => 'Multi-segment',
10898             6 => 'Partial',
10899             255 => 'Other',
10900             },
10901             },
10902             0x110920a => { #34
10903             Name => 'FocalLength',
10904             PrintConv => 'sprintf("%.1f mm",$val)',
10905             },
10906             0x110a431 => 'SerialNumber',
10907             0x110a432 => {
10908             Name => 'LensInfo',
10909             PrintConv => \&Image::ExifTool::Exif::PrintLensInfo,
10910             },
10911             0x110a433 => 'LensMake',
10912             0x110a434 => 'LensModel',
10913             0x110a435 => 'LensSerialNumber',
10914             #
10915             # 0x120**** tags correspond to 0x**** tags in GPS::Main
10916             #
10917             0x1200000 => {
10918             Name => 'GPSVersionID',
10919             Groups => { 1 => 'GPS', 2 => 'Location' },
10920             PrintConv => '$val =~ tr/ /./; $val',
10921             },
10922             0x1200001 => {
10923             Name => 'GPSLatitudeRef',
10924             Groups => { 1 => 'GPS', 2 => 'Location' },
10925             PrintConv => {
10926             N => 'North',
10927             S => 'South',
10928             },
10929             },
10930             0x1200002 => {
10931             Name => 'GPSLatitude',
10932             Groups => { 1 => 'GPS', 2 => 'Location' },
10933             ValueConv => q{
10934             require Image::ExifTool::GPS;
10935             Image::ExifTool::GPS::ToDegrees($val);
10936             },
10937             PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1)',
10938             },
10939             0x1200003 => {
10940             Name => 'GPSLongitudeRef',
10941             Groups => { 1 => 'GPS', 2 => 'Location' },
10942             PrintConv => {
10943             E => 'East',
10944             W => 'West',
10945             },
10946             },
10947             0x1200004 => {
10948             Name => 'GPSLongitude',
10949             Groups => { 1 => 'GPS', 2 => 'Location' },
10950             ValueConv => q{
10951             require Image::ExifTool::GPS;
10952             Image::ExifTool::GPS::ToDegrees($val);
10953             },
10954             PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1)',
10955             },
10956             0x1200005 => {
10957             Name => 'GPSAltitudeRef',
10958             Groups => { 1 => 'GPS', 2 => 'Location' },
10959             PrintConv => {
10960             0 => 'Above Sea Level',
10961             1 => 'Below Sea Level',
10962             },
10963             },
10964             0x1200006 => {
10965             Name => 'GPSAltitude',
10966             Groups => { 1 => 'GPS', 2 => 'Location' },
10967             PrintConv => '$val =~ /^(inf|undef)$/ ? $val : "$val m"',
10968             },
10969             0x1200007 => {
10970             Name => 'GPSTimeStamp',
10971             Groups => { 1 => 'GPS', 2 => 'Time' },
10972             ValueConv => q{
10973             require Image::ExifTool::GPS;
10974             Image::ExifTool::GPS::ConvertTimeStamp($val);
10975             },
10976             PrintConv => 'Image::ExifTool::GPS::PrintTimeStamp($val)',
10977             },
10978             0x1200008 => {
10979             Name => 'GPSSatellites',
10980             Groups => { 1 => 'GPS', 2 => 'Location' },
10981             },
10982             0x1200010 => {
10983             Name => 'GPSImgDirectionRef',
10984             Groups => { 1 => 'GPS', 2 => 'Location' },
10985             PrintConv => {
10986             M => 'Magnetic North',
10987             T => 'True North',
10988             },
10989             },
10990             0x1200011 => {
10991             Name => 'GPSImgDirection',
10992             Groups => { 1 => 'GPS', 2 => 'Location' },
10993             },
10994             0x1200012 => {
10995             Name => 'GPSMapDatum',
10996             Groups => { 1 => 'GPS', 2 => 'Location' },
10997             },
10998             0x120001d => {
10999             Name => 'GPSDateStamp',
11000             Groups => { 1 => 'GPS', 2 => 'Time' },
11001             ValueConv => 'Image::ExifTool::Exif::ExifDate($val)',
11002             },
11003             #
11004             # 0x200**** tags correspond to 0x**** tags in Nikon::Main
11005             # (must be duplicated here so tagInfo "Table" entry will point to correct table.
11006             # Also there would be a problem with the PRINT_CONV from the Main table)
11007             #
11008             0x2000001 => {
11009             Name => 'MakerNoteVersion',
11010             PrintConv => '$_=$val;s/^(\d{2})/$1\./;s/^0//;$_',
11011             },
11012             0x2000005 => 'WhiteBalance',
11013             0x2000007 => { Name => 'FocusMode', Writable => 'string' }, #34
11014             0x200000b => 'WhiteBalanceFineTune',
11015             0x200001b => {
11016             Name => 'CropHiSpeed',
11017             Writable => 'int16u',
11018             Count => 7,
11019             PrintConv => \%cropHiSpeed,
11020             },
11021             0x200001e => {
11022             Name => 'ColorSpace',
11023             PrintConv => {
11024             1 => 'sRGB',
11025             2 => 'Adobe RGB',
11026             },
11027             },
11028             0x200001f => {
11029             Name => 'VRInfo',
11030             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::VRInfo' },
11031             },
11032             0x2000022 => {
11033             Name => 'ActiveD-Lighting',
11034             Writable => 'int16u',
11035             PrintConv => {
11036             0 => 'Off',
11037             1 => 'Low',
11038             3 => 'Normal',
11039             5 => 'High',
11040             7 => 'Extra High',
11041             8 => 'Extra High 1',
11042             9 => 'Extra High 2',
11043             10 => 'Extra High 3',
11044             11 => 'Extra High 4',
11045             0xffff => 'Auto',
11046             },
11047             },
11048             0x2000023 => [
11049             { #PH (D300, but also found in D3,D3S,D3X,D90,D300S,D700,D3000,D5000)
11050             Name => 'PictureControlData',
11051             Condition => '$$valPt =~ /^01/',
11052             Writable => 'undef',
11053             Permanent => 0,
11054             Flags => [ 'Binary', 'Protected' ],
11055             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl' },
11056             },{ #28
11057             Name => 'PictureControlData',
11058             Condition => '$$valPt =~ /^02/',
11059             Writable => 'undef',
11060             Permanent => 0,
11061             Flags => [ 'Binary', 'Protected' ],
11062             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl2' },
11063             },{
11064             Name => 'PictureControlData',
11065             Condition => '$$valPt =~ /^03/',
11066             Writable => 'undef',
11067             Permanent => 0,
11068             Flags => [ 'Binary', 'Protected' ],
11069             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControl3' },
11070             },{
11071             Name => 'PictureControlData',
11072             Writable => 'undef',
11073             Permanent => 0,
11074             Flags => [ 'Binary', 'Protected' ],
11075             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::PictureControlUnknown' },
11076             },
11077             ],
11078             0x2000024 => {
11079             Name => 'WorldTime',
11080             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::WorldTime' },
11081             },
11082             0x2000025 => { #34
11083             Name => 'ISOInfo',
11084             SubDirectory => {
11085             TagTable => 'Image::ExifTool::Nikon::ISOInfo',
11086             ByteOrder => 'BigEndian', # (BigEndian even for D810, which is a little-endian camera)
11087             },
11088             },
11089             0x200002a => { #23 (this tag added with D3 firmware 1.10 -- also written by Nikon utilities)
11090             Name => 'VignetteControl',
11091             Writable => 'int16u',
11092             PrintConv => {
11093             0 => 'Off',
11094             1 => 'Low',
11095             3 => 'Normal',
11096             5 => 'High',
11097             },
11098             },
11099             0x200002c => {
11100             Name => 'UnknownInfo',
11101             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::UnknownInfo' },
11102             },
11103             # 0x200002d - int16u[3]: "512 0 0"
11104             0x2000032 => {
11105             Name => 'UnknownInfo2',
11106             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::UnknownInfo2' },
11107             },
11108             0x2000039 => {
11109             Name => 'LocationInfo',
11110             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LocationInfo' },
11111             },
11112             0x200003f => 'WhiteBalanceFineTune',
11113             # 0x200003f - rational64s[2]: "0 0"
11114             # 0x2000042 - undef[6]: "0100\x03\0"
11115             # 0x2000043 - undef[12]: all zeros
11116             0x200004e => {
11117             Name => 'NikonSettings',
11118             SubDirectory => { TagTable => 'Image::ExifTool::NikonSettings::Main' },
11119             },
11120             0x2000083 => {
11121             Name => 'LensType',
11122             # credit to Tom Christiansen (ref 7) for figuring this out...
11123             PrintConv => q[$_ = $val ? Image::ExifTool::DecodeBits($val,
11124             {
11125             0 => 'MF',
11126             1 => 'D',
11127             2 => 'G',
11128             3 => 'VR',
11129             4 => '1', #PH
11130             # bit 5 set for FT-1 adapter? - PH
11131             6 => 'E', #PH (electromagnetic aperture mechanism)
11132             # bit 7 set for AF-P lenses? - PH
11133             }) : 'AF';
11134             # remove commas and change "D G" to just "G"
11135             s/,//g; s/\bD G\b/G/;
11136             s/ E\b// and s/^(G )?/E /; # put "E" at the start instead of "G"
11137             s/ 1// and $_ = "1 $_"; # put "1" at start
11138             return $_;
11139             ],
11140             },
11141             0x2000084 => {
11142             Name => "Lens",
11143             # short focal, long focal, aperture at short focal, aperture at long focal
11144             PrintConv => \&Image::ExifTool::Exif::PrintLensInfo,
11145             },
11146             0x2000087 => {
11147             Name => 'FlashMode',
11148             Writable => 'int8u',
11149             PrintConv => {
11150             0 => 'Did Not Fire',
11151             1 => 'Fired, Manual', #14
11152             3 => 'Not Ready', #28
11153             7 => 'Fired, External', #14
11154             8 => 'Fired, Commander Mode',
11155             9 => 'Fired, TTL Mode',
11156             18 => 'LED Light', #G.F. (movie LED light)
11157             },
11158             },
11159             0x2000098 => [
11160             { #8
11161             Condition => '$$valPt =~ /^0100/', # D100, D1X - PH
11162             Name => 'LensData0100',
11163             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LensData00' },
11164             },
11165             { #8
11166             Condition => '$$valPt =~ /^0101/', # D70, D70s - PH
11167             Name => 'LensData0101',
11168             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::LensData01' },
11169             },
11170             # note: this information is encrypted if the version is 02xx
11171             { #8
11172             # 0201 - D200, D2Hs, D2X and D2Xs
11173             # 0202 - D40, D40X and D80
11174             # 0203 - D300
11175             Condition => '$$valPt =~ /^020[1-3]/',
11176             Name => 'LensData0201',
11177             SubDirectory => {
11178             TagTable => 'Image::ExifTool::Nikon::LensData01',
11179             ProcessProc => \&ProcessNikonEncrypted,
11180             WriteProc => \&ProcessNikonEncrypted,
11181             DecryptStart => 4,
11182             },
11183             },
11184             { #PH
11185             Condition => '$$valPt =~ /^0204/', # D90, D7000
11186             Name => 'LensData0204',
11187             SubDirectory => {
11188             TagTable => 'Image::ExifTool::Nikon::LensData0204',
11189             ProcessProc => \&ProcessNikonEncrypted,
11190             WriteProc => \&ProcessNikonEncrypted,
11191             DecryptStart => 4,
11192             },
11193             },
11194             {
11195             Condition => '$$valPt =~ /^040[01]/', # 0=1J1/1V1, 1=1J2
11196             Name => 'LensData0400',
11197             SubDirectory => {
11198             TagTable => 'Image::ExifTool::Nikon::LensData0400',
11199             ProcessProc => \&ProcessNikonEncrypted,
11200             WriteProc => \&ProcessNikonEncrypted,
11201             DecryptStart => 4,
11202             },
11203             },
11204             {
11205             Condition => '$$valPt =~ /^0402/', # 1J3/1S1/1V2
11206             Name => 'LensData0402',
11207             SubDirectory => {
11208             TagTable => 'Image::ExifTool::Nikon::LensData0402',
11209             ProcessProc => \&ProcessNikonEncrypted,
11210             WriteProc => \&ProcessNikonEncrypted,
11211             DecryptStart => 4,
11212             },
11213             },
11214             {
11215             Condition => '$$valPt =~ /^0403/', # 1J4,1J5
11216             Name => 'LensData0403',
11217             SubDirectory => {
11218             TagTable => 'Image::ExifTool::Nikon::LensData0403',
11219             ProcessProc => \&ProcessNikonEncrypted,
11220             WriteProc => \&ProcessNikonEncrypted,
11221             DecryptStart => 4,
11222             },
11223             },
11224             {
11225             Condition => '$$valPt =~ /^080[012]/', # Z6/Z7/Z9
11226             Name => 'LensData0800',
11227             SubDirectory => {
11228             TagTable => 'Image::ExifTool::Nikon::LensData0800',
11229             ProcessProc => \&ProcessNikonEncrypted,
11230             WriteProc => \&ProcessNikonEncrypted,
11231             DecryptStart => 4,
11232             ByteOrder => 'LittleEndian',
11233             # 0x5a0c - NikonMeteringMode for some Z6 ver1.00 samples (ref PH)
11234             },
11235             },
11236             {
11237             Name => 'LensDataUnknown',
11238             SubDirectory => {
11239             TagTable => 'Image::ExifTool::Nikon::LensDataUnknown',
11240             ProcessProc => \&ProcessNikonEncrypted,
11241             WriteProc => \&ProcessNikonEncrypted,
11242             DecryptStart => 4,
11243             },
11244             },
11245             ],
11246             0x20000a7 => { # Number of shots taken by camera so far (ref 2)
11247             Name => 'ShutterCount',
11248             PrintConv => '$val == 4294965247 ? "n/a" : $val',
11249             },
11250             0x20000a8 => [
11251             {
11252             Name => 'FlashInfo0100',
11253             Condition => '$$valPt =~ /^010[01]/',
11254             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0100' },
11255             },
11256             {
11257             Name => 'FlashInfo0102',
11258             Condition => '$$valPt =~ /^0102/',
11259             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0102' },
11260             },
11261             {
11262             Name => 'FlashInfo0103',
11263             # (0104 for D7000, 0105 for D800)
11264             Condition => '$$valPt =~ /^010[345]/',
11265             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0103' },
11266             },
11267             {
11268             Name => 'FlashInfo0106', # (0106 for D7100)
11269             Condition => '$$valPt =~ /^0106/',
11270             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0106' },
11271             },
11272             {
11273             Name => 'FlashInfo0107', # (0107 for D4S/D750/D810/D5500/D7200, 0108 for D5/D500/D3400)
11274             Condition => '$$valPt =~ /^010[78]/',
11275             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfo0107' },
11276             },
11277             {
11278             Name => 'FlashInfoUnknown',
11279             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::FlashInfoUnknown' },
11280             },
11281             ],
11282             0x20000ab => { Name => 'VariProgram', Writable => 'string' }, #2 (scene mode for DSLR's - PH)
11283             0x20000b1 => { #34
11284             Name => 'HighISONoiseReduction',
11285             Writable => 'int16u',
11286             PrintConv => {
11287             0 => 'Off',
11288             1 => 'Minimal', # for high ISO (>800) when setting is "Off"
11289             2 => 'Low', # Low,Normal,High take effect for ISO > 400
11290             3 => 'Medium Low',
11291             4 => 'Normal',
11292             5 => 'Medium High',
11293             6 => 'High',
11294             },
11295             },
11296             0x20000b7 => {
11297             Name => 'AFInfo2',
11298             SubDirectory => { TagTable => 'Image::ExifTool::Nikon::AFInfo2' },
11299             },
11300             # 0x20000c0 - undef[8]
11301             0x20000c3 => {
11302             Name => 'BarometerInfo',
11303             SubDirectory => {
11304             TagTable => 'Image::ExifTool::Nikon::BarometerInfo',
11305             # (little-endian in II EXIF, big-endian in MOV)
11306             },
11307             },
11308             );
11309              
11310             # Nikon XMP tags written in NKSC metadata
11311             %Image::ExifTool::Nikon::ast = (
11312             GROUPS => { 0 => 'XMP', 1 => 'XMP-ast', 2 => 'Image' },
11313             PROCESS_PROC => \&Image::ExifTool::XMP::ProcessXMP,
11314             NAMESPACE => 'ast',
11315             VARS => { NO_ID => 1 },
11316             NOTES => 'Tags used by Nikon NX Studio in Nikon NKSC sidecar files and trailers.',
11317             about => { },
11318             version => { },
11319             XMLPackets => {
11320             SubDirectory => { TagTable => 'Image::ExifTool::XMP::Main' },
11321             Encoding => 'Base64',
11322             Binary => 1,
11323             },
11324             IPTC => {
11325             SubDirectory => { TagTable => 'Image::ExifTool::IPTC::Main' },
11326             Encoding => 'Base64',
11327             Binary => 1,
11328             },
11329             GPSVersionID => { Groups => { 2 => 'Location' }, %base64bytes },
11330             GPSLatitudeRef => {
11331             Groups => { 2 => 'Location' },
11332             %base64int32u,
11333             PrintConv => { 0 => 'North', 1 => 'South' }, #PH (NC)
11334             },
11335             GPSLatitude => { Groups => { 2 => 'Location' }, %base64coord },
11336             GPSLongitudeRef => {
11337             Groups => { 2 => 'Location' },
11338             %base64int32u,
11339             PrintConv => { 2 => 'East', 3 => 'West' }, #PH (NC)
11340             },
11341             GPSLongitude => { Groups => { 2 => 'Location' }, %base64coord },
11342             GPSAltitudeRef => {
11343             Groups => { 2 => 'Location' },
11344             %base64bytes,
11345             PrintConv => {
11346             0 => 'Above Sea Level',
11347             1 => 'Below Sea Level',
11348             },
11349             },
11350             GPSAltitude => {
11351             Groups => { 2 => 'Location' },
11352             %base64double,
11353             PrintConv => '"$val m"',
11354             },
11355             GPSMapDatum => { Groups => { 2 => 'Location' } },
11356             GPSImgDirection => {
11357             Groups => { 2 => 'Location' },
11358             %base64double,
11359             PrintConv => 'sprintf("%.2f", $val)',
11360             },
11361             GPSImgDirectionRef => {
11362             Groups => { 2 => 'Location' },
11363             PrintConv => {
11364             M => 'Magnetic North',
11365             T => 'True North',
11366             },
11367             },
11368             );
11369             %Image::ExifTool::Nikon::sdc = (
11370             GROUPS => { 0 => 'XMP', 1 => 'XMP-sdc', 2 => 'Image' },
11371             PROCESS_PROC => \&Image::ExifTool::XMP::ProcessXMP,
11372             NAMESPACE => 'sdc',
11373             VARS => { NO_ID => 1 },
11374             about => { },
11375             version => { },
11376             appversion => { Name => 'AppVersion' },
11377             appname => { Name => 'AppName' },
11378             );
11379             %Image::ExifTool::Nikon::nine = (
11380             GROUPS => { 0 => 'XMP', 1 => 'XMP-nine', 2 => 'Image' },
11381             PROCESS_PROC => \&Image::ExifTool::XMP::ProcessXMP,
11382             NAMESPACE => 'nine',
11383             VARS => { NO_ID => 1 },
11384             about => { },
11385             version => { },
11386             Label => { },
11387             Rating => { },
11388             Trim => { %base64bin },
11389             NineEdits => {
11390             SubDirectory => {
11391             TagTable => 'Image::ExifTool::Nikon::NineEdits',
11392             IgnoreProp => { userData => 1 }, # remove "UserData" from already overly long tag names
11393             },
11394             Binary => 1,
11395             },
11396             );
11397             %Image::ExifTool::Nikon::NineEdits = (
11398             GROUPS => { 0 => 'XML', 1 => 'NineEdits', 2 => 'Image' },
11399             PROCESS_PROC => \&Image::ExifTool::XMP::ProcessXMP,
11400             VARS => { NO_ID => 1 },
11401             NOTES => 'XML-based tags used to store editing information.',
11402             filterParametersBinary => { %base64bin },
11403             filterParametersExportExportData => { %base64bin },
11404             filterParametersCustomCustomData => { %base64bin },
11405             );
11406              
11407             # Nikon composite tags
11408             %Image::ExifTool::Nikon::Composite = (
11409             GROUPS => { 2 => 'Camera' },
11410             LensSpec => {
11411             Require => {
11412             0 => 'Nikon:Lens',
11413             1 => 'Nikon:LensType',
11414             },
11415             ValueConv => '"$val[0] $val[1]"',
11416             PrintConv => '"$prt[0] $prt[1]"',
11417             },
11418             LensID => {
11419             SeparateTable => 'Nikon LensID', # print values in a separate table
11420             Require => {
11421             0 => 'Nikon:LensIDNumber',
11422             1 => 'LensFStops',
11423             2 => 'MinFocalLength',
11424             3 => 'MaxFocalLength',
11425             4 => 'MaxApertureAtMinFocal',
11426             5 => 'MaxApertureAtMaxFocal',
11427             6 => 'MCUVersion',
11428             7 => 'Nikon:LensType',
11429             },
11430             # construct lens ID string as per ref 11
11431             ValueConv => 'sprintf("%.2X"." %.2X"x7, @raw)',
11432             PrintConv => \%nikonLensIDs,
11433             PrintInt => 1,
11434             },
11435             AutoFocus => {
11436             Require => {
11437             0 => 'Nikon:PhaseDetectAF',
11438             1 => 'Nikon:ContrastDetectAF',
11439             },
11440             ValueConv => '($val[0] or $val[1]) ? 1 : 0',
11441             PrintConv => \%offOn,
11442             },
11443             );
11444              
11445             # add our composite tags
11446             Image::ExifTool::AddCompositeTags('Image::ExifTool::Nikon');
11447              
11448             #------------------------------------------------------------------------------
11449             # Process Nikon AVI tags (D5000 videos)
11450             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
11451             # Returns: 1 on success
11452             sub ProcessNikonAVI($$$)
11453             {
11454 0     0 0 0 my ($et, $dirInfo, $tagTablePtr) = @_;
11455 0         0 my $dataPt = $$dirInfo{DataPt};
11456 0   0     0 my $pos = $$dirInfo{DirStart} || 0;
11457 0         0 my $dirEnd = $pos + $$dirInfo{DirLen};
11458 0         0 $et->VerboseDir($dirInfo, undef, $$dirInfo{DirLen});
11459 0         0 SetByteOrder('II');
11460 0         0 while ($pos + 4 <= $dirEnd) {
11461 0         0 my $tag = Get16u($dataPt, $pos);
11462 0         0 my $size = Get16u($dataPt, $pos + 2);
11463 0         0 $pos += 4;
11464 0 0       0 last if $pos + $size > $dirEnd;
11465 0         0 $et->HandleTag($tagTablePtr, $tag, undef,
11466             DataPt => $dataPt,
11467             Start => $pos,
11468             Size => $size,
11469             );
11470 0         0 $pos += $size;
11471             }
11472 0         0 return 1;
11473             }
11474              
11475             #------------------------------------------------------------------------------
11476             # Print conversion for Nikon AF points
11477             # Inputs: 0) value to convert (as a string of hex bytes),
11478             # 1) lookup for AF point bit number (starting at 1)
11479             sub PrintAFPoints($$)
11480             {
11481 0     0 0 0 my ($val, $afPoints) = @_;
11482 0         0 my ($i, $j, @points);
11483 0         0 $val =~ tr/ //d; # remove spaces from hex string
11484 0         0 my @dat = unpack 'C*', pack 'H*', $val; # convert to array of bytes
11485             # loop through all bytes to find active AF points
11486 0         0 for ($i=0; $i<=@dat; ++$i) {
11487 0 0       0 next unless $dat[$i];
11488 0         0 for ($j=0; $j<8; ++$j) {
11489 0 0       0 next unless $dat[$i] & (1 << $j);
11490 0         0 my $point = $$afPoints{$i*8 + $j + 1};
11491 0 0       0 push @points, $point if defined $point;
11492             }
11493             }
11494 0 0       0 return '(none)' unless @points;
11495             # sort the points and return as comma-separated string
11496             return join ',', sort {
11497 0 0       0 return $a cmp $b if length($a) == length($b);
  0         0  
11498 0 0       0 return substr($a,0,1).'0'.substr($a,1,1) cmp $b if length($a) == 2;
11499 0         0 return $a cmp substr($b,0,1).'0'.substr($b,1,1);
11500             } @points;
11501             }
11502              
11503             #------------------------------------------------------------------------------
11504             # Inverse print conversion for AF points
11505             # Inputs: 0) AF point string, 1) AF point lookup
11506             # Returns: AF point data as a string of hex bytes
11507             sub PrintAFPointsInv($$)
11508             {
11509 8     8 0 33 my ($val, $afPoints) = @_;
11510 8         42 my @points = ($val =~ /[A-Za-z]\d+/g);
11511 8         73 my $size = int((scalar(keys %$afPoints) + 7) / 8);
11512 8         63 my @dat = (0) x $size;
11513 8 50       35 if (@points) {
11514 0         0 my (%bitNum, $point);
11515 0         0 $bitNum{$$afPoints{$_}} = $_ foreach keys %$afPoints; # build reverse lookup
11516 0         0 foreach $point (@points) {
11517 0 0       0 my $bitNum = $bitNum{uc $point} or next;
11518 0         0 my $byte = int(($bitNum - 1) / 8);
11519 0         0 $dat[$byte] |= (1 << (($bitNum - 1) % 8));
11520             }
11521             }
11522 8         180 return join(" ", unpack("H2"x$size, pack('C*', @dat)));
11523             }
11524              
11525             #------------------------------------------------------------------------------
11526             # Get AF point name for grid-type AF
11527             # Inputs: 0) AF point number, 1) number of columns, 2) true for inverse conversion
11528             # Returns: AF point name, or undef
11529             sub GetAFPointGrid($$;$)
11530             {
11531 0     0 0 0 my ($val, $ncol, $inv) = @_;
11532 0 0       0 if ($inv) {
11533 0 0       0 return undef unless $val =~ /^([A-J])(\d+)$/i;
11534 0         0 return (ord(uc($1))-65) * $ncol + $2 - 1;
11535             } else {
11536 0         0 my $row = int(($val + 0.5) / $ncol) & 0xff;
11537 0         0 my $col = $val - $ncol * $row + 1;
11538 0         0 return chr(65+$row) . $col;
11539             }
11540             }
11541              
11542             #------------------------------------------------------------------------------
11543             # Print conversion for grid-type AF points
11544             # Inputs: 0) value to convert (as a string of hex bytes),
11545             # 1) number of columns in grid
11546             sub PrintAFPointsGrid($$)
11547             {
11548 0     0 0 0 my ($val, $ncol) = @_;
11549 0         0 my ($i, $j, @points);
11550 0         0 $val =~ tr/ //d; # remove spaces from hex string
11551 0         0 my @dat = unpack 'C*', pack 'H*', $val; # convert to array of bytes
11552             # loop through all bytes to find active AF points
11553 0         0 for ($i=0; $i<@dat; ++$i) {
11554 0 0       0 next unless $dat[$i];
11555 0         0 for ($j=0; $j<8; ++$j) {
11556 0 0       0 next unless $dat[$i] & (1 << $j);
11557 0         0 my $point = GetAFPointGrid($i*8 + $j, $ncol);
11558 0 0       0 push @points, $point if defined $point;
11559             }
11560             }
11561 0 0       0 return '(none)' unless @points;
11562 0         0 return join ',', @points; # return as comma-separated string
11563             }
11564              
11565             #------------------------------------------------------------------------------
11566             # Inverse print conversion for AF points
11567             # Inputs: 0) AF point string, 1) number of columns, 2) size of data
11568             # Returns: AF point data as a string of hex bytes
11569             sub PrintAFPointsGridInv($$$)
11570             {
11571 0     0 0 0 my ($val, $ncol, $size) = @_;
11572 0         0 my @points = ($val =~ /[A-Za-z]\d+/g);
11573 0         0 my @dat = (0) x $size;
11574 0         0 foreach (@points) {
11575 0         0 my $n = GetAFPointGrid($_, $ncol, 1);
11576 0 0       0 next unless defined $n;
11577 0         0 my $byte = int($n / 8);
11578 0 0       0 next if $byte > $size;
11579 0         0 $dat[$byte] |= (1 << ($n - $byte * 8));
11580             }
11581 0         0 return join(" ", unpack("H2"x$size, pack('C*', @dat)));
11582             }
11583              
11584             #------------------------------------------------------------------------------
11585             # Print conversion for relative Left/Right AF points (ref 28)
11586             # Inputs: 0) column, 1) number of columns
11587             # Returns: AF point data as a string (e.g. '2L of Center' or 'C' or '3R of Center')
11588             sub PrintAFPointsLeftRight($$)
11589             {
11590 0     0 0 0 my ($col, $ncol) = @_;
11591 0         0 my $center = 1 + ($ncol + 1)/2;
11592 0 0       0 return 'n/a' if $col == 0; #out of focus
11593 0 0       0 return 'C' if $col == $center;
11594 0 0       0 return sprintf('%d', $center - $col) . 'L of Center' if $col < $center;
11595 0 0       0 return sprintf('%d', $col - $center) . 'R of Center' if $col > $center;
11596             }
11597              
11598             #------------------------------------------------------------------------------
11599             # Print conversion for relative Up/Down AF points (ref 28)
11600             # Inputs: 0) row, 1) number of rows
11601             # Returns: AF point data as a string (e.g. '2U from Center' or 'C' or '3D from Center')
11602             sub PrintAFPointsUpDown($$)
11603             {
11604 0     0 0 0 my ($row, $nrow) = @_;
11605 0         0 my $center = 1 + ($nrow + 1)/2;
11606 0 0       0 return 'n/a' if $row == 0; #out of focus
11607 0 0       0 return 'C' if $row == $center;
11608 0 0       0 return sprintf('%d', $center - $row) . 'U from Center' if $row < $center;
11609 0 0       0 return sprintf('%d', $row - $center) . 'D from Center' if $row > $center;
11610             }
11611              
11612             #------------------------------------------------------------------------------
11613             # Print PictureControl value
11614             # Inputs: 0) value (with 0x80 subtracted),
11615             # 1) 'Normal' (0 value) string (default 'Normal')
11616             # 2) format string for numbers (default '%+d'), 3) v2 divisor
11617             # Returns: PrintConv value
11618             sub PrintPC($;$$$)
11619             {
11620 0     0 0 0 my ($val, $norm, $fmt, $div) = @_;
11621 0 0 0     0 return $norm || 'Normal' if $val == 0;
11622 0 0       0 return 'n/a' if $val == 0x7f;
11623 0 0       0 return 'Auto' if $val == -128;
11624             # -127 = custom curve created in Camera Control Pro (show as "User" by D3) - ref 28
11625 0 0       0 return 'User' if $val == -127; #28
11626 0   0     0 return sprintf($fmt || '%+d', $val / ($div || 1));
      0        
11627             }
11628              
11629             #------------------------------------------------------------------------------
11630             # Inverse of PrintPC
11631             # Inputs: 0) PrintConv value (after subracting 0x80 from raw value), 1) v2 divisor
11632             # Returns: unconverted value
11633             # Notes: raw values: 0=Auto, 1=User, 0xff=n/a, ... 0x7f=-1, 0x80=0, 0x81=1, ...
11634             sub PrintPCInv($;$)
11635             {
11636 114     114 0 464 my ($val, $div) = @_;
11637 114 100 100     1413 return $val * ($div || 1) if $val =~ /^[-+]?\d+(\.\d+)?$/;
11638 114 50       239 return 0x7f if $val =~ /n\/a/i;
11639 114 100       198 return -128 if $val =~ /auto/i;
11640 111 50       144 return -127 if $val =~ /user/i; #28
11641 111         470 return 0;
11642             }
11643              
11644             #------------------------------------------------------------------------------
11645             # Convert unknown LensID values
11646             # Inputs: 0) value, 1) flag for inverse conversion, 2) PrintConv hash ref
11647             sub LensIDConv($$$)
11648             {
11649 0     0 0 0 my ($val, $inv, $conv) = @_;
11650 0 0       0 return undef if $inv;
11651             # multiple lenses with the same LensID are distinguished by decimal values
11652 0 0       0 if ($$conv{"$val.1"}) {
11653 0         0 my ($i, @vals, @user);
11654 0         0 for ($i=1; ; ++$i) {
11655 0 0       0 my $lens = $$conv{"$val.$i"} or last;
11656 0 0       0 if ($Image::ExifTool::userLens{$lens}) {
11657 0         0 push @user, $lens;
11658             } else {
11659 0         0 push @vals, $lens;
11660             }
11661             }
11662 0 0       0 return join(' or ', @user) if @user;
11663 0         0 return join(' or ', @vals);
11664             }
11665             # Sigma has been changing the LensIDNumber on some new lenses
11666             # and with some Sigma lenses the LensFStops changes! (argh!)
11667             # Also, older cameras my not set bits 4-7 of LensType
11668 0         0 my $pat = $val;
11669 0         0 $pat =~ s/^\w+ \w+/.. ../; # ignore LensIDNumber and LensFStops
11670 0         0 $pat =~ s/\w(\w)$/.$1/; # ignore bits 4-7 of LensType
11671 0         0 my @ids = sort grep /^$pat$/, keys %$conv;
11672 0 0       0 if (@ids) {
11673             # first try different LensFStops (2nd value)
11674 0         0 ($pat = $val) =~ s/ \w+/ ../;
11675 0         0 my @good = grep /^$pat$/, @ids;
11676 0 0       0 return $$conv{$good[0]} if @good;
11677             # then try different LensIDNumber (1st value)
11678 0         0 ($pat = $val) =~ s/^\w+/../;
11679 0         0 @good = grep /^$pat$/, @ids;
11680 0 0       0 return "Unknown ($val) $$conv{$good[0]} ?" if @good;
11681             # older cameras may not set bits 4-7 of LensType
11682 0         0 ($pat = $val) =~ s/\w(\w)$/.$1/;
11683 0         0 @good = grep /^$pat$/, @ids;
11684 0 0       0 return "Unknown ($val) $$conv{$good[0]} ?" if @good;
11685             }
11686 0         0 return undef;
11687             }
11688              
11689             #------------------------------------------------------------------------------
11690             # Clean up formatting of string values
11691             # Inputs: 0) string value
11692             # Returns: formatted string value
11693             # - removes trailing spaces and changes case to something more sensible
11694             sub FormatString($)
11695             {
11696 153     153 0 316 my $str = shift;
11697             # limit string length (can be very long for some unknown tags)
11698 153 50       372 if (length($str) > 60) {
11699 0         0 $str = substr($str,0,55) . "[...]";
11700             } else {
11701 153         759 $str =~ s/\s+$//; # remove trailing white space
11702             # Don't change case of non-words (no vowels)
11703 153 100       528 if ($str =~ /[AEIOUY]/) {
11704             # change all letters but the first to lower case,
11705             # but only in words containing a vowel
11706 97 100       580 if ($str =~ s/\b([AEIOUY])([A-Z]+)/$1\L$2/g) {
11707 50         153 $str =~ s/\bAf\b/AF/; # patch for "AF"
11708             # patch for a number of models that write improper string
11709             # terminator for ImageStabilization (VR-OFF, VR-ON)
11710 50         128 $str =~ s/ +.$//s;
11711             }
11712 97 100       578 if ($str =~ s/\b([A-Z])([A-Z]*[AEIOUY][A-Z]*)/$1\L$2/g) {
11713 46         118 $str =~ s/\bRaw\b/RAW/; # patch for "RAW"
11714             }
11715             }
11716             }
11717 153         479 return $str;
11718             }
11719              
11720             #------------------------------------------------------------------------------
11721             # decoding tables from ref 4
11722             my @xlat = (
11723             [ 0xc1,0xbf,0x6d,0x0d,0x59,0xc5,0x13,0x9d,0x83,0x61,0x6b,0x4f,0xc7,0x7f,0x3d,0x3d,
11724             0x53,0x59,0xe3,0xc7,0xe9,0x2f,0x95,0xa7,0x95,0x1f,0xdf,0x7f,0x2b,0x29,0xc7,0x0d,
11725             0xdf,0x07,0xef,0x71,0x89,0x3d,0x13,0x3d,0x3b,0x13,0xfb,0x0d,0x89,0xc1,0x65,0x1f,
11726             0xb3,0x0d,0x6b,0x29,0xe3,0xfb,0xef,0xa3,0x6b,0x47,0x7f,0x95,0x35,0xa7,0x47,0x4f,
11727             0xc7,0xf1,0x59,0x95,0x35,0x11,0x29,0x61,0xf1,0x3d,0xb3,0x2b,0x0d,0x43,0x89,0xc1,
11728             0x9d,0x9d,0x89,0x65,0xf1,0xe9,0xdf,0xbf,0x3d,0x7f,0x53,0x97,0xe5,0xe9,0x95,0x17,
11729             0x1d,0x3d,0x8b,0xfb,0xc7,0xe3,0x67,0xa7,0x07,0xf1,0x71,0xa7,0x53,0xb5,0x29,0x89,
11730             0xe5,0x2b,0xa7,0x17,0x29,0xe9,0x4f,0xc5,0x65,0x6d,0x6b,0xef,0x0d,0x89,0x49,0x2f,
11731             0xb3,0x43,0x53,0x65,0x1d,0x49,0xa3,0x13,0x89,0x59,0xef,0x6b,0xef,0x65,0x1d,0x0b,
11732             0x59,0x13,0xe3,0x4f,0x9d,0xb3,0x29,0x43,0x2b,0x07,0x1d,0x95,0x59,0x59,0x47,0xfb,
11733             0xe5,0xe9,0x61,0x47,0x2f,0x35,0x7f,0x17,0x7f,0xef,0x7f,0x95,0x95,0x71,0xd3,0xa3,
11734             0x0b,0x71,0xa3,0xad,0x0b,0x3b,0xb5,0xfb,0xa3,0xbf,0x4f,0x83,0x1d,0xad,0xe9,0x2f,
11735             0x71,0x65,0xa3,0xe5,0x07,0x35,0x3d,0x0d,0xb5,0xe9,0xe5,0x47,0x3b,0x9d,0xef,0x35,
11736             0xa3,0xbf,0xb3,0xdf,0x53,0xd3,0x97,0x53,0x49,0x71,0x07,0x35,0x61,0x71,0x2f,0x43,
11737             0x2f,0x11,0xdf,0x17,0x97,0xfb,0x95,0x3b,0x7f,0x6b,0xd3,0x25,0xbf,0xad,0xc7,0xc5,
11738             0xc5,0xb5,0x8b,0xef,0x2f,0xd3,0x07,0x6b,0x25,0x49,0x95,0x25,0x49,0x6d,0x71,0xc7 ],
11739             [ 0xa7,0xbc,0xc9,0xad,0x91,0xdf,0x85,0xe5,0xd4,0x78,0xd5,0x17,0x46,0x7c,0x29,0x4c,
11740             0x4d,0x03,0xe9,0x25,0x68,0x11,0x86,0xb3,0xbd,0xf7,0x6f,0x61,0x22,0xa2,0x26,0x34,
11741             0x2a,0xbe,0x1e,0x46,0x14,0x68,0x9d,0x44,0x18,0xc2,0x40,0xf4,0x7e,0x5f,0x1b,0xad,
11742             0x0b,0x94,0xb6,0x67,0xb4,0x0b,0xe1,0xea,0x95,0x9c,0x66,0xdc,0xe7,0x5d,0x6c,0x05,
11743             0xda,0xd5,0xdf,0x7a,0xef,0xf6,0xdb,0x1f,0x82,0x4c,0xc0,0x68,0x47,0xa1,0xbd,0xee,
11744             0x39,0x50,0x56,0x4a,0xdd,0xdf,0xa5,0xf8,0xc6,0xda,0xca,0x90,0xca,0x01,0x42,0x9d,
11745             0x8b,0x0c,0x73,0x43,0x75,0x05,0x94,0xde,0x24,0xb3,0x80,0x34,0xe5,0x2c,0xdc,0x9b,
11746             0x3f,0xca,0x33,0x45,0xd0,0xdb,0x5f,0xf5,0x52,0xc3,0x21,0xda,0xe2,0x22,0x72,0x6b,
11747             0x3e,0xd0,0x5b,0xa8,0x87,0x8c,0x06,0x5d,0x0f,0xdd,0x09,0x19,0x93,0xd0,0xb9,0xfc,
11748             0x8b,0x0f,0x84,0x60,0x33,0x1c,0x9b,0x45,0xf1,0xf0,0xa3,0x94,0x3a,0x12,0x77,0x33,
11749             0x4d,0x44,0x78,0x28,0x3c,0x9e,0xfd,0x65,0x57,0x16,0x94,0x6b,0xfb,0x59,0xd0,0xc8,
11750             0x22,0x36,0xdb,0xd2,0x63,0x98,0x43,0xa1,0x04,0x87,0x86,0xf7,0xa6,0x26,0xbb,0xd6,
11751             0x59,0x4d,0xbf,0x6a,0x2e,0xaa,0x2b,0xef,0xe6,0x78,0xb6,0x4e,0xe0,0x2f,0xdc,0x7c,
11752             0xbe,0x57,0x19,0x32,0x7e,0x2a,0xd0,0xb8,0xba,0x29,0x00,0x3c,0x52,0x7d,0xa8,0x49,
11753             0x3b,0x2d,0xeb,0x25,0x49,0xfa,0xa3,0xaa,0x39,0xa7,0xc5,0xa7,0x50,0x11,0x36,0xfb,
11754             0xc6,0x67,0x4a,0xf5,0xa5,0x12,0x65,0x7e,0xb0,0xdf,0xaf,0x4e,0xb3,0x61,0x7f,0x2f ]
11755             );
11756              
11757             my ($ci0, $cj0, $ck0, $decryptStart); # decryption parameters
11758              
11759             # Decrypt Nikon data block (ref 4)
11760             # Inputs: 0) reference to data block, 1) optional start offset (default 0)
11761             # 2) optional number of bytes to decode (default to the end of the data)
11762             # 3) optional serial number key (undef to continue previous decryption)
11763             # 4) optional shutter count key
11764             # Returns: data block with specified data decrypted
11765             # Notes: The first time this is called for a given encrypted data block the serial/count
11766             # keys must be defined, and $start must be the offset for initialization of the
11767             # decryption parameters (ie. the beginning of the encrypted data, which isn't
11768             # necessarily inside the data block if $len is zero). Subsequent calls for
11769             # the same data block do not specify the serial/count keys, and may be used
11770             # to decrypt data at any start point within the full data block.
11771             sub Decrypt($;$$$$)
11772             {
11773 5     5 0 28 my ($dataPt, $start, $len, $serial, $count) = @_;
11774 5         9 my ($ch, $cj, $ck);
11775              
11776 5 100       14 $start or $start = 0;
11777 5         11 my $maxLen = length($$dataPt) - $start;
11778 5 100 66     26 $len = $maxLen if not defined $len or $len > $maxLen;
11779 5 100 66     35 if (defined $serial and defined $count) {
11780             # initialize decryption parameters
11781 4         9 my $key = 0;
11782 4         25 $key ^= ($count >> ($_*8)) & 0xff foreach 0..3;
11783 4         15 $ci0 = $xlat[0][$serial & 0xff];
11784 4         10 $cj0 = $xlat[1][$key];
11785 4         8 $ck0 = 0x60;
11786 4         10 undef $decryptStart;
11787             }
11788 5 100       16 if (defined $decryptStart) {
11789             # initialize decryption parameters for this start position
11790 1         4 my $n = $start - $decryptStart;
11791 1         9 $cj = ($cj0 + $ci0 * ($n * $ck0 + ($n * ($n - 1))/2)) & 0xff;
11792 1         3 $ck = ($ck0 + $n) & 0xff;
11793             } else {
11794 4         6 $decryptStart = $start;
11795 4         9 ($cj, $ck) = ($cj0, $ck0);
11796             }
11797 5 100       19 return $$dataPt if $len <= 0;
11798 4         74 my @data = unpack('C*', substr($$dataPt, $start, $len));
11799 4         13 foreach $ch (@data) {
11800 616         777 $cj = ($cj + $ci0 * $ck) & 0xff;
11801 616         762 $ck = ($ck + 1) & 0xff;
11802 616         810 $ch ^= $cj;
11803             }
11804 4         84 return substr($$dataPt, 0, $start) . pack('C*', @data) . substr($$dataPt, $start+$len);
11805             }
11806              
11807             #------------------------------------------------------------------------------
11808             # Get serial number for use as a decryption key
11809             # Inputs: 0) ExifTool object ref, 1) serial number string
11810             # Returns: serial key integer or undef if no serial number provided
11811             sub SerialKey($$)
11812             {
11813 32     32 0 98 my ($et, $serial) = @_;
11814             # use serial number as key if integral
11815 32 50 66     364 return $serial if not defined $serial or $serial =~ /^\d+$/;
11816 0 0       0 return 0x22 if $$et{Model} =~ /\bD50$/; # D50 (ref 8)
11817 0         0 return 0x60; # D200 (ref 10), D40X (ref PH), etc
11818             }
11819              
11820             #------------------------------------------------------------------------------
11821             # Extract information from "NIKON APP" trailer (ref PH)
11822             # Inputs: 0) ExifTool ref, 1) Optional dirInfo ref for returning trailer info
11823             # Returns: true on success
11824             sub ProcessNikonApp($;$)
11825             {
11826 0     0 0 0 local $_;
11827 0         0 my ($et, $dirInfo) = @_;
11828 0         0 my $raf = $$et{RAF};
11829 0 0 0     0 my $offset = $dirInfo ? $$dirInfo{Offset} || 0 : 0;
11830 0         0 my $buff;
11831              
11832 0 0 0     0 return 0 unless $raf->Seek(-20-$offset, 2) and $raf->Read($buff, 20) == 20 and
      0        
11833             substr($buff,-16) eq "\0\0\0\0\0\0/NIKON APP"; # check magic number
11834              
11835 0         0 my $verbose = $et->Options('Verbose');
11836 0         0 my $fileEnd = $raf->Tell();
11837 0         0 my $trailerLen = unpack('N', $buff);
11838 0 0       0 $trailerLen > $fileEnd and $et->Warn('Bad NikonApp trailer size'), return 0;
11839 0 0       0 if ($dirInfo) {
11840 0         0 $$dirInfo{DirLen} = $trailerLen;
11841 0         0 $$dirInfo{DataPos} = $fileEnd - $trailerLen;
11842 0 0       0 if ($$dirInfo{OutFile}) {
11843 0 0 0     0 if ($$et{DEL_GROUP}{NikonApp}) {
    0 0        
11844 0         0 $et->VPrint(0, " Deleting NikonApp trailer ($trailerLen bytes)\n");
11845 0         0 ++$$et{CHANGED};
11846             # just copy the trailer when writing (read directly into output buffer)
11847             } elsif ($trailerLen > $fileEnd or not $raf->Seek($$dirInfo{DataPos}, 0) or
11848 0         0 $raf->Read(${$$dirInfo{OutFile}}, $trailerLen) != $trailerLen)
11849             {
11850 0         0 return 0;
11851             }
11852 0         0 return 1;
11853             }
11854 0 0 0     0 $et->DumpTrailer($dirInfo) if $verbose or $$et{HTML_DUMP};
11855             }
11856 0 0 0     0 unless ($trailerLen >= 0x40 and $raf->Seek($fileEnd - $trailerLen, 0) and
      0        
      0        
11857             $raf->Read($buff, 0x40) == 0x40 and $buff =~ m(NIKON APP\0))
11858             {
11859 0         0 $et->Warn('Error reading NikonApp trailer');
11860 0         0 return 0;
11861             }
11862 0         0 $$et{SET_GROUP0} = 'NikonApp';
11863 0         0 while ($raf->Read($buff, 8) == 8) {
11864 0         0 my ($id, $len) = unpack('N2', $buff);
11865 0 0       0 if ($len & 0x80000000) {
11866 0         0 $et->Warn('Invalid NikonApp record length');
11867 0         0 last;
11868             }
11869 0 0 0     0 last if $id == 0 and $len == 0;
11870 0 0       0 unless ($raf->Read($buff, $len) == $len) {
11871 0         0 $et->Warn('Truncated NikonApp record');
11872 0         0 last;
11873             }
11874 0 0       0 if ($id == 1) {
11875 0         0 require Image::ExifTool::XMP;
11876 0         0 Image::ExifTool::XMP::ProcessXMP($et, { DataPt => \$buff });
11877             } else { # (haven't seen any other types of records)
11878 0         0 $et->Warn("Unknown NikonApp record $id");
11879 0         0 last;
11880             }
11881             }
11882 0         0 delete $$et{SET_GROUP0};
11883 0         0 return 1;
11884             }
11885              
11886             #------------------------------------------------------------------------------
11887             # Read Nikon NCTG tags in MOV videos
11888             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
11889             # Returns: 1 on success
11890             sub ProcessNikonMOV($$$)
11891             {
11892 0     0 0 0 my ($et, $dirInfo, $tagTablePtr) = @_;
11893 0         0 my $dataPt = $$dirInfo{DataPt};
11894 0         0 my $dataPos = $$dirInfo{DataPos};
11895 0         0 my %needTags = ( 0x110a431 => 0, 0x20000a7 => undef ); # needed for decryption
11896 0         0 $et->VerboseDir($$dirInfo{DirName}, 0, $$dirInfo{DirLen});
11897 0         0 my $pass;
11898             # do two passes so we can pre-scan for necessary decryption keys
11899 0         0 for ($pass=0; $pass<2; ++$pass) {
11900 0         0 my $pos = $$dirInfo{DirStart};
11901 0         0 my $end = $pos + $$dirInfo{DirLen};
11902 0         0 while ($pos + 8 < $end) {
11903 0         0 my $tag = Get32u($dataPt, $pos);
11904 0         0 my $fmt = Get16u($dataPt, $pos + 4); # (same format code as EXIF)
11905 0         0 my $count = Get16u($dataPt, $pos + 6);
11906 0         0 $pos += 8;
11907 0         0 my $fmtStr = $Image::ExifTool::Exif::formatName[$fmt];
11908 0 0       0 unless ($fmtStr) {
11909 0 0       0 $et->Warn(sprintf("Unknown format ($fmt) for $$dirInfo{DirName} tag 0x%x",$tag)) if $pass;
11910 0         0 last;
11911             }
11912 0         0 my $size = $count * $Image::ExifTool::Exif::formatSize[$fmt];
11913 0 0       0 if ($pos + $size > $end) {
11914 0 0       0 $et->Warn(sprintf("Truncated data for $$dirInfo{DirName} tag 0x%x",$tag)) if $pass;
11915 0         0 last;
11916             }
11917 0 0       0 if ($pass) {
    0          
11918 0         0 my $rational;
11919 0         0 my $val = ReadValue($dataPt, $pos, $fmtStr, $count, $size, \$rational);
11920             my $key = $et->HandleTag($tagTablePtr, $tag, $val,
11921             DataPt => $dataPt,
11922             DataPos => $dataPos,
11923             Format => $fmtStr,
11924             Start => $pos,
11925             Size => $size,
11926             Base => $$dirInfo{Base},
11927 0         0 );
11928 0 0 0     0 $$et{RATIONAL}{$key} = $rational if $rational and $key;
11929             } elsif (exists $needTags{$tag}) {
11930 0         0 $needTags{$tag} = ReadValue($dataPt, $pos, $fmtStr, $count, $size);
11931 0         0 $$et{NikonSerialKey} = SerialKey($et, $needTags{0x110a431});
11932 0         0 $$et{NikonCountKey} = $needTags{0x20000a7};
11933             }
11934 0         0 $pos += $size; # is this padded to an even offset????
11935             }
11936             }
11937 0         0 return 1;
11938             }
11939              
11940             #------------------------------------------------------------------------------
11941             # Get offset of end-of-data for a tag
11942             # Inputs: 0) tag table ref, 1) tag ID, 2) true to not calculate end for a SubDirectory
11943             # Returns: offset of tag value end, undef if it can't be determined
11944             sub GetTagEnd($$;$)
11945             {
11946 3     3 0 10 my ($tagTablePtr, $tagID, $ignoreSubdir) = @_;
11947 3         6 my $tagInfo = $$tagTablePtr{$tagID};
11948 3 50       10 $tagInfo = $$tagInfo[0] if ref $tagInfo eq 'ARRAY';
11949             # (can't pre-determine position of offset-based subdirectories)
11950 3 0 33     11 return undef if $ignoreSubdir and $$tagInfo{SubDirectory};
11951 3   50     18 my $fmt = $$tagInfo{Format} || $$tagTablePtr{FORMAT} || 'int8u';
11952 3 100       19 my $nm = $fmt =~ s/\[(\d+)\]$// ? $1 : 1;
11953 3 50       13 my $sz = Image::ExifTool::FormatSize($fmt) or return undef;
11954 3         14 return int($tagID) + $sz * $nm;
11955             }
11956              
11957             #------------------------------------------------------------------------------
11958             # Initialize SubDirectory KnownStart/KnownEnd limits of known tags (used in decryption)
11959             # Inputs: 0) tagInfo ref containing this SubDirectory, 2) tag table ref for encrypted subdir
11960             # Notes: KnownStart/KnownEnd are relative to the SubDirectory Start. If KnownStart/KnownEnd
11961             # aren't set then the entire data is decrypted, so all of this effort is just for speed.
11962             sub InitEncryptedSubdir($$)
11963             {
11964 3     3 0 8 my ($tagInfo, $tagTablePtr) = @_;
11965             #
11966             # for encrypted NIKON_OFFSETS tables we loop through all SubDirectory tags in this table
11967             # and set the KnownEnd for each of these according to the last tag in the child tables
11968             #
11969 3         6 my $vars = $$tagTablePtr{VARS};
11970 3 50       16 $vars or $vars = $$tagTablePtr{VARS} = { };
11971 3 50 33     15 if ($$vars{NIKON_OFFSETS} and not $$vars{NIKON_INITIALIZED}) {
11972 0         0 $$vars{NIKON_INITIALIZED} = 1;
11973 0         0 my $tagID;
11974 0         0 foreach $tagID (TagTableKeys($tagTablePtr)) {
11975 0         0 my $tagInfo = $$tagTablePtr{$tagID};
11976 0 0       0 next unless ref $tagInfo eq 'HASH';
11977 0 0       0 my $subdir = $$tagInfo{SubDirectory} or next;
11978 0         0 my $tbl = GetTagTable($$subdir{TagTable});
11979 0         0 my ($last) = sort { $b <=> $a } TagTableKeys($tbl); # (reverse sort)
  0         0  
11980 0         0 $$subdir{KnownEnd} = GetTagEnd($tbl, $last, 1);
11981             }
11982             }
11983             #
11984             # for other encrypted Nikon tables we set the KnownStart/KnownEnd entries in the
11985             # SubDirectory of the parent tag
11986             #
11987 3 50       11 unless ($$tagInfo{NikonInitialized}) {
11988 3         11 $$tagInfo{NikonInitialized} = 1;
11989 3         6 my $subdir = $$tagInfo{SubDirectory};
11990 3   50     10 my $start = $$subdir{DecryptStart} || 0;
11991 3         6 my $off = $$subdir{DirOffset};
11992 3         12 my @tagIDs = sort { $a <=> $b } TagTableKeys($tagTablePtr);
  61         113  
11993 3 100       11 if (defined $off) {
11994 1         6 $off += $start; # (DirOffset, if specified, is relative to DecryptStart)
11995             } else {
11996             # ignore tags that come before the start of encryption
11997 2   66     20 shift @tagIDs while @tagIDs and $tagIDs[0] < $start;
11998 2         10 $off = 0;
11999             }
12000 3 50       12 if (@tagIDs) {
12001 3         11 my ($first, $last) = @tagIDs[0,-1];
12002 3         8 my $lastInfo = $$tagTablePtr{$last};
12003 3 50       12 $lastInfo = $$lastInfo[0] if ref $lastInfo eq 'ARRAY';
12004 3 100       12 $$subdir{KnownStart} = int($first) + $off if $first + $off > $start;
12005 3         10 $$subdir{KnownEnd} = GetTagEnd($tagTablePtr, $last);
12006 3 50       11 if (defined $$subdir{KnownEnd}) {
12007 3         11 $$subdir{KnownEnd} += $off;
12008             } else {
12009 0         0 warn "Internal error setting KnownEnd for $$tagTablePtr{SHORT_NAME}\n";
12010             }
12011             } else {
12012 0         0 $$subdir{KnownStart} = $$subdir{KnownEnd} = $start;
12013             }
12014             }
12015             }
12016              
12017             #------------------------------------------------------------------------------
12018             # Prepare to process NIKON_OFFSETS directory and decrypt necessary data
12019             # Inputs: 0) ExifTool ref, 1) data ref, 2) tag table ref, 3) decrypt start,
12020             # 4) decrypt mode (0=piecewise, 1=continuous to end of last known section, 2=all)
12021             # Returns: end of decrypted data (or undef for piecewise decryption)
12022             sub PrepareNikonOffsets($$$$$)
12023             {
12024 0     0 0 0 my ($et, $dataPt, $tagTablePtr, $start, $decryptMode) = @_;
12025 0         0 my $offset = $$tagTablePtr{VARS}{NIKON_OFFSETS};
12026 0         0 my $dataLen = length $$dataPt;
12027 0 0 0     0 return undef if $offset + 4 > $dataLen or $offset < $start;
12028 0         0 my $serial = $$et{NikonSerialKey};
12029 0         0 my $count = $$et{NikonCountKey};
12030 0         0 my $dpos = $offset + 4; # decrypt up to NumberOffsets
12031 0         0 $$dataPt = Decrypt($dataPt, $start, $dpos - $start, $serial, $count);
12032 0         0 my $numOffsets = Get32u($dataPt, $offset);
12033 0         0 my $more = $numOffsets * 4; # more bytes to decrypt entire offsets table
12034 0 0       0 return undef if $offset + 4 + $more > $dataLen;
12035 0         0 $$dataPt = Decrypt($dataPt, $dpos, $more);
12036 0         0 $dpos += $more;
12037 0         0 my $unknown = $et->Options('Unknown');
12038 0         0 my ($i, @offInfo, $end);
12039             # extract non-zero offsets and create unknown subdirectories if Unknown > 1
12040 0         0 for ($i=0; $i<$numOffsets; ++$i) {
12041 0         0 my $pos = $offset + 4 + 4 * $i;
12042 0 0       0 my $off = Get32u($dataPt, $pos) or next;
12043 0         0 my $tagInfo = $$tagTablePtr{$pos};
12044 0         0 my $known = 0;
12045 0 0       0 if ($tagInfo) {
    0          
12046 0 0 0     0 $known = 1 if ref $tagInfo ne 'HASH' or not $$tagInfo{Unknown};
12047             } elsif ($unknown > 1) {
12048             # create new table for unknown information
12049 0         0 my $tbl = sprintf('Image::ExifTool::Nikon::UnknownInfo%.2x', $pos);
12050 28     28   435 no strict 'refs';
  28         100  
  28         105759  
12051 0 0       0 unless (%$tbl) {
12052 0         0 %$tbl = ( %binaryDataAttrs, GROUPS => { 0=>'MakerNotes', 2=>'Unknown' } );
12053 0         0 GetTagTable($tbl);
12054             }
12055             # add unknown entry in offset table for this subdirectory
12056 0         0 $tagInfo = AddTagToTable($tagTablePtr, $pos, {
12057             Name => sprintf('UnknownOffset%.2x', $pos),
12058             Format => 'int32u',
12059             SubDirectory => { TagTable => $tbl },
12060             Unknown => 2,
12061             });
12062             }
12063 0         0 push @offInfo, [ $pos, $off, $known ]; # save parameters for non-zero offsets
12064             }
12065             # sort offsets in ascending order, and use the differences to calculate
12066             # directory lengths and update the SubDirectory DirLen's accordingly
12067 0 0       0 my @sorted = sort { $$a[1] <=> $$b[1] or $$a[0] <=> $$b[0] } @offInfo;
  0         0  
12068 0         0 push @sorted, [ 0, length($$dataPt), 0 ];
12069 0         0 for ($i=0; $i<@sorted-1; ++$i) {
12070 0         0 my $pos = $sorted[$i][0];
12071 0         0 my $len = $sorted[$i+1][1] - $sorted[$i][1];
12072             # set DirLen in SubDirectory entry
12073 0         0 my $tagInfo = $$tagTablePtr{$pos};
12074 0         0 my $subdir;
12075 0 0 0     0 $$subdir{DirLen} = $len if ref $tagInfo eq 'HASH' and defined($subdir=$$tagInfo{SubDirectory});
12076 0 0 0     0 if ($decryptMode) {
    0 0        
12077             # keep track of end of last known directory
12078 0 0       0 $end = $sorted[$i+1][1] if $sorted[$i][2];
12079             } elsif ($tagInfo and (ref $tagInfo ne 'HASH' or not $$tagInfo{Unknown})) {
12080             # decrypt data piecewise as necessary
12081 0         0 my $n = $len;
12082 0 0 0     0 if ($subdir and $$subdir{KnownEnd}) {
12083 0         0 $n = $$subdir{KnownEnd};
12084 0 0       0 if ($n > $len) {
12085 0         0 $et->Warn("Data too short for $$tagInfo{Name}",1);
12086 0         0 $n = $len;
12087             }
12088             }
12089 0         0 $$dataPt = Decrypt($dataPt, $sorted[$i][1], $n);
12090             }
12091             }
12092 0 0       0 if ($decryptMode) {
12093             # decrypt the remaining required data
12094 0 0 0     0 $end = length $$dataPt if $decryptMode == 2 or not $end or $end < $dpos;
      0        
12095 0         0 $$dataPt = Decrypt($dataPt, $dpos, $end - $dpos);
12096             }
12097 0         0 return $end;
12098             }
12099              
12100             #------------------------------------------------------------------------------
12101             # Read/Write Nikon Encrypted data block
12102             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
12103             # Returns: 1 on success when reading, or new directory when writing (IsWriting set)
12104             sub ProcessNikonEncrypted($$$)
12105             {
12106 121     121 0 295 my ($et, $dirInfo, $tagTablePtr) = @_;
12107 121 100       542 $et or return 1; # allow dummy access
12108 3         9 my $serial = $$et{NikonSerialKey};
12109 3         8 my $count = $$et{NikonCountKey};
12110 3 50 33     45 unless (defined $serial and defined $count and $serial =~ /^\d+$/ and $count =~ /^\d+$/) {
      33        
      33        
12111 0 0 0     0 if (defined $serial or defined $count) {
12112 0         0 my $msg;
12113 0 0 0     0 if (defined $serial and defined $count) {
12114 0 0       0 $msg = $serial =~ /^\d+$/ ? 'invalid ShutterCount' : 'invalid SerialNumber';
12115             } else {
12116 0 0       0 $msg = defined $serial ? 'no ShutterCount' : 'no SerialNumber';
12117             }
12118 0         0 $et->Warn("Can't decrypt Nikon information ($msg key)");
12119             }
12120 0         0 delete $$et{NikonSerialKey};
12121 0         0 delete $$et{NikonCountKey};
12122 0         0 return 0;
12123             }
12124 3         13 my $oldOrder = GetByteOrder();
12125 3         10 my $isWriting = $$dirInfo{IsWriting};
12126 3 50       17 my $verbose = $isWriting ? 0 : $et->Options('Verbose');
12127 3         7 my $tagInfo = $$dirInfo{TagInfo};
12128 3         7 my $dirStart = $$dirInfo{DirStart};
12129 3         6 my $data = substr(${$$dirInfo{DataPt}}, $dirStart, $$dirInfo{DirLen});
  3         12  
12130              
12131 3         9 my ($start, $len, $offset, $recrypt, $newSerial, $newCount, $didDecrypt);
12132              
12133             # must re-encrypt when writing if serial number or shutter count changes
12134 3 50       13 if ($isWriting) {
12135 0 0       0 if ($$et{NewNikonSerialKey}) {
12136 0         0 $newSerial = $$et{NewNikonSerialKey};
12137 0         0 $recrypt = 1;
12138             }
12139 0 0       0 if ($$et{NewNikonCountKey}) {
12140 0         0 $newCount = $$et{NewNikonCountKey};
12141 0         0 $recrypt = 1;
12142             }
12143             }
12144 3 50 33     18 if ($tagInfo and $$tagInfo{SubDirectory}) {
12145             # initialize SubDirectory entries used in encryption (KnownStart, KnownEnd)
12146 3         12 InitEncryptedSubdir($tagInfo, $tagTablePtr);
12147 3         6 my $subdir = $$tagInfo{SubDirectory};
12148 3   50     11 $start = $$subdir{DecryptStart} || 0;
12149             # DirOffset, if specified, is the offset to the start of the
12150             # directory relative to start of encrypted data
12151 3 100       13 $offset = defined $$subdir{DirOffset} ? $$subdir{DirOffset} + $start : 0;
12152             # must set byte ordering before calling PrepareNikonOffsets()
12153 3 100       14 SetByteOrder($$subdir{ByteOrder}) if $$subdir{ByteOrder};
12154             # prepare for processing NIKON_OFFSETS directory if necessary
12155 3   33     21 my $unknown = $verbose > 2 || $et->Options('Unknown') > 1;
12156             # decrypt mode: 0=piecewise, 1=continuous to end of last known section, 2=all
12157 3 0       19 my $dMode = $isWriting ? ($recrypt ? 2 : 1) : ($unknown ? 2 : 0);
    50          
    50          
12158 3 50       17 if ($$tagTablePtr{VARS}{NIKON_OFFSETS}) {
    50          
12159 0         0 $len = PrepareNikonOffsets($et, \$data, $tagTablePtr, $start, $dMode);
12160 0         0 $didDecrypt = 1;
12161             } elsif ($dMode < 2) {
12162 3 100 66     22 if ($dMode == 0 and $$subdir{KnownStart}) {
12163             # initialize decryption parameters for address DecryptStart address
12164 1         16 Decrypt(\$data, $start, 0, $serial, $count);
12165             # reset serial/count keys so we don't re-initialize below
12166 1         5 undef $serial;
12167 1         2 undef $count;
12168             # change decryption start to skip unnecessary data
12169 1         3 $start = $$subdir{KnownStart};
12170             }
12171 3 50       12 $len = $$subdir{KnownEnd} - $start if $$subdir{KnownEnd};
12172             }
12173             } else {
12174 0         0 $start = $offset = 0;
12175             }
12176 3         7 my $maxLen = length($data) - $start;
12177             # decrypt all the data unless the length was specified
12178 3 50 33     15 $len = $maxLen unless $len and $len < $maxLen;
12179              
12180 3 50       15 $data = Decrypt(\$data, $start, $len, $serial, $count) unless $didDecrypt;
12181              
12182 3 50       13 if ($verbose > 2) {
12183 0         0 $et->VerboseDir("Decrypted $$tagInfo{Name}");
12184             $et->VerboseDump(\$data,
12185 0         0 Prefix => $$et{INDENT} . ' ',
12186             # (remove this because it is useful to have decrypted offsets start at 0)
12187             #DataPos => $dirStart + $$dirInfo{DataPos} + ($$dirInfo{Base} || 0),
12188             );
12189             }
12190             # process the decrypted information
12191             my %subdirInfo = (
12192             DataPt => \$data,
12193             DirStart => $offset,
12194             DirLen => length($data) - $offset,
12195             DirName => $$dirInfo{DirName},
12196             DataPos => $$dirInfo{DataPos} + $dirStart,
12197             Base => $$dirInfo{Base},
12198 3         22 );
12199 3         7 my $rtnVal;
12200 3 50       10 if ($isWriting) {
12201 0         0 my $changed = $$et{CHANGED};
12202 0         0 $rtnVal = $et->WriteBinaryData(\%subdirInfo, $tagTablePtr);
12203             # must re-encrypt if serial number or shutter count changes
12204 0 0       0 if ($recrypt) {
12205 0 0       0 $serial = $newSerial if defined $newSerial;
12206 0 0       0 $count = $newCount if defined $newCount;
12207 0         0 ++$$et{CHANGED};
12208             }
12209 0 0       0 if ($changed == $$et{CHANGED}) {
12210 0         0 undef $rtnVal; # nothing changed so use original data
12211             } else {
12212             # add back any un-encrypted data at start
12213 0 0       0 $rtnVal = substr($data, 0, $offset) . $rtnVal if $offset;
12214             # re-encrypt data (symmetrical algorithm)
12215 0         0 $rtnVal = Decrypt(\$rtnVal, $start, $len, $serial, $count);
12216 0         0 $et->VPrint(2, $$et{INDENT}, " [recrypted $$tagInfo{Name}]");
12217             }
12218             } else {
12219 3         14 $rtnVal = $et->ProcessBinaryData(\%subdirInfo, $tagTablePtr);
12220             }
12221 3         12 SetByteOrder($oldOrder);
12222 3         13 return $rtnVal;
12223             }
12224              
12225             #------------------------------------------------------------------------------
12226             # Pre-scan EXIF directory to extract specific tags
12227             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) required tagID hash ref
12228             # Returns: 1 if directory was scanned successfully
12229             sub PrescanExif($$$)
12230             {
12231 24     24 0 84 my ($et, $dirInfo, $tagHash) = @_;
12232 24         71 my $dataPt = $$dirInfo{DataPt};
12233 24   100     133 my $dataPos = $$dirInfo{DataPos} || 0;
12234 24         64 my $dataLen = $$dirInfo{DataLen};
12235 24   50     101 my $dirStart = $$dirInfo{DirStart} || 0;
12236 24   50     96 my $base = $$dirInfo{Base} || 0;
12237 24         64 my $raf = $$dirInfo{RAF};
12238 24         57 my ($index, $numEntries, $data, $buff);
12239              
12240             # get number of entries in IFD
12241 24 50 33     151 if ($dirStart >= 0 and $dirStart <= $dataLen-2) {
12242 24         125 $numEntries = Get16u($dataPt, $dirStart);
12243             # reset $numEntries to read from file if necessary
12244 24 50       141 undef $numEntries if $dirStart + 2 + 12 * $numEntries > $dataLen;
12245             }
12246             # read IFD from file if necessary
12247 24 50       92 unless ($numEntries) {
12248 0 0       0 $raf or return 0;
12249 0         0 $dataPos += $dirStart; # read data from the start of the directory
12250 0 0 0     0 $raf->Seek($dataPos + $base, 0) and $raf->Read($data, 2) == 2 or return 0;
12251 0         0 $numEntries = Get16u(\$data, 0);
12252 0         0 my $len = 12 * $numEntries;
12253 0 0       0 $raf->Read($buff, $len) == $len or return 0;
12254 0         0 $data .= $buff;
12255             # update variables for the newly loaded IFD (already updated dataPos)
12256 0         0 $dataPt = \$data;
12257 0         0 $dataLen = length $data;
12258 0         0 $dirStart = 0;
12259             }
12260             # loop through Nikon MakerNote IFD entries
12261 24         116 for ($index=0; $index<$numEntries; ++$index) {
12262 597         908 my $entry = $dirStart + 2 + 12 * $index;
12263 597         1032 my $tagID = Get16u($dataPt, $entry);
12264 597 100       1604 next unless exists $$tagHash{$tagID}; # only extract required tags
12265 8         41 my $format = Get16u($dataPt, $entry+2);
12266 8 50 33     46 next if $format < 1 or $format > 13;
12267 8         29 my $count = Get32u($dataPt, $entry+4);
12268 8         32 my $size = $count * $Image::ExifTool::Exif::formatSize[$format];
12269 8         33 my $formatStr = $Image::ExifTool::Exif::formatName[$format];
12270 8         16 my $valuePtr = $entry + 8; # pointer to value within $$dataPt
12271 8 100       31 if ($size > 4) {
12272 1 50       5 next if $size > 0x1000000; # set a reasonable limit on data size (16MB)
12273 1         5 $valuePtr = Get32u($dataPt, $valuePtr);
12274             # convert offset to pointer in $$dataPt
12275             # (don't yet handle EntryBased or FixOffsets)
12276 1         5 $valuePtr -= $dataPos;
12277 1 50 33     10 if ($valuePtr < 0 or $valuePtr+$size > $dataLen) {
12278 0 0 0     0 next unless $raf and $raf->Seek($base + $valuePtr + $dataPos,0) and
      0        
12279             $raf->Read($buff,$size) == $size;
12280 0         0 $$tagHash{$tagID} = ReadValue(\$buff,0,$formatStr,$count,$size);
12281 0         0 next;
12282             }
12283             }
12284 8         34 $$tagHash{$tagID} = ReadValue($dataPt,$valuePtr,$formatStr,$count,$size);
12285             }
12286 24         89 return 1;
12287             }
12288              
12289             #------------------------------------------------------------------------------
12290             # Process Nikon Capture history data
12291             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
12292             # Returns: 1 on success
12293             sub ProcessNikonCaptureEditVersions($$$)
12294             {
12295 0     0 0 0 my ($et, $dirInfo, $tagTablePtr) = @_;
12296 0         0 require Image::ExifTool::NikonCapture;
12297 0         0 return Image::ExifTool::NikonCapture::ProcessNikonCaptureEditVersions($et, $dirInfo, $tagTablePtr);
12298             }
12299              
12300             #------------------------------------------------------------------------------
12301             # Process Nikon Capture Offsets IFD (ref PH)
12302             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
12303             # Returns: 1 on success
12304             # Notes: This isn't a normal IFD, but is close...
12305             sub ProcessNikonCaptureOffsets($$$)
12306             {
12307 2     2 0 8 my ($et, $dirInfo, $tagTablePtr) = @_;
12308 2         6 my $dataPt = $$dirInfo{DataPt};
12309 2         8 my $dirStart = $$dirInfo{DirStart};
12310 2         5 my $dirLen = $$dirInfo{DirLen};
12311 2         9 my $success = 0;
12312 2 50       10 return 0 unless $dirLen > 2;
12313 2         9 my $count = Get16u($dataPt, $dirStart);
12314 2 50 33     49 return 0 unless $count and $count * 12 + 2 <= $dirLen;
12315 2 50       11 if ($et->Options('Verbose')) {
12316 0         0 $et->VerboseDir('NikonCaptureOffsets', $count);
12317             }
12318 2         5 my $index;
12319 2         13 for ($index=0; $index<$count; ++$index) {
12320 6         14 my $pos = $dirStart + 12 * $index + 2;
12321 6         17 my $tagID = Get32u($dataPt, $pos);
12322 6         16 my $value = Get32u($dataPt, $pos + 4);
12323 6 50       22 $et->HandleTag($tagTablePtr, $tagID, $value,
12324             Index => $index,
12325             DataPt => $dataPt,
12326             Start => $pos,
12327             Size => 12,
12328             ) and $success = 1;
12329             }
12330 2         8 return $success;
12331             }
12332              
12333             #------------------------------------------------------------------------------
12334             # Read/write Nikon MakerNotes directory
12335             # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
12336             # Returns: 1 on success, otherwise returns 0 and sets a Warning when reading
12337             # or new directory when writing (IsWriting set in dirInfo)
12338             sub ProcessNikon($$$)
12339             {
12340 323     323 0 1138 my ($et, $dirInfo, $tagTablePtr) = @_;
12341 323 100       1514 $et or return 1; # allow dummy access
12342              
12343             # pre-scan IFD to get SerialNumber (0x001d) and ShutterCount (0x00a7) for use in decryption
12344 24         124 my %needTags = ( 0x001d => 0, 0x00a7 => undef );
12345 24         150 PrescanExif($et, $dirInfo, \%needTags);
12346 24         129 $$et{NikonSerialKey} = SerialKey($et, $needTags{0x001d});
12347 24         109 $$et{NikonCountKey} = $needTags{0x00a7};
12348              
12349             # process Nikon makernotes
12350 24         75 my $rtnVal;
12351 24 100       110 if ($$dirInfo{IsWriting}) {
12352             # get new decryptino keys if they are being changed
12353 8         55 my $serial = $et->GetNewValue($Image::ExifTool::Nikon::Main{0x001d});
12354 8         40 my $count = $et->GetNewValue($Image::ExifTool::Nikon::Main{0x00a7});
12355 8         42 $$et{NewNikonSerialKey} = SerialKey($et, $serial);
12356 8         34 $$et{NewNikonCountKey} = $count;
12357 8         97 $rtnVal = Image::ExifTool::Exif::WriteExif($et, $dirInfo, $tagTablePtr);
12358 8         34 delete $$et{NewNikonSerialKey};
12359 8         27 delete $$et{NewNikonCountKey};
12360             } else {
12361 16         167 $rtnVal = Image::ExifTool::Exif::ProcessExif($et, $dirInfo, $tagTablePtr);
12362             }
12363 24         106 delete $$et{NikonSerialKey};
12364 24         59 delete $$et{NikonCountKey};
12365 24         103 return $rtnVal;
12366             }
12367              
12368             1; # end
12369              
12370             __END__