File Coverage

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


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