File Coverage

blib/lib/Image/ExifTool/Pentax.pm
Criterion Covered Total %
statement 44 121 36.3
branch 14 74 18.9
condition 8 36 22.2
subroutine 9 13 69.2
pod 0 8 0.0
total 75 252 29.7


line stmt bran cond sub pod time code
1             #------------------------------------------------------------------------------
2             # File: Pentax.pm
3             #
4             # Description: Pentax/Asahi EXIF maker notes tags
5             #
6             # Revisions: 11/25/2003 - P. Harvey Created
7             # 02/10/2004 - P. Harvey Completely re-done
8             # 02/16/2004 - W. Smith Updated (see ref 3)
9             # 11/10/2004 - P. Harvey Added support for Asahi cameras
10             # 01/10/2005 - P. Harvey Added LensType with values from ref 4
11             # 03/30/2005 - P. Harvey Added new tags from ref 5
12             # 10/04/2005 - P. Harvey Added MOV tags
13             # 10/22/2007 - P. Harvey Got my new K10D! (more new tags to decode)
14             # 11/03/2010 - P. Harvey Got my new K-5! (a gold mine of new tags to discover!)
15             #
16             # References: 1) Image::MakerNotes::Pentax
17             # 2) http://johnst.org/sw/exiftags/ (Asahi cameras)
18             # 3) Wayne Smith private communication (Optio 550)
19             # 4) http://kobe1995.jp/~kaz/astro/istD.html
20             # 5) John Francis (http://www.panix.com/~johnf/raw/index.html) (ist-D/ist-DS)
21             # 6) http://www.cybercom.net/~dcoffin/dcraw/
22             # 7) Douglas O'Brien private communication (*istD, K10D)
23             # 8) Denis Bourez private communication
24             # 9) Kazumichi Kawabata private communication
25             # 10) David Buret private communication (*istD)
26             # 11) http://forums.dpreview.com/forums/read.asp?forum=1036&message=17465929
27             # 12) Derby Chang private communication
28             # 13) http://homepage3.nifty.com/kamisaka/makernote/makernote_pentax.htm (2007/02/28)
29             # 14) Ger Vermeulen private communication (Optio S6)
30             # 15) Barney Garrett private communication (Samsung GX-1S)
31             # 16) Axel Kellner private communication (K10D)
32             # 17) Cvetan Ivanov private communication (K100D)
33             # 18) http://gvsoft.homedns.org/exif/makernote-pentax-type3.html
34             # 19) Dave Nicholson private communication (K10D)
35             # 20) Bogdan and yeryry (http://www.cpanforum.com/posts/8037)
36             # 21) Peter (*istD, http://www.cpanforum.com/posts/8078)
37             # 22) Bozi (K10D, http://www.cpanforum.com/posts/8480)
38             # 23) Akos Szalkai (https://rt.cpan.org/Ticket/Display.html?id=43743)
39             # 24) Albert Bogner private communication
40             # 26) https://exiftool.org/forum/index.php/topic,3444.0.html
41             # 27) https://exiftool.org/forum/index.php/topic,3833.0.html
42             # 28) Klaus Homeister https://exiftool.org/forum/index.php/topic,4803.0.html
43             # 29) Louis Granboulan private communication (K-5II)
44             # 30) https://exiftool.org/forum/index.php?topic=5433
45             # 31) Andras Salamon private communication (K-70)
46             # IB) Iliah Borg private communication (LibRaw)
47             # JD) Jens Duttke private communication
48             # NJ) Niels Kristian Bech Jensen private communication
49             # KG) Karsten Gieselmann private communication
50             #
51             # Notes: See POD documentation at the bottom of this file
52             #------------------------------------------------------------------------------
53              
54             package Image::ExifTool::Pentax;
55              
56 26     26   5246 use strict;
  26         48  
  26         1051  
57 26     26   109 use vars qw($VERSION %pentaxLensTypes);
  26         45  
  26         1199  
58 26     26   1255 use Image::ExifTool::Exif;
  26         60  
  26         661  
59 26     26   609 use Image::ExifTool::GPS;
  26         42  
  26         588  
60 26     26   12172 use Image::ExifTool::HP;
  26         65  
  26         316494  
61              
62             $VERSION = '3.62';
63              
64             sub CryptShutterCount($$);
65             sub PrintFilter($$$);
66             sub DecodeAFPoints($$$$;$);
67             sub AFPointNamesK3III($$;$);
68             sub AFPointValuesK3III($$);
69             sub AFAreasK3III($$);
70              
71             # pentax lens type codes (ref 4)
72             # The first number gives the lens series, and the 2nd gives the model number
73             # Series numbers: K=1; A=2; F=3; FAJ=4; DFA=4,7; FA=3,4,5,6; FA*=5,6;
74             # DA=3,4,7; DA*=7,8; FA645=11; DFA645=13; Q=21
75             %pentaxLensTypes = (
76             Notes => q{
77             The first number gives the series of the lens, and the second identifies the
78             lens model. Note that newer series numbers may not always be properly
79             identified by cameras running older firmware versions.
80             },
81             OTHER => sub {
82             my ($val, $inv, $conv) = @_;
83             return undef if $inv;
84             # *istD may report a series number of 4 for series 7 lenses
85             $val =~ s/^4 /7 / and $$conv{$val} and return "$$conv{$val} ($_[0])";
86             # cameras that don't recognize SDM lenses (eg. older K10 firmware)
87             # may report series 7 instead of 8
88             $val =~ s/^7 /8 / and $$conv{$val} and return "$$conv{$val} ? ($_[0])";
89             # there seems to some inconsistency between FA and DFA lenses for the 645D...
90             ($val =~ s/^11 /13 / or $val =~ s/^13 /11 /) and $$conv{$val} and return "$$conv{$val} ? ($_[0])";
91             return undef;
92             },
93             '0 0' => 'M-42 or No Lens', #17
94             '1 0' => 'K or M Lens',
95             '2 0' => 'A Series Lens', #7 (from smc PENTAX-A 400mm F5.6)
96             '3 0' => 'Sigma',
97             # (and 'Sigma 18-50mm F2.8 EX Macro')
98             # (and 'Sigma 30mm F1.4 EX DC', ref PH)
99             # (and 'Sigma 50-500mm F4-6.3 DG APO')
100             # (and 'Sigma 70mm F2.8 EX DG Macro')
101             # (and 'Sigma 105mm F2.8 EX DG Macro', ref 24)
102             # (and 'Sigma 180mm F4.5 EX DG Macro')
103             '3 17' => 'smc PENTAX-FA SOFT 85mm F2.8', # (also F version, ref 29)
104             '3 18' => 'smc PENTAX-F 1.7X AF ADAPTER',
105             '3 19' => 'smc PENTAX-F 24-50mm F4',
106             '3 20' => 'smc PENTAX-F 35-80mm F4-5.6',
107             '3 21' => 'smc PENTAX-F 80-200mm F4.7-5.6',
108             '3 22' => 'smc PENTAX-F FISH-EYE 17-28mm F3.5-4.5',
109             '3 23' => 'smc PENTAX-F 100-300mm F4.5-5.6 or Sigma Lens',
110             '3 23.1' => 'Sigma AF 28-300mm F3.5-5.6 DL IF', #JD
111             '3 23.2' => 'Sigma AF 28-300mm F3.5-6.3 DG IF Macro', #JD
112             '3 23.3' => 'Tokina 80-200mm F2.8 ATX-Pro', #Exiv2
113             '3 24' => 'smc PENTAX-F 35-135mm F3.5-4.5',
114             '3 25' => 'smc PENTAX-F 35-105mm F4-5.6 or Sigma or Tokina Lens',
115             '3 25.1' => 'Sigma 55-200mm F4-5.6 DC', #JD
116             '3 25.2' => 'Sigma AF 28-300mm F3.5-5.6 DL IF', #11
117             '3 25.3' => 'Sigma AF 28-300mm F3.5-6.3 DL IF', #Exiv2
118             '3 25.4' => 'Sigma AF 28-300mm F3.5-6.3 DG IF Macro', #JD
119             '3 25.5' => 'Tokina 80-200mm F2.8 ATX-Pro', #12
120             '3 26' => 'smc PENTAX-F* 250-600mm F5.6 ED[IF]',
121             '3 27' => 'smc PENTAX-F 28-80mm F3.5-4.5 or Tokina Lens',
122             '3 27.1' => 'Tokina AT-X Pro AF 28-70mm F2.6-2.8', #JD
123             '3 28' => 'smc PENTAX-F 35-70mm F3.5-4.5 or Tokina Lens',
124             '3 28.1' => 'Tokina 19-35mm F3.5-4.5 AF', #12
125             '3 28.2' => 'Tokina AT-X AF 400mm F5.6', #NJ
126             '3 29' => 'PENTAX-F 28-80mm F3.5-4.5 or Sigma or Tokina Lens',
127             '3 29.1' => 'Sigma AF 18-125mm F3.5-5.6 DC', #11
128             '3 29.2' => 'Tokina AT-X PRO 28-70mm F2.6-2.8', #22
129             '3 30' => 'PENTAX-F 70-200mm F4-5.6',
130             '3 31' => 'smc PENTAX-F 70-210mm F4-5.6 or Tokina or Takumar Lens',
131             '3 31.1' => 'Tokina AF 730 75-300mm F4.5-5.6',
132             '3 31.2' => 'Takumar-F 70-210mm F4-5.6', #JD
133             '3 32' => 'smc PENTAX-F 50mm F1.4',
134             '3 33' => 'smc PENTAX-F 50mm F1.7',
135             '3 34' => 'smc PENTAX-F 135mm F2.8 [IF]',
136             '3 35' => 'smc PENTAX-F 28mm F2.8',
137             '3 36' => 'Sigma 20mm F1.8 EX DG Aspherical RF',
138             '3 38' => 'smc PENTAX-F* 300mm F4.5 ED[IF]',
139             '3 39' => 'smc PENTAX-F* 600mm F4 ED[IF]',
140             '3 40' => 'smc PENTAX-F Macro 100mm F2.8',
141             '3 41' => 'smc PENTAX-F Macro 50mm F2.8 or Sigma Lens', #4
142             '3 41.1' => 'Sigma 50mm F2.8 Macro', #16
143             '3 42' => 'Sigma 300mm F2.8 EX DG APO IF', #27
144             '3 44' => 'Sigma or Tamron Lens (3 44)',
145             '3 44.1' => 'Sigma AF 10-20mm F4-5.6 EX DC', #JD
146             '3 44.2' => 'Sigma 12-24mm F4.5-5.6 EX DG', #12 (added "-5.6", ref 29)
147             '3 44.3' => 'Sigma 17-70mm F2.8-4.5 DC Macro', #(Bart Hickman)
148             '3 44.4' => 'Sigma 18-50mm F3.5-5.6 DC', #4
149             '3 44.5' => 'Sigma 17-35mm F2.8-4 EX DG', #29
150             '3 44.6' => 'Tamron 35-90mm F4-5.6 AF', #12 (added "-5.6", ref IB)
151             '3 44.7' => 'Sigma AF 18-35mm F3.5-4.5 Aspherical', #29
152             '3 46' => 'Sigma or Samsung Lens (3 46)',
153             '3 46.1' => 'Sigma APO 70-200mm F2.8 EX',
154             '3 46.2' => 'Sigma EX APO 100-300mm F4 IF', #JD
155             '3 46.3' => 'Samsung/Schneider D-XENON 50-200mm F4-5.6 ED', #29
156             '3 50' => 'smc PENTAX-FA 28-70mm F4 AL',
157             '3 51' => 'Sigma 28mm F1.8 EX DG Aspherical Macro',
158             '3 52' => 'smc PENTAX-FA 28-200mm F3.8-5.6 AL[IF] or Tamron Lens',
159             '3 52.1' => 'Tamron AF LD 28-200mm F3.8-5.6 [IF] Aspherical (171D)', #JD
160             '3 53' => 'smc PENTAX-FA 28-80mm F3.5-5.6 AL',
161             '3 247' => 'smc PENTAX-DA FISH-EYE 10-17mm F3.5-4.5 ED[IF]',
162             '3 248' => 'smc PENTAX-DA 12-24mm F4 ED AL[IF]',
163             '3 250' => 'smc PENTAX-DA 50-200mm F4-5.6 ED',
164             '3 251' => 'smc PENTAX-DA 40mm F2.8 Limited',
165             '3 252' => 'smc PENTAX-DA 18-55mm F3.5-5.6 AL',
166             '3 253' => 'smc PENTAX-DA 14mm F2.8 ED[IF]',
167             '3 254' => 'smc PENTAX-DA 16-45mm F4 ED AL',
168             '3 255' => 'Sigma Lens (3 255)',
169             '3 255.1' => 'Sigma 18-200mm F3.5-6.3 DC', #8
170             '3 255.2' => 'Sigma DL-II 35-80mm F4-5.6', #12
171             '3 255.3' => 'Sigma DL Zoom 75-300mm F4-5.6', #12
172             '3 255.4' => 'Sigma DF EX Aspherical 28-70mm F2.8', #12
173             '3 255.5' => 'Sigma AF Tele 400mm F5.6 Multi-coated', #JD
174             '3 255.6' => 'Sigma 24-60mm F2.8 EX DG', #PH
175             '3 255.7' => 'Sigma 70-300mm F4-5.6 Macro', #JD (also DG Macro, ref 27)
176             '3 255.8' => 'Sigma 55-200mm F4-5.6 DC', #JD
177             '3 255.9' => 'Sigma 18-50mm F2.8 EX DC', #JD (also Macro version - PH)
178             '4 1' => 'smc PENTAX-FA SOFT 28mm F2.8',
179             '4 2' => 'smc PENTAX-FA 80-320mm F4.5-5.6',
180             '4 3' => 'smc PENTAX-FA 43mm F1.9 Limited',
181             '4 6' => 'smc PENTAX-FA 35-80mm F4-5.6',
182             '4 7' => 'Irix 45mm F1.4', #27
183             '4 8' => 'Irix 150mm F2.8 Macro', #exiv2 issue 1084
184             '4 9' => 'Irix 11mm F4 Firefly', #27 (guessing the Blackstone version may be the same ID - PH)
185             '4 10' => 'Irix 15mm F2.4', #27
186             '4 12' => 'smc PENTAX-FA 50mm F1.4', #17
187             '4 15' => 'smc PENTAX-FA 28-105mm F4-5.6 [IF]',
188             '4 16' => 'Tamron AF 80-210mm F4-5.6 (178D)', #13
189             '4 19' => 'Tamron SP AF 90mm F2.8 (172E)',
190             '4 20' => 'smc PENTAX-FA 28-80mm F3.5-5.6',
191             '4 21' => 'Cosina AF 100-300mm F5.6-6.7', #20
192             '4 22' => 'Tokina 28-80mm F3.5-5.6', #13
193             '4 23' => 'smc PENTAX-FA 20-35mm F4 AL',
194             '4 24' => 'smc PENTAX-FA 77mm F1.8 Limited',
195             '4 25' => 'Tamron SP AF 14mm F2.8', #13
196             '4 26' => 'smc PENTAX-FA Macro 100mm F3.5 or Cosina Lens',
197             '4 26.1' => 'Cosina 100mm F3.5 Macro', #JD
198             '4 27' => 'Tamron AF 28-300mm F3.5-6.3 LD Aspherical[IF] Macro (185D/285D)',
199             '4 28' => 'smc PENTAX-FA 35mm F2 AL',
200             '4 29' => 'Tamron AF 28-200mm F3.8-5.6 LD Super II Macro (371D)', #JD
201             '4 34' => 'smc PENTAX-FA 24-90mm F3.5-4.5 AL[IF]',
202             '4 35' => 'smc PENTAX-FA 100-300mm F4.7-5.8',
203             # '4 36' => 'Tamron AF70-300mm F4-5.6 LD Macro', # both 572D and A17 (Di) - ref JD
204             '4 36' => 'Tamron AF 70-300mm F4-5.6 LD Macro 1:2', #NJ
205             '4 37' => 'Tamron SP AF 24-135mm F3.5-5.6 AD AL (190D)', #13
206             '4 38' => 'smc PENTAX-FA 28-105mm F3.2-4.5 AL[IF]',
207             '4 39' => 'smc PENTAX-FA 31mm F1.8 AL Limited',
208             '4 41' => 'Tamron AF 28-200mm Super Zoom F3.8-5.6 Aspherical XR [IF] Macro (A03)',
209             '4 43' => 'smc PENTAX-FA 28-90mm F3.5-5.6',
210             '4 44' => 'smc PENTAX-FA J 75-300mm F4.5-5.8 AL',
211             '4 45' => 'Tamron Lens (4 45)',
212             '4 45.1' => 'Tamron 28-300mm F3.5-6.3 Ultra zoom XR',
213             '4 45.2' => 'Tamron AF 28-300mm F3.5-6.3 XR Di LD Aspherical [IF] Macro', #JD
214             '4 46' => 'smc PENTAX-FA J 28-80mm F3.5-5.6 AL',
215             '4 47' => 'smc PENTAX-FA J 18-35mm F4-5.6 AL',
216             #'4 49' => 'Tamron SP AF 28-75mm F2.8 XR Di (A09)',
217             '4 49' => 'Tamron SP AF 28-75mm F2.8 XR Di LD Aspherical [IF] Macro', #NJ
218             '4 51' => 'smc PENTAX-D FA 50mm F2.8 Macro',
219             '4 52' => 'smc PENTAX-D FA 100mm F2.8 Macro',
220             '4 55' => 'Samsung/Schneider D-XENOGON 35mm F2', #29
221             '4 56' => 'Samsung/Schneider D-XENON 100mm F2.8 Macro', #Alan Robinson
222             '4 75' => 'Tamron SP AF 70-200mm F2.8 Di LD [IF] Macro (A001)', #JD
223             '4 214' => 'smc PENTAX-DA 35mm F2.4 AL', #PH
224             '4 229' => 'smc PENTAX-DA 18-55mm F3.5-5.6 AL II', #JD
225             '4 230' => 'Tamron SP AF 17-50mm F2.8 XR Di II', #20
226             '4 231' => 'smc PENTAX-DA 18-250mm F3.5-6.3 ED AL [IF]', #21
227             '4 237' => 'Samsung/Schneider D-XENOGON 10-17mm F3.5-4.5', #JD
228             '4 239' => 'Samsung/Schneider D-XENON 12-24mm F4 ED AL [IF]', #23
229             '4 242' => 'smc PENTAX-DA* 16-50mm F2.8 ED AL [IF] SDM (SDM unused)', #Pietu Pohjalainen
230             '4 243' => 'smc PENTAX-DA 70mm F2.4 Limited', #JD
231             '4 244' => 'smc PENTAX-DA 21mm F3.2 AL Limited', #9
232             '4 245' => 'Samsung/Schneider D-XENON 50-200mm F4-5.6', #15
233             '4 246' => 'Samsung/Schneider D-XENON 18-55mm F3.5-5.6', #15
234             '4 247' => 'smc PENTAX-DA FISH-EYE 10-17mm F3.5-4.5 ED[IF]', #10
235             '4 248' => 'smc PENTAX-DA 12-24mm F4 ED AL [IF]', #10
236             '4 249' => 'Tamron XR DiII 18-200mm F3.5-6.3 (A14)',
237             '4 250' => 'smc PENTAX-DA 50-200mm F4-5.6 ED', #8
238             '4 251' => 'smc PENTAX-DA 40mm F2.8 Limited', #9
239             '4 252' => 'smc PENTAX-DA 18-55mm F3.5-5.6 AL', #8
240             '4 253' => 'smc PENTAX-DA 14mm F2.8 ED[IF]',
241             '4 254' => 'smc PENTAX-DA 16-45mm F4 ED AL',
242             '5 1' => 'smc PENTAX-FA* 24mm F2 AL[IF]',
243             '5 2' => 'smc PENTAX-FA 28mm F2.8 AL',
244             '5 3' => 'smc PENTAX-FA 50mm F1.7',
245             '5 4' => 'smc PENTAX-FA 50mm F1.4',
246             '5 5' => 'smc PENTAX-FA* 600mm F4 ED[IF]',
247             '5 6' => 'smc PENTAX-FA* 300mm F4.5 ED[IF]',
248             '5 7' => 'smc PENTAX-FA 135mm F2.8 [IF]',
249             '5 8' => 'smc PENTAX-FA Macro 50mm F2.8',
250             '5 9' => 'smc PENTAX-FA Macro 100mm F2.8',
251             '5 10' => 'smc PENTAX-FA* 85mm F1.4 [IF]',
252             '5 11' => 'smc PENTAX-FA* 200mm F2.8 ED[IF]',
253             '5 12' => 'smc PENTAX-FA 28-80mm F3.5-4.7',
254             '5 13' => 'smc PENTAX-FA 70-200mm F4-5.6',
255             '5 14' => 'smc PENTAX-FA* 250-600mm F5.6 ED[IF]',
256             '5 15' => 'smc PENTAX-FA 28-105mm F4-5.6',
257             '5 16' => 'smc PENTAX-FA 100-300mm F4.5-5.6',
258             '5 98' => 'smc PENTAX-FA 100-300mm F4.5-5.6', #JD (pre-production? - PH)
259             '6 1' => 'smc PENTAX-FA* 85mm F1.4 [IF]',
260             '6 2' => 'smc PENTAX-FA* 200mm F2.8 ED[IF]',
261             '6 3' => 'smc PENTAX-FA* 300mm F2.8 ED[IF]',
262             '6 4' => 'smc PENTAX-FA* 28-70mm F2.8 AL',
263             '6 5' => 'smc PENTAX-FA* 80-200mm F2.8 ED[IF]',
264             '6 6' => 'smc PENTAX-FA* 28-70mm F2.8 AL',
265             '6 7' => 'smc PENTAX-FA* 80-200mm F2.8 ED[IF]',
266             '6 8' => 'smc PENTAX-FA 28-70mm F4AL',
267             '6 9' => 'smc PENTAX-FA 20mm F2.8',
268             '6 10' => 'smc PENTAX-FA* 400mm F5.6 ED[IF]',
269             '6 13' => 'smc PENTAX-FA* 400mm F5.6 ED[IF]',
270             '6 14' => 'smc PENTAX-FA* Macro 200mm F4 ED[IF]',
271             '7 0' => 'smc PENTAX-DA 21mm F3.2 AL Limited', #13
272             '7 58' => 'smc PENTAX-D FA Macro 100mm F2.8 WR', #PH - this bit of information cost me $600 ;)
273             # '7 58' also 'HD PENTAX-D FA MACRO 100mm F2.8 ED AW' (ref 27)
274             '7 75' => 'Tamron SP AF 70-200mm F2.8 Di LD [IF] Macro (A001)', #(Anton Bondar)
275             '7 201' => 'smc Pentax-DA L 50-200mm F4-5.6 ED WR', #(Bruce Rusk)
276             '7 202' => 'smc PENTAX-DA L 18-55mm F3.5-5.6 AL WR', #29
277             '7 203' => 'HD PENTAX-DA 55-300mm F4-5.8 ED WR', #29
278             '7 204' => 'HD PENTAX-DA 15mm F4 ED AL Limited', #forum5318
279             '7 205' => 'HD PENTAX-DA 35mm F2.8 Macro Limited', #29
280             '7 206' => 'HD PENTAX-DA 70mm F2.4 Limited', #29
281             '7 207' => 'HD PENTAX-DA 21mm F3.2 ED AL Limited', #forum5327
282             '7 208' => 'HD PENTAX-DA 40mm F2.8 Limited', #PH
283             '7 212' => 'smc PENTAX-DA 50mm F1.8', #PH
284             '7 213' => 'smc PENTAX-DA 40mm F2.8 XS', #PH
285             '7 214' => 'smc PENTAX-DA 35mm F2.4 AL', #PH
286             '7 216' => 'smc PENTAX-DA L 55-300mm F4-5.8 ED', #PH
287             '7 217' => 'smc PENTAX-DA 50-200mm F4-5.6 ED WR', #JD
288             '7 218' => 'smc PENTAX-DA 18-55mm F3.5-5.6 AL WR', #JD
289             '7 220' => 'Tamron SP AF 10-24mm F3.5-4.5 Di II LD Aspherical [IF]', #24
290             '7 221' => 'smc PENTAX-DA L 50-200mm F4-5.6 ED', #Ar't
291             '7 222' => 'smc PENTAX-DA L 18-55mm F3.5-5.6', #PH (tag 0x003f -- was '7 229' in LensInfo of one test image)
292             '7 223' => 'Samsung/Schneider D-XENON 18-55mm F3.5-5.6 II', #PH
293             '7 224' => 'smc PENTAX-DA 15mm F4 ED AL Limited', #JD
294             '7 225' => 'Samsung/Schneider D-XENON 18-250mm F3.5-6.3', #8/PH
295             '7 226' => 'smc PENTAX-DA* 55mm F1.4 SDM (SDM unused)', #PH (NC)
296             '7 227' => 'smc PENTAX-DA* 60-250mm F4 [IF] SDM (SDM unused)', #PH (NC)
297             '7 228' => 'Samsung 16-45mm F4 ED', #29
298             '7 229' => 'smc PENTAX-DA 18-55mm F3.5-5.6 AL II', #JD
299             '7 230' => 'Tamron AF 17-50mm F2.8 XR Di-II LD (Model A16)', #JD
300             '7 231' => 'smc PENTAX-DA 18-250mm F3.5-6.3 ED AL [IF]', #JD
301             '7 233' => 'smc PENTAX-DA 35mm F2.8 Macro Limited', #JD
302             '7 234' => 'smc PENTAX-DA* 300mm F4 ED [IF] SDM (SDM unused)', #19 (NC)
303             '7 235' => 'smc PENTAX-DA* 200mm F2.8 ED [IF] SDM (SDM unused)', #PH (NC)
304             '7 236' => 'smc PENTAX-DA 55-300mm F4-5.8 ED', #JD
305             '7 238' => 'Tamron AF 18-250mm F3.5-6.3 Di II LD Aspherical [IF] Macro', #JD
306             '7 241' => 'smc PENTAX-DA* 50-135mm F2.8 ED [IF] SDM (SDM unused)', #PH
307             '7 242' => 'smc PENTAX-DA* 16-50mm F2.8 ED AL [IF] SDM (SDM unused)', #19
308             '7 243' => 'smc PENTAX-DA 70mm F2.4 Limited', #PH
309             '7 244' => 'smc PENTAX-DA 21mm F3.2 AL Limited', #16
310             '8 0' => 'Sigma 50-150mm F2.8 II APO EX DC HSM', #forum2997
311             '8 3' => 'Sigma 18-125mm F3.8-5.6 DC HSM', #forum10167
312             '8 4' => 'Sigma 50mm F1.4 EX DG HSM', #Artur private communication
313             '8 6' => 'Sigma 4.5mm F2.8 EX DC Fisheye', #IB
314             '8 7' => 'Sigma 24-70mm F2.8 IF EX DG HSM', #Exiv2
315             '8 8' => 'Sigma 18-250mm F3.5-6.3 DC OS HSM', #27
316             '8 11' => 'Sigma 10-20mm F3.5 EX DC HSM', #27
317             '8 12' => 'Sigma 70-300mm F4-5.6 DG OS', #forum3382
318             '8 13' => 'Sigma 120-400mm F4.5-5.6 APO DG OS HSM', #26
319             '8 14' => 'Sigma 17-70mm F2.8-4.0 DC Macro OS HSM', #(Hubert Meier)
320             '8 15' => 'Sigma 150-500mm F5-6.3 APO DG OS HSM', #26
321             '8 16' => 'Sigma 70-200mm F2.8 EX DG Macro HSM II', #26
322             '8 17' => 'Sigma 50-500mm F4.5-6.3 DG OS HSM', #(Heike Herrmann) (also APO, ref 26)
323             '8 18' => 'Sigma 8-16mm F4.5-5.6 DC HSM', #forum2998
324             '8 20' => 'Sigma 18-50mm F2.8-4.5 DC HSM', #IB
325             '8 21' => 'Sigma 17-50mm F2.8 EX DC OS HSM', #26
326             '8 22' => 'Sigma 85mm F1.4 EX DG HSM', #26
327             '8 23' => 'Sigma 70-200mm F2.8 APO EX DG OS HSM', #27
328             '8 24' => 'Sigma 17-70mm F2.8-4 DC Macro OS HSM', #27
329             '8 25' => 'Sigma 17-50mm F2.8 EX DC HSM', #Exiv2
330             '8 27' => 'Sigma 18-200mm F3.5-6.3 II DC HSM', #27
331             '8 28' => 'Sigma 18-250mm F3.5-6.3 DC Macro HSM', #27
332             '8 29' => 'Sigma 35mm F1.4 DG HSM', #27
333             '8 30' => 'Sigma 17-70mm F2.8-4 DC Macro HSM | C', #27
334             '8 31' => 'Sigma 18-35mm F1.8 DC HSM', #27
335             '8 32' => 'Sigma 30mm F1.4 DC HSM | A', #27
336             '8 33' => 'Sigma 18-200mm F3.5-6.3 DC Macro HSM', #DieterPearcey (C014)
337             '8 34' => 'Sigma 18-300mm F3.5-6.3 DC Macro HSM', #NJ
338             '8 59' => 'HD PENTAX-D FA 150-450mm F4.5-5.6 ED DC AW', #29
339             '8 60' => 'HD PENTAX-D FA* 70-200mm F2.8 ED DC AW', #29
340             '8 61' => 'HD PENTAX-D FA 28-105mm F3.5-5.6 ED DC WR', #PH
341             '8 62' => 'HD PENTAX-D FA 24-70mm F2.8 ED SDM WR', #PH
342             '8 63' => 'HD PENTAX-D FA 15-30mm F2.8 ED SDM WR', #PH
343             '8 64' => 'HD PENTAX-D FA* 50mm F1.4 SDM AW', #27
344             '8 65' => 'HD PENTAX-D FA 70-210mm F4 ED SDM WR', #PH
345             '8 66' => 'HD PENTAX-D FA 85mm F1.4 ED SDM AW', #James O'Neill
346             '8 67' => 'HD PENTAX-D FA 21mm F2.4 ED Limited DC WR', #ChristianShulz
347             '8 195' => 'HD PENTAX DA* 16-50mm F2.8 ED PLM AW', #27
348             '8 196' => 'HD PENTAX-DA* 11-18mm F2.8 ED DC AW', #29
349             '8 197' => 'HD PENTAX-DA 55-300mm F4.5-6.3 ED PLM WR RE', #29
350             '8 198' => 'smc PENTAX-DA L 18-50mm F4-5.6 DC WR RE', #29
351             '8 199' => 'HD PENTAX-DA 18-50mm F4-5.6 DC WR RE', #29
352             '8 200' => 'HD PENTAX-DA 16-85mm F3.5-5.6 ED DC WR', #29
353             '8 209' => 'HD PENTAX-DA 20-40mm F2.8-4 ED Limited DC WR', #29
354             '8 210' => 'smc PENTAX-DA 18-270mm F3.5-6.3 ED SDM', #Helmut Schutz
355             '8 211' => 'HD PENTAX-DA 560mm F5.6 ED AW', #PH
356             '8 215' => 'smc PENTAX-DA 18-135mm F3.5-5.6 ED AL [IF] DC WR', #PH
357             '8 226' => 'smc PENTAX-DA* 55mm F1.4 SDM', #JD
358             '8 227' => 'smc PENTAX-DA* 60-250mm F4 [IF] SDM', #JD
359             '8 232' => 'smc PENTAX-DA 17-70mm F4 AL [IF] SDM', #JD
360             '8 234' => 'smc PENTAX-DA* 300mm F4 ED [IF] SDM', #19
361             '8 235' => 'smc PENTAX-DA* 200mm F2.8 ED [IF] SDM', #JD
362             '8 241' => 'smc PENTAX-DA* 50-135mm F2.8 ED [IF] SDM', #JD
363             '8 242' => 'smc PENTAX-DA* 16-50mm F2.8 ED AL [IF] SDM', #JD
364             '8 255' => 'Sigma Lens (8 255)',
365             '8 255.1' => 'Sigma 70-200mm F2.8 EX DG Macro HSM II', #JD
366             '8 255.2' => 'Sigma 150-500mm F5-6.3 DG APO [OS] HSM', #JD (non-OS version has same type, ref 29)
367             '8 255.3' => 'Sigma 50-150mm F2.8 II APO EX DC HSM', #forum2997
368             '8 255.4' => 'Sigma 4.5mm F2.8 EX DC HSM Circular Fisheye', #PH
369             '8 255.5' => 'Sigma 50-200mm F4-5.6 DC OS', #26
370             '8 255.6' => 'Sigma 24-70mm F2.8 EX DG HSM', #29
371              
372             '9 0' => '645 Manual Lens', #PH (NC)
373             '9 3' => 'HD PENTAX-FA 43mm F1.9 Limited', #IB
374             '9 24' => 'HD PENTAX-FA 77mm F1.8 Limited', #IB
375             '9 39' => 'HD PENTAX-FA 31mm F1.8 AL Limited', #IB
376             '9 247' => 'HD PENTAX-DA FISH-EYE 10-17mm F3.5-4.5 ED [IF]', #IB
377             #
378             # 645 lenses
379             #
380             '10 0' => '645 A Series Lens', #PH
381             '11 1' => 'smc PENTAX-FA 645 75mm F2.8', #PH
382             '11 2' => 'smc PENTAX-FA 645 45mm F2.8', #PH
383             '11 3' => 'smc PENTAX-FA* 645 300mm F4 ED [IF]', #PH
384             '11 4' => 'smc PENTAX-FA 645 45-85mm F4.5', #PH
385             '11 5' => 'smc PENTAX-FA 645 400mm F5.6 ED [IF]', #PH
386             '11 7' => 'smc PENTAX-FA 645 Macro 120mm F4', #PH
387             '11 8' => 'smc PENTAX-FA 645 80-160mm F4.5', #PH
388             '11 9' => 'smc PENTAX-FA 645 200mm F4 [IF]', #PH
389             '11 10' => 'smc PENTAX-FA 645 150mm F2.8 [IF]', #PH
390             '11 11' => 'smc PENTAX-FA 645 35mm F3.5 AL [IF]', #PH
391             '11 12' => 'smc PENTAX-FA 645 300mm F5.6 ED [IF]', #29
392             '11 14' => 'smc PENTAX-FA 645 55-110mm F5.6', #PH
393             '11 16' => 'smc PENTAX-FA 645 33-55mm F4.5 AL', #PH
394             '11 17' => 'smc PENTAX-FA 645 150-300mm F5.6 ED [IF]', #PH
395             '11 21' => 'HD PENTAX-D FA 645 35mm F3.5 AL [IF]', #29
396             '13 18' => 'smc PENTAX-D FA 645 55mm F2.8 AL [IF] SDM AW', #PH
397             '13 19' => 'smc PENTAX-D FA 645 25mm F4 AL [IF] SDM AW', #PH
398             '13 20' => 'HD PENTAX-D FA 645 90mm F2.8 ED AW SR', #PH
399             '13 253' => 'HD PENTAX-DA 645 28-45mm F4.5 ED AW SR', #Dominique Schrekling email
400             '13 254' => 'smc PENTAX-DA 645 25mm F4 AL [IF] SDM AW', #forum8253
401             #
402             # Q-mount lenses (21=auto focus lens, 22=manual focus)
403             #
404             '20 0' => 'Pentax Q Manual Lens (Q, Q10)', #27
405             '21 0' => 'Pentax Q Manual Lens', #PH (Q7, Q-S1)
406             '21 1' => '01 Standard Prime 8.5mm F1.9', #PH
407             '21 2' => '02 Standard Zoom 5-15mm F2.8-4.5', #PH
408             '22 3' => '03 Fish-eye 3.2mm F5.6', #PH
409             '22 4' => '04 Toy Lens Wide 6.3mm F7.1', #PH
410             '22 5' => '05 Toy Lens Telephoto 18mm F8', #PH
411             '21 6' => '06 Telephoto Zoom 15-45mm F2.8', #PH
412             '21 7' => '07 Mount Shield 11.5mm F9', #PH (NC)
413             '21 8' => '08 Wide Zoom 3.8-5.9mm F3.7-4', #PH (NC)
414             '21 233' => 'Adapter Q for K-mount Lens', #29
415             #
416             # Ricoh lenses
417             #
418             '31 1' => '18.3mm F2.8', #PH (GR III built-in)
419             '31 4' => '26.1mm F2.8', #PH (GR IIIx built-in)
420             '31 5' => '26.1mm F2.8 GT-2 TC', #KG (GR IIIx built-in plus GT-2 TC)
421             '31 8' => '18.3mm F2.8', #KG (GR IV built-in)
422             );
423              
424             # Pentax model ID codes - PH
425             my %pentaxModelID = (
426             0x0000d => 'Optio 330/430',
427             0x12926 => 'Optio 230',
428             0x12958 => 'Optio 330GS',
429             0x12962 => 'Optio 450/550',
430             0x1296c => 'Optio S',
431             0x12971 => 'Optio S V1.01',
432             0x12994 => '*ist D',
433             0x129b2 => 'Optio 33L',
434             0x129bc => 'Optio 33LF',
435             0x129c6 => 'Optio 33WR/43WR/555',
436             0x129d5 => 'Optio S4',
437             0x12a02 => 'Optio MX',
438             0x12a0c => 'Optio S40',
439             0x12a16 => 'Optio S4i',
440             0x12a34 => 'Optio 30',
441             0x12a52 => 'Optio S30',
442             0x12a66 => 'Optio 750Z',
443             0x12a70 => 'Optio SV',
444             0x12a75 => 'Optio SVi',
445             0x12a7a => 'Optio X',
446             0x12a8e => 'Optio S5i',
447             0x12a98 => 'Optio S50',
448             0x12aa2 => '*ist DS',
449             0x12ab6 => 'Optio MX4',
450             0x12ac0 => 'Optio S5n',
451             0x12aca => 'Optio WP',
452             0x12afc => 'Optio S55',
453             0x12b10 => 'Optio S5z',
454             0x12b1a => '*ist DL',
455             0x12b24 => 'Optio S60',
456             0x12b2e => 'Optio S45',
457             0x12b38 => 'Optio S6',
458             0x12b4c => 'Optio WPi', #13
459             0x12b56 => 'BenQ DC X600',
460             0x12b60 => '*ist DS2',
461             0x12b62 => 'Samsung GX-1S',
462             0x12b6a => 'Optio A10',
463             0x12b7e => '*ist DL2',
464             0x12b80 => 'Samsung GX-1L',
465             0x12b9c => 'K100D',
466             0x12b9d => 'K110D',
467             0x12ba2 => 'K100D Super', #JD
468             0x12bb0 => 'Optio T10/T20',
469             0x12be2 => 'Optio W10',
470             0x12bf6 => 'Optio M10',
471             0x12c1e => 'K10D',
472             0x12c20 => 'Samsung GX10',
473             0x12c28 => 'Optio S7',
474             0x12c2d => 'Optio L20',
475             0x12c32 => 'Optio M20',
476             0x12c3c => 'Optio W20',
477             0x12c46 => 'Optio A20',
478             0x12c78 => 'Optio E30',
479             0x12c7d => 'Optio E35',
480             0x12c82 => 'Optio T30',
481             0x12c8c => 'Optio M30',
482             0x12c91 => 'Optio L30',
483             0x12c96 => 'Optio W30',
484             0x12ca0 => 'Optio A30',
485             0x12cb4 => 'Optio E40',
486             0x12cbe => 'Optio M40',
487             0x12cc3 => 'Optio L40',
488             0x12cc5 => 'Optio L36',
489             0x12cc8 => 'Optio Z10',
490             0x12cd2 => 'K20D',
491             0x12cd4 => 'Samsung GX20', #8
492             0x12cdc => 'Optio S10',
493             0x12ce6 => 'Optio A40',
494             0x12cf0 => 'Optio V10',
495             0x12cfa => 'K200D',
496             0x12d04 => 'Optio S12',
497             0x12d0e => 'Optio E50',
498             0x12d18 => 'Optio M50',
499             0x12d22 => 'Optio L50',
500             0x12d2c => 'Optio V20',
501             0x12d40 => 'Optio W60',
502             0x12d4a => 'Optio M60',
503             0x12d68 => 'Optio E60/M90',
504             0x12d72 => 'K2000',
505             0x12d73 => 'K-m',
506             0x12d86 => 'Optio P70',
507             0x12d90 => 'Optio L70',
508             0x12d9a => 'Optio E70',
509             0x12dae => 'X70',
510             0x12db8 => 'K-7',
511             0x12dcc => 'Optio W80',
512             0x12dea => 'Optio P80',
513             0x12df4 => 'Optio WS80',
514             0x12dfe => 'K-x',
515             0x12e08 => '645D',
516             0x12e12 => 'Optio E80',
517             0x12e30 => 'Optio W90',
518             0x12e3a => 'Optio I-10',
519             0x12e44 => 'Optio H90',
520             0x12e4e => 'Optio E90',
521             0x12e58 => 'X90',
522             0x12e6c => 'K-r',
523             0x12e76 => 'K-5',
524             0x12e8a => 'Optio RS1000/RS1500',
525             0x12e94 => 'Optio RZ10',
526             0x12e9e => 'Optio LS1000',
527             0x12ebc => 'Optio WG-1 GPS',
528             0x12ed0 => 'Optio S1',
529             0x12ee4 => 'Q',
530             0x12ef8 => 'K-01',
531             0x12f0c => 'Optio RZ18',
532             0x12f16 => 'Optio VS20',
533             0x12f2a => 'Optio WG-2 GPS',
534             0x12f48 => 'Optio LS465',
535             0x12f52 => 'K-30',
536             0x12f5c => 'X-5',
537             0x12f66 => 'Q10',
538             0x12f70 => 'K-5 II',
539             0x12f71 => 'K-5 II s', #forum4515
540             0x12f7a => 'Q7',
541             0x12f84 => 'MX-1',
542             0x12f8e => 'WG-3 GPS',
543             0x12f98 => 'WG-3',
544             0x12fa2 => 'WG-10',
545             0x12fb6 => 'K-50',
546             0x12fc0 => 'K-3', #29
547             0x12fca => 'K-500',
548             0x12fe8 => 'WG-4', # (Ricoh)
549             0x12fde => 'WG-4 GPS', # (Ricoh)
550             0x13006 => 'WG-20', # (Ricoh)
551             0x13010 => '645Z',
552             0x1301a => 'K-S1',
553             0x13024 => 'K-S2', #29 (Ricoh)
554             0x1302e => 'Q-S1',
555             0x13056 => 'WG-30', # (Ricoh)
556             0x1307e => 'WG-30W', # (Ricoh)
557             0x13088 => 'WG-5 GPS', # (Ricoh)
558             0x13092 => 'K-1', #IB (Ricoh)
559             0x1309c => 'K-3 II', #29 (Ricoh)
560             0x131f0 => 'WG-M2', # (Ricoh)
561             0x1320e => 'GR III', # (Ricoh)
562             0x13222 => 'K-70', #29 (Ricoh)
563             0x1322c => 'KP', #29 (Ricoh)
564             0x13240 => 'K-1 Mark II', # (Ricoh)
565             0x13254 => 'K-3 Mark III', #IB (Ricoh)
566             0x13290 => 'WG-70', # (Ricoh)
567             0x1329a => 'GR IIIx', # (Ricoh)
568             0x132b8 => 'KF', #github322 (Ricoh)
569             0x132d6 => 'K-3 Mark III Monochrome', #github226 (Ricoh)
570             0x132e0 => 'GR IV', #github347 (Ricoh)
571             0x13330 => 'GR IV Monochrome', #forum17904 (Ricoh)
572             );
573              
574             # Pentax city codes - (PH, Optio WP)
575             my %pentaxCities = (
576             0 => 'Pago Pago',
577             1 => 'Honolulu',
578             2 => 'Anchorage',
579             3 => 'Vancouver',
580             4 => 'San Francisco',
581             5 => 'Los Angeles',
582             6 => 'Calgary',
583             7 => 'Denver',
584             8 => 'Mexico City',
585             9 => 'Chicago',
586             10 => 'Miami',
587             11 => 'Toronto',
588             12 => 'New York',
589             13 => 'Santiago',
590             14 => 'Caracus',
591             15 => 'Halifax',
592             16 => 'Buenos Aires',
593             17 => 'Sao Paulo',
594             18 => 'Rio de Janeiro',
595             19 => 'Madrid',
596             20 => 'London',
597             21 => 'Paris',
598             22 => 'Milan',
599             23 => 'Rome',
600             24 => 'Berlin',
601             25 => 'Johannesburg',
602             26 => 'Istanbul',
603             27 => 'Cairo',
604             28 => 'Jerusalem',
605             29 => 'Moscow',
606             30 => 'Jeddah',
607             31 => 'Tehran',
608             32 => 'Dubai',
609             33 => 'Karachi',
610             34 => 'Kabul',
611             35 => 'Male',
612             36 => 'Delhi',
613             37 => 'Colombo',
614             38 => 'Kathmandu',
615             39 => 'Dacca',
616             40 => 'Yangon',
617             41 => 'Bangkok',
618             42 => 'Kuala Lumpur',
619             43 => 'Vientiane',
620             44 => 'Singapore',
621             45 => 'Phnom Penh',
622             46 => 'Ho Chi Minh',
623             47 => 'Jakarta',
624             48 => 'Hong Kong',
625             49 => 'Perth',
626             50 => 'Beijing',
627             51 => 'Shanghai',
628             52 => 'Manila',
629             53 => 'Taipei',
630             54 => 'Seoul',
631             55 => 'Adelaide',
632             56 => 'Tokyo',
633             57 => 'Guam',
634             58 => 'Sydney',
635             59 => 'Noumea',
636             60 => 'Wellington',
637             61 => 'Auckland',
638             62 => 'Lima',
639             63 => 'Dakar',
640             64 => 'Algiers',
641             65 => 'Helsinki',
642             66 => 'Athens',
643             67 => 'Nairobi',
644             68 => 'Amsterdam',
645             69 => 'Stockholm',
646             70 => 'Lisbon', #14
647             71 => 'Copenhagen', #NJ
648             72 => 'Warsaw',
649             73 => 'Prague',
650             74 => 'Budapest',
651             );
652              
653             # digital filter tag information (ref PH, K-5)
654             # (also see %filterSettings below for decoding of filter parameters)
655             my %digitalFilter = (
656             Format => 'undef[17]',
657             RawConv => '($val!~/^\\0/ or $$self{OPTIONS}{Unknown}) ? join(" ",unpack("Cc*",$val)) : undef',
658             SeparateTable => 'DigitalFilter',
659             ValueConvInv => q{
660             return "\0" x 17 if $val eq "0";
661             $val = pack("Cc*", $val=~/[-+]?\d+/g);
662             length($val)==17 or warn("Expecting 17 values\n"), return undef;
663             return $val;
664             },
665             PrintConv => {
666             OTHER => \&PrintFilter, # this routine actually converts all values
667             0 => 'Off',
668             1 => 'Base Parameter Adjust',
669             2 => 'Soft Focus',
670             3 => 'High Contrast',
671             4 => 'Color Filter',
672             5 => 'Extract Color',
673             6 => 'Monochrome',
674             7 => 'Slim',
675             9 => 'Fisheye',
676             10 => 'Toy Camera',
677             11 => 'Retro',
678             12 => 'Pastel',
679             13 => 'Water Color',
680             14 => 'HDR',
681             16 => 'Miniature',
682             17 => 'Starburst',
683             18 => 'Posterization',
684             19 => 'Sketch Filter',
685             20 => 'Shading', # (Q)
686             21 => 'Invert Color', # (Q)
687             23 => 'Tone Expansion', #Forum5247
688             27 => 'Unicolor Bold', #31
689             28 => 'Bold Monochrome', #31
690             29 => 'Replace Color', #31
691             254 => 'Custom Filter',
692             },
693             );
694              
695             # digital filter setting names and conversions (ref PH, K-5)
696             # Note: names must be unique for writing
697             my %filterSettings = (
698             1 => ['Brightness', '%+d'], # BPA (-8-+8)
699             2 => ['Saturation', '%+d'], # BPA (-3-+3)
700             3 => ['Hue', '%+d'], # BPA (-3-+3)
701             4 => ['Contrast', '%+d'], # BPA (-3-+3)
702             5 => ['Sharpness', '%+d'], # BPA (-3-+3)
703             6 => ['SoftFocus', '%d'], # Soft Focus/Custom (1-3)
704             7 => ['ShadowBlur', { 0=>'Off',1=>'On' }], # Soft Focus
705             8 => ['HighContrast', '%d'], # High Contrast/Custom (1-5)
706             9 => ['Color', { 1=>'Red',2=>'Magenta',3=>'Blue',4=>'Cyan',5=>'Green',6=>'Yellow' }], # Color Filter
707             10 => ['Density', { 1=>'Light',2=>'Standard',3=>'Dark' }], # Color Filter
708             11 => ['ExtractedColor',{ 0=>'Off',1=>'Red',2=>'Magenta',3=>'Blue',4=>'Cyan',5=>'Green',6=>'Yellow' }], # Extract Color [x2]
709             12 => ['ColorRange', '%+d'], # Extract Color [x2] (-2-+2)
710             13 => ['FilterEffect', { 0=>'Off',1=>'Red',2=>'Green',3=>'Blue',4=>'Infrared'}], # Monochrome
711             14 => ['ToningBA', '%+d'], # Monochrome (-3-+3)
712             15 => ['InvertColor', { 0=>'Off',1=>'On' }], # Custom/Invert Color
713             16 => ['Slim', '%+d'], # Slim (-8-+8)
714             17 => ['EffectDensity', { 1=>'Sparse',2=>'Normal',3=>'Dense' }], # Starburst
715             18 => ['Size', { 1=>'Small',2=>'Medium',3=>'Large' }], # Starburst
716             19 => ['Angle', { 0=>'0deg',2=>'30deg',3=>'45deg',4=>'60deg'}], # Starburst (1 is unused)
717             20 => ['Fisheye', { 1=>'Weak',2=>'Medium',3=>'Strong' }], # Fisheye
718             21 => ['DistortionType', '%d'], # Custom (1-3)
719             22 => ['DistortionLevel',{0=>'Off',1=>'Weak',2=>'Medium',3=>'Strong' }], #Custom
720             23 => ['ShadingType', '%d'], # Custom/Shading (1-6)
721             24 => ['ShadingLevel', '%+d'], # Custom/Shading (-3-+3)
722             25 => ['Shading', '%d'], # Toy Camera (1-3)
723             26 => ['Blur', '%d'], # Toy Camera (1-3)
724             27 => ['ToneBreak', { 0=>'Off',1=>'Red',2=>'Green',3=>'Blue',4=>'Yellow'}], # Toy Camera/Custom
725             28 => ['Toning', '%+d'], # Retro (-3-+3)
726             29 => ['FrameComposite',{ 0=>'None',1=>'Thin',2=>'Medium',3=>'Thick' }], # Retro
727             30 => ['PastelStrength',{ 1=>'Weak',2=>'Medium',3=>'Strong' }], # Pastel
728             31 => ['Intensity', '%d'], # Water Color (1-3)
729             32 => ['Saturation2', { 0=>'Off',1=>'Low',2=>'Medium',3=>'High' }], # Water Color
730             33 => ['HDR', { 1=>'Weak',2=>'Medium',3=>'Strong' }], # HDR
731             # (34 missing)
732             35 => ['FocusPlane', '%+d'], # Miniature (-3-+3)
733             36 => ['FocusWidth', { 1=>'Narrow',2=>'Middle',3=>'Wide' }], # Miniature
734             37 => ['PlaneAngle', { 0=>'Horizontal',1=>'Vertical',2=>'Positive slope',3=>'Negative slope' }], # Miniature
735             38 => ['Blur2', '%d'], # Miniature (1-3)
736             39 => ['Shape', { 1=>'Cross',2=>'Star',3=>'Snowflake',4=>'Heart',5=>'Note'}], # Starburst
737             40 => ['Posterization', '%d'], # Posterization (1-5)
738             41 => ['Contrast2', { 1=>'Low',2=>'Medium',3=>'High'}], # Sketch Filter
739             42 => ['ScratchEffect', { 0=>'Off',1=>'On' }], # Sketch Filter
740             45 => ['ToneExpansion', { 1=>'Low',2=>'Medium',3=>'High' }], # Tone Expansion (ref Forum5247)
741             47 => ['UnicolorBold', { 1=>'Red',2=>'Magenta',3=>'Blue',4=>'Cyan',5=>'Green',6=>'Yellow' }], #31 Unicolor Bold
742             48 => ['BoldMonochrome', '%d'], #31 Bold Monochrome (1-3)
743             49 => ['OriginalColor', { 1=>'Red',2=>'Magenta',3=>'Blue',4=>'Cyan',5=>'Green',6=>'Yellow' }], #31 Replace Color
744             50 => ['NewColor', { 1=>'Red',2=>'Magenta',3=>'Blue',4=>'Cyan',5=>'Green',6=>'Yellow' }], #31 Replace Color
745             51 => ['ColorScale', '%d'], #31 Replace Color (1-5)
746             52 => ['Toning2', '%+d'], #31 Extract Color (-3-+3)
747             );
748              
749             # order of selectable K-3iii AF points. The array looks like this:
750             # B1 C1 E1 G1 I1 K1 L1
751             # A3 B3 C3 E3 G3 I3 K3 L3 M3
752             # A5 B5 C5 E5 G5 I5 K5 L5 M5
753             # A7 B7 C7 E7 G7 I7 K7 L7 M7
754             # B9 C9 E9 G9 I9 K9 L9
755             my @k3iiiAF = qw(
756             C1 E1 G1 I1 K1 C3 E3 G3 I3 K3 C5 E5 G5
757             I5 K5 C7 E7 G7 I7 K7 C9 E9 G9 I9 K9 A5 M5 B3
758             L3 B5 L5 B7 L7 B1 L1 B9 L9 A3 M3 A7 M7
759             D1 F1 H1 J1 D3 F3 H3 J3 D5 F5 H5 J5 D7
760             F7 H7 J7 D9 F9 H9 J9 C2 E2 G2 I2 K2 C4
761             E4 G4 I4 K4 C6 E6 G6 I6 K6 C8 E8 G8 I8
762             K8 B2 L2 B4 L4 B6 L6 B8 L8 A1 M1 A2 M2
763             A4 M4 A6 M6 A8 M8 A9 M9
764             );
765              
766             # decoding for Pentax Firmware ID tags - PH
767             my %pentaxFirmwareID = (
768             # the first 2 numbers are the firmware version, I'm not sure what the second 2 mean
769             # Note: the byte order may be different for some models
770             # which give, for example, version 0.01 instead of 1.00
771             ValueConv => sub {
772             my $val = shift;
773             return $val unless length($val) == 4;
774             # (value is encrypted by toggling all bits)
775             my @a = map { $_ ^ 0xff } unpack("C*",$val);
776             return sprintf('%d %.2d %.2d %.2d', @a);
777             },
778             ValueConvInv => sub {
779             my $val = shift;
780             my @a = $val=~/\b\d+\b/g;
781             return $val unless @a == 4;
782             @a = map { ($_ & 0xff) ^ 0xff } @a;
783             return pack("C*", @a);
784             },
785             PrintConv => '$val=~tr/ /./; $val',
786             PrintConvInv => '$val=~s/^(\d+)\.(\d+)\.(\d+)\.(\d+)/$1 $2 $3 $4/ ? $val : undef',
787             );
788              
789             # convert 16 or 77 metering segment values to approximate LV equivalent - PH
790             my %convertMeteringSegments = (
791             PrintConv => sub { join ' ', map(
792             { $_==255 ? 'n/a' : $_==0 ? '0' : sprintf '%.1f', $_ / 8 - 6 } split(' ',$_[0])
793             ) },
794             PrintConvInv => sub { join ' ', map(
795             { /^n/i ? 255 : $_==0 ? '0' : int(($_ + 6) * 8 + 0.5) } split(' ',$_[0])
796             ) },
797             );
798              
799             # lens code conversions
800             my %lensCode = (
801             Unknown => 1,
802             PrintConv => 'sprintf("0x%.2x", $val)',
803             PrintConvInv => 'hex($val)',
804             );
805              
806             # conversions for tags 0x0053-0x005a
807             my %colorTemp = (
808             Writable => 'undef',
809             Count => 4,
810             ValueConv => sub {
811             my $val = shift;
812             return $val unless length $val == 4;
813             my @a = unpack 'nCC', $val;
814             $a[0] = 53190 - $a[0];
815             $a[1] = ($a[2] & 0x0f); $a[1] -= 16 if $a[1] >= 8;
816             $a[2] = ($a[2] >> 4); $a[2] -= 16 if $a[2] >= 8;
817             return "@a";
818             },
819             ValueConvInv => sub {
820             my $val = shift;
821             my @a = split ' ', $val;
822             return undef unless @a == 3;
823             return pack 'nCC', 53190 - $a[0], 0, ($a[1] & 0x0f) + (($a[2] & 0x0f) << 4);
824             },
825             PrintConv => sub {
826             $_ = shift;
827             s/ ([1-9])/ +$1/g;
828             s/ 0/ 0/g;
829             return $_;
830             },
831             PrintConvInv => '$val',
832             );
833              
834             # conversions for KelvinWB tags
835             my %kelvinWB = (
836             Format => 'int16u[4]',
837             ValueConv => sub {
838             my @a = split ' ', shift;
839             (53190 - $a[0]) . ' ' . $a[1] . ' ' . ($a[2] / 8192) . ' ' . ($a[3] / 8192);
840             },
841             ValueConvInv => sub {
842             my @a = split ' ', shift;
843             (53190 - $a[0]) . ' ' . $a[1] . ' ' . int($a[2]*8192+0.5) . ' ' . int($a[3]*8192+0.5);
844             },
845             );
846              
847             my %noYes = ( 0 => 'No', 1 => 'Yes' );
848              
849             # common attributes for writable BinaryData directories
850             my %binaryDataAttrs = (
851             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
852             WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
853             CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
854             WRITABLE => 1,
855             FIRST_ENTRY => 0,
856             );
857              
858             # Pentax makernote tags
859             %Image::ExifTool::Pentax::Main = (
860             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
861             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
862             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
863             WRITABLE => 1,
864             0x0000 => { #5
865             Name => 'PentaxVersion',
866             Writable => 'int8u',
867             Count => 4,
868             PrintConv => '$val=~tr/ /./; $val',
869             PrintConvInv => '$val=~tr/./ /; $val',
870             # 0.1.0.3 - PENTAX Optio E40
871             # 3.0.0.0 - K10D
872             # 3.1.0.0 - Optio A40/S10/L36/L40/M40/V10
873             # 3.1.1.0 - Optio L36/L40/M40/V10
874             # 3.1.2.0 - Optio Z10
875             # 4.0.2.0 - Optio E50
876             # 4.1.0.0 - Optio S12
877             # 4.1.1.0 - Optio M50
878             # 4.1.2.0 - K20D, K200D
879             # 4.2.0.0 - Optio L50/V20
880             # 4.2.1.0 - Optio E60/M90
881             # 4.2.2.0 - Optio W60
882             # 4.2.3.0 - Optio M60
883             # 4.4.0.1 - K-m, K2000
884             # 4.5.0.0 - Optio E70/L70
885             # 4.5.0.0 - Optio E70/L70/P70
886             # 4.6.0.0 - Optio E80/E90/W80
887             # 5.0.0.0 - K-7, Optio P80/WS80
888             # 5.1.0.0 - K-x
889             # 5.2.0.0 - Optio I-10
890             # 5.3.0.0 - Optio H90
891             # 5.3.2.0 - Optio W90/X90
892             # 6.0.0.0 - K-r, 645D
893             # 6.1.3.0 - Optio LS1000/RS1000/RS1500/RZ10
894             # 7.0.0.0 - K-5
895             # 7.1.0.0 - Optio WG-1GPS/WG-10/WG-20
896             # 7.2.0.0 - Optio S1
897             # 8.0.0.0 - Q
898             # 8.0.1.0 - Optio RZ18
899             # 8.0.4.0 - Optio VS20
900             # 8.1.0.0 - Optio LS465/WG-2GPS
901             # 9.0.0.0 - K-01
902             # 9.1.2.0 - X-5
903             # 10.0.0.0 - K-30, K-50, K-500, K-5 II, K-5 II s
904             # 10.0.2.0 - Q10
905             # 10.2.0.0 - WG-3/WG-4
906             # 10.2.1.0 - MX-1
907             # 10.4.1.0 - WG-3/4/5 GPS, WG-30/30W
908             # 10.6.1.0 - Q-S1, Q7
909             # 11.0.0.0 - K-3
910             # 11.2.1.0 - 645Z
911             # 11.3.0.0 - K-S1
912             # 11.5.0.0 - K-S2
913             # 11.6.1.0 - K-3 II
914             # 11.7.5.0 - Ricoh WG-M2
915             # 12.0.0.0 - K-1
916             # 12.1.3.0 - K-70
917             # 12.1.5.0 - KP
918             # 12.3.2.0 - K-1 Mark II
919             # 12.7.5.0 - Ricoh WG-M2
920             # 13.0.0.0 - Ricoh GR III / G900SE
921             # 13.1.1.0 - Ricoh WG-70
922             # 14.0.0.0 - K-3 Mark III
923             # 14.0.1.0 - Ricoh GR IIIx
924             # 14.2.0.0 - KF
925             # 15.2.3.0 - Ricoh GR IV
926             },
927             0x0001 => { #PH
928             Name => 'PentaxModelType',
929             Writable => 'int16u',
930             # (values of 0-5 seem to group models into 6 categories, ref 13)
931             },
932             0x0002 => { #PH
933             Name => 'PreviewImageSize',
934             Groups => { 2 => 'Image' },
935             Writable => 'int16u',
936             Count => 2,
937             PrintConv => '$val =~ tr/ /x/; $val',
938             PrintConvInv => '$val =~ tr/x/ /; $val',
939             },
940             0x0003 => { #PH
941             Name => 'PreviewImageLength',
942             OffsetPair => 0x0004, # point to associated offset
943             DataTag => 'PreviewImage',
944             Groups => { 2 => 'Image' },
945             Writable => 'int32u',
946             WriteGroup => 'MakerNotes',
947             Protected => 2,
948             },
949             0x0004 => { #PH
950             Name => 'PreviewImageStart',
951             IsOffset => 2, # code to use original base
952             OffsetPair => 0x0003, # point to associated byte count
953             DataTag => 'PreviewImage',
954             Groups => { 2 => 'Image' },
955             Writable => 'int32u',
956             WriteGroup => 'MakerNotes',
957             Protected => 2,
958             },
959             0x0005 => { #13
960             Name => 'PentaxModelID',
961             Writable => 'int32u',
962             PrintHex => 1,
963             SeparateTable => 1,
964             DataMember => 'PentaxModelID',
965             RawConv => '$$self{PentaxModelID} = $val',
966             PrintConv => \%pentaxModelID,
967             },
968             0x0006 => { #5
969             # Note: Year is int16u in MM byte ordering regardless of EXIF byte order
970             Name => 'Date',
971             Groups => { 2 => 'Time' },
972             Notes => 'changing either Date or Time will affect ShutterCount decryption',
973             Writable => 'undef',
974             Count => 4,
975             Shift => 'Time',
976             DataMember => 'PentaxDate',
977             RawConv => '$$self{PentaxDate} = $val', # save to decrypt ShutterCount
978             ValueConv => 'length($val)==4 ? sprintf("%.4d:%.2d:%.2d",unpack("nC2",$val)) : "Unknown ($val)"',
979             ValueConvInv => q{
980             $val =~ s/(\d) .*/$1/; # remove Time
981             my @v = split /:/, $val;
982             return pack("nC2",$v[0],$v[1],$v[2]);
983             },
984             },
985             0x0007 => { #5
986             Name => 'Time',
987             Groups => { 2 => 'Time' },
988             Writable => 'undef',
989             Count => 3,
990             Shift => 'Time',
991             DataMember => 'PentaxTime',
992             RawConv => '$$self{PentaxTime} = $val', # save to decrypt ShutterCount
993             ValueConv => 'length($val)>=3 ? sprintf("%.2d:%.2d:%.2d",unpack("C3",$val)) : "Unknown ($val)"',
994             ValueConvInv => q{
995             $val =~ s/^[0-9:]+ (\d)/$1/; # remove Date
996             return pack("C3",split(/:/,$val));
997             },
998             },
999             0x0008 => { #2
1000             Name => 'Quality',
1001             Writable => 'int16u',
1002             PrintConvColumns => 2,
1003             PrintConv => {
1004             0 => 'Good',
1005             1 => 'Better',
1006             2 => 'Best',
1007             3 => 'TIFF', #5
1008             4 => 'RAW', #5
1009             5 => 'Premium', #PH (K20D)
1010             7 => 'RAW (pixel shift enabled)', #forum6536 (K-3 II)
1011             8 => 'Dynamic Pixel Shift', #IB
1012             9 => 'Monochrome', #github226
1013             65535 => 'n/a', #PH (Q MOV video)
1014             },
1015             },
1016             0x0009 => { #3
1017             Name => 'PentaxImageSize',
1018             Groups => { 2 => 'Image' },
1019             Writable => 'int16u',
1020             PrintConvColumns => 2,
1021             PrintConv => {
1022             0 => '640x480',
1023             1 => 'Full', #PH - this can mean 2048x1536 or 2240x1680 or ... ?
1024             2 => '1024x768',
1025             3 => '1280x960', #PH (Optio WP)
1026             4 => '1600x1200',
1027             5 => '2048x1536',
1028             8 => '2560x1920 or 2304x1728', #PH (Optio WP) or #14
1029             9 => '3072x2304', #PH (Optio M30)
1030             10 => '3264x2448', #13
1031             19 => '320x240', #PH (Optio WP)
1032             20 => '2288x1712', #13
1033             21 => '2592x1944',
1034             22 => '2304x1728 or 2592x1944', #2 or #14
1035             23 => '3056x2296', #13
1036             25 => '2816x2212 or 2816x2112', #13 or #14
1037             27 => '3648x2736', #PH (Optio A20)
1038             29 => '4000x3000', #PH (X70)
1039             30 => '4288x3216', #PH (Optio RS1000)
1040             31 => '4608x3456', #PH (Optio RZ18)
1041             129 => '1920x1080', #PH (Optio RZ10)
1042             135 => '4608x2592', #PH (Q10 stretch filter)
1043             257 => '3216x3216', #PH (Optio RZ10)
1044             '0 0' => '2304x1728', #13
1045             '4 0' => '1600x1200', #PH (Optio MX4)
1046             '5 0' => '2048x1536', #13
1047             '8 0' => '2560x1920', #13
1048             '32 2' => '960x640', #7
1049             '33 2' => '1152x768', #7
1050             '34 2' => '1536x1024', #7
1051             '35 1' => '2400x1600', #7
1052             '36 0' => '3008x2008 or 3040x2024', #PH
1053             '37 0' => '3008x2000', #13
1054             # 65535 - seen for an X-5 panorama (PH)
1055             },
1056             },
1057             0x000b => { #3
1058             Name => 'PictureMode',
1059             Writable => 'int16u',
1060             Count => -1,
1061             Notes => q{
1062             1 or 2 values. Decimal values differentiate Optio 555 modes which are
1063             different from other models
1064             },
1065             ValueConv => '(IsInt($val) and $val < 4 and $$self{Model} =~ /Optio 555\b/) ? $val + 0.1 : $val',
1066             ValueConvInv => 'int $val',
1067             PrintConvColumns => 2,
1068             PrintConv => [{
1069             0 => 'Program', #PH
1070             0.1 => 'Av', #PH (Optio 555)
1071             1 => 'Shutter Speed Priority', #JD
1072             1.1 => 'M', #PH (Optio 555)
1073             2 => 'Program AE', #13
1074             2.1 => 'Tv', #PH (Optio 555)
1075             3 => 'Manual', #13
1076             3.1 => 'USER', #PH (Optio 555)
1077             5 => 'Portrait',
1078             6 => 'Landscape',
1079             8 => 'Sport', #PH
1080             9 => 'Night Scene',
1081             # 10 "full mode"? #13
1082             11 => 'Soft', #PH
1083             12 => 'Surf & Snow',
1084             13 => 'Candlelight', #13
1085             14 => 'Autumn',
1086             15 => 'Macro',
1087             17 => 'Fireworks',
1088             18 => 'Text',
1089             19 => 'Panorama', #PH
1090             20 => '3-D', #PH (Optio 555)
1091             21 => 'Black & White', #PH (Optio 555)
1092             22 => 'Sepia', #PH (Optio 555)
1093             23 => 'Red', #PH (Optio 555)
1094             24 => 'Pink', #PH (Optio 555)
1095             25 => 'Purple', #PH (Optio 555)
1096             26 => 'Blue', #PH (Optio 555)
1097             27 => 'Green', #PH (Optio 555)
1098             28 => 'Yellow', #PH (Optio 555)
1099             30 => 'Self Portrait', #PH
1100             31 => 'Illustrations', #13
1101             33 => 'Digital Filter', #13
1102             35 => 'Night Scene Portrait', #NJ
1103             37 => 'Museum', #PH
1104             38 => 'Food', #PH
1105             39 => 'Underwater', #NJ
1106             40 => 'Green Mode', #PH
1107             49 => 'Light Pet', #PH
1108             50 => 'Dark Pet', #PH
1109             51 => 'Medium Pet', #PH
1110             53 => 'Underwater', #PH
1111             54 => 'Candlelight', #PH
1112             55 => 'Natural Skin Tone', #PH
1113             56 => 'Synchro Sound Record', #PH
1114             58 => 'Frame Composite', #14
1115             59 => 'Report', #NJ
1116             60 => 'Kids', #13
1117             61 => 'Blur Reduction', #13
1118             63 => 'Panorama 2', #PH (X-5)
1119             65 => 'Half-length Portrait', #JD
1120             66 => 'Portrait 2', #PH (LS645)
1121             74 => 'Digital Microscope', #PH (WG-4)
1122             75 => 'Blue Sky', #PH (LS465)
1123             80 => 'Miniature', #PH (VS20)
1124             81 => 'HDR', #PH (LS465)
1125             83 => 'Fisheye', #PH (VS20)
1126             85 => 'Digital Filter 4', #PH (WG-5)
1127             221 => 'P', #PH (Optio 555)
1128             255=> 'PICT', #PH (Optio 555)
1129             }],
1130             },
1131             0x000c => { #PH
1132             Name => 'FlashMode',
1133             Writable => 'int16u',
1134             Count => -1,
1135             PrintHex => 1,
1136             PrintConv => [{
1137             0x000 => 'Auto, Did not fire',
1138             0x001 => 'Off, Did not fire',
1139             0x002 => 'On, Did not fire', #19
1140             0x003 => 'Auto, Did not fire, Red-eye reduction',
1141             0x005 => 'On, Did not fire, Wireless (Master)', #19
1142             0x100 => 'Auto, Fired',
1143             0x102 => 'On, Fired',
1144             0x103 => 'Auto, Fired, Red-eye reduction',
1145             0x104 => 'On, Red-eye reduction',
1146             0x105 => 'On, Wireless (Master)', #19
1147             0x106 => 'On, Wireless (Control)', #19
1148             0x108 => 'On, Soft',
1149             0x109 => 'On, Slow-sync',
1150             0x10a => 'On, Slow-sync, Red-eye reduction',
1151             0x10b => 'On, Trailing-curtain Sync',
1152             },{ #19 (AF-540FGZ flash)
1153             0x000 => 'n/a - Off-Auto-Aperture', #19
1154             0x03f => 'Internal',
1155             0x100 => 'External, Auto',
1156             0x23f => 'External, Flash Problem', #JD
1157             0x300 => 'External, Manual',
1158             0x304 => 'External, P-TTL Auto',
1159             0x305 => 'External, Contrast-control Sync', #JD
1160             0x306 => 'External, High-speed Sync',
1161             0x30c => 'External, Wireless',
1162             0x30d => 'External, Wireless, High-speed Sync',
1163             }],
1164             },
1165             0x000d => [ #2
1166             {
1167             Name => 'FocusMode',
1168             # (can't test for "PENTAX" because MOV videos don't have Make)
1169             Condition => '$$self{Make} !~ /^Asahi/',
1170             Notes => 'Pentax models',
1171             Writable => 'int16u',
1172             PrintConvColumns => 2,
1173             PrintHex => 1,
1174             PrintConv => { #PH
1175             0x00 => 'Normal',
1176             0x01 => 'Macro',
1177             0x02 => 'Infinity',
1178             0x03 => 'Manual',
1179             0x04 => 'Super Macro', #JD
1180             0x05 => 'Pan Focus',
1181             0x06 => 'Auto-area', # (GR III)
1182             0x07 => 'Zone Select', # (GR III)
1183             0x08 => 'Select', # (GR III)
1184             0x09 => 'Pinpoint', # (GR III)
1185             0x0a => 'Tracking', # (GR III)
1186             0x0b => 'Continuous', # (GR III)
1187             0x0c => 'Snap', # (GR III)
1188             0x10 => 'AF-S (Focus-priority)', #17
1189             0x11 => 'AF-C (Focus-priority)', #17
1190             0x12 => 'AF-A (Focus-priority)', #PH (educated guess)
1191             0x20 => 'Contrast-detect (Focus-priority)', #PH (K-5)
1192             0x21 => 'Tracking Contrast-detect (Focus-priority)', #PH (K-5)
1193             # bit 8 indicates release priority
1194             0x110 => 'AF-S (Release-priority)', #PH (K-5,K-3)
1195             0x111 => 'AF-C (Release-priority)', #PH (K-5,K-3)
1196             0x112 => 'AF-A (Release-priority)', #PH (K-3)
1197             0x120 => 'Contrast-detect (Release-priority)', #PH (K-01)
1198             # bit 15 indicates macro mode (disabled for MF, and defaults to Select for Snap, Infinity) #KG 'disabled for MF' - in contradiction with 0x8003 ??
1199             0x8003 => 'Manual (Macro)', # (GR IV)
1200             0x8006 => 'Auto-area (Macro)', # (GR III)
1201             0x8007 => 'Zone Select (Macro)', # (GR III)
1202             0x8008 => 'Select (Macro)', # (GR III)
1203             0x8009 => 'Pinpoint (Macro)', # (GR III)
1204             0x800a => 'Tracking (Macro)', # (GR III)
1205             0x800b => 'Continuous (Macro)', # (GR III)
1206             },
1207             },{
1208             Name => 'FocusMode',
1209             Writable => 'int16u',
1210             Notes => 'Asahi models',
1211             PrintConv => { #2
1212             0 => 'Normal',
1213             1 => 'Macro (1)',
1214             2 => 'Macro (2)',
1215             3 => 'Infinity',
1216             },
1217             },
1218             ],
1219             0x000e => [{ #29
1220             Name => 'AFPointSelected',
1221             Condition => '$$self{Model} =~ /(K-1|645Z)\b/', # (NC for 645Z)
1222             Writable => 'int16u',
1223             Notes => 'K-1',
1224             PrintConvColumns => 2,
1225             PrintConv => [{
1226             0xffff => 'Auto',
1227             0xfffe => 'Fixed Center',
1228             0xfffd => 'Automatic Tracking AF', #JD
1229             0xfffc => 'Face Detect AF', #JD
1230             0xfffb => 'AF Select', #PH (Q select from 25-areas)
1231             # AF pattern:
1232             # 01 02 03 04 05
1233             # 06 07 08 09 10 11 12
1234             # 13 14 15 16 17 18 19 20 21
1235             # 22 23 24 25 26 27 28
1236             # 29 30 31 32 33
1237             0 => 'None',
1238             1 => 'Top-left',
1239             2 => 'Top Near-left',
1240             3 => 'Top',
1241             4 => 'Top Near-right',
1242             5 => 'Top-right',
1243             6 => 'Upper Far-left',
1244             7 => 'Upper-left',
1245             8 => 'Upper Near-left',
1246             9 => 'Upper-middle',
1247             10 => 'Upper Near-right',
1248             11 => 'Upper-right',
1249             12 => 'Upper Far-right',
1250             13 => 'Far Far Left',
1251             14 => 'Far Left',
1252             15 => 'Left',
1253             16 => 'Near-left',
1254             17 => 'Center',
1255             18 => 'Near-right',
1256             19 => 'Right',
1257             20 => 'Far Right',
1258             21 => 'Far Far Right',
1259             22 => 'Lower Far-left',
1260             23 => 'Lower-left',
1261             24 => 'Lower Near-left',
1262             25 => 'Lower-middle',
1263             26 => 'Lower Near-right',
1264             27 => 'Lower-right',
1265             28 => 'Lower Far-right',
1266             29 => 'Bottom-left',
1267             30 => 'Bottom Near-left',
1268             31 => 'Bottom',
1269             32 => 'Bottom Near-right',
1270             33 => 'Bottom-right',
1271             263 => 'Zone Select Upper-left', # 01,02;06,07,08;14,15,16
1272             264 => 'Zone Select Upper Near-left', # 01,02,03;07,08,09;15,16,17
1273             265 => 'Zone Select Upper Middle', # 02,03,04;08,09,10;16,17,18
1274             266 => 'Zone Select Upper Near-right', # 03,04,05;09,10,11;17,18,19
1275             267 => 'Zone Select Upper-right', # 04,05;10,11,12;18,19,20
1276             270 => 'Zone Select Far Left', # 06,07;13,14,15;22,23
1277             271 => 'Zone Select Left', # 06,07,08;14,15,16;22,23,24
1278             272 => 'Zone Select Near-left', # 07,08,09;15,16,17;23,24,25
1279             273 => 'Zone Select Center', # 08,09,10;16,17,18;24,25,26
1280             274 => 'Zone Select Near-right', # 09,10,11;17,18,19;25,26,27
1281             275 => 'Zone Select Right', # 10,11,12;18,19,20;26,27,28
1282             276 => 'Zone Select Far Right', # 11,12;19,20,21;27,28
1283             279 => 'Zone Select Lower-left', # 14,15,16;22,23,24;29,30
1284             280 => 'Zone Select Lower Near-left', # 15,16,17;23,24,25;29,30,31
1285             281 => 'Zone Select Lower-middle', # 16,17,18;24,25,26;30,31,32
1286             282 => 'Zone Select Lower Near-right', # 17,18,19;25,26,27;31,32,33
1287             283 => 'Zone Select Lower-right', # 18,19,20;26,27,28;32,33
1288             },{
1289             0 => 'Single Point',
1290             1 => 'Expanded Area 9-point (S)',
1291             3 => 'Expanded Area 25-point (M)',
1292             5 => 'Expanded Area 33-point (L)',
1293             }],
1294             },{
1295             Name => 'AFPointSelected',
1296             Condition => '$$self{Model} =~ /(K-3|KP)\b/',
1297             Writable => 'int16u',
1298             Notes => 'K-3',
1299             PrintConvColumns => 2,
1300             PrintConv => [{
1301             # 0 - Contrast-detect AF? - PH (K-5)
1302             0xffff => 'Auto',
1303             0xfffe => 'Fixed Center',
1304             0xfffd => 'Automatic Tracking AF', #JD
1305             0xfffc => 'Face Detect AF', #JD
1306             0xfffb => 'AF Select', #PH (Q select from 25-areas)
1307             # AF pattern: (ref forum5422)
1308             # 01 02 03 04 05
1309             # 06 07 08 09 10
1310             # 11 12 13 14 15 16 17
1311             # 18 19 20 21 22
1312             # 23 24 25 26 27
1313             0 => 'None',
1314             1 => 'Top-left',
1315             2 => 'Top Near-left',
1316             3 => 'Top',
1317             4 => 'Top Near-right',
1318             5 => 'Top-right',
1319             6 => 'Upper-left',
1320             7 => 'Upper Near-left',
1321             8 => 'Upper-middle',
1322             9 => 'Upper Near-right',
1323             10 => 'Upper-right',
1324             11 => 'Far Left',
1325             12 => 'Left',
1326             13 => 'Near-left',
1327             14 => 'Center',
1328             15 => 'Near-right',
1329             16 => 'Right',
1330             17 => 'Far Right',
1331             18 => 'Lower-left',
1332             19 => 'Lower Near-left',
1333             20 => 'Lower-middle',
1334             21 => 'Lower Near-right',
1335             22 => 'Lower-right',
1336             23 => 'Bottom-left',
1337             24 => 'Bottom Near-left',
1338             25 => 'Bottom',
1339             26 => 'Bottom Near-right',
1340             27 => 'Bottom-right',
1341             #forum5892
1342             257 => 'Zone Select Top-left',
1343             258 => 'Zone Select Top Near-left',
1344             259 => 'Zone Select Top',
1345             260 => 'Zone Select Top Near-right',
1346             261 => 'Zone Select Top-right',
1347             262 => 'Zone Select Upper-left',
1348             263 => 'Zone Select Upper Near-left',
1349             264 => 'Zone Select Upper-middle',
1350             265 => 'Zone Select Upper Near-right',
1351             266 => 'Zone Select Upper-right',
1352             267 => 'Zone Select Far Left',
1353             268 => 'Zone Select Left',
1354             269 => 'Zone Select Near-left',
1355             270 => 'Zone Select Center',
1356             271 => 'Zone Select Near-right',
1357             272 => 'Zone Select Right',
1358             273 => 'Zone Select Far Right',
1359             274 => 'Zone Select Lower-left',
1360             275 => 'Zone Select Lower Near-left',
1361             276 => 'Zone Select Lower-middle',
1362             277 => 'Zone Select Lower Near-right',
1363             278 => 'Zone Select Lower-right',
1364             279 => 'Zone Select Bottom-left',
1365             280 => 'Zone Select Bottom Near-left',
1366             281 => 'Zone Select Bottom',
1367             282 => 'Zone Select Bottom Near-right',
1368             283 => 'Zone Select Bottom-right',
1369             },{ #forum5892
1370             0 => 'Single Point',
1371             1 => 'Expanded Area 9-point (S)',
1372             3 => 'Expanded Area 25-point (M)',
1373             5 => 'Expanded Area 27-point (L)',
1374             }],
1375             },{ #7
1376             Name => 'AFPointSelected',
1377             Writable => 'int16u',
1378             Notes => 'other models',
1379             PrintConvColumns => 2,
1380             PrintConv => [{
1381             # 0 - Contrast-detect AF? - PH (K-5)
1382             0xffff => 'Auto',
1383             0xfffe => 'Fixed Center',
1384             0xfffd => 'Automatic Tracking AF', #JD
1385             0xfffc => 'Face Detect AF', #JD
1386             0xfffb => 'AF Select', #PH (Q select from 25-areas)
1387             0xfffa => 'Auto 2', #KarstenGieselmann
1388             0 => 'None', #PH (Q in manual focus mode)
1389             1 => 'Upper-left',
1390             2 => 'Top',
1391             3 => 'Upper-right',
1392             4 => 'Left',
1393             5 => 'Mid-left',
1394             6 => 'Center',
1395             7 => 'Mid-right',
1396             8 => 'Right',
1397             9 => 'Lower-left',
1398             10 => 'Bottom',
1399             11 => 'Lower-right',
1400             },{
1401             # (second number exists for K-5II(s) is usually 0, but is 1 for AF.C with
1402             # AFPointMode=='Select' and extended tracking focus points are enabled in the settings)
1403             # -----
1404             #KG: for K-70 and older models with 11 PDAF points (K-S2, K-S1, K-50, K-500, K-30, K-5II(s) )
1405             0 => 'Single Point', # Select AF (1-point) in both PDAF and CAF modes
1406             1 => 'Expanded Area', # Expanded Area AF in AF-C
1407             }],
1408             }],
1409             0x000f => [{ #PH
1410             Name => 'AFPointsInFocus',
1411             Condition => '$$self{Model} =~ /K-(3|S1|S2)\b/', #KG: valid also for K-S1/S2
1412             Writable => 'int32u',
1413             Notes => 'K-3, K-S1 and K-S2 only',
1414             PrintHex => 1,
1415             PrintConv => {
1416             0 => '(none)',
1417             BITMASK => {
1418             0 => 'Top-left',
1419             1 => 'Top Near-left',
1420             2 => 'Top',
1421             3 => 'Top Near-right',
1422             4 => 'Top-right',
1423             5 => 'Upper-left',
1424             6 => 'Upper Near-left',
1425             7 => 'Upper-middle',
1426             8 => 'Upper Near-right',
1427             9 => 'Upper-right',
1428             10 => 'Far Left',
1429             11 => 'Left',
1430             12 => 'Near-left',
1431             13 => 'Center',
1432             14 => 'Near-right',
1433             15 => 'Right',
1434             16 => 'Far Right',
1435             17 => 'Lower-left',
1436             18 => 'Lower Near-left',
1437             19 => 'Lower-middle',
1438             20 => 'Lower Near-right',
1439             21 => 'Lower-right',
1440             22 => 'Bottom-left',
1441             23 => 'Bottom Near-left',
1442             24 => 'Bottom',
1443             25 => 'Bottom Near-right',
1444             26 => 'Bottom-right',
1445             },
1446             },
1447             },{ #PH
1448             Name => 'AFPointsInFocus',
1449             Notes => 'other models',
1450             Writable => 'int16u',
1451             PrintHex => 1,
1452             PrintConv => {
1453             0xffff => 'None',
1454             0 => 'Fixed Center or Multiple', #PH/14
1455             1 => 'Top-left',
1456             2 => 'Top-center',
1457             3 => 'Top-right',
1458             4 => 'Left',
1459             5 => 'Center',
1460             6 => 'Right',
1461             7 => 'Bottom-left',
1462             8 => 'Bottom-center',
1463             9 => 'Bottom-right',
1464             },
1465             }],
1466             0x0010 => { #PH
1467             Name => 'FocusPosition',
1468             Writable => 'int16u',
1469             Notes => 'related to focus distance but affected by focal length',
1470             },
1471             0x0012 => { #PH
1472             Name => 'ExposureTime',
1473             Writable => 'int32u',
1474             Priority => 0,
1475             ValueConv => '$val * 1e-5',
1476             ValueConvInv => '$val * 1e5',
1477             # value may be 0xffffffff in Bulb mode (ref JD)
1478             PrintConv => '$val > 42949 ? "Unknown (Bulb)" : Image::ExifTool::Exif::PrintExposureTime($val)',
1479             PrintConvInv => '$val=~/(unknown|bulb)/i ? $val : Image::ExifTool::Exif::ConvertFraction($val)',
1480             },
1481             0x0013 => { #PH
1482             Name => 'FNumber',
1483             Writable => 'int16u',
1484             Priority => 0,
1485             ValueConv => '$val / 10',
1486             ValueConvInv => '$val * 10',
1487             PrintConv => 'sprintf("%.1f",$val)',
1488             PrintConvInv => '$val',
1489             },
1490             # ISO Tag - Entries confirmed by W. Smith 12 FEB 04
1491             0x0014 => {
1492             Name => 'ISO',
1493             Writable => 'int16u',
1494             Notes => 'may be different than EXIF:ISO, which can round to the nearest full stop',
1495             PrintConvColumns => 4,
1496             PrintConv => {
1497             # 1/3 EV step values
1498             3 => 50,
1499             4 => 64,
1500             5 => 80,
1501             6 => 100,
1502             7 => 125, #PH
1503             8 => 160, #PH
1504             9 => 200,
1505             10 => 250,
1506             11 => 320, #PH
1507             12 => 400,
1508             13 => 500,
1509             14 => 640,
1510             15 => 800,
1511             16 => 1000,
1512             17 => 1250,
1513             18 => 1600, #PH
1514             19 => 2000, #PH
1515             20 => 2500, #PH
1516             21 => 3200, #PH
1517             22 => 4000,
1518             23 => 5000,
1519             24 => 6400, #PH
1520             25 => 8000, #PH
1521             26 => 10000, #PH
1522             27 => 12800, #PH
1523             28 => 16000, #PH
1524             29 => 20000, #PH
1525             30 => 25600, #PH
1526             31 => 32000, #PH
1527             32 => 40000, #PH
1528             33 => 51200, #PH
1529             34 => 64000, #PH (NC)
1530             35 => 80000, #PH (NC)
1531             36 => 102400, #27
1532             37 => 128000, #PH (NC)
1533             38 => 160000, #PH (NC)
1534             39 => 204800, #27
1535             40 => 256000, #PH (NC)
1536             41 => 320000, #PH (NC)
1537             42 => 409600, #PH (NC)
1538             43 => 512000, #PH (NC)
1539             44 => 640000, #PH (NC)
1540             45 => 819200, #PH (KP)
1541             # Optio 330/430 (oddball)
1542             50 => 50, #PH
1543             100 => 100, #PH
1544             200 => 200, #PH
1545             400 => 400, #PH
1546             800 => 800, #PH
1547             1600 => 1600, #PH
1548             3200 => 3200, #PH
1549             # 1/2 EV step values
1550             258 => 50, #PH (NC)
1551             259 => 70, #PH (NC)
1552             260 => 100, #19
1553             261 => 140, #19
1554             262 => 200, #19
1555             263 => 280, #19
1556             264 => 400, #19
1557             265 => 560, #19
1558             266 => 800, #19
1559             267 => 1100, #19
1560             268 => 1600, #19
1561             269 => 2200, #PH
1562             270 => 3200, #PH
1563             271 => 4500, #PH
1564             272 => 6400, #PH
1565             273 => 9000, #PH
1566             274 => 12800, #PH
1567             275 => 18000, #PH
1568             276 => 25600, #PH
1569             277 => 36000, #PH
1570             278 => 51200, #PH
1571             279 => 72000, #PH (NC)
1572             280 => 102400, #PH (NC)
1573             281 => 144000, #PH (NC)
1574             282 => 204800, #PH (NC)
1575             283 => 288000, #PH (NC)
1576             284 => 409600, #PH (NC)
1577             285 => 576000, #PH (NC)
1578             286 => 819200, #PH (NC)
1579             65534 => 'Auto 2', #PH (Q/Q10/Q7 MOV) [how is this different from 65535?]
1580             65535 => 'Auto', #PH/31 (K-01/K-70 MP4)
1581             },
1582             },
1583             0x0015 => { #PH
1584             Name => 'LightReading',
1585             Format => 'int16s', # (because I may have seen negative numbers)
1586             Writable => 'int16u',
1587             # ranges from 0-12 for my Optio WP - PH
1588             Notes => q{
1589             calibrated differently for different models. For the Optio WP, add 6 to get
1590             approximate Light Value. May not be valid for some models, eg. Optio S
1591             },
1592             },
1593             0x0016 => [{ #PH
1594             Name => 'ExposureCompensation',
1595             Condition => '$count == 1',
1596             Notes => q{
1597             some models write two values here. The second value is meaning of the
1598             second value is not yet known
1599             },
1600             Writable => 'int16u',
1601             ValueConv => '($val - 50) / 10',
1602             ValueConvInv => 'int($val * 10 + 50.5)',
1603             PrintConv => '$val ? sprintf("%+.1f", $val) : 0',
1604             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1605             },{
1606             Name => 'ExposureCompensation',
1607             Writable => 'int16u',
1608             # (2 values for K-70, etc -- have only seen "0" for the 2nd value - PH)
1609             Count => 2,
1610             ValueConv => '$val =~ s/ .*//; ($val - 50) / 10',
1611             ValueConvInv => 'int($val * 10 + 50.5) . " 0"',
1612             PrintConv => '$val ? sprintf("%+.1f", $val) : 0',
1613             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
1614             }],
1615             0x0017 => { #3
1616             Name => 'MeteringMode',
1617             Writable => 'int16u',
1618             PrintConv => {
1619             0 => 'Multi-segment',
1620             1 => 'Center-weighted average',
1621             2 => 'Spot',
1622             6 => 'Highlight', # (GR III)
1623             # have seen value of 16 for E70
1624             },
1625             },
1626             0x0018 => { #PH
1627             Name => 'AutoBracketing',
1628             Writable => 'int16u',
1629             Count => -1,
1630             Notes => q{
1631             1 or 2 values: exposure bracket step in EV, then extended bracket if
1632             available. Extended bracket values are printed as 'WB-BA', 'WB-GM',
1633             'Saturation', 'Sharpness', 'Contrast', 'Hue' or 'HighLowKey' followed by
1634             '+1', '+2' or '+3' for step size
1635             },
1636             # 1=.3ev, 2=.7, 3=1.0 ... 10=.5, 11=1.5, ... 4096=0, 4097=0.5 ... 8192=0, 8193=0.3
1637             # (models like K-1 and K-5 use 0x1000 and 0x2000 to indicate 1/2 and 1/3 EV step
1638             # size -- convert this as a fraction so we can recognize this format when writing)
1639             ValueConv => [ q{
1640             return $val / 3 if $val < 10;
1641             return $val - 9.5 if $val < 20;
1642             return ($val - 0x1000) . '/2' if $val & 0x1000;
1643             return ($val - 0x2000) . '/3' if $val & 0x2000;
1644             return $val; # (shouldn't happen)
1645             }],
1646             ValueConvInv => [ q{
1647             if ($val =~ s{/(\d+)$}{}) {
1648             return $val + 0x1000 if $1 == 2;
1649             return $val + 0x2000 if $1 == 3;
1650             return undef;
1651             }
1652             return abs($val-int($val)-.5)>0.05 ? int($val*3+0.5) : int($val+10);
1653             }],
1654             PrintConv => sub {
1655             my @v = split(' ', shift);
1656             $v[0] = sprintf('%.1f', $v[0]) if $v[0] and $v[0]!~m{/};
1657             if ($v[1]) {
1658             my %s = (1=>'WB-BA',2=>'WB-GM',3=>'Saturation',4=>'Sharpness',
1659             5=>'Contrast',6=>'Hue',7=>'HighLowKey');
1660             my $t = $v[1] >> 8;
1661             $v[1] = sprintf('%s+%d', $s{$t} || "Unknown($t)", $v[1] & 0xff);
1662             } elsif (defined $v[1]) {
1663             $v[1] = 'No Extended Bracket',
1664             }
1665             return join(' EV, ', @v);
1666             },
1667             PrintConvInv => sub {
1668             my @v = split(/, ?/, shift);
1669             $v[0] =~ s/ ?EV//i;
1670             if ($v[1]) {
1671             my %s = ('WB-BA'=>1,'WB-GM'=>2,'Saturation'=>3,'Sharpness'=>4,
1672             'Contrast'=>5,'Hue'=>6,'HighLowKey'=>7);
1673             if ($v[1] =~ /^No\b/i) {
1674             $v[1] = 0;
1675             } elsif ($v[1] =~ /Unknown\((\d+)\)\+(\d+)/i) {
1676             $v[1] = ($1 << 8) + $2;
1677             } elsif ($v[1] =~ /([\w-]+)\+(\d+)/ and $s{$1}) {
1678             $v[1] = ($s{$1} << 8) + $2;
1679             } else {
1680             warn "Bad extended bracket\n";
1681             }
1682             }
1683             return "@v";
1684             },
1685             },
1686             0x0019 => { #3
1687             Name => 'WhiteBalance',
1688             Writable => 'int16u',
1689             PrintConvColumns => 2,
1690             PrintConv => {
1691             0 => 'Auto',
1692             1 => 'Daylight',
1693             2 => 'Shade',
1694             3 => 'Fluorescent', #2
1695             4 => 'Tungsten',
1696             5 => 'Manual',
1697             6 => 'Daylight Fluorescent', #13
1698             7 => 'Day White Fluorescent', #13
1699             8 => 'White Fluorescent', #13
1700             9 => 'Flash', #13
1701             10 => 'Cloudy', #13
1702             11 => 'Warm White Fluorescent', #PH (K-3)
1703             14 => 'Multi Auto', #PH (K-3)
1704             15 => 'Color Temperature Enhancement', #PH
1705             17 => 'Kelvin', #PH
1706             0xfffe => 'Unknown', #13
1707             0xffff => 'User-Selected', #13
1708             },
1709             },
1710             0x001a => { #5
1711             Name => 'WhiteBalanceMode',
1712             Writable => 'int16u',
1713             PrintConv => {
1714             1 => 'Auto (Daylight)',
1715             2 => 'Auto (Shade)',
1716             3 => 'Auto (Flash)',
1717             4 => 'Auto (Tungsten)',
1718             6 => 'Auto (Daylight Fluorescent)', #19 (NC)
1719             7 => 'Auto (Day White Fluorescent)', #17 (K100D guess)
1720             8 => 'Auto (White Fluorescent)', #17 (K100D guess)
1721             10 => 'Auto (Cloudy)', #17 (K100D guess)
1722             # 0xfffd observed in K100D (ref 17)
1723             0xfffe => 'Unknown', #PH (you get this when shooting night sky shots)
1724             0xffff => 'User-Selected',
1725             },
1726             },
1727             0x001b => { #6
1728             Name => 'BlueBalance',
1729             Writable => 'int16u',
1730             ValueConv => '$val / 256',
1731             ValueConvInv => 'int($val * 256 + 0.5)',
1732             },
1733             0x001c => { #6
1734             Name => 'RedBalance',
1735             Writable => 'int16u',
1736             ValueConv => '$val / 256',
1737             ValueConvInv => 'int($val * 256 + 0.5)',
1738             },
1739             0x001d => [
1740             # Would be nice if there was a general way to determine units for FocalLength...
1741             {
1742             # Optio 30, 33WR, 43WR, 450, 550, 555, 750Z, X
1743             Name => 'FocalLength',
1744             Condition => '$self->{Model} =~ /^PENTAX Optio (30|33WR|43WR|450|550|555|750Z|X)\b/',
1745             Writable => 'int32u',
1746             Priority => 0,
1747             ValueConv => '$val / 10',
1748             ValueConvInv => '$val * 10',
1749             PrintConv => 'sprintf("%.1f mm",$val)',
1750             PrintConvInv => '$val=~s/\s*mm//;$val',
1751             },
1752             {
1753             # K100D, Optio 230, 330GS, 33L, 33LF, A10, M10, MX, MX4, S, S30,
1754             # S4, S4i, S5i, S5n, S5z, S6, S45, S50, S55, S60, SV, Svi, W10, WP,
1755             # *ist D, DL, DL2, DS, DS2
1756             # (Note: the Optio S6 seems to report the minimum focal length - PH)
1757             Name => 'FocalLength',
1758             Writable => 'int32u',
1759             Priority => 0,
1760             ValueConv => '$val / 100',
1761             ValueConvInv => '$val * 100',
1762             PrintConv => 'sprintf("%.1f mm",$val)',
1763             PrintConvInv => '$val=~s/\s*mm//;$val',
1764             },
1765             ],
1766             0x001e => { #3
1767             Name => 'DigitalZoom',
1768             Writable => 'int16u',
1769             ValueConv => '$val / 100', #14
1770             ValueConvInv => '$val * 100', #14
1771             },
1772             0x001f => {
1773             Name => 'Saturation',
1774             Writable => 'int16u',
1775             Count => -1,
1776             Notes => '1 or 2 values',
1777             PrintConvColumns => 2,
1778             PrintConv => [{ # the *istD has pairs of values - PH
1779             0 => '-2 (low)', #PH
1780             1 => '0 (normal)', #PH
1781             2 => '+2 (high)', #PH
1782             3 => '-1 (medium low)', #2
1783             4 => '+1 (medium high)', #2
1784             5 => '-3 (very low)', #PH
1785             6 => '+3 (very high)', #PH (NC)
1786             7 => '-4 (minimum)', #PH (NC)
1787             8 => '+4 (maximum)', #PH (K-5)
1788             65535 => 'None', #PH (Monochrome)
1789             }],
1790             },
1791             0x0020 => {
1792             Name => 'Contrast',
1793             Writable => 'int16u',
1794             Count => -1,
1795             Notes => '1 or 2 values',
1796             PrintConvColumns => 2,
1797             PrintConv => [{ # the *istD has pairs of values - PH
1798             0 => '-2 (low)', #PH
1799             1 => '0 (normal)', #PH
1800             2 => '+2 (high)', #PH
1801             3 => '-1 (medium low)', #2
1802             4 => '+1 (medium high)', #2
1803             5 => '-3 (very low)', #PH
1804             6 => '+3 (very high)', #PH (NC)
1805             7 => '-4 (minimum)', #PH (NC)
1806             8 => '+4 (maximum)', #PH (K-5)
1807             65535 => 'n/a', # got this for a Backlight Silhouette - PH (Q)
1808             }],
1809             },
1810             0x0021 => {
1811             Name => 'Sharpness',
1812             Writable => 'int16u',
1813             Count => -1,
1814             Notes => '1 or 2 values',
1815             PrintConvColumns => 2,
1816             PrintConv => [{ # the *istD has pairs of values - PH
1817             0 => '-2 (soft)', #PH
1818             1 => '0 (normal)', #PH
1819             2 => '+2 (hard)', #PH
1820             3 => '-1 (medium soft)', #2
1821             4 => '+1 (medium hard)', #2
1822             5 => '-3 (very soft)', #(NC)
1823             6 => '+3 (very hard)', #(NC)
1824             7 => '-4 (minimum)', #PH (NC)
1825             8 => '+4 (maximum)', #PH (NC)
1826             }],
1827             },
1828             0x0022 => { #PH
1829             Name => 'WorldTimeLocation',
1830             Groups => { 2 => 'Time' },
1831             Writable => 'int16u',
1832             PrintConv => {
1833             0 => 'Hometown',
1834             1 => 'Destination',
1835             },
1836             },
1837             0x0023 => { #PH
1838             Name => 'HometownCity',
1839             Groups => { 2 => 'Time' },
1840             Writable => 'int16u',
1841             SeparateTable => 'City',
1842             PrintConv => \%pentaxCities,
1843             },
1844             0x0024 => { #PH
1845             Name => 'DestinationCity',
1846             Groups => { 2 => 'Time' },
1847             Writable => 'int16u',
1848             SeparateTable => 'City',
1849             PrintConv => \%pentaxCities,
1850             },
1851             0x0025 => { #PH
1852             Name => 'HometownDST',
1853             Groups => { 2 => 'Time' },
1854             Writable => 'int16u',
1855             PrintConv => { 0 => 'No', 1 => 'Yes' },
1856             },
1857             0x0026 => { #PH
1858             Name => 'DestinationDST',
1859             Groups => { 2 => 'Time' },
1860             Writable => 'int16u',
1861             PrintConv => { 0 => 'No', 1 => 'Yes' },
1862             },
1863             0x0027 => { #PH
1864             Name => 'DSPFirmwareVersion',
1865             Writable => 'undef',
1866             # - for K10D, this comes from 4 bytes at offset 0x1c in the firmware file
1867             %pentaxFirmwareID,
1868             },
1869             0x0028 => { #PH
1870             Name => 'CPUFirmwareVersion',
1871             Writable => 'undef',
1872             # - for K10D, this comes from 4 bytes at offset 0x83fbf8 in firmware file
1873             %pentaxFirmwareID,
1874             },
1875             0x0029 => { #5
1876             Name => 'FrameNumber',
1877             # - one report that this has a value of 84 for the first image with a *istDS
1878             # - another report that file number 4 has frameNumber 154 for *istD, and
1879             # that framenumber jumped at about 9700 to around 26000
1880             # - with *istDS firmware 2.0, this tag was removed and ShutterCount was added
1881             Writable => 'int32u',
1882             },
1883             # 0x002b - definitely exposure related somehow - PH
1884             0x002d => [{ #PH
1885             Name => 'EffectiveLV',
1886             Condition => '$format eq "int16u"',
1887             Notes => 'camera-calculated light value, but includes exposure compensation',
1888             Writable => 'int16u',
1889             Format => 'int16s', # (negative values are valid even though Pentax writes int16u)
1890             ValueConv => '$val/1024',
1891             ValueConvInv => '$val * 1024',
1892             PrintConv => 'sprintf("%.1f",$val)',
1893             PrintConvInv => '$val',
1894             },{
1895             Name => 'EffectiveLV',
1896             Condition => '$format eq "int32u"',
1897             Writable => 'int32u',
1898             Format => 'int32s',
1899             ValueConv => '$val/1024',
1900             ValueConvInv => '$val * 1024',
1901             PrintConv => 'sprintf("%.1f",$val)',
1902             PrintConvInv => '$val',
1903             }],
1904             0x0032 => { #13
1905             Name => 'ImageEditing',
1906             Writable => 'undef',
1907             Format => 'int8u',
1908             Count => 4,
1909             PrintConv => {
1910             '0 0' => 'None', #PH
1911             '0 0 0 0' => 'None',
1912             '0 0 0 4' => 'Digital Filter',
1913             '1 0 0 0' => 'Resized', #PH (K-5)
1914             '2 0 0 0' => 'Cropped', #PH
1915             # note: doesn't apply to digital filters applied when picture is taken
1916             '4 0 0 0' => 'Digital Filter 4', #PH (K10D, Ricoh WG-5)
1917             '6 0 0 0' => 'Digital Filter 6', #PH (K-5)
1918             '8 0 0 0' => 'Red-eye Correction', #PH (WG-10)
1919             '16 0 0 0' => 'Frame Synthesis?',
1920             },
1921             },
1922             0x0033 => { #PH (K110D/K100D/K-m)
1923             Name => 'PictureMode',
1924             Writable => 'int8u',
1925             Count => 3,
1926             Relist => [ [0, 1], 2 ], # join values 0 and 1 for PrintConv
1927             PrintConvColumns => 2,
1928             PrintConv => [{
1929             # Program dial modes (from K110D)
1930             '0 0' => 'Program', # (also on K10D, custom settings: Program Line 1, e-dial in Program 3, 4 or 5)
1931             '0 1' => 'Hi-speed Program', #19 (K10D, custom settings: Program Line 2, e-dial in Program 3, 4 or 5)
1932             '0 2' => 'DOF Program', #19 (K10D, custom settings: Program Line 3, e-dial in Program 3, 4 or 5)
1933             '0 3' => 'MTF Program', #19 (K10D, custom settings: Program Line 4, e-dial in Program 3, 4 or 5)
1934             '0 4' => 'Standard', #13
1935             '0 5' => 'Portrait',
1936             '0 6' => 'Landscape',
1937             '0 7' => 'Macro',
1938             '0 8' => 'Sport',
1939             '0 9' => 'Night Scene Portrait',
1940             '0 10' => 'No Flash',
1941             # SCN modes (menu-selected) (from K100D)
1942             '0 11' => 'Night Scene',
1943             '0 12' => 'Surf & Snow',
1944             '0 13' => 'Text',
1945             '0 14' => 'Sunset',
1946             '0 15' => 'Kids',
1947             '0 16' => 'Pet',
1948             '0 17' => 'Candlelight',
1949             '0 18' => 'Museum',
1950             '0 19' => 'Food',
1951             '0 20' => 'Stage Lighting',
1952             '0 21' => 'Night Snap',
1953             '0 23' => 'Blue Sky', # (Q)
1954             '0 24' => 'Sunset', # (Q)
1955             '0 26' => 'Night Scene HDR', # (Q)
1956             '0 27' => 'HDR', # (Q)
1957             '0 28' => 'Quick Macro', # (Q)
1958             '0 29' => 'Forest', # (Q)
1959             '0 30' => 'Backlight Silhouette', # (Q)
1960             '0 31' => 'Max. Aperture Priority', #KG (Ricoh GR III)
1961             '0 32' => 'DOF', #PH (GR III) #KG ???? GR III 'DOF Priority (Deep)' is mapped to '0 2' ???
1962             # AUTO PICT modes (auto-selected)
1963             '1 4' => 'Auto PICT (Standard)', #13
1964             '1 5' => 'Auto PICT (Portrait)', #7 (K100D)
1965             '1 6' => 'Auto PICT (Landscape)', # K110D
1966             '1 7' => 'Auto PICT (Macro)', #13
1967             '1 8' => 'Auto PICT (Sport)', #13
1968             # *istD modes (ref 7)
1969             '2 0' => 'Program (HyP)', #13 (K-5 Normal program line - PH)
1970             '2 1' => 'Hi-speed Program (HyP)', #19 (K10D, custom settings: Program Line 2, e-dial in Program 1, 2)
1971             '2 2' => 'DOF Program (HyP)', #19 (K10D, custom settings: Program Line 3, e-dial in Program 1, 2)
1972             '2 3' => 'MTF Program (HyP)', #19 (K10D, custom settings: Program Line 4, e-dial in Program 1, 2)
1973             '2 22' => 'Shallow DOF (HyP)', #PH (K-5)
1974             '3 0' => 'Green Mode', #16
1975             '4 0' => 'Shutter Speed Priority',
1976             '4 2' => 'Shutter Speed Priority 2', #KG Coding error? 'DOF Priority' in Tv makes no sense
1977             '4 31' => 'Shutter Speed Priority 31',#KG Coding error? 'Max Aperture' in Tv makes no sense
1978             '5 0' => 'Aperture Priority',
1979             '5 2' => 'Aperture Priority 2', #KG Coding error? 'DOF Priority' in Av makes no sense
1980             '5 31' => 'Aperture Priority 31', #KG Coding error? 'DOF Priority' in Av makes no sense
1981             '6 0' => 'Program Tv Shift',
1982             '7 0' => 'Program Av Shift', #19
1983             '8 0' => 'Manual',
1984             '9 0' => 'Bulb',
1985             '10 0' => 'Aperture Priority, Off-Auto-Aperture',
1986             '11 0' => 'Manual, Off-Auto-Aperture',
1987             '12 0' => 'Bulb, Off-Auto-Aperture',
1988             '19 0' => 'Astrotracer', #29
1989             # extra K10D modes (ref 16)
1990             '13 0' => 'Shutter & Aperture Priority AE',
1991             '14 0' => 'Shutter Priority AE', #KG (K-3III))
1992             '15 0' => 'Sensitivity Priority AE',
1993             '16 0' => 'Flash X-Sync Speed AE',
1994             '17 0' => 'Flash X-Sync Speed', #KG (K-3III))
1995             '18 0' => 'Auto Program (Normal)', #PH (K-5)
1996             '18 1' => 'Auto Program (Hi-speed)', #PH (NC)
1997             '18 2' => 'Auto Program (DOF)', #PH (K-5)
1998             '18 3' => 'Auto Program (MTF)', #PH (NC)
1999             '18 22' => 'Auto Program (Shallow DOF)', #PH (NC)
2000             '20 22' => 'Blur Control', #PH (Q)
2001             '24 0' => 'Aperture Priority (Adv.Hyp)', #KG (K-3III)
2002             '25 0' => 'Manual Exposure (Adv.Hyp)', #KG (K-3III)
2003             '26 0' => 'Shutter and Aperture Priority (TAv)', #PH (K-3III)
2004             '249 0' => 'Movie (TAv)', #31
2005             '250 0' => 'Movie (TAv, Auto Aperture)', #31
2006             '251 0' => 'Movie (Manual)', #31
2007             '252 0' => 'Movie (Manual, Auto Aperture)', #31
2008             '253 0' => 'Movie (Av)', #31
2009             '254 0' => 'Movie (Av, Auto Aperture)', #31
2010             '255 0' => 'Movie (P, Auto Aperture)', #31
2011             '255 4' => 'Video (4)', #PH (K-x,K-01)
2012             },{
2013             # EV step size (ref 19)
2014             0 => '1/2 EV steps',
2015             1 => '1/3 EV steps',
2016             }],
2017             },
2018             0x0034 => { #7/PH
2019             Name => 'DriveMode',
2020             Writable => 'int8u',
2021             Count => 4,
2022             PrintConv => [{
2023             0 => 'Single-frame', # (also Interval Shooting for K-01 - PH)
2024             1 => 'Continuous', #KG *ist D, *ist Ds, *ist DS2, K110D, K10D, K100D, K100D Super, K20D, Ricoh GR III / GR IIIx
2025             #KG Hi: K200D, K-x, K-7, K-r, K-5, K-01, K-5 II, K-5 IIs, K-30, K-500, K-50, K-S1, K-S2, K-70
2026             #KG High: K-3, K-3 II, K-1, K-1 II, KP, K-3 III, K-3 III Mono
2027             2 => 'Continuous (Lo)', #KG all models listed under 'Hi'
2028             3 => 'Burst', #PH (K20D)
2029             4 => 'Continuous (Medium)', #KG all models listed under 'High'
2030             5 => 'Continuous (Low)', #KG all models listed under 'High'
2031             255 => 'Video', #PH (K-x)
2032             },{
2033             0 => 'No Timer',
2034             1 => 'Self-timer (12 s)',
2035             2 => 'Self-timer (2 s)',
2036             15 => 'Video', #PH (Q MOV)
2037             16 => 'Mirror Lock-up', # (K-5)
2038             255 => 'n/a', #PH (K-x)
2039             },{
2040             0 => 'Shutter Button', # (also computer remote control - PH)
2041             1 => 'Remote Control (3 s delay)', #19
2042             2 => 'Remote Control', #19
2043             4 => 'Remote Continuous Shooting', # (K-5)
2044             },{
2045             0x00 => 'Single Exposure',
2046             0x01 => 'Multiple Exposure',
2047             0x02 => 'Composite Average', #31
2048             0x03 => 'Composite Additive', #31
2049             0x04 => 'Composite Bright', #31
2050             0x08 => 'Interval Shooting', #31
2051             0x0a => 'Interval Composite Average', #31
2052             0x0b => 'Interval Composite Additive', #31
2053             0x0c => 'Interval Composite Bright', #31
2054             0x0f => 'Interval Movie', #PH (K-01)
2055             0x10 => 'HDR', #PH (645D)
2056             0x20 => 'HDR Strong 1', #PH (NC) (K-5)
2057             0x30 => 'HDR Strong 2', #PH (K-5)
2058             0x40 => 'HDR Strong 3', #PH (K-5)
2059             0x50 => 'HDR Manual', #31 (K-70 HDR 1 and HDR 2)
2060             0xe0 => 'HDR Auto', #PH (K-5, K-70)
2061             0xff => 'Video', #PH (K-x)
2062             }],
2063             },
2064             0x0035 => { #PH
2065             Name => 'SensorSize',
2066             Format => 'int16u',
2067             Count => 2,
2068             Notes => 'includes masked pixels',
2069             # values for various models (not sure why this is in 2um increments):
2070             # 11894 7962 (K10D,K-m) 12012 7987 (*istDS,K100D,K110D) 12012 8019 (*istD),
2071             # 12061 7988 (K-5) 12053 8005 (K-r,K-x) 14352 9535 (K20D,K-7)
2072             # 22315 16711 (645) 12080 8008 (K-01)
2073             ValueConv => 'my @a=split(" ",$val); $_/=500 foreach @a; join(" ",@a)',
2074             ValueConvInv => 'my @a=split(" ",$val); $_*=500 foreach @a; join(" ",@a)',
2075             PrintConv => 'sprintf("%.3f x %.3f mm", split(" ",$val))',
2076             PrintConvInv => '$val=~s/\s*mm$//; $val=~s/\s*x\s*/ /; $val',
2077             },
2078             0x0037 => { #13
2079             Name => 'ColorSpace',
2080             Writable => 'int16u',
2081             PrintConv => {
2082             0 => 'sRGB',
2083             1 => 'Adobe RGB',
2084             },
2085             },
2086             0x0038 => { #5 (PEF only)
2087             Name => 'ImageAreaOffset',
2088             Writable => 'int16u',
2089             Count => 2,
2090             },
2091             0x0039 => { #PH
2092             Name => 'RawImageSize',
2093             Writable => 'int16u',
2094             Count => 2,
2095             PrintConv => '$_=$val;s/ /x/;$_',
2096             },
2097             0x003c => { #7/PH
2098             Name => 'AFPointsInFocus',
2099             # not writable because I'm not decoding these 4 bytes fully:
2100             # Nibble pattern: XSSSYUUU
2101             # X = unknown (AF focused flag?, 0 or 1)
2102             # SSS = selected AF point bitmask (0x000 or 0x7ff if unused)
2103             # Y = unknown (observed 0,6,7,b,e, always 0 if SSS is 0x000 or 0x7ff)
2104             # UUU = af points used
2105             Format => 'int32u',
2106             Notes => '*istD only',
2107             ValueConv => '$val & 0x7ff', # ignore other bits for now
2108             PrintConvColumns => 2,
2109             PrintConv => {
2110             0 => '(none)',
2111             BITMASK => {
2112             0 => 'Upper-left',
2113             1 => 'Top',
2114             2 => 'Upper-right',
2115             3 => 'Left',
2116             4 => 'Mid-left',
2117             5 => 'Center',
2118             6 => 'Mid-right',
2119             7 => 'Right',
2120             8 => 'Lower-left',
2121             9 => 'Bottom',
2122             10 => 'Lower-right',
2123             },
2124             },
2125             },
2126             0x003d => { #IB
2127             Name => 'DataScaling',
2128             Writable => 'int16u',
2129             # divide by the second value of Pentax_0x0201 (WhitePoint), usually
2130             # 8192, to get the floating point normalization factor.
2131             # One of the examples of how this tag can be used is calculation of
2132             # baseline exposure compensation (Adobe-style) for a PEF:
2133             # log2(Pentax_0x007e)-14-0.5+log2(Pentax_0x003d)-13
2134             # or
2135             # log2(Pentax_0x007e*(Pentax_0x003d/(2^13))/(2^14))-0.5
2136             # where
2137             # makernotes:Pentax_0x003d/(2^13) is the normalization factor. (ref IB)
2138             # - 8192 for most images, but occasionally 11571 for K100D/K110D,
2139             # and 8289 or 8456 for the K-x (ref PH)
2140             },
2141             0x003e => { #PH
2142             Name => 'PreviewImageBorders',
2143             Writable => 'int8u',
2144             Count => 4,
2145             Notes => 'top, bottom, left, right',
2146             },
2147             0x003f => { #PH
2148             Name => 'LensRec',
2149             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::LensRec' },
2150             },
2151             0x0040 => { #PH
2152             Name => 'SensitivityAdjust',
2153             Writable => 'int16u',
2154             ValueConv => '($val - 50) / 10',
2155             ValueConvInv => '$val * 10 + 50',
2156             PrintConv => '$val ? sprintf("%+.1f", $val) : 0',
2157             PrintConvInv => '$val',
2158             },
2159             0x0041 => { #19
2160             Name => 'ImageEditCount',
2161             Writable => 'int16u',
2162             },
2163             0x0047 => { #PH
2164             Name => 'CameraTemperature', # (chassis temperature, ref forum6677)
2165             Writable => 'int8s',
2166             PrintConv => '"$val C"',
2167             PrintConvInv => '$val=~s/ ?c$//i; $val',
2168             },
2169             0x0048 => { #19
2170             Name => 'AELock',
2171             Writable => 'int16u',
2172             PrintConv => {
2173             0 => 'Off',
2174             1 => 'On',
2175             },
2176             },
2177             0x0049 => { #13
2178             Name => 'NoiseReduction',
2179             Writable => 'int16u',
2180             PrintConv => { 0 => 'Off', 1 => 'On' },
2181             },
2182             0x004d => [{ #PH
2183             Name => 'FlashExposureComp',
2184             Condition => '$count == 1',
2185             Writable => 'int32s',
2186             ValueConv => '$val / 256',
2187             ValueConvInv => 'int($val * 256 + ($val > 0 ? 0.5 : -0.5))',
2188             PrintConv => '$val ? sprintf("%+.1f", $val) : 0',
2189             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
2190             },{ #PH (K-3)
2191             Name => 'FlashExposureComp',
2192             Writable => 'int8s',
2193             Count => 2, # (don't know what the 2nd number is for)
2194             ValueConv => [ '$val / 6' ],
2195             ValueConvInv => [ '$val / 6' ],
2196             PrintConv => [ '$val ? sprintf("%+.1f", $val) : 0' ],
2197             PrintConvInv => [ 'Image::ExifTool::Exif::ConvertFraction($val)' ],
2198             }],
2199             0x004f => { #PH
2200             Name => 'ImageTone', # (Called CustomImageMode for K20D and ImageControlMode for GR III)
2201             Writable => 'int16u',
2202             PrintConvColumns => 2,
2203             PrintConv => {
2204             0 => 'Natural',
2205             1 => 'Bright',
2206             2 => 'Portrait', # (K20D/K200D)
2207             3 => 'Landscape', # (K20D)
2208             4 => 'Vibrant', # (K20D)
2209             5 => 'Monochrome', # (K20D)
2210             6 => 'Muted', # (645D)
2211             7 => 'Reversal Film', # (645D) (Ricoh WG-5 "Slide Film")
2212             8 => 'Bleach Bypass', # (K-5)
2213             9 => 'Radiant', # (Q)
2214             10 => 'Cross Processing', #31 (K-70)
2215             11 => 'Flat', #31 (K-70)
2216             # the following values from GR III
2217             256 => 'Standard',
2218             257 => 'Vivid',
2219             258 => 'Monotone',
2220             259 => 'Soft Monotone',
2221             260 => 'Hard Monotone',
2222             261 => 'Hi-contrast B&W',
2223             262 => 'Positive Film',
2224             263 => 'Bleach Bypass 2',
2225             264 => 'Retro',
2226             265 => 'HDR Tone',
2227             266 => 'Cross Processing 2',
2228             267 => 'Negative Film',
2229             # 256 - seen for GR III
2230             # 257 - seen for GR III
2231             # 262 - seen for GR III
2232             32768 => 'Standard', #KG (K-3IIIm) (was "n/a" previously - PH)
2233             32769 => 'Hard', #KG (K-3IIIm)
2234             32770 => 'Soft', #KG (K-3IIIm)
2235             33024 => 'Monochrome', #forum17904 (GR IV Monochrome)
2236             },
2237             },
2238             0x0050 => { #PH
2239             Name => 'ColorTemperature',
2240             Writable => 'int16u',
2241             RawConv => '$val ? $val : undef',
2242             ValueConv => '53190 - $val',
2243             ValueConvInv => '53190 - $val',
2244             },
2245             # 0x0053-0x005a - not in JPEG images - PH
2246             0x0053 => { #28
2247             Name => 'ColorTempDaylight',
2248             %colorTemp,
2249             Notes => '0x0053-0x005a are 3 numbers: Kelvin, shift AB, shift GM',
2250             },
2251             0x0054 => { Name => 'ColorTempShade', %colorTemp }, #28
2252             0x0055 => { Name => 'ColorTempCloudy', %colorTemp }, #28
2253             0x0056 => { Name => 'ColorTempTungsten', %colorTemp }, #28
2254             0x0057 => { Name => 'ColorTempFluorescentD', %colorTemp }, #28
2255             0x0058 => { Name => 'ColorTempFluorescentN', %colorTemp }, #28
2256             0x0059 => { Name => 'ColorTempFluorescentW', %colorTemp }, #28
2257             0x005a => { Name => 'ColorTempFlash', %colorTemp }, #28
2258             0x005c => [{ #PH
2259             Name => 'ShakeReductionInfo',
2260             Condition => '$count == 4', # (2 bytes for the K-3)
2261             Format => 'undef', # (written as int8u) - do this just to save time converting the value
2262             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::SRInfo' },
2263             },{
2264             Name => 'ShakeReductionInfo',
2265             Format => 'undef', # (written as int8u) - do this just to save time converting the value
2266             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::SRInfo2' },
2267             }],
2268             0x005d => { #JD/PH
2269             # (used by all Pentax DSLR's except *istD and *istDS until firmware 2.0 - PH)
2270             # Observed values for the first shot of a new K10D are: 81 [PH], 181 [19],
2271             # 246 [7], and 209 [18 (one of the first 20 shots)], so there must be a number
2272             # of test images shot in the factory. (But my new K-5 started at 1 - PH)
2273             # This count includes shutter actuations even if they don't result in a
2274             # recorded image (eg. manual white balance frame or digital preview), but
2275             # does not include actuations due to Live View or video recording - PH
2276             Name => 'ShutterCount',
2277             Writable => 'undef',
2278             Count => 4,
2279             Notes => q{
2280             Note: May be reset by servicing! Also, does not include shutter actuations
2281             for live view or video recording
2282             },
2283             # raw value is a big-endian 4-byte integer, encrypted using Date and Time
2284             RawConv => 'length($val) == 4 ? unpack("N",$val) : undef',
2285             RawConvInv => q{
2286             my $val = Image::ExifTool::Pentax::CryptShutterCount($val,$self);
2287             return pack('N', $val);
2288             },
2289             ValueConv => \&CryptShutterCount,
2290             ValueConvInv => '$val',
2291             },
2292             # 0x005e -
2293             0x0060 => { #PH (K-5)
2294             Name => 'FaceInfo',
2295             Format => 'undef', # (written as int8u)
2296             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::FaceInfo' },
2297             },
2298             0x0062 => { #forum4803
2299             Name => 'RawDevelopmentProcess',
2300             Condition => '$$self{Make} =~ /^(PENTAX|RICOH)/', # rules out Kodak, which also use this tag
2301             Writable => 'int16u',
2302             PrintConv => {
2303             1 => '1 (K10D,K200D,K2000,K-m)',
2304             3 => '3 (K20D)',
2305             4 => '4 (K-7)',
2306             5 => '5 (K-x)',
2307             6 => '6 (645D)',
2308             7 => '7 (K-r)',
2309             8 => '8 (K-5,K-5II,K-5IIs)',
2310             9 => '9 (Q)',
2311             10 => '10 (K-01,K-30,K-50,K-500)',
2312             11 => '11 (Q10)',
2313             12 => '12 (MX-1,Q-S1,Q7)',
2314             13 => '13 (K-3,K-3II)',
2315             14 => '14 (645Z)',
2316             15 => '15 (K-S1,K-S2)', #PH
2317             16 => '16 (K-1)', #PH
2318             17 => '17 (K-70)', #29
2319             18 => '18 (KP)', #PH
2320             19 => '19 (GR III)', #PH
2321             20 => '20 (K-3III)', #PH
2322             21 => '21 (K-3IIIMonochrome)', #github226
2323             },
2324             },
2325             0x0067 => { #PH (K-5)
2326             Name => 'Hue',
2327             Writable => 'int16u',
2328             PrintConvColumns => 2,
2329             PrintConv => {
2330             0 => -2,
2331             1 => 'Normal',
2332             2 => 2,
2333             3 => -1,
2334             4 => 1,
2335             5 => -3,
2336             6 => 3,
2337             7 => -4,
2338             8 => 4,
2339             65535 => 'None', # (Monochrome)
2340             },
2341             },
2342             # 0x0067 - int16u: 1 [and 65535 in Monochrome] (K20D,K200D) - PH
2343             0x0068 => { #PH
2344             Name => 'AWBInfo',
2345             Format => 'undef', # (written as int8u)
2346             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::AWBInfo' },
2347             },
2348             0x0069 => { #PH (K20D, K-5, K-01 highlights only)
2349             Name => 'DynamicRangeExpansion',
2350             Notes => q{
2351             called highlight correction by Pentax for the K20D, K-5, K-01 and maybe
2352             other models
2353             },
2354             Writable => 'undef',
2355             Format => 'int8u',
2356             Count => 4,
2357             PrintConv => [{
2358             0 => 'Off',
2359             1 => 'On',
2360             },{
2361             0 => 0,
2362             1 => 'Enabled', # (K-01)
2363             2 => 'Auto', # (K-01)
2364             }],
2365             },
2366             0x006b => { #PH (K-5)
2367             Name => 'TimeInfo',
2368             Format => 'undef', # (written as int8u)
2369             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::TimeInfo' },
2370             },
2371             0x006c => { #PH (K-5)
2372             Name => 'HighLowKeyAdj',
2373             Description => 'High/Low Key Adj',
2374             Writable => 'int16s',
2375             Count => 2,
2376             PrintConvColumns => 3,
2377             PrintConv => {
2378             '-4 0' => -4,
2379             '-3 0' => -3,
2380             '-2 0' => -2,
2381             '-1 0' => -1,
2382             '0 0' => 0,
2383             '1 0' => 1,
2384             '2 0' => 2,
2385             '3 0' => 3,
2386             '4 0' => 4,
2387             },
2388             },
2389             0x006d => { #PH (K-5)
2390             Name => 'ContrastHighlight',
2391             Writable => 'int16s',
2392             Count => 2,
2393             PrintConvColumns => 3,
2394             PrintConv => {
2395             '-4 0' => -4,
2396             '-3 0' => -3,
2397             '-2 0' => -2,
2398             '-1 0' => -1,
2399             '0 0' => 0,
2400             '1 0' => 1,
2401             '2 0' => 2,
2402             '3 0' => 3,
2403             '4 0' => 4,
2404             },
2405             },
2406             0x006e => { #PH (K-5)
2407             Name => 'ContrastShadow',
2408             Writable => 'int16s',
2409             Count => 2,
2410             PrintConvColumns => 3,
2411             PrintConv => {
2412             '-4 0' => -4,
2413             '-3 0' => -3,
2414             '-2 0' => -2,
2415             '-1 0' => -1,
2416             '0 0' => 0,
2417             '1 0' => 1,
2418             '2 0' => 2,
2419             '3 0' => 3,
2420             '4 0' => 4,
2421             },
2422             },
2423             0x006f => { #PH (K-5)
2424             Name => 'ContrastHighlightShadowAdj',
2425             Description => 'Contrast Highlight/Shadow Adj',
2426             Writable => 'int8u',
2427             PrintConv => {
2428             0 => 'Off',
2429             1 => 'On',
2430             },
2431             },
2432             0x0070 => { #PH (K-5)
2433             Name => 'FineSharpness',
2434             Writable => 'int8u',
2435             Count => -1, # 1 for K20/K200, 2 for K-5
2436             PrintConv => [{
2437             0 => 'Off',
2438             1 => 'On',
2439             },{
2440             0 => 'Normal',
2441             2 => 'Extra fine',
2442             }],
2443             },
2444             0x0071 => { #PH (K20D,K-x)
2445             Name => 'HighISONoiseReduction',
2446             Format => 'int8u',
2447             PrintConv => [{
2448             0 => 'Off',
2449             1 => 'Weakest',
2450             2 => 'Weak', # (called "Low" by K-x)
2451             3 => 'Strong', # (called "High" by K-x)
2452             4 => 'Medium',
2453             255 => 'Auto', # (K-5)
2454             },{
2455             0 => 'Inactive',
2456             1 => 'Active',
2457             2 => 'Active (Weak)', # (K-5)
2458             3 => 'Active (Strong)', # (K-5)
2459             4 => 'Active (Medium)', # (K-5)
2460             },{ # Start ISO level for NR (K-x)
2461             48 => 'ISO>400',
2462             56 => 'ISO>800',
2463             64 => 'ISO>1600',
2464             72 => 'ISO>3200',
2465             }],
2466             },
2467             0x0072 => { #JD (K20D)
2468             Name => 'AFAdjustment',
2469             Writable => 'int16s',
2470             },
2471             0x0073 => { #PH (K-5)
2472             Name => 'MonochromeFilterEffect',
2473             Writable => 'int16u',
2474             PrintConvColumns => 2,
2475             PrintConv => {
2476             65535 => 'None',
2477             1 => 'Green',
2478             2 => 'Yellow',
2479             3 => 'Orange',
2480             4 => 'Red',
2481             5 => 'Magenta',
2482             6 => 'Blue',
2483             7 => 'Cyan',
2484             8 => 'Infrared',
2485             },
2486             },
2487             0x0074 => { #PH (K-5)
2488             Name => 'MonochromeToning',
2489             Writable => 'int16u',
2490             PrintConvColumns => 2,
2491             PrintConv => {
2492             65535 => 'None',
2493             0 => -4,
2494             1 => -3,
2495             2 => -2,
2496             3 => -1,
2497             4 => 0,
2498             5 => 1,
2499             6 => 2,
2500             7 => 3,
2501             8 => 4,
2502             },
2503             },
2504             0x0076 => { #PH (K-5)
2505             Name => 'FaceDetect',
2506             Writable => 'int8u',
2507             Count => 2,
2508             # the Optio S12 writes this but not the FacesDetected tag, so get FacesDetected from here
2509             DataMember => 'FacesDetected',
2510             RawConv => '$val =~ / (\d+)/ and $$self{FacesDetected} = $1; $val',
2511             # (the K-3 reports "On" even in phase-detect focus modes)
2512             PrintConv => [
2513             '$val ? "On ($val faces max)" : "Off"',
2514             '"$val faces detected"',
2515             ],
2516             PrintConvInv => [
2517             '$val =~ /(\d+)/ ? $1 : 0',
2518             '$val =~ /(\d+)/ ? $1 : 0',
2519             ],
2520             },
2521             0x0077 => { #PH (K-5)
2522             # set by taking a picture with face detect AF,
2523             # but it isn't reset until camera is turned off? - PH
2524             Name => 'FaceDetectFrameSize',
2525             Writable => 'int16u',
2526             Count => 2,
2527             },
2528             # 0x0078 - int16u[2]: '0 0' (K-5,K-7,K-r,K-x)
2529             0x0079 => { #PH
2530             Name => 'ShadowCorrection',
2531             Writable => 'int8u',
2532             Count => -1,
2533             PrintConvColumns => 2,
2534             PrintConv => {
2535             # (1 value for K-m/K2000, 2 for 645D)
2536             0 => 'Off',
2537             1 => 'On',
2538             2 => 'Auto 2', # (NC, WG-3)
2539             '0 0' => 'Off',
2540             '1 1' => 'Weak',
2541             '1 2' => 'Normal',
2542             '1 3' => 'Strong',
2543             '2 4' => 'Auto', # (K-01)
2544             },
2545             },
2546             0x007a => { #PH
2547             Name => 'ISOAutoMinSpeed',
2548             Writable => 'int8u',
2549             Count => 2,
2550             # From the K-3III menus for the "ISO Auto with Min. Speed" setting: 'Fast' = "Increases
2551             # the sensitivity from a shutter speed faster than the standard setting in ISO Auto"
2552             ValueConv => [ undef, '$val ? exp(-Image::ExifTool::Pentax::PentaxEv($val-68)*log(2)) : 0' ],
2553             ValueConvInv => [ undef, '$val ? Image::ExifTool::Pentax::PentaxEvInv(-log($val)/log(2))+68 : 0' ],
2554             PrintConv => [
2555             {
2556             1 => 'Shutter Speed Control',
2557             2 => 'Auto Slow',
2558             3 => 'Auto Standard',
2559             4 => 'Auto Fast',
2560             },
2561             'Image::ExifTool::Exif::PrintExposureTime($val)',
2562             ],
2563             PrintConvInv => [ undef, 'Image::ExifTool::Exif::ConvertFraction($val)' ],
2564             },
2565             0x007b => { #PH (K-5)
2566             Name => 'CrossProcess',
2567             Writable => 'int8u',
2568             PrintConvColumns => 2,
2569             PrintConv => {
2570             0 => 'Off',
2571             1 => 'Random',
2572             2 => 'Preset 1',
2573             3 => 'Preset 2',
2574             4 => 'Preset 3',
2575             33 => 'Favorite 1',
2576             34 => 'Favorite 2',
2577             35 => 'Favorite 3',
2578             },
2579             },
2580             0x007d => { #PH
2581             Name => 'LensCorr',
2582             Format => 'undef', # (written as int8u)
2583             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::LensCorr' },
2584             },
2585             0x007e => { #IB
2586             Name => 'WhiteLevel', # (with black level already subtracted)
2587             Writable => 'int32u',
2588             # 15859,15860,15864,15865,16315 (K-5 PEF/DNG only) - PH
2589             # 3934, 3935 (Q DNG) - PH
2590             },
2591             0x007f => { #PH (K-5)
2592             Name => 'BleachBypassToning',
2593             Writable => 'int16u',
2594             PrintConvColumns => 2,
2595             PrintConv => {
2596             65535 => 'n/a', #31
2597             0 => 'Off', #31
2598             1 => 'Green',
2599             2 => 'Yellow',
2600             3 => 'Orange',
2601             4 => 'Red',
2602             5 => 'Magenta',
2603             6 => 'Purple',
2604             7 => 'Blue',
2605             8 => 'Cyan',
2606             },
2607             },
2608             0x0080 => { #PH (Q)
2609             Name => 'AspectRatio',
2610             PrintConv => {
2611             0 => '4:3',
2612             1 => '3:2',
2613             2 => '16:9',
2614             3 => '1:1',
2615             },
2616             },
2617             # 0x0081 - int8u: 0 (Q)
2618             0x0082 => {
2619             Name => 'BlurControl',
2620             Writable => 'int8u',
2621             Count => 4,
2622             PrintConv => [
2623             {
2624             0 => 'Off',
2625             1 => 'Low',
2626             2 => 'Medium',
2627             3 => 'High',
2628             },
2629             undef, # 0 with BlurControl is Off, seen 0,1,3 when on (related to subject distance?)
2630             undef, # 0 with BlurControl Off, 45 when on
2631             undef, # always 0
2632             ],
2633             },
2634             # 0x0083 - int8u: 0 (Q DNG)
2635             # 0x0084 - int8u: 0 (Q)
2636             0x0085 => { #PH
2637             Name => 'HDR',
2638             Format => 'int8u',
2639             Count => 4,
2640             PrintConv => [{ # (K-01,K-3)
2641             0 => 'Off',
2642             1 => 'HDR Auto',
2643             2 => 'HDR 1',
2644             3 => 'HDR 2',
2645             4 => 'HDR 3',
2646             5 => 'HDR Advanced', #29 (K-1)
2647             },{ # (K-01)
2648             0 => 'Auto-align Off',
2649             1 => 'Auto-align On',
2650             },{
2651             # not sure about this - PH
2652             # - you can set HDR "Exposure Bracket Value" with the K-3
2653             # - guessed from imaging-resource K-3 samples K3OUTBHDR_A{1,2,3}
2654             0 => 'n/a',
2655             4 => '1 EV',
2656             8 => '2 EV',
2657             12 => '3 EV', # (get this from K-01, but can't set EV)
2658             },
2659             # (4th number is always 0)
2660             ],
2661             },
2662             # 0x0086 - int8u: 0, 111[Sport,Pet] (Q) - related to Tracking FocusMode?
2663             # 0x0087 - int8u: 0 (Q)
2664             0x0087 => { #PH
2665             Name => 'ShutterType',
2666             Writable => 'int8u',
2667             PrintConv => {
2668             0 => 'Normal', # ('Mechanical' if the camera has a mechanical shutter)
2669             1 => 'Electronic', # (KP)
2670             },
2671             },
2672             0x0088 => { #PH
2673             Name => 'NeutralDensityFilter',
2674             Writable => 'int8u',
2675             Count => -1,
2676             PrintConv => {
2677             0 => 'Off',
2678             1 => 'On',
2679             '0 0' => 'Off (Off)', #PH (GR III)
2680             '1 1' => 'On (On)', #PH (GR III)
2681             '0 2' => 'Off (Auto)', #PH (GR III)
2682             '1 2' => 'On (Auto)', #PH (GR III)
2683             },
2684             },
2685             0x008b => { #PH (LS465)
2686             Name => 'ISO',
2687             Priority => 0,
2688             Writable => 'int32u',
2689             },
2690             0x0092 => { #31
2691             Name => 'IntervalShooting',
2692             Notes => '2 numbers: 1. Shot number 2. Total number of shots',
2693             Writable => 'int16u',
2694             Count => 2,
2695             PrintConv => {
2696             '0 0' => 'Off',
2697             OTHER => sub {
2698             my ($val, $inv) = @_;
2699             if ($inv) {
2700             $val =~ tr/0-9 //dc;
2701             } else {
2702             $val =~ s/(\d+) (\d+)/Shot $1 of $2/;
2703             }
2704             return $val;
2705             },
2706             },
2707             },
2708             0x0095 => [{ #31
2709             Name => 'SkinToneCorrection',
2710             Condition => '$count == 2',
2711             Writable => 'int8s',
2712             Count => 2,
2713             PrintConv => {
2714             '0 0' => 'Off',
2715             '1 1' => 'On (type 1)',
2716             '1 2' => 'On (type 2)',
2717             },
2718             },{
2719             Name => 'SkinToneCorrection',
2720             Condition => '$count == 3',
2721             Writable => 'int8s',
2722             Count => 3,
2723             PrintConv => {
2724             '0 0 0' => 'Off',
2725             },
2726             }],
2727             0x0096 => { #31
2728             Name => 'ClarityControl',
2729             Writable => 'int8s',
2730             Count => 2,
2731             PrintConv => {
2732             '0 0' => 'Off',
2733             OTHER => sub {
2734             my ($val, $inv) = @_;
2735             if ($inv) {
2736             $val =~ /(\d+ -?\d+)/ and return $1;
2737             return ("1 $val");
2738             } elsif ($val =~ /^1 (-?\d+)$/) {
2739             return $1 ? sprintf('%+d', $1) : 0;
2740             } else {
2741             return "Unknown ($val)";
2742             }
2743             },
2744             },
2745             },
2746             0x0200 => { #5
2747             Name => 'BlackPoint',
2748             Writable => 'int16u',
2749             Count => 4,
2750             },
2751             0x0201 => { #5
2752             # (this doesn't change for different fixed white balances in JPEG images: Daylight,
2753             # Tungsten, Kelvin, etc -- always "8192 8192 8192 8192", but it varies for these in
2754             # RAW images, all images in Auto, for different Manual WB settings, and for images
2755             # taken via Pentax Remote Assistant) - PH
2756             Name => 'WhitePoint',
2757             Writable => 'int16u',
2758             Count => 4,
2759             },
2760             # 0x0202: int16u[4]: all 0's in all my samples
2761             0x0203 => { #JD (not really sure what these mean)
2762             Name => 'ColorMatrixA', # (camera RGB to sRGB matrix, *ist D, ref IB)
2763             Writable => 'int16s',
2764             Count => 9,
2765             ValueConv => 'join(" ",map({ $_/8192 } split(" ",$val)))',
2766             ValueConvInv => 'join(" ",map({ int($_*8192 + ($_<0?-0.5:0.5)) } split(" ",$val)))',
2767             PrintConv => 'join(" ",map({sprintf("%.5f",$_)} split(" ",$val)))',
2768             PrintConvInv => '"$val"',
2769             },
2770             0x0204 => { #JD
2771             Name => 'ColorMatrixB', # (camera RGB to Adobe RGB matrix, *ist D, ref IB)
2772             Writable => 'int16s',
2773             Count => 9,
2774             ValueConv => 'join(" ",map({ $_/8192 } split(" ",$val)))',
2775             ValueConvInv => 'join(" ",map({ int($_*8192 + ($_<0?-0.5:0.5)) } split(" ",$val)))',
2776             PrintConv => 'join(" ",map({sprintf("%.5f",$_)} split(" ",$val)))',
2777             PrintConvInv => '"$val"',
2778             },
2779             0x0205 => [{ #19
2780             Name => 'CameraSettings',
2781             # size: *istD/*istDs/K100D/K110D=16, K-m/K2000=14, K-7/K-x=19,
2782             # K200D/K20D/K-5/645D=20, K-r=21, K10D=22, K-01=25
2783             Condition => '$count < 25', # (not valid for the K-01)
2784             SubDirectory => {
2785             TagTable => 'Image::ExifTool::Pentax::CameraSettings',
2786             ByteOrder => 'BigEndian',
2787             },
2788             },{
2789             Name => 'CameraSettingsUnknown',
2790             SubDirectory => {
2791             TagTable => 'Image::ExifTool::Pentax::CameraSettingsUnknown',
2792             ByteOrder => 'BigEndian',
2793             },
2794             }],
2795             0x0206 => [{ #PH
2796             Name => 'AEInfo',
2797             # size: *istD/*istDs/K100D/K110D=14, K10D/K200D/K20D=16, K-m/K2000=20,
2798             # K-7/K-x=24, K-5/K-r/645D=25
2799             Condition => '$count <= 25 and $count != 21 and $$self{AEInfoSize} = $count',
2800             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::AEInfo' },
2801             },{
2802             Name => 'AEInfo2',
2803             # size: K-01=21
2804             Condition => '$count == 21',
2805             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::AEInfo2' },
2806             },{
2807             Name => 'AEInfo3',
2808             # size: K-30=48, K-1mkII,K-70,KP=64
2809             Condition => '$count == 48 or $count == 64',
2810             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::AEInfo3' },
2811             },{
2812             Name => 'AEInfoUnknown',
2813             # size: Q/Q10=34
2814             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::AEInfoUnknown' },
2815             }],
2816             0x0207 => [ #PH
2817             {
2818             Name => 'LensInfo',
2819             # the *ist series (and Samsung GX-1) always use the old format, and all
2820             # other models but the K100D, K110D and K100D Super always use the newer
2821             # format, and for the K110D/K110D we expect ff or 00 00 at byte 20 if
2822             # it is the old format.)
2823             Condition => q{
2824             $$self{Model}=~/(\*ist|GX-1[LS])/ or
2825             ($$self{Model}=~/(K100D|K110D)/ and $$valPt=~/^.{20}(\xff|\0\0)/s)
2826             },
2827             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::LensInfo' },
2828             },{
2829             Name => 'LensInfo',
2830             Condition => '$count != 90 and $count != 91 and $count != 80 and $count != 128 and $count != 168',
2831             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::LensInfo2' },
2832             },{
2833             Name => 'LensInfo', # 645D
2834             Condition => '$count == 90',
2835             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::LensInfo3' },
2836             },{
2837             Name => 'LensInfo', # K-r, K-5, K-5II
2838             Condition => '$count == 91',
2839             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::LensInfo4' },
2840             },{
2841             Name => 'LensInfo', # K-01, K-30, K-50, K-500, K-3, K-3II
2842             Condition => '$count == 80 or $count == 128',
2843             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::LensInfo5' },
2844             }
2845             # ($count == 168 - Ricoh GR III)
2846             ],
2847             0x0208 => [ #PH
2848             {
2849             Name => 'FlashInfo',
2850             Condition => '$count == 27',
2851             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::FlashInfo' },
2852             },
2853             {
2854             Name => 'FlashInfoUnknown',
2855             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::FlashInfoUnknown' },
2856             },
2857             ],
2858             0x0209 => { #PH
2859             Name => 'AEMeteringSegments',
2860             Format => 'int8u',
2861             Count => -1,
2862             Notes => q{
2863             measurements from each of the 16 AE metering segments for models such as the
2864             K10D, 77 metering segments for models such as the K-5, and 4050 metering
2865             segments for the K-3, converted to LV
2866             },
2867             %convertMeteringSegments,
2868             # 16 metering segment 77 metering segment
2869             # locations (ref JD, K10D) locations (ref PH, K-5)
2870             # +-------------------------+
2871             # | 14 | +----------------------------------+
2872             # | +---+---+---+---+ | | 0 1 2 3 4 5 6 7 8 9 10 |
2873             # | | 5 | 3/1\ 2| 4 | | | 11 12 13 14 15 16 17 18 19 20 21 |
2874             # | +-+-+-+-+ - +-+-+-+-+ | | 22 23 24 25 26 27 28 29 30 31 32 |
2875             # +--+ 9 | 7 ||0|| 6 | 8 +--+ | 33 34 35 36 37 38 39 40 41 42 43 |
2876             # | +-+-+-+-+ - +-+-+-+-+ | | 44 45 46 47 48 49 50 51 52 53 54 |
2877             # | |13 |11\ /10|12 | | | 55 56 57 58 59 60 61 62 63 64 65 |
2878             # | +---+---+---+---+ | | 66 67 68 69 70 71 72 73 74 75 76 |
2879             # | 15 | +----------------------------------+
2880             # +-------------------------+
2881             },
2882             0x020a => { #PH/JD/19
2883             Name => 'FlashMeteringSegments',
2884             Format => 'int8u',
2885             Count => -1,
2886             %convertMeteringSegments,
2887             },
2888             0x020b => { #PH/JD/19
2889             Name => 'SlaveFlashMeteringSegments',
2890             Format => 'int8u',
2891             Count => -1,
2892             Notes => 'used in wireless control mode',
2893             %convertMeteringSegments,
2894             },
2895             0x020d => { #PH
2896             Name => 'WB_RGGBLevelsDaylight',
2897             Writable => 'int16u',
2898             Count => 4,
2899             },
2900             0x020e => { #PH
2901             Name => 'WB_RGGBLevelsShade',
2902             Writable => 'int16u',
2903             Count => 4,
2904             },
2905             0x020f => { #PH
2906             Name => 'WB_RGGBLevelsCloudy',
2907             Writable => 'int16u',
2908             Count => 4,
2909             },
2910             0x0210 => { #PH
2911             Name => 'WB_RGGBLevelsTungsten',
2912             Writable => 'int16u',
2913             Count => 4,
2914             },
2915             0x0211 => { #PH
2916             Name => 'WB_RGGBLevelsFluorescentD',
2917             Writable => 'int16u',
2918             Count => 4,
2919             },
2920             0x0212 => { #PH
2921             Name => 'WB_RGGBLevelsFluorescentN',
2922             Writable => 'int16u',
2923             Count => 4,
2924             },
2925             0x0213 => { #PH
2926             Name => 'WB_RGGBLevelsFluorescentW',
2927             Writable => 'int16u',
2928             Count => 4,
2929             },
2930             0x0214 => { #PH
2931             Name => 'WB_RGGBLevelsFlash',
2932             Writable => 'int16u',
2933             Count => 4,
2934             },
2935             0x0215 => { #PH
2936             Name => 'CameraInfo',
2937             Format => 'undef', # (written as int32u)
2938             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::CameraInfo' },
2939             },
2940             0x0216 => { #PH
2941             Name => 'BatteryInfo',
2942             SubDirectory => {
2943             TagTable => 'Image::ExifTool::Pentax::BatteryInfo',
2944             ByteOrder => 'BigEndian', # have seen makernotes changed to little-endian in DNG!
2945             },
2946             },
2947             # 0x021a - undef[1068] (K-5) - ToneMode/Saturation mapping matrices (ref 28)
2948             0x021b => { #19
2949             Name => 'SaturationInfo',
2950             Flags => [ 'Unknown', 'Binary' ],
2951             Writable => 0,
2952             Notes => 'only in PEF and DNG images',
2953             # K10D values with various Saturation settings (ref 19):
2954             # Very Low: 000000022820f9a0fe4000802660f92002e0fee01e402c40f880fb40ffc02b20f52002e0fe401ee0
2955             # Low: 000000022ae0f700fe20ff402840f88001e0fcc021602f60f560fb40fe602d20f48001c0fbc02280
2956             # Med Low: 000000022dc0f420fe20fe002a20f7e000c0fa8024c032c0f220fb20fce02f60f3c000a0f9202640
2957             # Normal: 000000023120f0e0fe00fc802c40f740ffa0f7e028803660ee80fb20fb4031c0f300ff60f6202a80
2958             # Med High: 0000000234e0ed40fde0fae02ea0f680fe60f5002ca03a80ea80fb00f9603480f220fe00f2e02f20
2959             # High: 0000000238c0e960fde0f9203140f5a0fce0f1e031403f00e600fb00f7803760f120fc60ef403460
2960             # Very High:000000023d20e520fdc0f7203420f4c0fb60ee6036404400e120fae0f5403aa0f020fac0eb403a00
2961             },
2962             0x021c => { #IB
2963             Name => 'ColorMatrixA2',
2964             Format => 'int16s',
2965             Writable => 'undef',
2966             Count => 9,
2967             },
2968             0x021d => { #IB
2969             Name => 'ColorMatrixB2',
2970             Format => 'int16s',
2971             Writable => 'undef',
2972             Count => 9,
2973             },
2974             # 0x021e - undef[8] (K-5, Q)
2975             0x021f => { #JD
2976             Name => 'AFInfo',
2977             SubDirectory => {
2978             # NOTE: Most of these subdirectories are 'undef' format, and as such the
2979             # byte ordering is not changed when changed via the Pentax software (which
2980             # will write a little-endian TIFF on an Intel system). So we must define
2981             # BigEndian byte ordering for any of these which contain multi-byte values. - PH
2982             ByteOrder => 'BigEndian',
2983             TagTable => 'Image::ExifTool::Pentax::AFInfo',
2984             },
2985             },
2986             0x0220 => { #6
2987             Name => 'HuffmanTable',
2988             Flags => [ 'Unknown', 'Binary' ],
2989             Writable => 0,
2990             Notes => 'found in K10D, K20D and K2000 PEF images',
2991             },
2992             0x0221 => { #28
2993             Name => 'KelvinWB',
2994             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::KelvinWB' },
2995             },
2996             0x0222 => { #PH
2997             Name => 'ColorInfo',
2998             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::ColorInfo' },
2999             },
3000             # 0x0223 - undef[198] (K-5 PEF/DNG only)
3001             0x0224 => { #19
3002             Name => 'EVStepInfo',
3003             Drop => 200, # drop if larger than 200 bytes (40 kB in Pentax Q and Q10)
3004             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::EVStepInfo' },
3005             },
3006             0x0226 => { #PH
3007             Name => 'ShotInfo', # (may want to change this later when more is decoded)
3008             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::ShotInfo' },
3009             },
3010             0x0227 => { #PH
3011             Name => 'FacePos',
3012             Condition => '$$self{FacesDetected}', # ignore if no faces to decode
3013             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::FacePos' },
3014             },
3015             0x0228 => { #PH
3016             Name => 'FaceSize',
3017             Condition => '$$self{FacesDetected}', # ignore if no faces to decode
3018             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::FaceSize' },
3019             },
3020             0x0229 => { #PH (verified) (K-m, K-x, K-7)
3021             Name => 'SerialNumber',
3022             Writable => 'string',
3023             Notes => 'left blank by some cameras',
3024             },
3025             0x022a => [{ #PH (RICOH models (GR III))
3026             Name => 'FilterInfo',
3027             Condition => '$$self{Make} =~ /^RICOH/',
3028             SubDirectory => {
3029             TagTable => 'Image::ExifTool::Pentax::FilterInfo',
3030             ByteOrder => 'LittleEndian',
3031             },
3032             },{ #PH (K-5)
3033             Name => 'FilterInfo',
3034             SubDirectory => {
3035             TagTable => 'Image::ExifTool::Pentax::FilterInfo',
3036             ByteOrder => 'BigEndian',
3037             },
3038             }],
3039             0x022b => [{
3040             Name => 'LevelInfoK3III',
3041             Condition => '$$self{Model} =~ /K-3 Mark III/',
3042             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::LevelInfoK3III' },
3043             },{ #PH (K-5)
3044             Name => 'LevelInfo',
3045             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::LevelInfo' },
3046             }],
3047             # 0x022c - undef[46] (K-5)
3048             0x022d => { #28
3049             Name => 'WBLevels',
3050             Condition => '$count == 100', # (just to be safe, but no other counts observed)
3051             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::WBLevels' },
3052             },
3053             0x022e => { #PH (K-5 AVI videos)
3054             Name => 'Artist',
3055             Groups => { 2 => 'Author' },
3056             Writable => 'string',
3057             },
3058             0x022f => { #PH (K-5 AVI videos)
3059             Name => 'Copyright',
3060             Groups => { 2 => 'Author' },
3061             Writable => 'string',
3062             },
3063             0x0230 => { #PH (K-x AVI videos) (and K-70/Q-S1 MOV videos, ref 31)
3064             Name => 'FirmwareVersion',
3065             Notes => 'only in videos',
3066             # this tag only exists in AVI/MOV videos, and for the K-x the value of
3067             # this tag is "K-x Ver 1.00", which is the same as the EXIF Software
3068             # tag. I used a different tag name for this because Pentax uses the
3069             # AVI Software tag for a different string, "PENTAX K-x".
3070             Writable => 'string',
3071             },
3072             0x0231 => { #PH (K-5)
3073             Name => 'ContrastDetectAFArea',
3074             Writable => 'int16u',
3075             Count => 4,
3076             Notes => q{
3077             AF area of the most recent contrast-detect focus operation. Coordinates
3078             are left, top, width and height in a 720x480 frame, with Y downwards
3079             },
3080             },
3081             0x0235 => { #PH (K-5)
3082             Name => 'CrossProcessParams',
3083             # (it would be interesting to know exactly what these mean)
3084             Writable => 'undef',
3085             Format => 'int8u',
3086             Count => 10,
3087             },
3088             # 0x0236 - undef[52] (Q)
3089             # 0x0237 - undef[11] possibly related to smart effect setting? (Q)
3090             # 0x0238 - undef[9] (Q)
3091             0x0238 => { #KarstenGieselmann
3092             Name => 'CAFPointInfo',
3093             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::CAFPointInfo' },
3094             },
3095             0x0239 => { #PH
3096             Name => 'LensInfoQ',
3097             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::LensInfoQ' },
3098             },
3099             # 0x023a - undef[10] (Q)
3100             # 0x023b - undef[9] (K-01)
3101             # 01a700500000000000, 91a700500000000000, 41a700500000000000, 002700500000000000
3102             # c00500400000000000, 400500500000000000, 4004ff420100000000, 4087ff480000000000
3103             0x023f => { #31 (K-70 MOV videos)
3104             Name => 'Model',
3105             Description => 'Camera Model Name',
3106             Writable => 'string',
3107             },
3108             0x0243 => { #PH
3109             Name => 'PixelShiftInfo',
3110             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::PixelShiftInfo' },
3111             },
3112             0x0245 => { #29
3113             Name => 'AFPointInfo',
3114             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::AFPointInfo' },
3115             },
3116             0x03fe => { #PH
3117             Name => 'DataDump',
3118             Writable => 0,
3119             PrintConv => '\$val',
3120             },
3121             0x03ff => [ #PH
3122             {
3123             Name => 'TempInfo',
3124             Condition => '$$self{Model} =~ /K-(01|3|30|5|50|500)\b/',
3125             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::TempInfo' },
3126             },{
3127             Name => 'UnknownInfo',
3128             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::UnknownInfo' },
3129             },
3130             ],
3131             0x0402 => { #5
3132             Name => 'ToneCurve',
3133             PrintConv => '\$val',
3134             },
3135             0x0403 => { #5
3136             Name => 'ToneCurves',
3137             PrintConv => '\$val',
3138             },
3139             # 0x0404 - undef[2086] (K-5)
3140             0x0405 => { #PH - undef[24200] (K-5 PEF/DNG only), undef[28672] (Q DNG)
3141             Name => 'UnknownBlock',
3142             Writable => 'undef',
3143             Notes => 'large unknown data block in PEF/DNG images but not JPG images',
3144             Flags => [ 'Unknown', 'Binary', 'Drop' ],
3145             },
3146             # 0x0406 - undef[4116] (K-5)
3147             # 0x0407 - undef[3072] (Q DNG)
3148             # 0x0408 - undef[1024] (Q DNG)
3149             0x040b => {
3150             Name => 'FaceInfoK3III',
3151             # undef[1640] (actually int32u[410], K3III)
3152             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::FaceInfoK3III' },
3153             },
3154             0x040c => {
3155             Name => 'AFInfoK3III',
3156             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::AFInfoK3III' },
3157             },
3158             0x0e00 => {
3159             Name => 'PrintIM',
3160             Description => 'Print Image Matching',
3161             Writable => 0,
3162             SubDirectory => { TagTable => 'Image::ExifTool::PrintIM::Main' },
3163             },
3164             );
3165              
3166             # shake reduction information (ref PH)
3167             %Image::ExifTool::Pentax::SRInfo = (
3168             %binaryDataAttrs,
3169             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3170             NOTES => 'Shake reduction information.',
3171             0 => {
3172             Name => 'SRResult',
3173             PrintConv => { #PH/JD
3174             0 => 'Not stabilized',
3175             BITMASK => {
3176             0 => 'Stabilized',
3177             # have seen 1 and 4 for 0.5 and 0.3 sec exposures with NR on and Bit 0 also set - ref 19
3178             # have seen bits 1,2,3,4 in K-5 AVI videos - PH
3179             6 => 'Not ready',
3180             },
3181             },
3182             },
3183             1 => {
3184             Name => 'ShakeReduction',
3185             PrintConv => {
3186             0 => 'Off',
3187             1 => 'On',
3188             4 => 'Off (4)', # (K20D, K200D, K-7, K-5)
3189             5 => 'On but Disabled', # (K20D, K-5)
3190             # (can be 5 "On but Disabled" for K-5 with HDR [auto-align off only],
3191             # Composition Adjust, DriveMode = Self-timer or Remote, and movie with SR off!)
3192             6 => 'On (Video)', # (K-7)
3193             7 => 'On (7)', #(NC) (K20D, K200D, K-m, K-5)
3194             15 => 'On (15)', # (K20D with Tamron 10-20mm @ 10mm)
3195             39 => 'On (mode 2)', # (K-01) (on during capture and live view)
3196             135 => 'On (135)', # (K-5IIs)
3197             167 => 'On (mode 1)', # (K-01) (on during capture only)
3198             },
3199             },
3200             2 => {
3201             Name => 'SRHalfPressTime',
3202             # (was SR_SWSToSWRTime: SWS=photometering switch, SWR=shutter release switch)
3203             # (from http://www.patentstorm.us/patents/6597867-description.html)
3204             # (here, SR could more accurately mean Shutter Release, not Shake Reduction)
3205             # (not valid for K-01 - PH)
3206             Notes => q{
3207             time from when the shutter button was half pressed to when the shutter was
3208             released, including time for focusing. Not valid for some models
3209             },
3210             # (constant of 60 determined from times: 2sec=127; 3sec=184,197; 4sec=244,249,243,246 - PH)
3211             ValueConv => '$val / 60',
3212             ValueConvInv => 'my $v=$val*60; $v < 255 ? int($v + 0.5) : 255',
3213             PrintConv => 'sprintf("%.2f s",$val) . ($val > 254.5/60 ? " or longer" : "")',
3214             PrintConvInv => '$val=~tr/0-9.//dc; $val',
3215             },
3216             3 => { #JD
3217             Name => 'SRFocalLength',
3218             ValueConv => '$val & 0x01 ? $val * 4 : $val / 2',
3219             ValueConvInv => '$val <= 127 ? int($val) * 2 : int($val / 4) | 0x01',
3220             PrintConv => '"$val mm"',
3221             PrintConvInv => '$val=~s/\s*mm//;$val',
3222             },
3223             );
3224              
3225             # shake reduction information for the K-3 (ref PH)
3226             %Image::ExifTool::Pentax::SRInfo2 = (
3227             %binaryDataAttrs,
3228             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3229             NOTES => 'Shake reduction information for the K-3.',
3230             0 => {
3231             Name => 'SRResult',
3232             Unknown => 1,
3233             PrintConv => { BITMASK => {
3234             # Bit 0 - have seen this set in a few Pentax samples - PH
3235             # Bit 6 - usually set when SR is Off, and occasionally when On - PH
3236             # Bit 7 - set when AA simulation is on - PH
3237             }},
3238             },
3239             1 => {
3240             Name => 'ShakeReduction',
3241             PrintConv => { #forum5425
3242             0 => 'Off', # (NC for K-3)
3243             1 => 'On', # (NC for K-3)
3244             4 => 'Off (AA simulation off)',
3245             5 => 'On but Disabled', # (NC for K-3)
3246             6 => 'On (Video)', # (NC for K-3)
3247             7 => 'On (AA simulation off)',
3248             8 => 'Off (AA simulation type 1) (8)', #forum8362 (K-70)
3249             12 => 'Off (AA simulation type 1)', # (AA linear motion)
3250             15 => 'On (AA simulation type 1)', # (AA linear motion)
3251             16 => 'Off (AA simulation type 2) (16)', #forum8362 (K-70)
3252             20 => 'Off (AA simulation type 2)', # (AA circular motion)
3253             23 => 'On (AA simulation type 2)', # (AA circular motion)
3254             },
3255             },
3256             );
3257              
3258             # face detection information (ref PH, K-5)
3259             %Image::ExifTool::Pentax::FaceInfo = (
3260             %binaryDataAttrs,
3261             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3262             DATAMEMBER => [ 0 ],
3263             0 => {
3264             Name => 'FacesDetected',
3265             RawConv => '$$self{FacesDetected} = $val',
3266             },
3267             2 => {
3268             Name => 'FacePosition',
3269             Notes => q{
3270             X/Y coordinates of the center of the main face in percent of frame size,
3271             with positive Y downwards
3272             },
3273             Format => 'int8u[2]',
3274             },
3275             );
3276              
3277             # automatic white balance settings (ref PH, K-5)
3278             %Image::ExifTool::Pentax::AWBInfo = (
3279             %binaryDataAttrs,
3280             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3281             # 0 - always 1?
3282             # (data ends here for the K20D, K200D, K-x and K-7)
3283             0 => {
3284             Name => 'WhiteBalanceAutoAdjustment',
3285             PrintConv => {
3286             0 => 'Off',
3287             1 => 'On',
3288             },
3289             },
3290             1 => { # (exists only for K-5)
3291             Name => 'TungstenAWB',
3292             PrintConv => {
3293             0 => 'Subtle Correction',
3294             1 => 'Strong Correction',
3295             },
3296             },
3297             );
3298              
3299             # world time settings (ref PH, K-5)
3300             %Image::ExifTool::Pentax::TimeInfo = (
3301             %binaryDataAttrs,
3302             GROUPS => { 0 => 'MakerNotes', 2 => 'Time' },
3303             0.1 => {
3304             Name => 'WorldTimeLocation',
3305             Mask => 0x01,
3306             PrintConv => {
3307             0 => 'Hometown',
3308             1 => 'Destination',
3309             },
3310             },
3311             0.2 => {
3312             Name => 'HometownDST',
3313             Mask => 0x02,
3314             PrintConv => \%noYes,
3315             },
3316             0.3 => {
3317             Name => 'DestinationDST',
3318             Mask => 0x04,
3319             PrintConv => \%noYes,
3320             },
3321             2 => {
3322             Name => 'HometownCity',
3323             SeparateTable => 'City',
3324             PrintConv => \%pentaxCities,
3325             },
3326             3 => {
3327             Name => 'DestinationCity',
3328             SeparateTable => 'City',
3329             PrintConv => \%pentaxCities,
3330             },
3331             );
3332              
3333             # lens distortion correction (ref PH, K-5)
3334             %Image::ExifTool::Pentax::LensCorr = (
3335             %binaryDataAttrs,
3336             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
3337             0 => {
3338             Name => 'DistortionCorrection',
3339             PrintConv => { 0 => 'Off', 1 => 'On' },
3340             },
3341             1 => {
3342             Name => 'ChromaticAberrationCorrection',
3343             PrintConv => { 0 => 'Off', 1 => 'On' },
3344             },
3345             2 => {
3346             Name => 'PeripheralIlluminationCorr',
3347             PrintConv => { 0 => 'Off', 1 => 'On' },
3348             },
3349             3 => {
3350             Name => 'DiffractionCorrection',
3351             PrintConv => { 0 => 'Off', 16 => 'On' },
3352             },
3353             );
3354              
3355             # camera settings (ref 19)
3356             %Image::ExifTool::Pentax::CameraSettings = (
3357             %binaryDataAttrs,
3358             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3359             PRIORITY => 0,
3360             NOTES => 'Camera settings information written by Pentax DSLR cameras.',
3361             0 => {
3362             Name => 'PictureMode2',
3363             PrintConv => {
3364             0 => 'Scene Mode', #PH
3365             1 => 'Auto PICT', #PH (NC)
3366             2 => 'Program AE',
3367             3 => 'Green Mode',
3368             4 => 'Shutter Speed Priority',
3369             5 => 'Aperture Priority',
3370             6 => 'Program Tv Shift', #PH
3371             7 => 'Program Av Shift',
3372             8 => 'Manual', #PH
3373             9 => 'Bulb', #PH
3374             10 => 'Aperture Priority, Off-Auto-Aperture', #PH (NC)
3375             11 => 'Manual, Off-Auto-Aperture', #PH
3376             12 => 'Bulb, Off-Auto-Aperture', #PH (NC)
3377             13 => 'Shutter & Aperture Priority AE',
3378             15 => 'Sensitivity Priority AE',
3379             16 => 'Flash X-Sync Speed AE', #PH
3380             },
3381             },
3382             1.1 => {
3383             Name => 'ProgramLine',
3384             # only set to other than Normal when in Program AE mode
3385             Mask => 0x03,
3386             PrintConv => {
3387             0 => 'Normal',
3388             1 => 'Hi Speed',
3389             2 => 'Depth',
3390             3 => 'MTF',
3391             },
3392             },
3393             1.2 => { # (K10D, K-5)
3394             Name => 'EVSteps',
3395             Mask => 0x20,
3396             PrintConv => {
3397             0 => '1/2 EV Steps',
3398             1 => '1/3 EV Steps',
3399             },
3400             },
3401             1.3 => { # (this bit is set for movies with the K-5 - PH)
3402             Name => 'E-DialInProgram',
3403             # always set even when not in Program AE mode
3404             Mask => 0x40,
3405             PrintConv => {
3406             0 => 'Tv or Av',
3407             1 => 'P Shift',
3408             },
3409             },
3410             1.4 => { # (K10D, K-5)
3411             Name => 'ApertureRingUse',
3412             # always set even Aperture Ring is in A mode
3413             Mask => 0x80,
3414             PrintConv => {
3415             0 => 'Prohibited',
3416             1 => 'Permitted',
3417             },
3418             },
3419             2 => {
3420             Name => 'FlashOptions',
3421             Notes => 'the camera flash options settings, set even if the flash is off',
3422             Mask => 0xf0,
3423             # Note: These tags correlate with the FlashMode and InternalFlashMode values,
3424             # and match what is displayed by the Pentax software
3425             PrintConv => {
3426             0 => 'Normal', # (this value can occur in Green Mode) - ref 19
3427             1 => 'Red-eye reduction', # (this value can occur in Green Mode) - ref 19
3428             2 => 'Auto', # (this value can occur in other than Green Mode) - ref 19
3429             3 => 'Auto, Red-eye reduction', #PH (this value can occur in other than Green Mode) - ref 19
3430             5 => 'Wireless (Master)',
3431             6 => 'Wireless (Control)',
3432             8 => 'Slow-sync',
3433             9 => 'Slow-sync, Red-eye reduction',
3434             10 => 'Trailing-curtain Sync'
3435             },
3436             },
3437             2.1 => {
3438             Name => 'MeteringMode2',
3439             Mask => 0x0f,
3440             Notes => 'may not be valid for some models, eg. *ist D',
3441             PrintConv => {
3442             0 => 'Multi-segment',
3443             BITMASK => {
3444             0 => 'Center-weighted average',
3445             1 => 'Spot',
3446             },
3447             },
3448             },
3449             3 => {
3450             Name => 'AFPointMode',
3451             Mask => 0xf0,
3452             PrintConv => {
3453             0 => 'Auto',
3454             BITMASK => {
3455             0 => 'Select',
3456             1 => 'Fixed Center',
3457             # have seen bit 2 set in pre-production images (firmware 0.20) - PH
3458             },
3459             },
3460             },
3461             3.1 => {
3462             Name => 'FocusMode2',
3463             Mask => 0x0f,
3464             PrintConv => {
3465             0 => 'Manual',
3466             1 => 'AF-S',
3467             2 => 'AF-C',
3468             3 => 'AF-A', #PH
3469             },
3470             },
3471             4 => {
3472             Name => 'AFPointSelected2',
3473             Format => 'int16u',
3474             PrintConv => {
3475             0 => 'Auto',
3476             BITMASK => {
3477             0 => 'Upper-left',
3478             1 => 'Top',
3479             2 => 'Upper-right',
3480             3 => 'Left',
3481             4 => 'Mid-left',
3482             5 => 'Center',
3483             6 => 'Mid-right',
3484             7 => 'Right',
3485             8 => 'Lower-left',
3486             9 => 'Bottom',
3487             10 => 'Lower-right',
3488             },
3489             },
3490             },
3491             6 => {
3492             Name => 'ISOFloor', #PH
3493             # manual ISO or minimum ISO in Auto ISO mode - PH
3494             ValueConv => 'int(100*exp(Image::ExifTool::Pentax::PentaxEv($val-32)*log(2))+0.5)',
3495             ValueConvInv => 'Image::ExifTool::Pentax::PentaxEvInv(log($val/100)/log(2))+32',
3496             },
3497             7 => {
3498             Name => 'DriveMode2',
3499             PrintConv => {
3500             0 => 'Single-frame',
3501             BITMASK => {
3502             0 => 'Continuous', # (K-5 Hi)
3503             1 => 'Continuous (Lo)', #PH (K-5)
3504             2 => 'Self-timer (12 s)', #PH
3505             3 => 'Self-timer (2 s)', #PH
3506             4 => 'Remote Control (3 s delay)',
3507             5 => 'Remote Control',
3508             6 => 'Exposure Bracket', #PH/19
3509             7 => 'Multiple Exposure',
3510             },
3511             },
3512             },
3513             8 => {
3514             Name => 'ExposureBracketStepSize',
3515             # This is set even when Exposure Bracket is Off (and the K10D
3516             # displays "---" as the step size when you press the EB button) - DaveN
3517             # because the last value is remembered and if you turn Exposure Bracket
3518             # on the step size goes back to what it was before.
3519             PrintConv => {
3520             3 => '0.3',
3521             4 => '0.5',
3522             5 => '0.7',
3523             8 => '1.0', #PH
3524             11 => '1.3',
3525             12 => '1.5',
3526             13 => '1.7', #(NC)
3527             16 => '2.0', #PH
3528             },
3529             },
3530             9 => { #PH/19
3531             Name => 'BracketShotNumber',
3532             PrintHex => 1,
3533             PrintConv => {
3534             0 => 'n/a',
3535             0x02 => '1 of 2', #PH (K-5)
3536             0x12 => '2 of 2', #PH (K-5)
3537             0x03 => '1 of 3',
3538             0x13 => '2 of 3',
3539             0x23 => '3 of 3',
3540             0x05 => '1 of 5',
3541             0x15 => '2 of 5',
3542             0x25 => '3 of 5',
3543             0x35 => '4 of 5',
3544             0x45 => '5 of 5',
3545             },
3546             },
3547             10 => {
3548             Name => 'WhiteBalanceSet',
3549             Mask => 0xf0,
3550             # Not necessarily the white balance used; for example if the custom menu is set to
3551             # "WB when using flash" -> "2 Flash", then this tag reports the camera setting while
3552             # tag 0x0019 reports Flash if the Flash was used.
3553             PrintConv => {
3554             0 => 'Auto',
3555             1 => 'Daylight',
3556             2 => 'Shade',
3557             3 => 'Cloudy',
3558             4 => 'Daylight Fluorescent',
3559             5 => 'Day White Fluorescent',
3560             6 => 'White Fluorescent',
3561             7 => 'Tungsten',
3562             8 => 'Flash',
3563             9 => 'Manual',
3564             # The three Set Color Temperature settings refer to the 3 preset settings which
3565             # can be saved in the menu (see page 123 of the K10D manual)
3566             12 => 'Set Color Temperature 1',
3567             13 => 'Set Color Temperature 2',
3568             14 => 'Set Color Temperature 3',
3569             },
3570             },
3571             10.1 => {
3572             Name => 'MultipleExposureSet',
3573             Mask => 0x0f,
3574             PrintConv => {
3575             0 => 'Off',
3576             1 => 'On',
3577             },
3578             },
3579             13 => {
3580             Name => 'RawAndJpgRecording',
3581             Condition => '$$self{Model} =~ /(K10D|GX10)\b/',
3582             Notes => 'K10D only',
3583             # this is actually a bit field: - PH
3584             # bit 0=JPEG, bit 2=PEF, bit 3=DNG; high nibble: 0x00=best, 0x20=better, 0x40=good
3585             PrintHex => 1,
3586             PrintConv => {
3587             0x01 => 'JPEG (Best)', #PH
3588             0x04 => 'RAW (PEF, Best)',
3589             0x05 => 'RAW+JPEG (PEF, Best)',
3590             0x08 => 'RAW (DNG, Best)', #PH (NC)
3591             0x09 => 'RAW+JPEG (DNG, Best)', #PH (NC)
3592             0x21 => 'JPEG (Better)', #PH
3593             0x24 => 'RAW (PEF, Better)',
3594             0x25 => 'RAW+JPEG (PEF, Better)', #PH
3595             0x28 => 'RAW (DNG, Better)', #PH
3596             0x29 => 'RAW+JPEG (DNG, Better)', #PH (NC)
3597             0x41 => 'JPEG (Good)',
3598             0x44 => 'RAW (PEF, Good)', #PH (NC)
3599             0x45 => 'RAW+JPEG (PEF, Good)', #PH (NC)
3600             0x48 => 'RAW (DNG, Good)', #PH (NC)
3601             0x49 => 'RAW+JPEG (DNG, Good)',
3602             # have seen values of 0,2,34 for other models (not K10D) - PH
3603             },
3604             },
3605             14.1 => { #PH
3606             Name => 'JpgRecordedPixels',
3607             Condition => '$$self{Model} =~ /(K10D|GX10)\b/',
3608             Notes => 'K10D only',
3609             Mask => 0x03,
3610             PrintConv => {
3611             0 => '10 MP',
3612             1 => '6 MP',
3613             2 => '2 MP',
3614             },
3615             },
3616             14.2 => { #PH (K-5)
3617             Name => 'LinkAEToAFPoint',
3618             Condition => '$$self{Model} =~ /K-5\b/',
3619             Notes => 'K-5 only',
3620             Mask => 0x01,
3621             PrintConv => { 0 => 'Off', 1 => 'On' },
3622             },
3623             14.3 => { #PH (K-5)
3624             Name => 'SensitivitySteps',
3625             Condition => '$$self{Model} =~ /K-5\b/',
3626             Notes => 'K-5 only',
3627             Mask => 0x02,
3628             PrintConv => {
3629             0 => '1 EV Steps',
3630             1 => 'As EV Steps',
3631             },
3632             },
3633             14.4 => { #PH (K-5)
3634             Name => 'ISOAuto',
3635             Condition => '$$self{Model} =~ /K-5\b/',
3636             Notes => 'K-5 only',
3637             Mask => 0x04,
3638             PrintConv => { 0 => 'Off', 1 => 'On' },
3639             },
3640             # 14.5 Mask 0x80 - changes for K-5
3641             16 => {
3642             Name => 'FlashOptions2',
3643             Condition => '$$self{Model} =~ /(K10D|GX10)\b/',
3644             Notes => 'K10D only; set even if the flash is off',
3645             Mask => 0xf0,
3646             # Note: the Normal and Auto values (0x00 to 0x30) do not tags always
3647             # correlate with the FlashMode, InternalFlashMode and FlashOptions values
3648             # however, these values seem to better match the K10D's actual functionality
3649             # (always Auto in Green mode always Normal otherwise if one of the other options
3650             # isn't selected) - ref 19
3651             # (these tags relate closely to InternalFlashMode values - PH)
3652             PrintConv => {
3653             0 => 'Normal', # (this value never occurs in Green Mode) - ref 19
3654             1 => 'Red-eye reduction', # (this value never occurs in Green Mode) - ref 19
3655             2 => 'Auto', # (this value only occurs in Green Mode) - ref 19
3656             3 => 'Auto, Red-eye reduction', # (this value only occurs in Green Mode) - ref 19
3657             5 => 'Wireless (Master)',
3658             6 => 'Wireless (Control)',
3659             8 => 'Slow-sync',
3660             9 => 'Slow-sync, Red-eye reduction',
3661             10 => 'Trailing-curtain Sync'
3662             },
3663             },
3664             16.1 => {
3665             Name => 'MeteringMode3',
3666             Condition => '$$self{Model} =~ /(K10D|GX10)\b/',
3667             Notes => 'K10D only',
3668             Mask => 0x0f,
3669             PrintConv => {
3670             0 => 'Multi-segment',
3671             BITMASK => {
3672             0 => 'Center-weighted average',
3673             1 => 'Spot',
3674             },
3675             },
3676             },
3677             # 16 Mask 0x0f - changes when changing EV steps? (K-5)
3678             17.1 => {
3679             Name => 'SRActive',
3680             Condition => '$$self{Model} =~ /(K10D|GX10)\b/',
3681             Notes => q{
3682             K10D only; SR is active only when ShakeReduction is On, DriveMode is not
3683             Remote or Self-timer, and Internal/ExternalFlashMode is not "On, Wireless"
3684             },
3685             Mask => 0x80,
3686             PrintConv => \%noYes,
3687             },
3688             17.2 => {
3689             Name => 'Rotation',
3690             Condition => '$$self{Model} =~ /(K10D|GX10)\b/',
3691             Notes => 'K10D only',
3692             Mask => 0x60,
3693             PrintConv => {
3694             0 => 'Horizontal (normal)',
3695             1 => 'Rotate 180',
3696             2 => 'Rotate 90 CW',
3697             3 => 'Rotate 270 CW',
3698             },
3699             },
3700             # Bit 0x08 is set on 3 of my 3000 shots to (All 3 were Shutter Priority
3701             # but this may not mean anything with such a small sample) - ref 19
3702             17.3 => {
3703             Name => 'ISOSetting',
3704             Condition => '$$self{Model} =~ /(K10D|GX10)\b/',
3705             Notes => 'K10D only',
3706             Mask => 0x04,
3707             PrintConv => {
3708             0 => 'Manual',
3709             1 => 'Auto',
3710             },
3711             },
3712             17.4 => {
3713             Name => 'SensitivitySteps',
3714             Condition => '$$self{Model} =~ /(K10D|GX10)\b/',
3715             Notes => 'K10D only',
3716             Mask => 0x02,
3717             PrintConv => {
3718             0 => '1 EV Steps',
3719             1 => 'As EV Steps',
3720             },
3721             },
3722             # 17 Mask 0x08 - changed when changing Auto ISO range (K-5)
3723             18 => {
3724             Name => 'TvExposureTimeSetting',
3725             Condition => '$$self{Model} =~ /(K10D|GX10)\b/',
3726             Notes => 'K10D only',
3727             ValueConv => 'exp(-Image::ExifTool::Pentax::PentaxEv($val-68)*log(2))',
3728             ValueConvInv => 'Image::ExifTool::Pentax::PentaxEvInv(-log($val)/log(2))+68',
3729             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
3730             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
3731             },
3732             19 => {
3733             Name => 'AvApertureSetting',
3734             Condition => '$$self{Model} =~ /(K10D|GX10)\b/',
3735             Notes => 'K10D only',
3736             ValueConv => 'exp(Image::ExifTool::Pentax::PentaxEv($val-68)*log(2)/2)',
3737             ValueConvInv => 'Image::ExifTool::Pentax::PentaxEvInv(log($val)*2/log(2))+68',
3738             PrintConv => 'sprintf("%.1f",$val)',
3739             PrintConvInv => '$val',
3740             },
3741             20 => { #PH
3742             Name => 'SvISOSetting',
3743             Condition => '$$self{Model} =~ /(K10D|GX10)\b/',
3744             Notes => 'K10D only',
3745             # ISO setting for sensitivity-priority mode
3746             # (conversion may not give actual displayed values:)
3747             # 32 => 100, 35 => 125, 36 => 140, 37 => 160,
3748             # 40 => 200, 43 => 250, 44 => 280, 45 => 320,
3749             # 48 => 400, 51 => 500, 52 => 560, 53 => 640,
3750             # 56 => 800, 59 => 1000,60 => 1100,61 => 1250, 64 => 1600
3751             ValueConv => 'int(100*exp(Image::ExifTool::Pentax::PentaxEv($val-32)*log(2))+0.5)',
3752             ValueConvInv => 'Image::ExifTool::Pentax::PentaxEvInv(log($val/100)/log(2))+32',
3753             },
3754             21 => { #PH
3755             Name => 'BaseExposureCompensation',
3756             Condition => '$$self{Model} =~ /(K10D|GX10)\b/',
3757             Notes => 'K10D only; exposure compensation without auto bracketing',
3758             ValueConv => 'Image::ExifTool::Pentax::PentaxEv(64-$val)',
3759             ValueConvInv => '64-Image::ExifTool::Pentax::PentaxEvInv($val)',
3760             PrintConv => '$val ? sprintf("%+.1f", $val) : 0',
3761             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
3762             },
3763             );
3764              
3765             # unknown camera settings (K-01)
3766             %Image::ExifTool::Pentax::CameraSettingsUnknown = (
3767             %binaryDataAttrs,
3768             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3769             NOTES => 'This information has not yet been decoded for models such as the K-01.',
3770             );
3771              
3772             # auto-exposure information (ref PH)
3773             %Image::ExifTool::Pentax::AEInfo = (
3774             %binaryDataAttrs,
3775             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3776             DATAMEMBER => [ 7 ],
3777             NOTES => 'Auto-exposure information for most Pentax models.',
3778             # instead of /8, should these be PentaxEv(), as in CameraSettings? - PH
3779             0 => {
3780             Name => 'AEExposureTime',
3781             Notes => 'val = 24 * 2**((32-raw)/8)',
3782             ValueConv => '24*exp(-($val-32)*log(2)/8)',
3783             ValueConvInv => '-log($val/24)*8/log(2)+32',
3784             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
3785             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
3786             },
3787             1 => {
3788             Name => 'AEAperture',
3789             Notes => 'val = 2**((raw-68)/16)',
3790             ValueConv => 'exp(($val-68)*log(2)/16)',
3791             ValueConvInv => 'log($val)*16/log(2)+68',
3792             PrintConv => 'sprintf("%.1f",$val)',
3793             PrintConvInv => '$val',
3794             },
3795             2 => {
3796             Name => 'AE_ISO',
3797             Notes => 'val = 100 * 2**((raw-32)/8)',
3798             ValueConv => '100*exp(($val-32)*log(2)/8)',
3799             ValueConvInv => 'log($val/100)*8/log(2)+32',
3800             PrintConv => 'int($val + 0.5)',
3801             PrintConvInv => '$val',
3802             },
3803             3 => {
3804             Name => 'AEXv',
3805             Notes => 'val = (raw-64)/8',
3806             ValueConv => '($val-64)/8',
3807             ValueConvInv => '$val * 8 + 64',
3808             },
3809             4 => {
3810             Name => 'AEBXv',
3811             Format => 'int8s',
3812             Notes => 'val = raw / 8',
3813             ValueConv => '$val / 8',
3814             ValueConvInv => '$val * 8',
3815             },
3816             5 => {
3817             Name => 'AEMinExposureTime', #19
3818             Notes => 'val = 24 * 2**((32-raw)/8)',
3819             ValueConv => '24*exp(-($val-32)*log(2)/8)', #JD
3820             ValueConvInv => '-log($val/24)*8/log(2)+32',
3821             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
3822             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
3823             },
3824             6 => {
3825             Name => 'AEProgramMode',
3826             PrintConvColumns => 2,
3827             PrintConv => {
3828             0 => 'M, P or TAv',
3829             1 => 'Av, B or X',
3830             2 => 'Tv',
3831             3 => 'Sv or Green Mode',
3832             8 => 'Hi-speed Program',
3833             11 => 'Hi-speed Program (P-Shift)', #19
3834             16 => 'DOF Program', #19
3835             19 => 'DOF Program (P-Shift)', #19
3836             24 => 'MTF Program', #19
3837             27 => 'MTF Program (P-Shift)', #19
3838             35 => 'Standard',
3839             43 => 'Portrait',
3840             51 => 'Landscape',
3841             59 => 'Macro',
3842             67 => 'Sport',
3843             75 => 'Night Scene Portrait',
3844             83 => 'No Flash',
3845             91 => 'Night Scene',
3846             # 96 - seen for Pentax Q10
3847             99 => 'Surf & Snow',
3848             104 => 'Night Snap', # (Q)
3849             107 => 'Text',
3850             115 => 'Sunset',
3851             # 116 - seen for Pentax Q (vivid?)
3852             123 => 'Kids',
3853             131 => 'Pet',
3854             139 => 'Candlelight',
3855             144 => 'SCN', # (Q)
3856             160 => 'Program', # (Q)
3857             # 142 - seen for Pentax Q in Program mode
3858             147 => 'Museum',
3859             184 => 'Shallow DOF Program', # (K-5)
3860             216 => 'HDR', # (Q)
3861             },
3862             },
3863             7 => {
3864             Name => 'AEFlags',
3865             Writable => 0,
3866             Hook => '$size > 20 and $varSize += 1',
3867             Notes => 'indices after this are incremented by 1 for some models',
3868             # (this tag can't be unknown because the Hook must be evaluated
3869             # to shift the following offsets if necessary. Instead, ignore
3870             # the return value unless Unknown option used)
3871             RawConv => '$$self{OPTIONS}{Unknown} ? $val : undef',
3872             PrintConv => { #19
3873             # (seems to be the warnings displayed in the viewfinder for several bits)
3874             BITMASK => {
3875             # 0 - seen in extreme low light conditions (e.g. Lens Cap On)
3876             # 1 - seen in 2 cases, Aperture Priority mode, Auto ISO at 100,
3877             # Shutter speed at 1/4000 and aperture opened wider causing under exposure
3878             # 2 - only (but not always) set in Shutter Speed Priority (seems to be when over/under exposed).
3879             # In one case set when auto exposure compensation changed the Tv from 1/250 to 1/80.
3880             # In another case set when external flash was in SB mode so did not fire.
3881             3 => 'AE lock',
3882             4 => 'Flash recommended?', # not 100% sure of this one
3883             # 5 - seen lots...
3884             # 6 - seen lots...
3885             7 => 'Aperture wide open', # mostly true... (Set for all my lenses except for DA* 16-50mm)
3886             },
3887             },
3888             },
3889             # Note: Offsets below shifted by 1 if record size is > 20 bytes
3890             # (implemented by the Hook above)
3891             8 => { #30
3892             Name => 'AEApertureSteps',
3893             Notes => q{
3894             number of steps the aperture has been stopped down from wide open. There
3895             are roughly 8 steps per F-stop for most lenses, or 18 steps for 645D lenses,
3896             but it varies slightly by lens
3897             },
3898             PrintConv => '$val == 255 ? "n/a" : $val',
3899             PrintConvInv => '$val eq "n/a" ? 255 : $val',
3900             },
3901             9 => { #19
3902             Name => 'AEMaxAperture',
3903             Notes => 'val = 2**((raw-68)/16)',
3904             ValueConv => 'exp(($val-68)*log(2)/16)',
3905             ValueConvInv => 'log($val)*16/log(2)+68',
3906             PrintConv => 'sprintf("%.1f",$val)',
3907             PrintConvInv => '$val',
3908             },
3909             10 => { #19
3910             Name => 'AEMaxAperture2',
3911             Notes => 'val = 2**((raw-68)/16)',
3912             ValueConv => 'exp(($val-68)*log(2)/16)',
3913             ValueConvInv => 'log($val)*16/log(2)+68',
3914             PrintConv => 'sprintf("%.1f",$val)',
3915             PrintConvInv => '$val',
3916             },
3917             11 => { #19
3918             Name => 'AEMinAperture',
3919             Notes => 'val = 2**((raw-68)/16)',
3920             ValueConv => 'exp(($val-68)*log(2)/16)',
3921             ValueConvInv => 'log($val)*16/log(2)+68',
3922             PrintConv => 'sprintf("%.0f",$val)',
3923             PrintConvInv => '$val',
3924             },
3925             12 => { #19
3926             Name => 'AEMeteringMode',
3927             PrintConv => {
3928             0 => 'Multi-segment',
3929             BITMASK => {
3930             4 => 'Center-weighted average',
3931             5 => 'Spot',
3932             },
3933             },
3934             },
3935             13 => { #30
3936             Name => 'AEWhiteBalance',
3937             Condition => '$$self{AEInfoSize} == 24', # (not thoroughly tested for other sizes)
3938             Notes => 'K7 and Kx',
3939             Mask => 0xf0,
3940             PrintConv => {
3941             0 => 'Standard',
3942             1 => 'Daylight',
3943             2 => 'Shade',
3944             3 => 'Cloudy',
3945             4 => 'Daylight Fluorescent',
3946             5 => 'Day White Fluorescent',
3947             6 => 'White Fluorescent',
3948             7 => 'Tungsten',
3949             8 => 'Unknown', #31 (or not set due to inadequate lighting)
3950             },
3951             },
3952             13.1 => { #30
3953             Name => 'AEMeteringMode2',
3954             Condition => '$$self{AEInfoSize} == 24', # (not thoroughly tested for other sizes)
3955             Notes => 'K7 and Kx, override for an incompatible metering mode setting',
3956             Mask => 0x0f,
3957             PrintConv => {
3958             0 => 'Multi-segment',
3959             BITMASK => {
3960             0 => 'Center-weighted average',
3961             1 => 'Spot',
3962             # 2 - seen for K7 AVI movie
3963             },
3964             },
3965             },
3966             14 => { #19
3967             Name => 'FlashExposureCompSet',
3968             Description => 'Flash Exposure Comp. Setting',
3969             Format => 'int8s',
3970             Notes => q{
3971             reports the camera setting, unlike tag 0x004d which reports 0 in Green mode
3972             or if flash was on but did not fire. Both this tag and 0x004d report the
3973             setting even if the flash is off
3974             },
3975             ValueConv => 'Image::ExifTool::Pentax::PentaxEv($val)',
3976             ValueConvInv => 'Image::ExifTool::Pentax::PentaxEvInv($val)',
3977             PrintConv => '$val ? sprintf("%+.1f", $val) : 0',
3978             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
3979             },
3980             21 => { #30
3981             Name => 'LevelIndicator',
3982             PrintConv => '$val == 90 ? "n/a" : $val',
3983             PrintConvInv => '$val eq "n/a" ? 90 : $val',
3984             },
3985             );
3986              
3987             # auto-exposure information for the K-01 (ref PH)
3988             %Image::ExifTool::Pentax::AEInfo2 = (
3989             %binaryDataAttrs,
3990             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
3991             NOTES => 'Auto-exposure information for the K-01.',
3992             # instead of /8, should these be PentaxEv(), as in CameraSettings? - PH
3993             2 => {
3994             Name => 'AEExposureTime',
3995             Notes => 'val = 24 * 2**((32-raw)/8)',
3996             ValueConv => '24*exp(-($val-32)*log(2)/8)',
3997             ValueConvInv => '-log($val/24)*8/log(2)+32',
3998             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
3999             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
4000             },
4001             3 => {
4002             Name => 'AEAperture',
4003             Notes => 'val = 2**((raw-68)/16)',
4004             ValueConv => 'exp(($val-68)*log(2)/16)',
4005             ValueConvInv => 'log($val)*16/log(2)+68',
4006             PrintConv => 'sprintf("%.1f",$val)',
4007             PrintConvInv => '$val',
4008             },
4009             4 => {
4010             Name => 'AE_ISO',
4011             Notes => 'val = 100 * 2**((raw-32)/8)',
4012             ValueConv => '100*exp(($val-32)*log(2)/8)',
4013             ValueConvInv => 'log($val/100)*8/log(2)+32',
4014             PrintConv => 'int($val + 0.5)',
4015             PrintConvInv => '$val',
4016             },
4017             5 => {
4018             Name => 'AEXv',
4019             # this is the negative of exposure compensation, not including bracketing
4020             Notes => 'val = (raw-64)/8',
4021             ValueConv => '($val-64)/8',
4022             ValueConvInv => '$val * 8 + 64',
4023             },
4024             6 => {
4025             Name => 'AEBXv',
4026             # this is the negative of auto exposure bracketing compensation
4027             Format => 'int8s',
4028             Notes => 'val = raw / 8',
4029             ValueConv => '$val / 8',
4030             ValueConvInv => '$val * 8',
4031             },
4032             8 => {
4033             Name => 'AEError',
4034             Format => 'int8s',
4035             # this is usually zero except in M exposure mode, but it can be non-zero
4036             # in other modes (eg. if you hit an aperture limit in Tv mode)
4037             ValueConv => '-($val-64)/8', # (negate to make overexposed positive)
4038             ValueConvInv => '-$val * 8 + 64',
4039             },
4040             11 => {
4041             Name => 'AEApertureSteps',
4042             Notes => q{
4043             number of steps the aperture has been stopped down from wide open. There
4044             are roughly 8 steps per F-stop, but it varies slightly by lens
4045             },
4046             PrintConv => '$val == 255 ? "n/a" : $val',
4047             PrintConvInv => '$val eq "n/a" ? 255 : $val',
4048             },
4049             15 => {
4050             Name => 'SceneMode',
4051             PrintConvColumns => 2,
4052             PrintConv => {
4053             0 => 'Off',
4054             1 => 'HDR',
4055             4 => 'Auto PICT',
4056             5 => 'Portrait',
4057             6 => 'Landscape',
4058             7 => 'Macro',
4059             8 => 'Sport',
4060             9 => 'Night Scene Portrait',
4061             10 => 'No Flash',
4062             11 => 'Night Scene',
4063             12 => 'Surf & Snow',
4064             14 => 'Sunset',
4065             15 => 'Kids',
4066             16 => 'Pet',
4067             17 => 'Candlelight',
4068             18 => 'Museum',
4069             20 => 'Food',
4070             21 => 'Stage Lighting',
4071             22 => 'Night Snap',
4072             25 => 'Night Scene HDR',
4073             26 => 'Blue Sky',
4074             27 => 'Forest',
4075             29 => 'Backlight Silhouette',
4076             },
4077             },
4078             16 => {
4079             Name => 'AEMaxAperture',
4080             Notes => 'val = 2**((raw-68)/16)',
4081             ValueConv => 'exp(($val-68)*log(2)/16)',
4082             ValueConvInv => 'log($val)*16/log(2)+68',
4083             PrintConv => 'sprintf("%.1f",$val)',
4084             PrintConvInv => '$val',
4085             },
4086             17 => {
4087             Name => 'AEMaxAperture2',
4088             Notes => 'val = 2**((raw-68)/16)',
4089             ValueConv => 'exp(($val-68)*log(2)/16)',
4090             ValueConvInv => 'log($val)*16/log(2)+68',
4091             PrintConv => 'sprintf("%.1f",$val)',
4092             PrintConvInv => '$val',
4093             },
4094             18 => {
4095             Name => 'AEMinAperture',
4096             Notes => 'val = 2**((raw-68)/16)',
4097             ValueConv => 'exp(($val-68)*log(2)/16)',
4098             ValueConvInv => 'log($val)*16/log(2)+68',
4099             PrintConv => 'sprintf("%.0f",$val)',
4100             PrintConvInv => '$val',
4101             },
4102             19 => {
4103             Name => 'AEMinExposureTime',
4104             Notes => 'val = 24 * 2**((32-raw)/8)',
4105             ValueConv => '24*exp(-($val-32)*log(2)/8)',
4106             ValueConvInv => '-log($val/24)*8/log(2)+32',
4107             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
4108             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
4109             },
4110             );
4111              
4112             # auto-exposure information for the K-30 (ref PH)
4113             %Image::ExifTool::Pentax::AEInfo3 = (
4114             %binaryDataAttrs,
4115             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4116             NOTES => q{
4117             Auto-exposure information for the K-1mkII, K-3, K-30, K-50, K-70, K-500 and
4118             KP.
4119             },
4120             # instead of /8, should these be PentaxEv(), as in CameraSettings? - PH
4121             16 => {
4122             Name => 'AEExposureTime',
4123             Notes => 'val = 24 * 2**((32-raw)/8)',
4124             ValueConv => '24*exp(-($val-32)*log(2)/8)',
4125             ValueConvInv => '-log($val/24)*8/log(2)+32',
4126             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
4127             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
4128             },
4129             17 => {
4130             Name => 'AEAperture',
4131             Notes => 'val = 2**((raw-68)/16)',
4132             ValueConv => 'exp(($val-68)*log(2)/16)',
4133             ValueConvInv => 'log($val)*16/log(2)+68',
4134             PrintConv => 'sprintf("%.1f",$val)',
4135             PrintConvInv => '$val',
4136             },
4137             18 => {
4138             Name => 'AE_ISO',
4139             Notes => 'val = 100 * 2**((raw-32)/8)',
4140             ValueConv => '100*exp(($val-32)*log(2)/8)',
4141             ValueConvInv => 'log($val/100)*8/log(2)+32',
4142             PrintConv => 'int($val + 0.5)',
4143             PrintConvInv => '$val',
4144             },
4145             # 23 - bit 0 is related to LiveView, but it isn't reliable
4146             28 => {
4147             Name => 'AEMaxAperture',
4148             Notes => 'val = 2**((raw-68)/16)',
4149             ValueConv => 'exp(($val-68)*log(2)/16)',
4150             ValueConvInv => 'log($val)*16/log(2)+68',
4151             PrintConv => 'sprintf("%.1f",$val)',
4152             PrintConvInv => '$val',
4153             },
4154             29 => {
4155             Name => 'AEMaxAperture2',
4156             Notes => 'val = 2**((raw-68)/16)',
4157             ValueConv => 'exp(($val-68)*log(2)/16)',
4158             ValueConvInv => 'log($val)*16/log(2)+68',
4159             PrintConv => 'sprintf("%.1f",$val)',
4160             PrintConvInv => '$val',
4161             },
4162             30 => {
4163             Name => 'AEMinAperture',
4164             Notes => 'val = 2**((raw-68)/16)',
4165             ValueConv => 'exp(($val-68)*log(2)/16)',
4166             ValueConvInv => 'log($val)*16/log(2)+68',
4167             PrintConv => 'sprintf("%.0f",$val)',
4168             PrintConvInv => '$val',
4169             },
4170             31 => {
4171             Name => 'AEMinExposureTime',
4172             Notes => 'val = 24 * 2**((32-raw)/8)',
4173             ValueConv => '24*exp(-($val-32)*log(2)/8)',
4174             ValueConvInv => '-log($val/24)*8/log(2)+32',
4175             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
4176             PrintConvInv => 'Image::ExifTool::Exif::ConvertFraction($val)',
4177             },
4178             );
4179              
4180             # unknown auto-exposure information (Q, Q10)
4181             %Image::ExifTool::Pentax::AEInfoUnknown = (
4182             %binaryDataAttrs,
4183             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4184             );
4185              
4186             # lens type
4187             %Image::ExifTool::Pentax::LensRec = (
4188             %binaryDataAttrs,
4189             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4190             NOTES => q{
4191             This record stores the LensType, plus one or two unknown bytes for some
4192             models.
4193             },
4194             0 => {
4195             Name => 'LensType',
4196             Format => 'int8u[2]',
4197             Priority => 0,
4198             ValueConvInv => '$val=~s/\.\d+$//; $val',
4199             PrintConv => \%pentaxLensTypes,
4200             SeparateTable => 1,
4201             PrintInt => 1,
4202             },
4203             3 => { #PH
4204             Name => 'ExtenderStatus',
4205             Notes => 'not valid if a non-AF lens is used',
4206             PrintConv => { 0 => 'Not attached', 1 => 'Attached' },
4207             },
4208             # this is a binaryData table because some cameras add an extra
4209             # byte or two here (typically zeros)...
4210             );
4211              
4212             # lens information (ref PH)
4213             %Image::ExifTool::Pentax::LensInfo = (
4214             %binaryDataAttrs,
4215             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4216             IS_SUBDIR => [ 3 ],
4217             NOTES => 'Pentax lens information structure for models such as the *istD.',
4218             0 => {
4219             Name => 'LensType',
4220             Format => 'int8u[2]',
4221             Priority => 0,
4222             ValueConvInv => '$val=~s/\.\d+$//; $val',
4223             PrintConv => \%pentaxLensTypes,
4224             SeparateTable => 1,
4225             PrintInt => 1,
4226             },
4227             3 => {
4228             Name => 'LensData',
4229             Format => 'undef[17]',
4230             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::LensData' },
4231             },
4232             );
4233              
4234             # lens information for newer models (ref PH)
4235             %Image::ExifTool::Pentax::LensInfo2 = (
4236             %binaryDataAttrs,
4237             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4238             IS_SUBDIR => [ 4 ],
4239             NOTES => 'Pentax lens information structure for models such as the K10D and K20D.',
4240             0 => {
4241             Name => 'LensType',
4242             Format => 'int8u[4]',
4243             Priority => 0,
4244             ValueConv => q{
4245             my @v = split(' ',$val);
4246             $v[0] &= 0x0f;
4247             $v[1] = $v[2] * 256 + $v[3]; # (always high byte first)
4248             return "$v[0] $v[1]";
4249             },
4250             # just fill in the missing bits/bytes with zeros...
4251             ValueConvInv => q{
4252             my @v = split(' ',$val);
4253             return undef unless @v == 2;
4254             $v[2] = ($v[1] >> 8) & 0xff;
4255             $v[3] = $v[1] & 0xff;
4256             $v[1] = 0;
4257             return "@v";
4258             },
4259             PrintConv => \%pentaxLensTypes,
4260             SeparateTable => 1,
4261             PrintInt => 1,
4262             },
4263             4 => {
4264             Name => 'LensData',
4265             Format => 'undef[17]',
4266             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::LensData' },
4267             },
4268             );
4269              
4270             # lens information for 645D (ref PH)
4271             %Image::ExifTool::Pentax::LensInfo3 = (
4272             %binaryDataAttrs,
4273             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4274             IS_SUBDIR => [ 13 ],
4275             NOTES => 'Pentax lens information structure for 645D.',
4276             1 => {
4277             Name => 'LensType',
4278             Format => 'int8u[4]',
4279             Priority => 0,
4280             ValueConv => q{
4281             my @v = split(' ',$val);
4282             $v[0] &= 0x0f;
4283             $v[1] = $v[2] * 256 + $v[3]; # (always high byte first)
4284             return "$v[0] $v[1]";
4285             },
4286             # just fill in the missing bits/bytes with zeros...
4287             ValueConvInv => q{
4288             my @v = split(' ',$val);
4289             return undef unless @v == 2;
4290             $v[2] = ($v[1] >> 8) & 0xff;
4291             $v[3] = $v[1] & 0xff;
4292             $v[1] = 0;
4293             return "@v";
4294             },
4295             PrintConv => \%pentaxLensTypes,
4296             SeparateTable => 1,
4297             PrintInt => 1,
4298             },
4299             13 => {
4300             Name => 'LensData',
4301             Format => 'undef[17]',
4302             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::LensData' },
4303             },
4304             );
4305              
4306             # lens information for K-5, K-r, etc (ref PH)
4307             %Image::ExifTool::Pentax::LensInfo4 = (
4308             %binaryDataAttrs,
4309             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4310             IS_SUBDIR => [ 12 ],
4311             NOTES => 'Pentax lens information structure for models such as the K-5 and K-r.',
4312             1 => {
4313             Name => 'LensType',
4314             Format => 'int8u[4]',
4315             Priority => 0,
4316             ValueConv => q{
4317             my @v = split(' ',$val);
4318             $v[0] &= 0x0f;
4319             $v[1] = $v[2] * 256 + $v[3]; # (always high byte first)
4320             return "$v[0] $v[1]";
4321             },
4322             # just fill in the missing bits/bytes with zeros...
4323             ValueConvInv => q{
4324             my @v = split(' ',$val);
4325             return undef unless @v == 2;
4326             $v[2] = ($v[1] >> 8) & 0xff;
4327             $v[3] = $v[1] & 0xff;
4328             $v[1] = 0;
4329             return "@v";
4330             },
4331             PrintConv => \%pentaxLensTypes,
4332             SeparateTable => 1,
4333             PrintInt => 1,
4334             },
4335             12 => {
4336             Name => 'LensData',
4337             Format => 'undef[18]',
4338             Condition => '$$self{NewLensData} = 1', # not really a condition, just used to set flag
4339             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::LensData' },
4340             },
4341             );
4342              
4343             # lens information for K-01, K-30, K-50, K-500, K-3, K-3II, K-S1 (ref PH)
4344             %Image::ExifTool::Pentax::LensInfo5 = (
4345             %binaryDataAttrs,
4346             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4347             IS_SUBDIR => [ 15 ],
4348             NOTES => 'Pentax lens information structure for the K-01 and newer models.',
4349             1 => {
4350             Name => 'LensType',
4351             Format => 'int8u[5]',
4352             Priority => 0,
4353             ValueConv => q{
4354             my @v = split(' ',$val);
4355             $v[0] &= 0x0f;
4356             $v[1] = $v[3] * 256 + $v[4]; # (always high byte first)
4357             return "$v[0] $v[1]";
4358             },
4359             # just fill in the missing bits/bytes with zeros...
4360             ValueConvInv => q{
4361             my @v = split(' ',$val);
4362             return undef unless @v == 2;
4363             $v[3] = ($v[1] >> 8) & 0xff;
4364             $v[4] = $v[1] & 0xff;
4365             $v[1] = $v[2] = 0;
4366             return "@v";
4367             },
4368             PrintConv => \%pentaxLensTypes,
4369             SeparateTable => 1,
4370             PrintInt => 1,
4371             },
4372             15 => {
4373             Name => 'LensData',
4374             Format => 'undef[17]',
4375             SubDirectory => { TagTable => 'Image::ExifTool::Pentax::LensData' },
4376             },
4377             );
4378              
4379             # lens data information, including lens codes (ref PH)
4380             %Image::ExifTool::Pentax::LensData = (
4381             %binaryDataAttrs,
4382             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4383             DATAMEMBER => [ 12.1 ],
4384             NOTES => q{
4385             Pentax lens data information. Some of these tags require interesting binary
4386             gymnastics to decode them into useful values.
4387             },
4388             # this byte comes from the lens electrical contacts
4389             # (see http://kmp.bdimitrov.de/technology/K-mount/Ka.html)
4390             0.1 => { #JD
4391             Name => 'AutoAperture',
4392             Condition => 'not $$self{NewLensData}',
4393             Notes => 'not valid for the K-r, K-5 or K-5II', #29
4394             Mask => 0x01,
4395             PrintConv => { 0 => 'On', 1 => 'Off' },
4396             },
4397             0.2 => { #JD
4398             Name => 'MinAperture',
4399             Condition => 'not $$self{NewLensData}',
4400             Notes => 'not valid for the K-r, K-5 or K-5II', #29
4401             Mask => 0x06,
4402             PrintConv => {
4403             0 => 22,
4404             1 => 32,
4405             2 => 45,
4406             3 => 16,
4407             },
4408             },
4409             0.3 => { #JD
4410             Name => 'LensFStops',
4411             Condition => 'not $$self{NewLensData}',
4412             Notes => 'not valid for the K-r, K-5 or K-5II', #29
4413             Mask => 0x70,
4414             ValueConv => '5 + ($val ^ 0x07) / 2',
4415             ValueConvInv => '(($val - 5) * 2) ^ 0x07',
4416             },
4417             # 1-16 look like Lens Codes LC0-LC15, ref patent 5617173 and 5999753 [+notes by PH]
4418             1 => { # LC0 = lens kind + version data
4419             Name => 'LensKind',
4420             %lensCode,
4421             },
4422             2 => { # LC1 = lens data (changes with AF setting)
4423             Name => 'LC1',
4424             %lensCode,
4425             },
4426             # LC2 = distance data
4427             3 => { #29
4428             Name => 'MinFocusDistance',
4429             Notes => 'minimum focus distance for the lens',
4430             Mask => 0xf8,
4431             PrintConv => {
4432             0 => '0.13-0.19 m', # (plus K or M lenses)
4433             1 => '0.20-0.24 m',
4434             2 => '0.25-0.28 m',
4435             3 => '0.28-0.30 m',
4436             4 => '0.35-0.38 m',
4437             5 => '0.40-0.45 m',
4438             6 => '0.49-0.50 m', # (plus many Sigma lenses)
4439             7 => '0.6 m', #PH (NC)
4440             8 => '0.7 m', # (plus Sigma 55-200)
4441             9 => '0.8-0.9 m', #PH (NC) Tokina 28-70/2.6-2.8
4442             10 => '1.0 m', # (plus Sigma 70 macro)
4443             11 => '1.1-1.2 m',
4444             12 => '1.4-1.5 m',
4445             13 => '1.5 m', # Sigma 70-300/4-5.6 macro
4446             14 => '2.0 m',
4447             15 => '2.0-2.1 m', #PH (NC)
4448             16 => '2.1 m', # Sigma 135-400 APO & DG: 2.0-2.2m
4449             17 => '2.2-2.9 m', #PH (NC)
4450             18 => '3.0 m', # Sigma 50-500 : 1.0-3.0m depending on the focal length
4451             ## 50mm, 100mm => 1.0m
4452             ## 200mm => 1.1m
4453             ## 300mm => 1.5m
4454             ## 400mm => 2.2m
4455             ## 500mm => 3.0m
4456             19 => '4-5 m', #PH (NC)
4457             20 => '5.6 m', # Pentax DA 560
4458             # To check: Sigma 120-400 OS: MFD 1.5m
4459             # To check: Sigma 150-500 OS: MFD 2.2m
4460             # To check: Sigma 50-500 has MFD 50-180cm
4461             # 0xd0 - seen for the Sigma 4.5mm F2.8 EX DC HSM Circular Fisheye (ref PH)
4462             },
4463             },
4464             3.1 => { #29
4465             Name => 'FocusRangeIndex',
4466             Mask => 0x07,
4467             PrintConv => {
4468             7 => '0 (very close)',
4469             6 => '1 (close)',
4470             4 => '2',
4471             5 => '3',
4472             1 => '4',
4473             0 => '5',
4474             2 => '6 (far)',
4475             3 => '7 (very far)',
4476             },
4477             },
4478             4 => { # LC3 = K-value data (AF pulses to displace image by unit length)
4479             Name => 'LC3',
4480             %lensCode,
4481             },
4482             5 => { # LC4 = aberration correction, near distance data
4483             Name => 'LC4',
4484             %lensCode,
4485             },
4486             6 => { # LC5 = light color aberration correction data
4487             Name => 'LC5',
4488             %lensCode,
4489             },
4490             7 => { # LC6 = open aberration data
4491             Name => 'LC6',
4492             %lensCode,
4493             },
4494             8 => { # LC7 = AF minimum actuation condition
4495             Name => 'LC7',
4496             %lensCode,
4497             },
4498             9 => [{ # LC8 = focal length data
4499             Name => 'LensFocalLength',
4500             Notes => 'focal length of lens alone, without adapter', #PH
4501             Priority => 0,
4502             Condition => '$$self{Model} !~ /645Z/', #PH (doesn't work for 645Z)
4503             ValueConv => '10*($val>>2) * 4**(($val&0x03)-2)', #JD
4504             ValueConvInv => q{
4505             my $range = int(log($val/10)/(2*log(2)));
4506             warn("Value out of range") and return undef if $range < 0 or $range > 3;
4507             return $range + (int($val/(10*4**($range-2))+0.5) << 2);
4508             },
4509             PrintConv => 'sprintf("%.1f mm", $val)',
4510             PrintConvInv => '$val=~s/\s*mm//; $val',
4511             },{
4512             Name => 'LC8',
4513             %lensCode,
4514             }],
4515             # the following aperture values change with focal length
4516             10 => { # LC9 = nominal AVmin/AVmax data (open/closed aperture values)
4517             Name => 'NominalMaxAperture',
4518             Mask => 0xf0,
4519             ValueConv => '2**($val/4)', #JD
4520             ValueConvInv => '4*log($val)/log(2)',
4521             PrintConv => 'sprintf("%.1f", $val)',
4522             PrintConvInv => '$val',
4523             },
4524             10.1 => { # LC9 = nominal AVmin/AVmax data (open/closed aperture values)
4525             Name => 'NominalMinAperture',
4526             Mask => 0x0f,
4527             ValueConv => '2**(($val+10)/4)', #JD
4528             ValueConvInv => '4*log($val)/log(2) - 10',
4529             PrintConv => 'sprintf("%.0f", $val)',
4530             PrintConvInv => '$val',
4531             },
4532             11 => { # LC10 = mv'/nv' data (full-aperture metering error compensation/marginal lumination compensation)
4533             Name => 'LC10',
4534             %lensCode,
4535             },
4536             12 => { # LC11 = AVC 1/EXP data
4537             Name => 'LC11',
4538             %lensCode,
4539             },
4540             12.1 => {
4541             Name => 'NewLensDataHook',
4542             Hidden => 1,
4543             Hook => '$varSize += 1 if $$self{NewLensData}',
4544             RawConv => 'undef',
4545             },
4546             13 => { # LC12 = mv1 AVminsif data
4547             Name => 'LC12',
4548             Notes => "ID's 13-16 are offset by 1 for the K-r, K-5 and K-5II", #29
4549             %lensCode,
4550             },
4551             # 14 - related to live view for K-5 (normally 3, but 1 or 5 in LV mode)
4552             14.1 => { # LC13 = AVmin (open aperture value) [MaxAperture=(2**((AVmin-1)/32))]
4553             Name => 'MaxAperture',
4554             Condition => '$$self{Model} ne "K-5"',
4555             Notes => 'effective wide open aperture for current focal length',
4556             Mask => 0x7f, # (not sure what the high bit indicates)
4557             # (a value of 1 seems to indicate 'n/a')
4558             RawConv => '$val > 1 ? $val : undef',
4559             ValueConv => '2**(($val-1)/32)',
4560             ValueConvInv => '32*log($val)/log(2) + 1',
4561             PrintConv => 'sprintf("%.1f", $val)',
4562             PrintConvInv => '$val',
4563             },
4564             15 => { # LC14 = UNT_12 UNT_6 data
4565             Name => 'LC14',
4566             %lensCode,
4567             },
4568             16 => { # LC15 = incorporated flash suited END data
4569             Name => 'LC15',
4570             %lensCode,
4571             },
4572             );
4573              
4574             # flash information (ref PH)
4575             %Image::ExifTool::Pentax::FlashInfo = (
4576             %binaryDataAttrs,
4577             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4578             NOTES => 'Flash information tags for the K10D, K20D and K200D.',
4579             0 => {
4580             Name => 'FlashStatus',
4581             PrintHex => 1,
4582             PrintConv => { #19
4583             0x00 => 'Off',
4584             0x01 => 'Off (1)', #PH (K-5)
4585             0x02 => 'External, Did not fire', # 0010
4586             0x06 => 'External, Fired', # 0110
4587             0x08 => 'Internal, Did not fire (0x08)',
4588             0x09 => 'Internal, Did not fire', # 1001
4589             0x0d => 'Internal, Fired', # 1101
4590             },
4591             },
4592             1 => {
4593             Name => 'InternalFlashMode',
4594             PrintHex => 1,
4595             PrintConv => {
4596             0x00 => 'n/a - Off-Auto-Aperture', #19
4597             0x86 => 'Fired, Wireless (Control)', #19
4598             0x95 => 'Fired, Wireless (Master)', #19
4599             0xc0 => 'Fired', # K10D
4600             0xc1 => 'Fired, Red-eye reduction', # *istDS2, K10D
4601             0xc2 => 'Fired, Auto', # K100D, K110D
4602             0xc3 => 'Fired, Auto, Red-eye reduction', #PH
4603             0xc6 => 'Fired, Wireless (Control), Fired normally not as control', #19 (Remote 3s)
4604             0xc8 => 'Fired, Slow-sync', # K10D
4605             0xc9 => 'Fired, Slow-sync, Red-eye reduction', # K10D
4606             0xca => 'Fired, Trailing-curtain Sync', # K10D
4607             0xf0 => 'Did not fire, Normal', #19
4608             0xf1 => 'Did not fire, Red-eye reduction', #19
4609             0xf2 => 'Did not fire, Auto', #19
4610             0xf3 => 'Did not fire, Auto, Red-eye reduction', #19
4611             0xf4 => 'Did not fire, (Unknown 0xf4)', #19
4612             0xf5 => 'Did not fire, Wireless (Master)', #19
4613             0xf6 => 'Did not fire, Wireless (Control)', #19
4614             0xf8 => 'Did not fire, Slow-sync', #19
4615             0xf9 => 'Did not fire, Slow-sync, Red-eye reduction', #19
4616             0xfa => 'Did not fire, Trailing-curtain Sync', #19
4617             },
4618             },
4619             2 => {
4620             Name => 'ExternalFlashMode',
4621             PrintHex => 1,
4622             PrintConv => { #19
4623             0x00 => 'n/a - Off-Auto-Aperture',
4624             0x3f => 'Off',
4625             0x40 => 'On, Auto',
4626             0xbf => 'On, Flash Problem', #JD
4627             0xc0 => 'On, Manual',
4628             0xc4 => 'On, P-TTL Auto',
4629             0xc5 => 'On, Contrast-control Sync', #JD
4630             0xc6 => 'On, High-speed Sync',
4631             0xcc => 'On, Wireless',
4632             0xcd => 'On, Wireless, High-speed Sync',
4633             0xf0 => 'Not Connected', #PH (K-5)
4634             },
4635             },
4636             3 => {
4637             Name => 'InternalFlashStrength',
4638             Notes => 'saved from the most recent flash picture, on a scale of about 0 to 100',
4639             },
4640             4 => 'TTL_DA_AUp',
4641             5 => 'TTL_DA_ADown',
4642             6 => 'TTL_DA_BUp',
4643             7 => 'TTL_DA_BDown',
4644             24.1 => { #19/17
4645             Name => 'ExternalFlashGuideNumber',
4646             Mask => 0x1f,
4647             Notes => 'val = 2**(raw/16 + 4), with a few exceptions',
4648             ValueConv => q{
4649             return 0 unless $val;
4650             $val = -3 if $val == 29; # -3 is stored as 0x1d
4651             return 2**($val/16 + 4);
4652             },
4653             ValueConvInv => q{
4654             return 0 unless $val;
4655             my $raw = int((log($val)/log(2)-4)*16+0.5);
4656             $raw = 29 if $raw < 0; # guide number of 14 gives -3 which is stored as 0x1d
4657             $raw = 31 if $raw > 31; # maximum value is 0x1f
4658             return $raw;
4659             },
4660             PrintConv => '$val ? int($val + 0.5) : "n/a"',
4661             PrintConvInv => '$val=~/^n/ ? 0 : $val',
4662             # observed values for various flash focal lengths/guide numbers:
4663             # AF-540FGZ (ref 19) AF-360FGZ (ref 17)
4664             # 6 => 20mm/21 29 => 20mm/14 (wide angle panel used)
4665             # 16 => 24mm/32 6 => 24mm/21
4666             # 18 => 28mm/35 7 => 28mm/22
4667             # 21 => 35mm/39 10 => 35mm/25
4668             # 24 => 50mm/45 14 => 50mm/30
4669             # 26 => 70mm/50 17 => 70mm/33
4670             # 28 => 85mm/54 19 => 85mm/36
4671             # (I have also seen a value of 31 when both flashes are used together
4672             # in a wired configuration, but I don't know exactly what this means - PH)
4673             },
4674             # 24 - have seen bit 0x80 set when 2 external wired flashes are used - PH
4675             # 24 - have seen bit 0x40 set when wireless high speed sync is used - ref 19
4676             25 => { #19
4677             Name => 'ExternalFlashExposureComp',
4678             PrintConv => {
4679             0 => 'n/a', # Off or Auto Modes
4680             144 => 'n/a (Manual Mode)', # Manual Flash Output
4681             164 => '-3.0',
4682             167 => '-2.5',
4683             168 => '-2.0',
4684             171 => '-1.5',
4685             172 => '-1.0',
4686             175 => '-0.5',
4687             176 => '0.0',
4688             179 => '0.5',
4689             180 => '1.0',
4690             },
4691             },
4692             26 => { #17
4693             Name => 'ExternalFlashBounce',
4694             Notes => 'saved from the most recent external flash picture', #19
4695             PrintConv => {
4696             0 => 'n/a',
4697             16 => 'Direct',
4698             48 => 'Bounce',
4699             },
4700             },
4701             # ? => 'ExternalFlashAOutput',
4702             # ? => 'ExternalFlashBOutput',
4703             );
4704              
4705             %Image::ExifTool::Pentax::FlashInfoUnknown = (
4706             %binaryDataAttrs,
4707             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4708             # 4 - changes with FEC for K-5 - PH
4709             );
4710              
4711             # camera manufacture information (ref PH)
4712             %Image::ExifTool::Pentax::CameraInfo = (
4713             %binaryDataAttrs,
4714             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4715             FORMAT => 'int32u',
4716             0 => {
4717             Name => 'PentaxModelID',
4718             Priority => 0, # (Optio SVi uses incorrect Optio SV ID here)
4719             SeparateTable => 1,
4720             PrintHex => 1,
4721             PrintConv => \%pentaxModelID,
4722             },
4723             1 => {
4724             Name => 'ManufactureDate',
4725             Groups => { 2 => 'Time' },
4726             Notes => q{
4727             this value, and the values of the tags below, may change if the camera is
4728             serviced
4729             },
4730             ValueConv => q{
4731             $val =~ /^(\d{4})(\d{2})(\d{2})$/ and return "$1:$2:$3";
4732             # Optio A10 and A20 leave "200" off the year
4733             $val =~ /^(\d)(\d{2})(\d{2})$/ and return "200$1:$2:$3";
4734             return "Unknown ($val)";
4735             },
4736             ValueConvInv => '$val=~tr/0-9//dc; $val',
4737             },
4738             2 => {
4739             #(see http://www.pentaxforums.com/forums/pentax-dslr-discussion/25711-k10d-update-model-revision-8-1-yes-no-8.html)
4740             Name => 'ProductionCode', #(previously ModelRevision)
4741             Format => 'int32u[2]',
4742             Note => 'values of 8.x indicate that the camera has been serviced',
4743             ValueConv => '$val=~tr/ /./; $val',
4744             ValueConvInv => '$val=~tr/./ /; $val',
4745             PrintConv => '$val=~/^8\./ ? "$val (camera has been serviced)" : $val',
4746             PrintConvInv => '$val=~s/\s+.*//s; $val',
4747             },
4748             4 => 'InternalSerialNumber',
4749             );
4750              
4751             # battery information (ref PH)
4752             %Image::ExifTool::Pentax::BatteryInfo = (
4753             %binaryDataAttrs,
4754             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4755             # size of data:
4756             # 4 (K-m,K2000=4xAA), 6 (*istD,K10D,K100D,K110D=2xCR-V3/4xAA),
4757             # 7 (K20D=D-LI50, K200D=4xAA), 8 (645D=D-LI90), 10 (K-r pre-production?),
4758             # 14 (K-7=D-LI90, K-r=D-LI109/4xAA, K-x=4xAA), 26 (K-5=D-LI90)
4759             # battery grips available for:
4760             # BG1 (*istD), BG2 (K10D/K20D), BG3 (K200D), BG4 (K-7,K-5)
4761             # no grip available: K-x
4762             0.1 => [{ #19
4763             Name => 'PowerSource',
4764             Condition => '$$self{Model} !~ /K-3 Mark III/',
4765             Mask => 0x0f,
4766             # have seen the upper bit set (value of 0x82) for the
4767             # *istDS and K100D, but I'm not sure what this means - PH
4768             # I've also seen: 0x42 (K2000), 0xf2 (K-7,K-r,K-5), 0x12,0x22 (K-x) - PH
4769             PrintConv => {
4770             1 => 'Camera Battery', #PH (NC, GR III)
4771             2 => 'Body Battery',
4772             3 => 'Grip Battery',
4773             4 => 'External Power Supply', #PH
4774             },
4775             },{ #PH (forum15976)
4776             Name => 'PowerSource',
4777             Mask => 0x0f,
4778             Notes => 'K-3III',
4779             # have seen the upper bit set (value of 0x82) for the
4780             # *istDS and K100D, but I'm not sure what this means - PH
4781             # I've also seen: 0x42 (K2000), 0xf2 (K-7,K-r,K-5), 0x12,0x22 (K-x) - PH
4782             PrintConv => {
4783             1 => 'Body Battery',
4784             2 => 'Grip Battery',
4785             4 => 'External Power Supply',
4786             },
4787             }],
4788             0.2 => {
4789             Name => 'PowerAvailable',
4790             Condition => '$$self{Model} =~ /K-3 Mark III/',
4791             Notes => 'K-3III',
4792             Mask => 0xf0,
4793             PrintConv => { BITMASK => {
4794             0 => 'Body Battery',
4795             1 => 'Grip Battery',
4796             3 => 'External Power Supply',
4797             }},
4798             },
4799             1.1 => [
4800             {
4801             Name => 'BodyBatteryState',
4802             Condition => '$$self{Model} =~ /(\*ist|K100D|K200D|K10D|GX10|K20D|GX20|GX-1[LS]?)\b/',
4803             Notes => '*istD, K100D, K200D, K10D and K20D',
4804             Mask => 0xf0,
4805             PrintConv => { #19
4806             1 => 'Empty or Missing',
4807             2 => 'Almost Empty',
4808             3 => 'Running Low',
4809             4 => 'Full',
4810             },
4811             },{
4812             Name => 'BodyBatteryState',
4813             Condition => '$$self{Model} !~ /(K110D|K2000|K-m|K-3 Mark III)\b/',
4814             Notes => 'most other models except the K110D, K2000, K-m and K-3III',
4815             Mask => 0xf0,
4816             PrintConv => {
4817             1 => 'Empty or Missing',
4818             2 => 'Almost Empty',
4819             3 => 'Running Low',
4820             4 => 'Close to Full',
4821             5 => 'Full',
4822             },
4823             },
4824             ],
4825             1.2 => [
4826             {
4827             Name => 'GripBatteryState',
4828             Condition => '$$self{Model} =~ /(K10D|GX10|K20D|GX20)\b/',
4829             Notes => 'K10D and K20D',
4830             Mask => 0x0f,
4831             PrintConv => { #19
4832             1 => 'Empty or Missing',
4833             2 => 'Almost Empty',
4834             3 => 'Running Low',
4835             4 => 'Full',
4836             },
4837             },
4838             ],
4839             # internal and grip battery voltage Analogue to Digital measurements,
4840             # open circuit and under load
4841             2 => [
4842             {
4843             Name => 'BodyBatteryADNoLoad',
4844             Description => 'Body Battery A/D No Load',
4845             Condition => '$$self{Model} =~ /(K10D|GX10|K20D|GX20)\b/',
4846             Notes => 'roughly calibrated for K10D with a new Pentax battery',
4847             # rough linear calibration drops quickly below 30% - PH
4848             # DVM readings: 8.18V=186, 8.42-8.40V=192 (full), 6.86V=155 (empty)
4849             PrintConv => 'sprintf("%d (%.1fV, %d%%)",$val,$val*8.18/186,($val-155)*100/35)',
4850             PrintConvInv => '$val=~s/ .*//; $val',
4851             },
4852             {
4853             Name => 'BodyBatteryADNoLoad',
4854             Description => 'Body Battery A/D No Load',
4855             Condition => '$$self{Model} =~ /(\*ist|K100D|K200D|GX-1[LS]?)\b/',
4856             },
4857             {
4858             Name => 'BodyBatteryVoltage1', # (static?)
4859             Condition => '$$self{Model} =~ /(645D|645Z|K-(1|01|3|5|7|30|50|70|500|r|x|S[12])|KP)\b/ and $$self{Model} !~ /III/',
4860             Format => 'int16u',
4861             ValueConv => '$val / 100',
4862             ValueConvInv => '$val * 100',
4863             PrintConv => 'sprintf("%.2f V", $val)',
4864             PrintConvInv => '$val =~ s/\s*V$//',
4865             # For my K-5: Min (0%) Max (100%) At Meas
4866             # BodyBatteryVoltage1 6.24 V 7.75 V 7.66 V
4867             # BodyBatteryVoltage2 5.98 V 7.43 V 7.34 V
4868             # BodyBatteryVoltage3 6.41 V 7.93 V 7.84 V
4869             # BodyBatteryVoltage4 6.10 V 7.55 V 7.45 V
4870             # "Meas" open-circuit voltages with DVM: AB=0V, AC=+8.33V, BC=+8.22V
4871             # (terminal "C" is closest to edge of battery)
4872             },{
4873             Name => 'BodyBatteryState',
4874             Condition => '$$self{Model} =~ /K-3 Mark III/',
4875             Notes => 'K-3III',
4876             PrintConv => {
4877             0 => 'Empty or Missing',
4878             1 => 'Almost Empty',
4879             2 => 'Running Low',
4880             3 => 'Half Full',
4881             4 => 'Close to Full',
4882             5 => 'Full',
4883             },
4884             }
4885             ],
4886             3 => [
4887             {
4888             Name => 'BodyBatteryADLoad',
4889             Description => 'Body Battery A/D Load',
4890             Condition => '$$self{Model} =~ /(K10D|GX10|K20D|GX20)\b/',
4891             Notes => 'roughly calibrated for K10D with a new Pentax battery',
4892             # [have seen 187] - PH
4893             PrintConv => 'sprintf("%d (%.1fV, %d%%)",$val,$val*8.18/186,($val-152)*100/34)',
4894             PrintConvInv => '$val=~s/ .*//; $val',
4895             },
4896             {
4897             Name => 'BodyBatteryADLoad',
4898             Description => 'Body Battery A/D Load',
4899             Condition => '$$self{Model} =~ /(\*ist|K100D|K200D)\b/',
4900             },{
4901             Name => 'BodyBatteryPercent',
4902             Condition => '$$self{Model} =~ /K-3 Mark III/',
4903             Notes => 'K-3III',
4904             }
4905             ],
4906             4 => [
4907             {
4908             Name => 'GripBatteryADNoLoad',
4909             Description => 'Grip Battery A/D No Load',
4910             Condition => '$$self{Model} =~ /(\*ist|K10D|GX10|K20D|GX20|GX-1[LS]?)\b/',
4911             },
4912             {
4913             Name => 'BodyBatteryVoltage2', # (less than BodyBatteryVoltage1 -- under load?)
4914             Condition => '$$self{Model} =~ /(645D|645Z|K-(1|01|3|5|7|30|50|70|500|r|x|S[12])|KP)\b/ and $$self{Model} !~ /III/',
4915             Format => 'int16u',
4916             ValueConv => '$val / 100',
4917             ValueConvInv => '$val * 100',
4918             PrintConv => 'sprintf("%.2f V", $val)',
4919             PrintConvInv => '$val =~ s/\s*V$//',
4920             },
4921             {
4922             Name => 'BodyBatteryVoltage',
4923             Condition => '$$self{Model} =~ /K-3 Mark III/',
4924             Format => 'int32u',
4925             ValueConv => '$val * 4e-8 + 0.27219',
4926             ValueConvInv => '($val - 0.27219) / 4e-8',
4927             PrintConv => 'sprintf("%.2f V", $val)',
4928             PrintConvInv => '$val =~ s/\s*V$//',
4929             },
4930             ],
4931             5 => {
4932             Name => 'GripBatteryADLoad',
4933             Condition => '$$self{Model} =~ /(\*ist|K10D|GX10|K20D|GX20)\b/',
4934             Description => 'Grip Battery A/D Load',
4935             },
4936             6 => {
4937             Name => 'BodyBatteryVoltage3', # (greater than BodyBatteryVoltage1)
4938             Condition => '$$self{Model} =~ /(K-5|K-r|645D)\b/',
4939             Format => 'int16u',
4940             Notes => 'K-5, K-r and 645D only',
4941             ValueConv => '$val / 100',
4942             ValueConvInv => '$val * 100',
4943             PrintConv => 'sprintf("%.2f V", $val)',
4944             PrintConvInv => '$val =~ s/\s*V$//',
4945             },
4946             8 => {
4947             Name => 'BodyBatteryVoltage4', # (between BodyBatteryVoltage1 and BodyBatteryVoltage2)
4948             Condition => '$$self{Model} =~ /(K-5|K-r)\b/',
4949             Format => 'int16u',
4950             Notes => 'K-5 and K-r only',
4951             ValueConv => '$val / 100',
4952             ValueConvInv => '$val * 100',
4953             PrintConv => 'sprintf("%.2f V", $val)',
4954             PrintConvInv => '$val =~ s/\s*V$//',
4955             },
4956             16 => {
4957             Name => 'GripBatteryState',
4958             Condition => '$$self{Model} =~ /K-3 Mark III/',
4959             Notes => 'K-3III',
4960             PrintConv => {
4961             0 => 'Empty or Missing',
4962             1 => 'Almost Empty',
4963             2 => 'Running Low',
4964             3 => 'Half Full',
4965             4 => 'Close to Full',
4966             5 => 'Full',
4967             },
4968             },
4969             17 => {
4970             Name => 'GripBatteryPercent',
4971             Condition => '$$self{Model} =~ /K-3 Mark III/',
4972             Notes => 'K-3III',
4973             },
4974             18 => {
4975             Name => 'GripBatteryVoltage',
4976             Condition => '$$self{Model} =~ /K-3 Mark III/',
4977             Notes => 'K-3III',
4978             Format => 'int32u',
4979             ValueConv => '$val * 4e-8 + 0.27219',
4980             ValueConvInv => '($val - 0.27219) / 4e-8',
4981             PrintConv => 'sprintf("%.2f V", $val)',
4982             PrintConvInv => '$val =~ s/\s*V$//',
4983             },
4984             );
4985              
4986             # auto focus information
4987             %Image::ExifTool::Pentax::AFInfo = (
4988             %binaryDataAttrs,
4989             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
4990             # AF Info tag names in K10D debugging output - PH:
4991             # SelectArea, InFocusArea, Predictor, Defocus, IntegTime2msStep,
4992             # CalFlag, ContrastFlag, PrecalFlag, SelectSensor
4993             0x00 => { #PH
4994             Name => 'AFPointsUnknown1',
4995             Condition => '$$self{Model} !~ /K-3 Mark III/', # (and maybe others?)
4996             Unknown => 1,
4997             Format => 'int16u',
4998             ValueConv => '$self->Options("Unknown") ? $val : $val & 0x7ff',
4999             ValueConvInv => '$val',
5000             PrintConvColumns => 2,
5001             PrintConv => {
5002             0 => '(none)',
5003             0x07ff => 'All',
5004             0x0777 => 'Central 9 points',
5005             BITMASK => {
5006             0 => 'Upper-left',
5007             1 => 'Top',
5008             2 => 'Upper-right',
5009             3 => 'Left',
5010             4 => 'Mid-left',
5011             5 => 'Center',
5012             6 => 'Mid-right',
5013             7 => 'Right',
5014             8 => 'Lower-left',
5015             9 => 'Bottom',
5016             10 => 'Lower-right',
5017             # (bits 12-15 are flags of some sort)
5018             },
5019             },
5020             },
5021             0x02 => { #PH
5022             Name => 'AFPointsUnknown2',
5023             Condition => '$$self{Model} !~ /K-3 Mark III/', # (and maybe others?)
5024             Unknown => 1,
5025             Format => 'int16u',
5026             ValueConv => '$self->Options("Unknown") ? $val : $val & 0x7ff',
5027             ValueConvInv => '$val',
5028             PrintConvColumns => 2,
5029             PrintConv => {
5030             0 => 'Auto',
5031             BITMASK => {
5032             0 => 'Upper-left',
5033             1 => 'Top',
5034             2 => 'Upper-right',
5035             3 => 'Left',
5036             4 => 'Mid-left',
5037             5 => 'Center',
5038             6 => 'Mid-right',
5039             7 => 'Right',
5040             8 => 'Lower-left',
5041             9 => 'Bottom',
5042             10 => 'Lower-right',
5043             # (bits 12-15 are flags of some sort)
5044             # bit 15 is set for center focus point only if it is vertical
5045             },
5046             },
5047             },
5048             0x04 => { #PH (educated guess - predicted amount to drive lens)
5049             Name => 'AFPredictor',
5050             Format => 'int16s',
5051             },
5052             0x06 => 'AFDefocus', #PH (educated guess - calculated distance from focused)
5053             0x07 => { #PH
5054             # effective exposure time for AF sensors in 2 ms increments
5055             Name => 'AFIntegrationTime',
5056             Notes => 'times less than 2 ms give a value of 0',
5057             ValueConv => '$val * 2',
5058             ValueConvInv => 'int($val / 2)', # (don't round up)
5059             PrintConv => '"$val ms"',
5060             PrintConvInv => '$val=~tr/0-9//dc; $val',
5061             },
5062             # 0x0a - values: 00,05,0d,15,86,8e,a6,ae
5063             0x0b => { #JD
5064             Name => 'AFPointsInFocus',
5065             Condition => '$$self{Model} !~ /(K-(1|3|70|S1|S2)|KP)\b/', #KG: valid also for K-S1/S2
5066             Notes => q{
5067             models other than the K-1, K-3, K-70, KP and K-S1/S2. May report two points
5068             in focus even though a single AFPoint has been selected, in which case the
5069             selected AFPoint is the first reported
5070             },
5071             PrintConvColumns => 2,
5072             PrintConv => {
5073             0 => 'None',
5074             1 => 'Lower-left, Bottom',
5075             2 => 'Bottom',
5076             3 => 'Lower-right, Bottom',
5077             4 => 'Mid-left, Center',
5078             5 => 'Center (horizontal)', #PH
5079             6 => 'Mid-right, Center',
5080             7 => 'Upper-left, Top',
5081             8 => 'Top',
5082             9 => 'Upper-right, Top',
5083             10 => 'Right',
5084             11 => 'Lower-left, Mid-left',
5085             12 => 'Upper-left, Mid-left',
5086             13 => 'Bottom, Center',
5087             14 => 'Top, Center',
5088             15 => 'Lower-right, Mid-right',
5089             16 => 'Upper-right, Mid-right',
5090             17 => 'Left',
5091             18 => 'Mid-left',
5092             19 => 'Center (vertical)', #PH
5093             20 => 'Mid-right',
5094             },
5095             },
5096             0x14 => {
5097             Name => 'AFPointValues',
5098             Condition => '$$self{Model} =~ /K-3 Mark III/', #KG
5099             Format => 'int16uRev[69]',
5100             Unknown => 1,
5101             Notes => 'some unknown values related to each AFPoint',
5102             # order is the same as AFPointsSelected below, but there is an additional value for
5103             # each AF point starting at offset 28 in the array (yes, the range overlaps
5104             # with the 1st values)
5105             # (values are int16s stored in reversed byte order)
5106             ValueConv => 'my @a=split " ",$val;$_>32767 and $_-=65536 foreach @a;join " ",@a',
5107             PrintConv => \&AFPointValuesK3III,
5108             },
5109             0x12a => {
5110             Name => 'AFPointsSelected', # (should probably be "AFPointSelected", but the bitmask allows multiple points)
5111             Condition => '$$self{Model} =~ /K-3 Mark III/',
5112             Notes => q{
5113             K-3III only. 41 selectable AF points from a total of 101 available in a 13x9
5114             grid. Columns are labelled A-M and rows are 1-9. The center point is G5. The
5115             exact meaning of this tag is not fully understood, although it does seem
5116             related to the selected AF point
5117             },
5118             Format => 'int8u[101]',
5119             # value of 1 means "selected point", and 2 means "center of selected area"
5120             PrintConv => \&AFPointNamesK3III,
5121             },
5122             #
5123             # (maybe not coincidentally, there are 60 unknown bytes
5124             # here, and there are also 60 non-selectable AF points)
5125             #
5126             0x18f => { # byte has a value of 1 if corresponding AF point is ... in focus maybe?
5127             # usually the same points as AFPointsSelected above, but not always
5128             Name => 'AFPointsUnknown',
5129             Condition => '$$self{Model} =~ /K-3 Mark III/', #KG
5130             Unknown => 1,
5131             Format => 'int8u[101]',
5132             PrintConv => \&AFPointNamesK3III,
5133             },
5134             0x1fa => {
5135             Name => 'LiveView',
5136             Notes => 'decoded only for the K-3 III',
5137             Condition => '$$self{Model} =~ /K-3 Mark III/', #KG
5138             PrintConv => { 0 => 'Off', 1 => 'On' },
5139             },
5140             0x1fd => {
5141             Name => 'AFHold',
5142             Notes => 'decoded only for the K-3 II',
5143             Condition => '$$self{Model} eq "PENTAX K-3 II"',
5144             PrintConv => { 0 => 'Off', 1 => 'Short', 2 => 'Medium', 3 => 'Long' },
5145             },
5146             0x021f => { #KG
5147             Name => 'FirstFrameActionInAFC',
5148             Condition => '$$self{Model} =~ /K-3 Mark III/',
5149             PrintConv => {
5150             '0' => 'Auto',
5151             '1' => 'Release Priority',
5152             '2' => 'Focus Priority',
5153             # there is at least another value '3' but I couldn't figure out the
5154             # meaning. However, this occurs for a few AF-S captures, so it has
5155             # no real practical meaning.
5156             },
5157             },
5158             0x0220 => { #KG
5159             Name => 'ActionInAFCCont',
5160             Condition => '$$self{Model} =~ /K-3 Mark III/',
5161             PrintConv => {
5162             '0' => 'Auto',
5163             '1' => 'Focus Priority',
5164             '2' => 'FPS Priority',
5165             },
5166             },
5167             545 => { #KG
5168             Name => 'AFCHold',
5169             Condition => '$$self{Model} =~ /K-3 Mark III/',
5170             Mask => 0x03,
5171             PrintConv => { 0 => 'Low', 1 => 'Medium', 2 => 'High', 3 => 'Off' },
5172             },
5173             545.1 => { #KG
5174             Name => 'AFCPointTracking',
5175             Condition => '$$self{Model} =~ /K-3 Mark III/',
5176             Mask => 0x0c,
5177             PrintConv => { 0 => 'Type 1', 1 => 'Type 2', 2 => 'Type 3' },
5178             },
5179             545.2 => { #KG
5180             Name => 'AFCSensitivity',
5181             Condition => '$$self{Model} =~ /K-3 Mark III/',
5182             Mask => 0x70,
5183             PrintConv => '5 - $val',
5184             PrintConvInv => '5 - $val',
5185             },
5186             0x0960 => { #KG
5187             Name => 'SubjectRecognition',
5188             Condition => '$$self{Model} =~ /K-3 Mark III/',
5189             PrintConv => {
5190             0 => 'Off',
5191             1 => 'On',
5192             },
5193             },
5194             );
5195              
5196             # AF information for K-01 and later (ref Karsten Gieselmann private communication)
5197             %Image::ExifTool::Pentax::CAFPointInfo = (
5198             %binaryDataAttrs,
5199             FIRST_ENTRY => 0,
5200             DATAMEMBER => [ 1 ],
5201             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5202             NOTES => 'Contrast-detect AF-point information for the K-01 and later models.',
5203             1 => {
5204             Name => 'NumCAFPoints',
5205             RawConv => '$$self{NumCAFPoints} = ($val & 0x0f) * ($val >> 4); $val',
5206             ValueConv => '($val >> 4) * ($val & 0x0f)',
5207             },
5208             1.1 => {
5209             Name => 'CAFGridSize',
5210             ValueConv => '($val >> 4) . " " . ($val & 0x0f)', # (width x height)
5211             PrintConv => '$val =~ tr/ /x/; $val',
5212             },
5213             2 => {
5214             Name => 'CAFPointsInFocus',
5215             Format => 'int8u[int(($val{1}+3)/4)]',
5216             Writable => 0,
5217             PrintConv => 'Image::ExifTool::Pentax::DecodeAFPoints($val,$$self{NumCAFPoints},2,0x02)',
5218             },
5219             2.1 => {
5220             Name => 'CAFPointsSelected',
5221             Format => 'int8u[int(($val{1}+3)/4)]',
5222             Writable => 0,
5223             PrintConv => 'Image::ExifTool::Pentax::DecodeAFPoints($val,$$self{NumCAFPoints},2,0x03)',
5224             },
5225             );
5226              
5227             # Kelvin white balance information (ref 28, topic 4834)
5228             %Image::ExifTool::Pentax::KelvinWB = (
5229             %binaryDataAttrs,
5230             FORMAT => 'int16u',
5231             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5232             NOTES => 'White balance Blue/Red gains as a function of color temperature.',
5233             1 => { Name => 'KelvinWB_Daylight', %kelvinWB },
5234             5 => { Name => 'KelvinWB_01', %kelvinWB },
5235             9 => { Name => 'KelvinWB_02', %kelvinWB },
5236             13 => { Name => 'KelvinWB_03', %kelvinWB },
5237             17 => { Name => 'KelvinWB_04', %kelvinWB },
5238             21 => { Name => 'KelvinWB_05', %kelvinWB },
5239             25 => { Name => 'KelvinWB_06', %kelvinWB },
5240             29 => { Name => 'KelvinWB_07', %kelvinWB },
5241             33 => { Name => 'KelvinWB_08', %kelvinWB },
5242             37 => { Name => 'KelvinWB_09', %kelvinWB },
5243             41 => { Name => 'KelvinWB_10', %kelvinWB },
5244             45 => { Name => 'KelvinWB_11', %kelvinWB },
5245             49 => { Name => 'KelvinWB_12', %kelvinWB },
5246             53 => { Name => 'KelvinWB_13', %kelvinWB },
5247             57 => { Name => 'KelvinWB_14', %kelvinWB },
5248             61 => { Name => 'KelvinWB_15', %kelvinWB },
5249             65 => { Name => 'KelvinWB_16', %kelvinWB },
5250             );
5251              
5252             # color information - PH
5253             %Image::ExifTool::Pentax::ColorInfo = (
5254             %binaryDataAttrs,
5255             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
5256             FORMAT => 'int8s',
5257             16 => {
5258             Name => 'WBShiftAB',
5259             Notes => 'positive is a shift toward blue',
5260             },
5261             17 => {
5262             Name => 'WBShiftGM',
5263             Notes => 'positive is a shift toward green',
5264             },
5265             );
5266              
5267             # EV step size information - ref 19
5268             %Image::ExifTool::Pentax::EVStepInfo = (
5269             %binaryDataAttrs,
5270             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5271             0 => {
5272             Name => 'EVSteps',
5273             PrintConv => {
5274             0 => '1/2 EV Steps',
5275             1 => '1/3 EV Steps',
5276             },
5277             },
5278             1 => {
5279             Name => 'SensitivitySteps',
5280             PrintConv => {
5281             0 => '1 EV Steps',
5282             1 => 'As EV Steps',
5283             },
5284             },
5285             3 => { #PH
5286             Name => 'LiveView',
5287             PrintConv => { 0 => 'Off', 1 => 'On' },
5288             },
5289             );
5290              
5291             # shot information? - ref PH (K-5)
5292             %Image::ExifTool::Pentax::ShotInfo = (
5293             %binaryDataAttrs,
5294             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5295             # 0: 0xf2/0xf3 (HDR), 0xf0 (otherwise)
5296             1 => { # (presumably this is from an orientation sensor)
5297             Name => 'CameraOrientation',
5298             Condition => '$$self{Model} =~ /K-(5|7|r|x)\b/',
5299             Notes => 'K-5, K-7, K-r and K-x',
5300             PrintHex => 1,
5301             PrintConv => {
5302             0x10 => 'Horizontal (normal)',
5303             0x20 => 'Rotate 180',
5304             0x30 => 'Rotate 90 CW',
5305             0x40 => 'Rotate 270 CW',
5306             0x50 => 'Upwards', # (to the sky)
5307             0x60 => 'Downwards', # (to the ground)
5308             },
5309             },
5310             # 2: 0xd3 (live view), 0xdb (HDR), 0x7b (otherwise)
5311             # 3: 0xff
5312             # 4: 0x64, 0x6a, 0x6f, 0xa4, 0xaa, 0xab, 0xbf
5313             # 5: 0xfe
5314             # 6: 0x0e
5315             # 7: 0x02 (live view), 0x06 (otherwise)
5316             # 8-10: 0x00
5317             );
5318              
5319             # face detect positions - ref PH (Optio RZ10)
5320             %Image::ExifTool::Pentax::FacePos = (
5321             %binaryDataAttrs,
5322             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
5323             FORMAT => 'int16u',
5324             0 => {
5325             Name => 'Face1Position',
5326             Format => 'int16u[2]',
5327             RawConv => '$$self{FacesDetected} < 1 ? undef : $val',
5328             Notes => 'X/Y coordinates of face center in full-sized image',
5329             },
5330             2 => {
5331             Name => 'Face2Position',
5332             Format => 'int16u[2]',
5333             RawConv => '$$self{FacesDetected} < 2 ? undef : $val',
5334             },
5335             4 => {
5336             Name => 'Face3Position',
5337             Format => 'int16u[2]',
5338             RawConv => '$$self{FacesDetected} < 3 ? undef : $val',
5339             },
5340             6 => {
5341             Name => 'Face4Position',
5342             Format => 'int16u[2]',
5343             RawConv => '$$self{FacesDetected} < 4 ? undef : $val',
5344             },
5345             8 => {
5346             Name => 'Face5Position',
5347             Format => 'int16u[2]',
5348             RawConv => '$$self{FacesDetected} < 5 ? undef : $val',
5349             },
5350             10 => {
5351             Name => 'Face6Position',
5352             Format => 'int16u[2]',
5353             RawConv => '$$self{FacesDetected} < 6 ? undef : $val',
5354             },
5355             12 => {
5356             Name => 'Face7Position',
5357             Format => 'int16u[2]',
5358             RawConv => '$$self{FacesDetected} < 7 ? undef : $val',
5359             },
5360             14 => {
5361             Name => 'Face8Position',
5362             Format => 'int16u[2]',
5363             RawConv => '$$self{FacesDetected} < 8 ? undef : $val',
5364             },
5365             16 => {
5366             Name => 'Face9Position',
5367             Format => 'int16u[2]',
5368             RawConv => '$$self{FacesDetected} < 9 ? undef : $val',
5369             },
5370             18 => {
5371             Name => 'Face10Position',
5372             Format => 'int16u[2]',
5373             RawConv => '$$self{FacesDetected} < 10 ? undef : $val',
5374             },
5375             20 => {
5376             Name => 'Face11Position',
5377             Format => 'int16u[2]',
5378             RawConv => '$$self{FacesDetected} < 11 ? undef : $val',
5379             },
5380             22 => {
5381             Name => 'Face12Position',
5382             Format => 'int16u[2]',
5383             RawConv => '$$self{FacesDetected} < 12 ? undef : $val',
5384             },
5385             24 => {
5386             Name => 'Face13Position',
5387             Format => 'int16u[2]',
5388             RawConv => '$$self{FacesDetected} < 13 ? undef : $val',
5389             },
5390             26 => {
5391             Name => 'Face14Position',
5392             Format => 'int16u[2]',
5393             RawConv => '$$self{FacesDetected} < 14 ? undef : $val',
5394             },
5395             28 => {
5396             Name => 'Face15Position',
5397             Format => 'int16u[2]',
5398             RawConv => '$$self{FacesDetected} < 15 ? undef : $val',
5399             },
5400             30 => {
5401             Name => 'Face16Position',
5402             Format => 'int16u[2]',
5403             RawConv => '$$self{FacesDetected} < 16 ? undef : $val',
5404             },
5405             32 => {
5406             Name => 'Face17Position',
5407             Format => 'int16u[2]',
5408             RawConv => '$$self{FacesDetected} < 17 ? undef : $val',
5409             },
5410             34 => {
5411             Name => 'Face18Position',
5412             Format => 'int16u[2]',
5413             RawConv => '$$self{FacesDetected} < 18 ? undef : $val',
5414             },
5415             36 => {
5416             Name => 'Face19Position',
5417             Format => 'int16u[2]',
5418             RawConv => '$$self{FacesDetected} < 19 ? undef : $val',
5419             },
5420             38 => {
5421             Name => 'Face20Position',
5422             Format => 'int16u[2]',
5423             RawConv => '$$self{FacesDetected} < 20 ? undef : $val',
5424             },
5425             40 => {
5426             Name => 'Face21Position',
5427             Format => 'int16u[2]',
5428             RawConv => '$$self{FacesDetected} < 21 ? undef : $val',
5429             },
5430             42 => {
5431             Name => 'Face22Position',
5432             Format => 'int16u[2]',
5433             RawConv => '$$self{FacesDetected} < 22 ? undef : $val',
5434             },
5435             44 => {
5436             Name => 'Face23Position',
5437             Format => 'int16u[2]',
5438             RawConv => '$$self{FacesDetected} < 23 ? undef : $val',
5439             },
5440             46 => {
5441             Name => 'Face24Position',
5442             Format => 'int16u[2]',
5443             RawConv => '$$self{FacesDetected} < 24 ? undef : $val',
5444             },
5445             48 => {
5446             Name => 'Face25Position',
5447             Format => 'int16u[2]',
5448             RawConv => '$$self{FacesDetected} < 25 ? undef : $val',
5449             },
5450             50 => {
5451             Name => 'Face26Position',
5452             Format => 'int16u[2]',
5453             RawConv => '$$self{FacesDetected} < 26 ? undef : $val',
5454             },
5455             52 => {
5456             Name => 'Face27Position',
5457             Format => 'int16u[2]',
5458             RawConv => '$$self{FacesDetected} < 27 ? undef : $val',
5459             },
5460             54 => {
5461             Name => 'Face28Position',
5462             Format => 'int16u[2]',
5463             RawConv => '$$self{FacesDetected} < 28 ? undef : $val',
5464             },
5465             56 => {
5466             Name => 'Face29Position',
5467             Format => 'int16u[2]',
5468             RawConv => '$$self{FacesDetected} < 29 ? undef : $val',
5469             },
5470             58 => {
5471             Name => 'Face30Position',
5472             Format => 'int16u[2]',
5473             RawConv => '$$self{FacesDetected} < 30 ? undef : $val',
5474             },
5475             60 => {
5476             Name => 'Face31Position',
5477             Format => 'int16u[2]',
5478             RawConv => '$$self{FacesDetected} < 31 ? undef : $val',
5479             },
5480             62 => {
5481             Name => 'Face32Position',
5482             Format => 'int16u[2]',
5483             RawConv => '$$self{FacesDetected} < 32 ? undef : $val',
5484             },
5485             );
5486              
5487             # face detect sizes - ref PH (Optio RZ10)
5488             %Image::ExifTool::Pentax::FaceSize = (
5489             %binaryDataAttrs,
5490             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
5491             FORMAT => 'int16u',
5492             0 => {
5493             Name => 'Face1Size',
5494             Format => 'int16u[2]',
5495             RawConv => '$$self{FacesDetected} < 1 ? undef : $val',
5496             },
5497             2 => {
5498             Name => 'Face2Size',
5499             Format => 'int16u[2]',
5500             RawConv => '$$self{FacesDetected} < 2 ? undef : $val',
5501             },
5502             4 => {
5503             Name => 'Face3Size',
5504             Format => 'int16u[2]',
5505             RawConv => '$$self{FacesDetected} < 3 ? undef : $val',
5506             },
5507             6 => {
5508             Name => 'Face4Size',
5509             Format => 'int16u[2]',
5510             RawConv => '$$self{FacesDetected} < 4 ? undef : $val',
5511             },
5512             8 => {
5513             Name => 'Face5Size',
5514             Format => 'int16u[2]',
5515             RawConv => '$$self{FacesDetected} < 5 ? undef : $val',
5516             },
5517             10 => {
5518             Name => 'Face6Size',
5519             Format => 'int16u[2]',
5520             RawConv => '$$self{FacesDetected} < 6 ? undef : $val',
5521             },
5522             12 => {
5523             Name => 'Face7Size',
5524             Format => 'int16u[2]',
5525             RawConv => '$$self{FacesDetected} < 7 ? undef : $val',
5526             },
5527             14 => {
5528             Name => 'Face8Size',
5529             Format => 'int16u[2]',
5530             RawConv => '$$self{FacesDetected} < 8 ? undef : $val',
5531             },
5532             16 => {
5533             Name => 'Face9Size',
5534             Format => 'int16u[2]',
5535             RawConv => '$$self{FacesDetected} < 9 ? undef : $val',
5536             },
5537             18 => {
5538             Name => 'Face10Size',
5539             Format => 'int16u[2]',
5540             RawConv => '$$self{FacesDetected} < 10 ? undef : $val',
5541             },
5542             20 => {
5543             Name => 'Face11Size',
5544             Format => 'int16u[2]',
5545             RawConv => '$$self{FacesDetected} < 11 ? undef : $val',
5546             },
5547             22 => {
5548             Name => 'Face12Size',
5549             Format => 'int16u[2]',
5550             RawConv => '$$self{FacesDetected} < 12 ? undef : $val',
5551             },
5552             24 => {
5553             Name => 'Face13Size',
5554             Format => 'int16u[2]',
5555             RawConv => '$$self{FacesDetected} < 13 ? undef : $val',
5556             },
5557             26 => {
5558             Name => 'Face14Size',
5559             Format => 'int16u[2]',
5560             RawConv => '$$self{FacesDetected} < 14 ? undef : $val',
5561             },
5562             28 => {
5563             Name => 'Face15Size',
5564             Format => 'int16u[2]',
5565             RawConv => '$$self{FacesDetected} < 15 ? undef : $val',
5566             },
5567             30 => {
5568             Name => 'Face16Size',
5569             Format => 'int16u[2]',
5570             RawConv => '$$self{FacesDetected} < 16 ? undef : $val',
5571             },
5572             32 => {
5573             Name => 'Face17Size',
5574             Format => 'int16u[2]',
5575             RawConv => '$$self{FacesDetected} < 17 ? undef : $val',
5576             },
5577             34 => {
5578             Name => 'Face18Size',
5579             Format => 'int16u[2]',
5580             RawConv => '$$self{FacesDetected} < 18 ? undef : $val',
5581             },
5582             36 => {
5583             Name => 'Face19Size',
5584             Format => 'int16u[2]',
5585             RawConv => '$$self{FacesDetected} < 19 ? undef : $val',
5586             },
5587             38 => {
5588             Name => 'Face20Size',
5589             Format => 'int16u[2]',
5590             RawConv => '$$self{FacesDetected} < 20 ? undef : $val',
5591             },
5592             40 => {
5593             Name => 'Face21Size',
5594             Format => 'int16u[2]',
5595             RawConv => '$$self{FacesDetected} < 21 ? undef : $val',
5596             },
5597             42 => {
5598             Name => 'Face22Size',
5599             Format => 'int16u[2]',
5600             RawConv => '$$self{FacesDetected} < 22 ? undef : $val',
5601             },
5602             44 => {
5603             Name => 'Face23Size',
5604             Format => 'int16u[2]',
5605             RawConv => '$$self{FacesDetected} < 23 ? undef : $val',
5606             },
5607             46 => {
5608             Name => 'Face24Size',
5609             Format => 'int16u[2]',
5610             RawConv => '$$self{FacesDetected} < 24 ? undef : $val',
5611             },
5612             48 => {
5613             Name => 'Face25Size',
5614             Format => 'int16u[2]',
5615             RawConv => '$$self{FacesDetected} < 25 ? undef : $val',
5616             },
5617             50 => {
5618             Name => 'Face26Size',
5619             Format => 'int16u[2]',
5620             RawConv => '$$self{FacesDetected} < 26 ? undef : $val',
5621             },
5622             52 => {
5623             Name => 'Face27Size',
5624             Format => 'int16u[2]',
5625             RawConv => '$$self{FacesDetected} < 27 ? undef : $val',
5626             },
5627             54 => {
5628             Name => 'Face28Size',
5629             Format => 'int16u[2]',
5630             RawConv => '$$self{FacesDetected} < 28 ? undef : $val',
5631             },
5632             56 => {
5633             Name => 'Face29Size',
5634             Format => 'int16u[2]',
5635             RawConv => '$$self{FacesDetected} < 29 ? undef : $val',
5636             },
5637             58 => {
5638             Name => 'Face30Size',
5639             Format => 'int16u[2]',
5640             RawConv => '$$self{FacesDetected} < 30 ? undef : $val',
5641             },
5642             60 => {
5643             Name => 'Face31Size',
5644             Format => 'int16u[2]',
5645             RawConv => '$$self{FacesDetected} < 31 ? undef : $val',
5646             },
5647             62 => {
5648             Name => 'Face32Size',
5649             Format => 'int16u[2]',
5650             RawConv => '$$self{FacesDetected} < 32 ? undef : $val',
5651             },
5652             );
5653              
5654             # digital filter information - ref PH (K-5)
5655             %Image::ExifTool::Pentax::FilterInfo = (
5656             %binaryDataAttrs,
5657             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
5658             FORMAT => 'int8u',
5659             NOTES => q{
5660             The parameters associated with each type of digital filter are unique, and
5661             these settings are also extracted with the DigitalFilter tag. Information
5662             is not extracted for filters that are "Off" unless the L option is
5663             used.
5664             },
5665             0 => {
5666             Name => 'SourceDirectoryIndex',
5667             Format => 'int16u',
5668             },
5669             2 => {
5670             Name => 'SourceFileIndex',
5671             Format => 'int16u',
5672             },
5673             0x005 => { Name => 'DigitalFilter01', %digitalFilter },
5674             0x016 => { Name => 'DigitalFilter02', %digitalFilter },
5675             0x027 => { Name => 'DigitalFilter03', %digitalFilter },
5676             0x038 => { Name => 'DigitalFilter04', %digitalFilter },
5677             0x049 => { Name => 'DigitalFilter05', %digitalFilter },
5678             0x05a => { Name => 'DigitalFilter06', %digitalFilter },
5679             0x06b => { Name => 'DigitalFilter07', %digitalFilter },
5680             0x07c => { Name => 'DigitalFilter08', %digitalFilter },
5681             0x08d => { Name => 'DigitalFilter09', %digitalFilter },
5682             0x09e => { Name => 'DigitalFilter10', %digitalFilter },
5683             0x0af => { Name => 'DigitalFilter11', %digitalFilter },
5684             0x0c0 => { Name => 'DigitalFilter12', %digitalFilter },
5685             0x0d1 => { Name => 'DigitalFilter13', %digitalFilter },
5686             0x0e2 => { Name => 'DigitalFilter14', %digitalFilter },
5687             0x0f3 => { Name => 'DigitalFilter15', %digitalFilter },
5688             0x104 => { Name => 'DigitalFilter16', %digitalFilter },
5689             0x115 => { Name => 'DigitalFilter17', %digitalFilter },
5690             0x126 => { Name => 'DigitalFilter18', %digitalFilter },
5691             0x137 => { Name => 'DigitalFilter19', %digitalFilter },
5692             0x148 => { Name => 'DigitalFilter20', %digitalFilter },
5693             );
5694              
5695             # electronic level information - ref PH (K-5)
5696             %Image::ExifTool::Pentax::LevelInfo = (
5697             %binaryDataAttrs,
5698             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5699             FORMAT => 'int8s',
5700             NOTES => q{
5701             Tags decoded from the electronic level information for the K-5. May not be
5702             valid for other models.
5703             },
5704             0 => {
5705             Name => 'LevelOrientation',
5706             Mask => 0x0f,
5707             PrintHex => 0,
5708             PrintConv => {
5709             0 => 'n/a', #PH (NC, GR III)
5710             1 => 'Horizontal (normal)',
5711             2 => 'Rotate 180',
5712             3 => 'Rotate 90 CW',
5713             4 => 'Rotate 270 CW',
5714             9 => 'Horizontal; Off Level',
5715             10 => 'Rotate 180; Off Level',
5716             11 => 'Rotate 90 CW; Off Level',
5717             12 => 'Rotate 270 CW; Off Level',
5718             13 => 'Upwards',
5719             14 => 'Downwards',
5720             },
5721             },
5722             0.1 => {
5723             Name => 'CompositionAdjust',
5724             Mask => 0xf0,
5725             PrintConv => {
5726             0 => 'Off',
5727             2 => 'Composition Adjust',
5728             10 => 'Composition Adjust + Horizon Correction',
5729             12 => 'Horizon Correction',
5730             },
5731             },
5732             1 => {
5733             Name => 'RollAngle',
5734             Notes => 'converted to degrees of clockwise camera rotation',
5735             ValueConv => '-$val / 2',
5736             ValueConvInv => '-$val * 2',
5737             },
5738             2 => {
5739             Name => 'PitchAngle',
5740             Notes => 'converted to degrees of upward camera tilt',
5741             ValueConv => '-$val / 2',
5742             ValueConvInv => '-$val * 2',
5743             },
5744             # 3,4 - related somehow to horizon correction and composition adjust
5745             # 5,6,7 - (the notes below refer to how the image moves in the LCD monitor)
5746             5 => {
5747             Name => 'CompositionAdjustX',
5748             Notes => 'steps to the right, 1/16 mm per step',
5749             ValueConv => '-$val',
5750             ValueConvInv => '-$val',
5751             },
5752             6 => {
5753             Name => 'CompositionAdjustY',
5754             Notes => 'steps up, 1/16 mm per step',
5755             ValueConv => '-$val',
5756             ValueConvInv => '-$val',
5757             },
5758             7 => {
5759             Name => 'CompositionAdjustRotation',
5760             Notes => 'steps clockwise, 1/8 degree per step',
5761             ValueConv => '-$val / 2',
5762             ValueConvInv => '-$val * 2',
5763             },
5764             );
5765              
5766             %Image::ExifTool::Pentax::LevelInfoK3III = (
5767             %binaryDataAttrs,
5768             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5769             FORMAT => 'int8s',
5770             NOTES => 'Tags decoded from the electronic level information for the K-3 III.',
5771             1 => {
5772             Name => 'CameraOrientation',
5773             PrintConv => {
5774             0 => 'Horizontal (normal)',
5775             1 => 'Rotate 270 CW',
5776             2 => 'Rotate 180',
5777             3 => 'Rotate 90 CW',
5778             4 => 'Upwards', # (to the sky)
5779             5 => 'Downwards', # (to the ground)
5780             },
5781             },
5782             3 => {
5783             Name => 'RollAngle',
5784             Notes => 'converted to degrees of clockwise camera rotation',
5785             Format => 'int16s',
5786             ValueConv => '-$val / 2',
5787             ValueConvInv => '-$val * 2',
5788             },
5789             5 => {
5790             Name => 'PitchAngle',
5791             Notes => 'converted to degrees of upward camera tilt',
5792             Format => 'int16s',
5793             ValueConv => '-$val / 2',
5794             ValueConvInv => '-$val * 2',
5795             },
5796             );
5797              
5798             %Image::ExifTool::Pentax::FaceInfoK3III = (
5799             %binaryDataAttrs,
5800             GROUPS => { 0 => 'MakerNotes', 2 => 'Image' },
5801             FORMAT => 'int32u',
5802             DATAMEMBER => [ 6, 8 ],
5803             0.1 => {
5804             Name => 'FaceInfoK3III',
5805             Format => 'int32u[$size/4]',
5806             Notes => q{
5807             entire FaceInfoK3III structure. Provides access to raw numerical values and
5808             facilitates the writing of the whole structure
5809             },
5810             Unknown => 1,
5811             },
5812             0 => { Name => 'FaceImageSize', Format => 'int32u[2]' },
5813             2 => { Name => 'CAFArea', Format => 'int32u[4]', Notes => 'top, left, width, height' },
5814             6 => { Name => 'FacesDetectedA', RawConv => '$$self{FacesA} = $val' },
5815             8 => { Name => 'FacesDetectedB', RawConv => '$$self{FacesA} = $val' },
5816             10 => { Name => 'Face1AArea', Condition => '$$self{FacesA} >= 1', Format => 'int32u[4]' },
5817             14 => { Name => 'Face1AEye1', Condition => '$$self{FacesA} >= 1', Format => 'int32u[4]' },
5818             18 => { Name => 'Face1AEye2', Condition => '$$self{FacesA} >= 1', Format => 'int32u[4]' },
5819             30 => { Name => 'Face2AArea', Condition => '$$self{FacesA} >= 2', Format => 'int32u[4]' },
5820             34 => { Name => 'Face2AEye1', Condition => '$$self{FacesA} >= 2', Format => 'int32u[4]' },
5821             38 => { Name => 'Face2AEye2', Condition => '$$self{FacesA} >= 2', Format => 'int32u[4]' },
5822             50 => { Name => 'Face3AArea', Condition => '$$self{FacesA} >= 3', Format => 'int32u[4]' },
5823             54 => { Name => 'Face3AEye1', Condition => '$$self{FacesA} >= 3', Format => 'int32u[4]' },
5824             58 => { Name => 'Face3AEye2', Condition => '$$self{FacesA} >= 3', Format => 'int32u[4]' },
5825             70 => { Name => 'Face4AArea', Condition => '$$self{FacesA} >= 4', Format => 'int32u[4]' },
5826             74 => { Name => 'Face4AEye1', Condition => '$$self{FacesA} >= 4', Format => 'int32u[4]' },
5827             78 => { Name => 'Face4AEye2', Condition => '$$self{FacesA} >= 4', Format => 'int32u[4]' },
5828             90 => { Name => 'Face5AArea', Condition => '$$self{FacesA} >= 5', Format => 'int32u[4]' },
5829             94 => { Name => 'Face5AEye1', Condition => '$$self{FacesA} >= 5', Format => 'int32u[4]' },
5830             98 => { Name => 'Face5AEye2', Condition => '$$self{FacesA} >= 5', Format => 'int32u[4]' },
5831             110 => { Name => 'Face6AArea', Condition => '$$self{FacesA} >= 6', Format => 'int32u[4]' },
5832             114 => { Name => 'Face6AEye1', Condition => '$$self{FacesA} >= 6', Format => 'int32u[4]' },
5833             118 => { Name => 'Face6AEye2', Condition => '$$self{FacesA} >= 6', Format => 'int32u[4]' },
5834             130 => { Name => 'Face7AArea', Condition => '$$self{FacesA} >= 7', Format => 'int32u[4]' },
5835             134 => { Name => 'Face7AEye1', Condition => '$$self{FacesA} >= 7', Format => 'int32u[4]' },
5836             138 => { Name => 'Face7AEye2', Condition => '$$self{FacesA} >= 7', Format => 'int32u[4]' },
5837             150 => { Name => 'Face8AArea', Condition => '$$self{FacesA} >= 8', Format => 'int32u[4]' },
5838             154 => { Name => 'Face8AEye1', Condition => '$$self{FacesA} >= 8', Format => 'int32u[4]' },
5839             158 => { Name => 'Face8AEye2', Condition => '$$self{FacesA} >= 8', Format => 'int32u[4]' },
5840             170 => { Name => 'Face9AArea', Condition => '$$self{FacesA} >= 9', Format => 'int32u[4]' },
5841             174 => { Name => 'Face9AEye1', Condition => '$$self{FacesA} >= 9', Format => 'int32u[4]' },
5842             178 => { Name => 'Face9AEye2', Condition => '$$self{FacesA} >= 9', Format => 'int32u[4]' },
5843             190 => { Name => 'Face10AArea',Condition => '$$self{FacesA} >= 10', Format => 'int32u[4]' },
5844             194 => { Name => 'Face10AEye1',Condition => '$$self{FacesA} >= 10', Format => 'int32u[4]' },
5845             198 => { Name => 'Face10AEye2',Condition => '$$self{FacesA} >= 10', Format => 'int32u[4]' },
5846             210 => { Name => 'Face1BArea', Condition => '$$self{FacesA} >= 1', Format => 'int32u[4]' },
5847             214 => { Name => 'Face1BEye1', Condition => '$$self{FacesA} >= 1', Format => 'int32u[4]' },
5848             218 => { Name => 'Face1BEye2', Condition => '$$self{FacesA} >= 1', Format => 'int32u[4]' },
5849             230 => { Name => 'Face2BArea', Condition => '$$self{FacesA} >= 2', Format => 'int32u[4]' },
5850             234 => { Name => 'Face2BEye1', Condition => '$$self{FacesA} >= 2', Format => 'int32u[4]' },
5851             238 => { Name => 'Face2BEye2', Condition => '$$self{FacesA} >= 2', Format => 'int32u[4]' },
5852             250 => { Name => 'Face3BArea', Condition => '$$self{FacesA} >= 3', Format => 'int32u[4]' },
5853             254 => { Name => 'Face3BEye1', Condition => '$$self{FacesA} >= 3', Format => 'int32u[4]' },
5854             258 => { Name => 'Face3BEye2', Condition => '$$self{FacesA} >= 3', Format => 'int32u[4]' },
5855             270 => { Name => 'Face4BArea', Condition => '$$self{FacesA} >= 4', Format => 'int32u[4]' },
5856             274 => { Name => 'Face4BEye1', Condition => '$$self{FacesA} >= 4', Format => 'int32u[4]' },
5857             278 => { Name => 'Face4BEye2', Condition => '$$self{FacesA} >= 4', Format => 'int32u[4]' },
5858             290 => { Name => 'Face5BArea', Condition => '$$self{FacesA} >= 5', Format => 'int32u[4]' },
5859             294 => { Name => 'Face5BEye1', Condition => '$$self{FacesA} >= 5', Format => 'int32u[4]' },
5860             298 => { Name => 'Face5BEye2', Condition => '$$self{FacesA} >= 5', Format => 'int32u[4]' },
5861             310 => { Name => 'Face6BArea', Condition => '$$self{FacesA} >= 6', Format => 'int32u[4]' },
5862             314 => { Name => 'Face6BEye1', Condition => '$$self{FacesA} >= 6', Format => 'int32u[4]' },
5863             318 => { Name => 'Face6BEye2', Condition => '$$self{FacesA} >= 6', Format => 'int32u[4]' },
5864             330 => { Name => 'Face7BArea', Condition => '$$self{FacesA} >= 7', Format => 'int32u[4]' },
5865             334 => { Name => 'Face7BEye1', Condition => '$$self{FacesA} >= 7', Format => 'int32u[4]' },
5866             338 => { Name => 'Face7BEye2', Condition => '$$self{FacesA} >= 7', Format => 'int32u[4]' },
5867             350 => { Name => 'Face8BArea', Condition => '$$self{FacesA} >= 8', Format => 'int32u[4]' },
5868             354 => { Name => 'Face8BEye1', Condition => '$$self{FacesA} >= 8', Format => 'int32u[4]' },
5869             358 => { Name => 'Face8BEye2', Condition => '$$self{FacesA} >= 8', Format => 'int32u[4]' },
5870             370 => { Name => 'Face9BArea', Condition => '$$self{FacesA} >= 9', Format => 'int32u[4]' },
5871             374 => { Name => 'Face9BEye1', Condition => '$$self{FacesA} >= 9', Format => 'int32u[4]' },
5872             378 => { Name => 'Face9BEye2', Condition => '$$self{FacesA} >= 9', Format => 'int32u[4]' },
5873             390 => { Name => 'Face10BArea',Condition => '$$self{FacesA} >= 10', Format => 'int32u[4]' },
5874             394 => { Name => 'Face10BEye1',Condition => '$$self{FacesA} >= 10', Format => 'int32u[4]' },
5875             398 => { Name => 'Face10BEye2',Condition => '$$self{FacesA} >= 10', Format => 'int32u[4]' },
5876             );
5877              
5878             %Image::ExifTool::Pentax::AFInfoK3III = (
5879             %binaryDataAttrs,
5880             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5881             FORMAT => 'int16u',
5882             DATAMEMBER => [ 2, 3 ],
5883             NOTES => 'AF tags written by the K-3 Mark III, GR III, GR IIIx and GR IV.',
5884             0 => {
5885             Name => 'AFInfoK3III',
5886             Format => 'int16u[$size/2]',
5887             Notes => q{
5888             entire AFInfoK3III structure. Provides access to raw numerical values and
5889             facilitates the writing of the whole structure
5890             },
5891             Unknown => 1,
5892             },
5893             0.1 => {
5894             Name => 'AFMode',
5895             PrintConv => {
5896             0 => 'Phase Detect',
5897             2 => 'Contrast Detect',
5898             255 => 'Manual Focus',
5899             },
5900             },
5901             1 => {
5902             Name => 'AFSelectionMode',
5903             PrintHex => 1,
5904             PrintConv => {
5905             0 => 'Manual Focus',
5906             1 => 'Spot',
5907             2 => 'Select (5-points)',
5908             3 => 'Expanded Area (S)',
5909             4 => 'Expanded Area (M)',
5910             5 => 'Expanded Area (L)',
5911             6 => 'Select (S)',
5912             7 => 'Zone Select (21-point)',
5913             8 => 'Select XS',
5914             0xff => 'Auto Area',
5915             # Contrast-detect modes
5916             0x2001 => 'Contrast-detect Auto Area',
5917             0x2002 => 'Contrast-detect Select', # (GR III)
5918             0x2003 => 'Pinpoint', # (GR III)
5919             0x2004 => 'Tracking',
5920             0x2005 => 'Continuous', # (GR III)
5921             0x2006 => 'Face Detection',
5922             0x2007 => 'Contrast-detect Select (S)',
5923             0x2008 => 'Contrast-detect Select (M)',
5924             0x2009 => 'Contrast-detect Select (L)',
5925             0x200a => 'Contrast-detect Zone Select', # (GR III)
5926             0x200b => 'Contrast-detect Spot',
5927             },
5928             },
5929             2 => {
5930             Name => 'MaxNumAFPoints',
5931             RawConv => '$$self{MaxNumAFPoints} = $val',
5932             },
5933             3 => {
5934             Name => 'NumAFPoints',
5935             RawConv => '$$self{NumAFPoints} = $val',
5936             },
5937             # the data for each AF point consists of 7 int16u values:
5938             # the frame width/height, the X/Y position of the focus area,
5939             # width/height of the focus area (0/0 for phase-detect modes),
5940             # followed by a flags word
5941             7 => { # (the same for all areas in my samples, so only extract the first)
5942             Name => 'AFFrameSize',
5943             Condition => '$$self{NumAFPoints} > 0',
5944             Format => 'int16u[2]',
5945             Writable => 0,
5946             PrintConv => '$val=~s/ /x/; $val',
5947             },
5948             7.1 => {
5949             Name => 'AFAreas',
5950             Format => 'int16u[7 * $val{3}]',
5951             Notes => q{
5952             X,Y position of each AF area, width, with "in-focus" for points in focus,
5953             "central" for the center of the selected area, or "peripheral" for points
5954             outside the selected area
5955             },
5956             Writable => 0,
5957             List => 1, # (for documentation purposes only)
5958             PrintConv => \&AFAreasK3III,
5959             },
5960             11 => { # (the same for all areas in my samples, so only extract the first)
5961             Name => 'AFAreaSize',
5962             Condition => '$$self{NumAFPoints} > 0 and $$valPt !~ /^\0\0\0\0/',
5963             Notes => 'only for contrast-detect modes',
5964             Format => 'int16u[2]',
5965             Writable => 0,
5966             PrintConv => '$val=~s/ /x/; $val',
5967             },
5968             );
5969              
5970             # white balance RGGB levels (ref 28)
5971             %Image::ExifTool::Pentax::WBLevels = (
5972             %binaryDataAttrs,
5973             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
5974             # 0 - 11 (number of entries in this table)
5975             # 1 - 0
5976             2 => {
5977             Name => 'WB_RGGBLevelsDaylight',
5978             Format => 'int16u[4]',
5979             },
5980             # 10 - 1
5981             11 => {
5982             Name => 'WB_RGGBLevelsShade',
5983             Format => 'int16u[4]',
5984             },
5985             # 19 - 2
5986             20 => {
5987             Name => 'WB_RGGBLevelsCloudy',
5988             Format => 'int16u[4]',
5989             },
5990             # 28 - 3
5991             29 => {
5992             Name => 'WB_RGGBLevelsTungsten',
5993             Format => 'int16u[4]',
5994             },
5995             # 37 - 4
5996             38 => {
5997             Name => 'WB_RGGBLevelsFluorescentD',
5998             Format => 'int16u[4]',
5999             },
6000             # 46 - 5
6001             47 => {
6002             Name => 'WB_RGGBLevelsFluorescentN',
6003             Format => 'int16u[4]',
6004             },
6005             # 55 - 6
6006             56 => {
6007             Name => 'WB_RGGBLevelsFluorescentW',
6008             Format => 'int16u[4]',
6009             },
6010             # 64 - 7
6011             65 => {
6012             Name => 'WB_RGGBLevelsFlash',
6013             Format => 'int16u[4]',
6014             },
6015             # 73 - 8
6016             74 => {
6017             Name => 'WB_RGGBLevelsFluorescentL',
6018             Format => 'int16u[4]',
6019             },
6020             # 82 - 0xfe
6021             83 => {
6022             Name => 'WB_RGGBLevelsUnknown',
6023             Format => 'int16u[4]',
6024             Unknown => 1,
6025             },
6026             # 91 - 0xff
6027             92 => {
6028             Name => 'WB_RGGBLevelsUserSelected',
6029             Format => 'int16u[4]',
6030             },
6031             );
6032              
6033             # lens information for Pentax Q (ref PH)
6034             # (306 bytes long, I wonder if this contains vignetting information too?)
6035             %Image::ExifTool::Pentax::LensInfoQ = (
6036             %binaryDataAttrs,
6037             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6038             NOTES => 'More lens information stored by the Pentax Q.',
6039             0x0c => {
6040             Name => 'LensModel',
6041             Format => 'string[30]',
6042             },
6043             0x2a => {
6044             Name => 'LensInfo',
6045             Format => 'string[20]',
6046             ValueConv => '$val=~s/mm/mm /; $val',
6047             ValueConvInv => '$val=~tr/ //d; $val',
6048             }
6049             );
6050              
6051             # Pixel shift information for the K-3II (ref PH)
6052             %Image::ExifTool::Pentax::PixelShiftInfo = (
6053             %binaryDataAttrs,
6054             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6055             NOTES => 'Pixel shift information stored by the K-3 II.',
6056             0x00 => {
6057             Name => 'PixelShiftResolution',
6058             PrintConv => { 0 => 'Off', 1 => 'On' },
6059             },
6060             );
6061              
6062             # AF point information for the K-1 (ref 29)
6063             %Image::ExifTool::Pentax::AFPointInfo = (
6064             %binaryDataAttrs,
6065             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6066             DATAMEMBER => [ 2 ],
6067             NOTES => 'AF point information written by the K-1.',
6068             # 0 - int16u: 1 (version?)
6069             2 => {
6070             Name => 'NumAFPoints',
6071             Format => 'int16u',
6072             RawConv => '$$self{NumAFPoints} = $val',
6073             },
6074             4 => {
6075             Name => 'AFPointsInFocus',
6076             Condition => '$$self{Model} =~ /K(P|-1|-70)\b/',
6077             Format => 'int8u[int(($val{2}+3)/4)]',
6078             Writable => 0,
6079             PrintConv => 'Image::ExifTool::Pentax::DecodeAFPoints($val,$$self{NumAFPoints},2,0x02)',
6080             },
6081             4.1 => {
6082             Name => 'AFPointsSelected',
6083             Condition => '$$self{Model} =~ /K(P|-1|-70)\b/',
6084             Format => 'int8u[int(($val{2}+3)/4)]',
6085             Writable => 0,
6086             PrintConv => 'Image::ExifTool::Pentax::DecodeAFPoints($val,$$self{NumAFPoints},2,0x03)',
6087             },
6088             4.2 => {
6089             Name => 'AFPointsSpecial',
6090             Condition => '$$self{Model} =~ /K(P|-1|-70)\b/',
6091             Format => 'int8u[int(($val{2}+3)/4)]',
6092             Writable => 0,
6093             PrintConv => 'Image::ExifTool::Pentax::DecodeAFPoints($val,$$self{NumAFPoints},2,0x03,0x03)',
6094             },
6095             );
6096              
6097             # temperature information for some models - PH
6098             %Image::ExifTool::Pentax::TempInfo = (
6099             %binaryDataAttrs,
6100             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6101             NOTES => q{
6102             A number of additional temperature readings are extracted from this 256-byte
6103             binary-data block in images from models such as the K-01, K-3, K-5, K-50 and
6104             K-500. It is currently not known where the corresponding temperature
6105             sensors are located in the camera.
6106             },
6107             0x0a => { #KG
6108             Name => 'ShotNumber',
6109             Condition => '$$self{Model} =~ /K-3 Mark III/',
6110             # The exact same method to detect this tag with a similar set of files
6111             # does not reveal anything for K-1. Is this only available for K-3-III ?
6112             # Internal representation starts at 0 for the 1st shot
6113             ValueConv => '$val+1',
6114             },
6115             # (it would be nice to know where these temperature sensors are located,
6116             # but since according to the manual the Slow Shutter Speed NR Auto mode
6117             # is based on "internal temperature", my guess is that there must be
6118             # at least one on the sensor itself. These temperatures seem to rise
6119             # more quickly than CameraTemperature when shooting video.)
6120             0x0c => {
6121             Name => 'SensorTemperature', #forum6677 (was CameraTemperature2)
6122             Condition => '$$self{Model} !~ /K-3 Mark III/', # (and maybe others?)
6123             Format => 'int16s',
6124             ValueConv => '$val / 10',
6125             ValueConvInv => '$val * 10',
6126             PrintConv => 'sprintf("%.1f C", $val)',
6127             PrintConvInv => '$val=~s/ ?c$//i; $val',
6128             },
6129             0x0e => {
6130             Name => 'SensorTemperature2', #forum6677 (was CameraTemperature3)
6131             Condition => '$$self{Model} !~ /K-3 Mark III/', # (and maybe others?)
6132             Format => 'int16s',
6133             ValueConv => '$val / 10',
6134             ValueConvInv => '$val * 10',
6135             PrintConv => 'sprintf("%.1f C", $val)',
6136             PrintConvInv => '$val=~s/ ?c$//i; $val',
6137             },
6138             0x14 => {
6139             Name => 'CameraTemperature4',
6140             Condition => '$$self{Model} =~ /K-5\b/',
6141             Format => 'int16s',
6142             PrintConv => '"$val C"',
6143             PrintConvInv => '$val=~s/ ?c$//i; $val',
6144             },
6145             0x16 => { # usually the same as CameraTemperature4, but not always
6146             Name => 'CameraTemperature5',
6147             Condition => '$$self{Model} =~ /K-5\b/',
6148             Format => 'int16s',
6149             PrintConv => '"$val C"',
6150             PrintConvInv => '$val=~s/ ?c$//i; $val',
6151             },
6152             # 0x18,0x1a,0x1c,0x1e = int16u[4] BlackPoint - PH
6153             0x2a => {
6154             Name => 'SensorTemperature',
6155             Condition => '$$self{Model} =~ /K-3 Mark III/',
6156             Format => 'int16s',
6157             ValueConv => '$val / 10',
6158             ValueConvInv => '$val * 10',
6159             PrintConv => 'sprintf("%.1f C", $val)',
6160             PrintConvInv => '$val=~s/ ?c$//i; $val',
6161             },
6162             );
6163              
6164             # currently unknown info
6165             %Image::ExifTool::Pentax::UnknownInfo = (
6166             %binaryDataAttrs,
6167             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6168             # K10D: first 8 bytes seem to be short integers which change with ISO (value
6169             # is usually close to ISO/100) possibly smoothing or gain parameters? - PH
6170             # byte 0-1 - Higher for high color temperatures (red boost or red noise suppression?)
6171             # byte 6-7 - Higher for low color temperatures (blue boost or blue noise suppression?)
6172             # also changing are bytes 10,11,14,15
6173             );
6174              
6175             # Pentax type 2 (Casio-like) maker notes (ref 1)
6176             %Image::ExifTool::Pentax::Type2 = (
6177             WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
6178             CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
6179             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6180             WRITABLE => 'int16u',
6181             NOTES => q{
6182             These tags are used by the Pentax Optio 330 and 430, and are similar to the
6183             tags used by Casio.
6184             },
6185             0x0001 => {
6186             Name => 'RecordingMode',
6187             PrintConv => {
6188             0 => 'Auto',
6189             1 => 'Night Scene',
6190             2 => 'Manual',
6191             },
6192             },
6193             0x0002 => {
6194             Name => 'Quality',
6195             PrintConv => {
6196             0 => 'Good',
6197             1 => 'Better',
6198             2 => 'Best',
6199             },
6200             },
6201             0x0003 => {
6202             Name => 'FocusMode',
6203             PrintConv => {
6204             2 => 'Custom',
6205             3 => 'Auto',
6206             },
6207             },
6208             0x0004 => {
6209             Name => 'FlashMode',
6210             PrintConv => {
6211             1 => 'Auto',
6212             2 => 'On',
6213             4 => 'Off',
6214             6 => 'Red-eye reduction',
6215             },
6216             },
6217             # Casio 0x0005 is FlashIntensity
6218             # Casio 0x0006 is ObjectDistance
6219             0x0007 => {
6220             Name => 'WhiteBalance',
6221             PrintConv => {
6222             0 => 'Auto',
6223             1 => 'Daylight',
6224             2 => 'Shade',
6225             3 => 'Tungsten',
6226             4 => 'Fluorescent',
6227             5 => 'Manual',
6228             },
6229             },
6230             0x000a => {
6231             Name => 'DigitalZoom',
6232             Writable => 'int32u',
6233             },
6234             0x000b => {
6235             Name => 'Sharpness',
6236             PrintConv => {
6237             0 => 'Normal',
6238             1 => 'Soft',
6239             2 => 'Hard',
6240             },
6241             },
6242             0x000c => {
6243             Name => 'Contrast',
6244             PrintConv => {
6245             0 => 'Normal',
6246             1 => 'Low',
6247             2 => 'High',
6248             },
6249             },
6250             0x000d => {
6251             Name => 'Saturation',
6252             PrintConv => {
6253             0 => 'Normal',
6254             1 => 'Low',
6255             2 => 'High',
6256             },
6257             },
6258             0x0014 => {
6259             Name => 'ISO',
6260             Priority => 0,
6261             PrintConv => {
6262             10 => 100,
6263             16 => 200,
6264             50 => 50, #PH
6265             100 => 100, #PH
6266             200 => 200, #PH
6267             400 => 400, #PH
6268             800 => 800, #PH
6269             1600 => 1600, #PH
6270             3200 => 3200, #PH
6271             65534 => 'Auto 2', #PH (Q-S1 MOV) [how is this different from 65535?]
6272             65535 => 'Auto', #PH (K-S1 MOV)
6273             },
6274             },
6275             0x0017 => {
6276             Name => 'ColorFilter',
6277             PrintConv => {
6278             1 => 'Full',
6279             2 => 'Black & White',
6280             3 => 'Sepia',
6281             },
6282             },
6283             # Casio 0x0018 is AFPoint
6284             # Casio 0x0019 is FlashIntensity
6285             0x0e00 => {
6286             Name => 'PrintIM',
6287             Description => 'Print Image Matching',
6288             Writable => 0,
6289             SubDirectory => {
6290             TagTable => 'Image::ExifTool::PrintIM::Main',
6291             },
6292             },
6293             0x1000 => {
6294             Name => 'HometownCityCode',
6295             Writable => 'undef',
6296             Count => 4,
6297             },
6298             0x1001 => { #PH
6299             Name => 'DestinationCityCode',
6300             Writable => 'undef',
6301             Count => 4,
6302             },
6303             );
6304              
6305             # ASCII-based maker notes of Optio E20 and E25 - PH
6306             %Image::ExifTool::Pentax::Type4 = (
6307             PROCESS_PROC => \&Image::ExifTool::HP::ProcessHP,
6308             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6309             NOTES => q{
6310             The following few tags are extracted from the wealth of information
6311             available in maker notes of the Optio E20 and E25. These maker notes are
6312             stored as ASCII text in a format very similar to some HP models.
6313             },
6314             'F/W Version' => 'FirmwareVersion',
6315             );
6316              
6317             # tags in Pentax QuickTime videos (PH - tests with Optio WP)
6318             # (similar information in Kodak,Minolta,Nikon,Olympus,Pentax and Sanyo videos)
6319             %Image::ExifTool::Pentax::MOV = (
6320             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
6321             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6322             FIRST_ENTRY => 0,
6323             NOTES => 'This information is found in MOV videos from cameras such as the Optio WP.',
6324             0x00 => {
6325             Name => 'Make',
6326             Format => 'string[24]',
6327             },
6328             # (01 00 at offset 0x20)
6329             0x26 => {
6330             Name => 'ExposureTime',
6331             Format => 'int32u',
6332             ValueConv => '$val ? 10 / $val : 0',
6333             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
6334             },
6335             0x2a => {
6336             Name => 'FNumber',
6337             Format => 'rational64u',
6338             PrintConv => 'sprintf("%.1f",$val)',
6339             },
6340             0x32 => {
6341             Name => 'ExposureCompensation',
6342             Format => 'rational64s',
6343             PrintConv => '$val ? sprintf("%+.1f", $val) : 0',
6344             },
6345             0x44 => {
6346             Name => 'WhiteBalance',
6347             Format => 'int16u',
6348             PrintConv => {
6349             0 => 'Auto',
6350             1 => 'Daylight',
6351             2 => 'Shade',
6352             3 => 'Fluorescent', #2
6353             4 => 'Tungsten',
6354             5 => 'Manual',
6355             },
6356             },
6357             0x48 => {
6358             Name => 'FocalLength',
6359             Format => 'rational64u',
6360             PrintConv => 'sprintf("%.1f mm",$val)',
6361             },
6362             0xaf => {
6363             Name => 'ISO',
6364             Format => 'int16u',
6365             },
6366             );
6367              
6368             # Pentax metadata in AVI videos (PH)
6369             %Image::ExifTool::Pentax::AVI = (
6370             NOTES => 'Pentax-specific RIFF tags found in AVI videos.',
6371             GROUPS => { 0 => 'MakerNotes', 2 => 'Video' },
6372             hymn => {
6373             Name => 'MakerNotes',
6374             SubDirectory => {
6375             TagTable => 'Image::ExifTool::Pentax::Main',
6376             Start => 10,
6377             Base => '$start',
6378             ByteOrder => 'Unknown', # K-70 is little-endian, K-x is big-endian
6379             },
6380             },
6381             mknt => { # (Q-S1)
6382             Name => 'MakerNotes',
6383             SubDirectory => {
6384             TagTable => 'Image::ExifTool::Pentax::Main',
6385             Start => 10,
6386             Base => '$start',
6387             ByteOrder => 'Unknown',
6388             },
6389             },
6390             );
6391              
6392             # Pentax metadata in S1 AVI maker notes (PH)
6393             %Image::ExifTool::Pentax::S1 = (
6394             NOTES => 'Tags extracted from the maker notes of AVI videos from the Optio S1.',
6395             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6396             0x0000 => { #5
6397             Name => 'MakerNoteVersion',
6398             Writable => 'undef',
6399             Count => 4,
6400             },
6401             );
6402              
6403             # Pentax metadata in AVI videos from the RS1000 (PH)
6404             %Image::ExifTool::Pentax::Junk = (
6405             NOTES => 'Tags found in the JUNK chunk of AVI videos from the RS1000.',
6406             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
6407             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6408             0x0c => {
6409             Name => 'Model',
6410             Description => 'Camera Model Name',
6411             Format => 'string[32]',
6412             },
6413             );
6414              
6415             # PreviewImage information found in PXTH atom of K-01 MOV videos
6416             %Image::ExifTool::Pentax::PXTH = (
6417             NOTES => 'Tags found in the PXTH atom of MOV videos from the K-01.',
6418             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
6419             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6420             0x00 => {
6421             Name => 'PreviewImageLength',
6422             Format => 'int32u',
6423             },
6424             0x04 => {
6425             Name => 'PreviewImage',
6426             Groups => { 2 => 'Preview' },
6427             Format => 'undef[$val{0}]',
6428             Notes => '640-pixel-wide JPEG preview', # (360 pixels high, may depend on aspect ratio)
6429             RawConv => '$self->ValidateImage(\$val,$tag)',
6430             },
6431             );
6432              
6433             # information in PENT atom of MOV videos from the Optio WG-2 GPS
6434             %Image::ExifTool::Pentax::PENT = (
6435             NOTES => 'Tags found in the PENT atom of MOV videos from the Optio WG-2 GPS.',
6436             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
6437             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6438             0 => {
6439             Name => 'Make',
6440             Format => 'string[24]',
6441             },
6442             0x1a => {
6443             Name => 'Model',
6444             Description => 'Camera Model Name',
6445             Format => 'string[24]',
6446             },
6447             0x38 => { #(NC)
6448             Name => 'ExposureTime',
6449             Format => 'int32u',
6450             ValueConv => '$val ? 10 / $val : 0',
6451             PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
6452             },
6453             0x3c => {
6454             Name => 'FNumber',
6455             Format => 'rational64u',
6456             PrintConv => 'sprintf("%.1f",$val)',
6457             },
6458             0x44 => { #(NC)
6459             Name => 'ExposureCompensation',
6460             Format => 'rational64s',
6461             PrintConv => '$val ? sprintf("%+.1f", $val) : 0',
6462             },
6463             0x54 => { #(NC)
6464             Name => 'FocalLength',
6465             Format => 'int32u',
6466             PrintConv => '"$val mm"',
6467             },
6468             0x71 => {
6469             Name => 'DateTime1',
6470             Format => 'string[24]',
6471             Groups => { 2 => 'Time' },
6472             },
6473             0x8b => {
6474             Name => 'DateTime2',
6475             Format => 'string[24]',
6476             Groups => { 2 => 'Time' },
6477             },
6478             0xa7 => { #(NC)
6479             Name => 'ISO',
6480             Format => 'int32u',
6481             },
6482             0xc7 => {
6483             Name => 'GPSVersionID',
6484             Format => 'undef[8]',
6485             Groups => { 1 => 'GPS', 2 => 'Location' },
6486             DataMember => 'GPSVersionID',
6487             RawConv => '$$self{GPSVersionID} = ($val=~s/GPS_// ? join(" ",unpack("C*",$val)) : undef)',
6488             PrintConv => '$val =~ tr/ /./; $val',
6489             },
6490             0xcf => {
6491             Name => 'GPSLatitudeRef',
6492             Condition => '$$self{GPSVersionID}',
6493             Format => 'string[2]',
6494             Groups => { 1 => 'GPS', 2 => 'Location' },
6495             PrintConv => {
6496             N => 'North',
6497             S => 'South',
6498             },
6499             },
6500             0xd1 => {
6501             Name => 'GPSLatitude',
6502             Condition => '$$self{GPSVersionID}',
6503             Format => 'rational64u[3]',
6504             Groups => { 1 => 'GPS', 2 => 'Location' },
6505             ValueConv => 'Image::ExifTool::GPS::ToDegrees($val)',
6506             PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1)',
6507             },
6508             0xe9 => {
6509             Name => 'GPSLongitudeRef',
6510             Condition => '$$self{GPSVersionID}',
6511             Format => 'string[2]',
6512             Groups => { 1 => 'GPS', 2 => 'Location' },
6513             PrintConv => {
6514             E => 'East',
6515             W => 'West',
6516             },
6517             },
6518             0xeb => {
6519             Name => 'GPSLongitude',
6520             Condition => '$$self{GPSVersionID}',
6521             Format => 'rational64u[3]',
6522             Groups => { 1 => 'GPS', 2 => 'Location' },
6523             ValueConv => 'Image::ExifTool::GPS::ToDegrees($val)',
6524             PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1)',
6525             },
6526             0x103 => {
6527             Name => 'GPSAltitudeRef',
6528             Condition => '$$self{GPSVersionID}',
6529             Format => 'int8u',
6530             Groups => { 1 => 'GPS', 2 => 'Location' },
6531             PrintConv => {
6532             0 => 'Above Sea Level',
6533             1 => 'Below Sea Level',
6534             },
6535             },
6536             0x104 => {
6537             Name => 'GPSAltitude',
6538             Condition => '$$self{GPSVersionID}',
6539             Format => 'rational64u',
6540             Groups => { 1 => 'GPS', 2 => 'Location' },
6541             PrintConv => '$val =~ /^(inf|undef)$/ ? $val : "$val m"',
6542             },
6543             0x11c => {
6544             Name => 'GPSTimeStamp',
6545             Condition => '$$self{GPSVersionID}',
6546             Groups => { 1 => 'GPS', 2 => 'Time' },
6547             Format => 'rational64u[3]',
6548             ValueConv => 'Image::ExifTool::GPS::ConvertTimeStamp($val)',
6549             PrintConv => 'Image::ExifTool::GPS::PrintTimeStamp($val)',
6550             },
6551             0x134 => {
6552             Name => 'GPSSatellites',
6553             Condition => '$$self{GPSVersionID}',
6554             Format => 'string[3]',
6555             Groups => { 1 => 'GPS', 2 => 'Location' },
6556             },
6557             0x137 => {
6558             Name => 'GPSStatus',
6559             Condition => '$$self{GPSVersionID}',
6560             Format => 'string[2]',
6561             Groups => { 1 => 'GPS', 2 => 'Location' },
6562             PrintConv => {
6563             A => 'Measurement Active',
6564             V => 'Measurement Void',
6565             },
6566             },
6567             0x139 => {
6568             Name => 'GPSMeasureMode',
6569             Condition => '$$self{GPSVersionID}',
6570             Format => 'string[2]',
6571             Groups => { 1 => 'GPS', 2 => 'Location' },
6572             PrintConv => {
6573             2 => '2-Dimensional Measurement',
6574             3 => '3-Dimensional Measurement',
6575             },
6576             },
6577             0x13b => {
6578             Name => 'GPSMapDatum',
6579             Condition => '$$self{GPSVersionID}',
6580             Format => 'string[7]',
6581             Groups => { 1 => 'GPS', 2 => 'Location' },
6582             },
6583             0x142 => {
6584             Name => 'GPSDateStamp',
6585             Condition => '$$self{GPSVersionID}',
6586             Groups => { 1 => 'GPS', 2 => 'Time' },
6587             Format => 'string[11]',
6588             ValueConv => 'Image::ExifTool::Exif::ExifDate($val)',
6589             },
6590             0x173 => { #(NC)
6591             Name => 'AudioCodecID',
6592             Format => 'string[4]',
6593             },
6594             0x7d3 => {
6595             Name => 'PreviewImage',
6596             Groups => { 2 => 'Preview' },
6597             Format => 'undef[$size-0x7d3]',
6598             Notes => '640x480 JPEG preview image', # (black borders pad to 480 pixels high)
6599             RawConv => '$self->ValidateImage(\$val,$tag)',
6600             },
6601             );
6602              
6603             # tags in Pentax Optio RZ18 AVI videos (ref PH)
6604             # (very similar to Olympus::AVI tags)
6605             %Image::ExifTool::Pentax::Junk2 = (
6606             PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
6607             GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
6608             FIRST_ENTRY => 0,
6609             NOTES => 'This information is found in AVI videos from the Optio RZ18.',
6610             0x12 => {
6611             Name => 'Make',
6612             Format => 'string[24]',
6613             },
6614             0x2c => {
6615             Name => 'Model',
6616             Description => 'Camera Model Name',
6617             Format => 'string[24]',
6618             },
6619             0x5e => {
6620             Name => 'FNumber',
6621             Format => 'rational64u',
6622             PrintConv => 'sprintf("%.1f",$val)',
6623             },
6624             0x83 => {
6625             Name => 'DateTime1',
6626             Format => 'string[24]',
6627             Groups => { 2 => 'Time' },
6628             },
6629             0x9d => {
6630             Name => 'DateTime2',
6631             Format => 'string[24]',
6632             Groups => { 2 => 'Time' },
6633             },
6634             0x12b => {
6635             Name => 'ThumbnailWidth',
6636             Format => 'int16u',
6637             },
6638             0x12d => {
6639             Name => 'ThumbnailHeight',
6640             Format => 'int16u',
6641             },
6642             0x12f => {
6643             Name => 'ThumbnailLength',
6644             Format => 'int32u',
6645             },
6646             0x133 => {
6647             Name => 'ThumbnailImage',
6648             Groups => { 2 => 'Preview' },
6649             Format => 'undef[$val{0x12f}]',
6650             Notes => '160x120 JPEG thumbnail image',
6651             RawConv => '$self->ValidateImage(\$val,$tag)',
6652             },
6653             );
6654              
6655             #------------------------------------------------------------------------------
6656             # Convert filter settings (ref PH, K-5)
6657             # Inputs: 0) value to convert, 1) flag for inverse conversion, 2) lookup table
6658             # Returns: converted value
6659             sub PrintFilter($$$)
6660             {
6661 20     20 0 28 my ($val, $inv, $conv) = @_;
6662 20         23 my (@vals, @cval, $t, $v);
6663              
6664 20 50       37 if (not $inv) {
6665             # forward conversion (reading):
6666 0         0 @vals = split ' ',$val;
6667 0         0 $t = shift @vals;
6668 0   0     0 push @cval, $$conv{$t} || "Unknown ($t)";
6669 0         0 while (@vals) {
6670 0         0 $t = shift @vals;
6671 0         0 $v = shift @vals;
6672 0 0       0 next unless $t;
6673 0 0       0 last unless defined $v;
6674 0         0 my $c = $filterSettings{$t};
6675 0 0       0 if ($c) {
6676 0         0 my $c1 = $$c[1];
6677 0 0       0 if (ref $c1) {
    0          
6678 0   0     0 $v = $$c1{$v} || "Unknown($v)";
6679             } elsif ($v) {
6680 0         0 $v = sprintf $c1, $v;
6681             }
6682 0         0 push @cval, "$$c[0]=$v";
6683             } else {
6684 0         0 push @cval, "Unknown($t)=$v";
6685             }
6686             }
6687 0 0       0 return @cval ? \@cval : undef;
6688             } else {
6689             # reverse conversion (writing):
6690 20         37 @vals = split /,\s*/, $val;
6691             # convert filter name
6692 20         30 delete $$conv{OTHER}; # avoid recursion
6693 20         49 $v = Image::ExifTool::ReverseLookup(shift(@vals), $conv);
6694 20         37 $$conv{OTHER} = \&PrintFilter;
6695 20 50       60 return undef unless defined $v;
6696 0         0 push @cval, $v;
6697             # generate a lookup table for the filter setting name
6698 0         0 my %settingNames;
6699 0         0 $settingNames{$_} = $filterSettings{$_}[0] foreach keys %filterSettings;
6700             # convert filter settings
6701 0         0 foreach $v (@vals) {
6702 0 0       0 $v =~ /^(.*)=(.*)$/ or return undef;
6703 0         0 ($t, $v) = ($1, $2);
6704             # look up settings name
6705 0         0 $t = Image::ExifTool::ReverseLookup($t, \%settingNames);
6706 0 0       0 return undef unless defined $t;
6707 0 0       0 if (ref $filterSettings{$t}[1]) {
6708             # look up settings value
6709 0         0 $v = Image::ExifTool::ReverseLookup($v, $filterSettings{$t}[1]);
6710 0 0       0 return undef unless defined $v;
6711             } else {
6712 0 0       0 return undef unless Image::ExifTool::IsInt($v);
6713             }
6714 0         0 push @cval, $t, $v;
6715             }
6716 0 0       0 push @cval, (0) x (17 - @cval) if @cval < 17; # pad with zeros if necessary
6717 0         0 return join(' ', @cval);
6718             }
6719             }
6720              
6721             #------------------------------------------------------------------------------
6722             # Decode AF bit mask (ref 29)
6723             # Inputs: 0) raw binary value, 1) number of AF points, 2) number of bits per AF point,
6724             # 3) bit mask, 4) bit value (undef for any bit set)
6725             sub DecodeAFPoints($$$$;$)
6726             {
6727 0     0 0 0 my ($val, $num, $bits, $mask, $bitVal) = @_;
6728 0         0 my @bytes = split ' ', $val;
6729 0 0       0 return '(none)' unless @bytes;
6730 0         0 my $i = 1; # (starts at AF point number 1)
6731 0         0 my $shift = 8 - $bits;
6732 0         0 my $byte = shift @bytes;
6733 0         0 my @bitList;
6734 0         0 for (;;) {
6735 0 0       0 if ($bitVal) {
6736 0 0       0 push @bitList, $i if (($byte >> $shift) & $mask) == $bitVal;
6737             } else {
6738 0 0       0 push @bitList, $i if ($byte >> $shift) & $mask;
6739             }
6740 0 0       0 last if ++$i > $num;
6741 0         0 $shift -= $bits;
6742 0 0       0 if ($shift < 0) {
6743 0 0       0 last unless @bytes;
6744 0         0 $byte = shift @bytes;
6745 0         0 $shift += 8;
6746             }
6747             }
6748 0         0 return join(',', @bitList);
6749             }
6750              
6751             #------------------------------------------------------------------------------
6752             # Print K-3III AF Point names (ref PH)
6753             # Inputs: 0) value, 1) ExifTool ref, 2) optional value to match
6754             sub AFPointNamesK3III($$;$)
6755             {
6756 0     0 0 0 my @a = split ' ', $_[0];
6757 0         0 my $match = $_[2];
6758 0         0 my @pts;
6759 0 0       0 if ($match) {
6760 0   0     0 $a[$_] == $match and push @pts, $k3iiiAF[$_] || "Unknown($_)" foreach 0..$#a;
      0        
6761             } else {
6762 0   0     0 $a[$_] and push @pts, $k3iiiAF[$_] || "Unknown($_)" foreach 0..$#a;
      0        
6763             }
6764 0 0       0 return @pts ? join ',', sort @pts : '(none)';
6765             }
6766              
6767             #------------------------------------------------------------------------------
6768             # Print K-3III AF point values (ref PH)
6769             # Inputs: 0) value, 1) ExifTool ref
6770             # Notes: this is experimental and not well understood
6771             sub AFPointValuesK3III($$)
6772             {
6773 0     0 0 0 my @a = split ' ', shift;
6774 0         0 my @vals;
6775             # (I really don't understand why Pentax seemed to use 28 instead of 41 for
6776             # the first index of the 2nd value, because as it stands there is
6777             # overlap between the ranges of the 1st and 2nd values, and there is
6778             # no way to tell which is which for cases were multiple points have values)
6779 0         0 foreach (0 .. $#a) {
6780 0 0       0 next unless $a[$_];
6781 0 0       0 my $pt = $k3iiiAF[$_] ? $k3iiiAF[$_] . '=' : $k3iiiAF[$_-28] . '=/';
6782 0         0 push @vals, "$pt$a[$_]";
6783 0 0       0 next unless $a[$_ + 28];
6784 0         0 $vals[-1] .= '/' . $a[$_ + 28];
6785 0         0 $a[$_ + 28] = undef;
6786             }
6787 0 0       0 return @vals ? join ',', sort @vals : '(none)';
6788             }
6789              
6790             #------------------------------------------------------------------------------
6791             # Print K-3III AF point positions from tag 0x040c (ref KG)
6792             # Inputs: 0) raw value, 1) ExifTool ref
6793             sub AFAreasK3III($$)
6794             {
6795 0     0 0 0 my ($val, $et) = @_;
6796 0 0       0 return '(none)' unless $val;
6797 0         0 my @vals = split ' ', $val;
6798             # flags bits: [mask, value, description]
6799 0         0 my @flags = ([0x10,0x10,'central'],[0x08,0,'peripheral'],[0x04,0x04,'in-focus']);
6800 0         0 my ($i, @strs);
6801 0         0 for ($i=0; $i+7<=@vals; $i+=7) {
6802 0         0 my @a;
6803 0   0     0 ($vals[$i+6] & $$_[0]) == $$_[1] and push @a, $$_[2] foreach @flags;
6804 0 0       0 push @strs, $vals[$i+2] . ',' . $vals[$i+3] . (@a ? '(' . join(',',@a) . ')' : '');
6805             }
6806 0         0 return \@strs;
6807             }
6808              
6809             #------------------------------------------------------------------------------
6810             # Convert Pentax hex-based EV (modulo 8) to real number
6811             # Inputs: 0) value to convert
6812             # eg) 0x00 -> 0
6813             # 0x03 -> 0.33333
6814             # 0x04 -> 0.5
6815             # 0x05 -> 0.66666
6816             # 0x08 -> 1 ... etc
6817             sub PentaxEv($)
6818             {
6819 26     26 0 43 my $val = shift;
6820 26 100       64 if ($val & 0x01) {
6821 12 50       31 my $sign = $val < 0 ? -1 : 1;
6822 12         23 my $frac = ($val * $sign) & 0x07;
6823 12 100       37 if ($frac == 0x03) {
    50          
6824 4         15 $val += $sign * ( 8 / 3 - $frac);
6825             } elsif ($frac == 0x05) {
6826 8         23 $val += $sign * (16 / 3 - $frac);
6827             }
6828             }
6829 26         200 return $val / 8;
6830             }
6831              
6832             #------------------------------------------------------------------------------
6833             # Convert number to Pentax hex-based EV (modulo 8)
6834             # Inputs: 0) number
6835             # Returns: Pentax EV code
6836             sub PentaxEvInv($)
6837             {
6838 9     9 0 24 my $num = shift;
6839 9         23 my $val = $num * 8;
6840             # extra fudging makes sure 0.3 and 0.33333 both round up to 3, etc
6841 9 50       25 my $sign = $num < 0 ? -1 : 1;
6842 9         27 my $inum = $num * $sign - int($num * $sign);
6843 9 100 100     86 if ($inum > 0.29 and $inum < 0.4) {
    100 66        
6844 1         3 $val += $sign / 3;
6845             } elsif ($inum > 0.6 and $inum < .71) {
6846 3         7 $val -= $sign / 3;
6847             }
6848 9         71 return int($val + 0.5 * $sign);
6849             }
6850              
6851             #------------------------------------------------------------------------------
6852             # Encrypt or decrypt Pentax ShutterCount (symmetrical encryption) - PH
6853             # Inputs: 0) shutter count value, 1) ExifTool object ref
6854             # Returns: Encrypted or decrypted ShutterCount
6855             sub CryptShutterCount($$)
6856             {
6857 4     4 0 15 my ($val, $et) = @_;
6858             # Pentax Date and Time values are used in the encryption
6859             return undef unless $$et{PentaxDate} and $$et{PentaxTime} and
6860 4 50 33     61 length($$et{PentaxDate})==4 and length($$et{PentaxTime})>=3;
      33        
      33        
6861             # get Date and Time as integers (after padding Time with a null byte)
6862 4         18 my $date = unpack('N', $$et{PentaxDate});
6863 4         12 my $time = unpack('N', $$et{PentaxTime} . "\0");
6864 4         17 return $val ^ $date ^ (0xffffffff - $time);
6865             }
6866              
6867              
6868             1; # end
6869              
6870             __END__