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