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