File Coverage

blib/lib/Image/ExifTool/Pentax.pm
Criterion Covered Total %
statement 44 93 47.3
branch 14 56 25.0
condition 8 21 38.1
subroutine 9 10 90.0
pod 0 5 0.0
total 75 185 40.5


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