~ubuntu-branches/ubuntu/karmic/libimage-exiftool-perl/karmic

« back to all changes in this revision

Viewing changes to lib/Image/ExifTool/Pentax.pm

  • Committer: Bazaar Package Importer
  • Author(s): Mari Wang
  • Date: 2008-02-04 20:32:53 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080204203253-mpbal8trlfe1fz5d
Tags: 7.00-1
* Upload of new production release (Closes: #456430)
* Added Recommends: libcompress-zlib-perl (Closes: #435589)
* Package now includes iptc2xmp.args and xmp2iptc.args, they are put
  into /usr/share/libimage-exiftool/ (Closes: #436100)
* Updated standards-version (3.7.2 -> 3.7.3). No changes needed.
* Lots of updates and bugfixes compared to last debian version
  (6.90).  See the Changes file for details
* Upload sponsored by Petter Reinholdtsen

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#               4) http://kobe1995.jp/~kaz/astro/istD.html
18
18
#               5) John Francis (http://www.panix.com/~johnf/raw/index.html) (ist-D/ist-DS)
19
19
#               6) http://www.cybercom.net/~dcoffin/dcraw/
20
 
#               7) Douglas O'Brien private communication (*istD)
 
20
#               7) Douglas O'Brien private communication (*istD, K10D)
21
21
#               8) Denis Bourez private communication
22
22
#               9) Kazumichi Kawabata private communication
23
23
#              10) David Buret private communication (*istD)
29
29
#              16) Axel Kellner private communication (K10D)
30
30
#              17) Cvetan Ivanov private communication (K100D)
31
31
#              18) http://www.gvsoft.homedns.org/exif/makernote-pentax-type3.html
 
32
#              19) Jens Duttke private communication
32
33
#
33
34
# Notes:        See POD documentation at the bottom of this file
34
35
#------------------------------------------------------------------------------
38
39
use strict;
39
40
use vars qw($VERSION);
40
41
use Image::ExifTool::Exif;
41
 
 
42
 
$VERSION = '1.52';
 
42
use Image::ExifTool::HP;
 
43
 
 
44
$VERSION = '1.61';
 
45
 
 
46
sub CryptShutterCount($$);
43
47
 
44
48
# pentax lens type codes (ref 4)
45
49
my %pentaxLensType = (
55
59
    '3 22' => 'smc PENTAX-F FISH-EYE 17-28mm F3.5-4.5',
56
60
    '3 23' => 'smc PENTAX-F 100-300mm F4.5-5.6',
57
61
    '3 24' => 'smc PENTAX-F 35-135mm F3.5-4.5',
58
 
    '3 25' => 'smc PENTAX-F 35-105mm F4-5.6 or SIGMA AF 28-300 F3.5-5.6 DL IF', #11 (sigma)
 
62
    '3 25' => 'smc PENTAX-F 35-105mm F4-5.6 or SIGMA or Tokina',
 
63
    # or '3 25' => SIGMA AF 28-300 F3.5-5.6 DL IF', #11
59
64
    # or '3 25' => 'Tokina 80-200mm F2.8 ATX-Pro', #12
 
65
    # or '3 25' => 'SIGMA 55-200mm F4-5.6 DC', #19
60
66
    '3 26' => 'smc PENTAX-F* 250-600mm F5.6 ED[IF]',
61
67
    '3 27' => 'smc PENTAX-F 28-80mm F3.5-4.5',
62
68
    '3 28' => 'smc PENTAX-F 35-70mm F3.5-4.5',
73
79
    '3 38' => 'smc PENTAX-F* 300mm F4.5 ED[IF]',
74
80
    '3 39' => 'smc PENTAX-F* 600mm F4 ED[IF]',
75
81
    '3 40' => 'smc PENTAX-F MACRO 100mm F2.8',
76
 
    '3 41' => 'smc PENTAX-F MACRO 50mm F2.8',
77
 
    '3 44' => 'SIGMA 18-50mm F3.5-5.6 DC, 12-24mm F4.5 EX DG or Tamron 35-90mm F4 AF', #4,12,12
 
82
    '3 41' => 'smc PENTAX-F MACRO 50mm F2.8 or Sigma 50mm F2,8 MACRO', #4,16
 
83
    #'3 44' => 'SIGMA 17-70mm F2.8-4.5 DC MACRO', (Bart Hickman)
 
84
    #'3 44' => 'SIGMA 18-50mm F3.5-5.6 DC, 12-24mm F4.5 EX DG or Tamron 35-90mm F4 AF', #4,12,12
 
85
    #'3 44' => 'SIGMA AF 10-20mm F4-5.6 EX DC', #19
 
86
    '3 44' => 'Tamron 35-90mm F4 AF or various SIGMA models', #4,12,Bart,19
78
87
    '3 46' => 'SIGMA APO 70-200mm F2.8 EX',
79
88
    '3 50' => 'smc PENTAX-FA 28-70mm F4 AL',
80
89
    '3 51' => 'SIGMA 28mm F1.8 EX DG ASPHERICAL MACRO',
81
90
    '3 52' => 'smc PENTAX-FA 28-200mm F3.8-5.6 AL[IF]',
 
91
    # or '3 52' => 'Tamron AF LD 28-200mm F3.8-5.6 (IF) Aspherical (171D), #19
82
92
    '3 53' => 'smc PENTAX-FA 28-80mm F3.5-5.6 AL',
83
93
    '3 247' => 'smc PENTAX-DA FISH-EYE 10-17mm F3.5-4.5 ED[IF]',
84
94
    '3 248' => 'smc PENTAX-DA 12-24mm F4 ED AL[IF]',
92
102
    # '3 255' => 'SIGMA DL-II 35-80mm F4-5.6', #12
93
103
    # '3 255' => 'SIGMA DL Zoom 75-300mm F4-5.6', #12
94
104
    # '3 255' => 'SIGMA DF EX Aspherical 28-70mm F2.8', #12
 
105
    # '3 255' => 'SIGMA AF Tele 400mm F5.6 Multi-coated', #19
95
106
    '4 1' => 'smc PENTAX-FA SOFT 28mm F2.8',
96
107
    '4 2' => 'smc PENTAX-FA 80-320mm F4.5-5.6',
97
108
    '4 3' => 'smc PENTAX-FA 43mm F1.9 Limited',
106
117
    '4 24' => 'smc PENTAX-FA 77mm F1.8 Limited',
107
118
    '4 25' => 'TAMRON SP AF 14mm F2.8', #13
108
119
    '4 26' => 'smc PENTAX-FA MACRO 100mm F3.5',
109
 
    '4 27' => 'TAMRON AF28-300mm F/3.5-6.3 LD Aspherical[IF]Macro (285D)',
 
120
    '4 27' => 'TAMRON AF28-300mm F/3.5-6.3 LD Aspherical[IF] MACRO (285D)',
110
121
    '4 28' => 'smc PENTAX-FA 35mm F2 AL',
 
122
    '4 29' => 'TAMRON AF 28-200mm F/3.8-5.6 LD Super II MACRO (371D)', #19
111
123
    '4 34' => 'smc PENTAX-FA 24-90mm F3.5-4.5 AL[IF]',
112
124
    '4 35' => 'smc PENTAX-FA 100-300mm F4.7-5.8',
113
 
    '4 36' => 'TAMRON AF70-300mm F/4-5.6 LD MACRO (572D)',
 
125
    '4 36' => 'TAMRON AF70-300mm F/4-5.6 LD MACRO', # both 572D and A17 (Di) - ref 19
114
126
    '4 37' => 'TAMRON SP AF 24-135mm F3.5-5.6 AD AL (190D)', #13
115
127
    '4 38' => 'smc PENTAX-FA 28-105mm F3.2-4.5 AL[IF]',
116
128
    '4 39' => 'smc PENTAX-FA 31mm F1.8AL Limited',
163
175
    '6 13' => 'smc PENTAX-FA* 400mm F5.6 ED[IF]',
164
176
    '6 14' => 'smc PENTAX-FA* MACRO 200mm F4 ED[IF]',
165
177
    '7 0' => 'smc PENTAX-DA 21mm F3.2 AL Limited', #13
 
178
    '7 238' => 'TAMRON AF 18-250mm F3.5-6.3 Di II LD Aspherical [IF] MACRO', #19
166
179
    '7 243' => 'smc PENTAX-DA 70mm F2.4 Limited', #PH (K10D)
167
180
    '7 244' => 'smc PENTAX-DA 21mm F3.2 AL Limited', #16
 
181
    '8 241' => 'smc PENTAX-DA* 50-135mm F2.8 ED [IF] SDM', #19
 
182
    '8 242' => 'smc PENTAX-DA* 16-50mm F2.8 ED AL [IF] SDM', #19
168
183
);
169
184
 
170
185
# Pentax model ID codes (PH)
209
224
    0x12b80 => 'Samsung GX-1L',
210
225
    0x12b9c => 'K100D',
211
226
    0x12b9d => 'K110D',
212
 
    0x12bb0 => 'Optio T10',
 
227
    0x12ba2 => 'K100D Super', #19
 
228
    0x12bb0 => 'Optio T10/T20',
213
229
    0x12be2 => 'Optio W10',
214
230
    0x12bf6 => 'Optio M10',
215
231
    0x12c1e => 'K10D',
216
232
    0x12c20 => 'Samsung GX10',
217
233
    0x12c28 => 'Optio S7',
 
234
    0x12c2d => 'Optio L20',
218
235
    0x12c32 => 'Optio M20',
219
236
    0x12c3c => 'Optio W20',
220
237
    0x12c46 => 'Optio A20',
223
240
    0x12c82 => 'Optio T30',
224
241
    0x12c96 => 'Optio W30',
225
242
    0x12ca0 => 'Optio A30',
 
243
    0x12cb4 => 'Optio E40',
 
244
    0x12cbe => 'Optio M40',
 
245
    0x12cc8 => 'Optio Z10',
 
246
    0x12cdc => 'Optio S10',
 
247
    0x12ce6 => 'Optio A40',
 
248
    0x12cf0 => 'Optio V10',
226
249
);
227
250
 
228
251
# Pentax city codes - (PH, Optio WP)
312
335
        PrintConv => '$val=~tr/ /./; $val',
313
336
        PrintConvInv => '$val=~tr/./ /; $val',
314
337
    },
315
 
    0x0001 => {
316
 
        Name => 'PentaxMode',
 
338
    0x0001 => { #PH
 
339
        Name => 'PentaxModelType',
317
340
        Writable => 'int16u',
318
 
        PrintConv => {
319
 
            0 => 'Auto',
320
 
            1 => 'Night Scene',
321
 
            2 => 'Manual',
322
 
        },
 
341
        # (values of 0-5 seem to group models into 6 categories, ref 13)
323
342
    },
324
 
    0x0002 => {
 
343
    0x0002 => { #PH
325
344
        Name => 'PreviewImageSize',
326
345
        Groups => { 2 => 'Image' },
327
346
        Writable => 'int16u',
328
347
        Count => 2,
329
348
        PrintConv => '$val =~ tr/ /x/; $val',
330
349
    },
331
 
    0x0003 => {
 
350
    0x0003 => { #PH
332
351
        Name => 'PreviewImageLength',
333
352
        OffsetPair => 0x0004, # point to associated offset
334
353
        DataTag => 'PreviewImage',
336
355
        Writable => 'int32u',
337
356
        Protected => 2,
338
357
    },
339
 
    0x0004 => {
 
358
    0x0004 => { #PH
340
359
        Name => 'PreviewImageStart',
341
360
        IsOffset => 2,  # code to use original base
342
361
        Protected => 2,
359
378
        Writable => 'undef',
360
379
        Count => 4,
361
380
        Shift => 'Time',
 
381
        DataMember => 'PentaxDate',
 
382
        RawConv => '$$self{PentaxDate} = $val', # save to decrypt ShutterCount
362
383
        ValueConv => 'length($val)==4 ? sprintf("%.4d:%.2d:%.2d",unpack("nC2",$val)) : "Unknown ($val)"',
363
384
        ValueConvInv => 'my @v=split /:/, $val;pack("nC2",$v[0],$v[1],$v[2])',
364
385
    },
368
389
        Writable => 'undef',
369
390
        Count => 3,
370
391
        Shift => 'Time',
 
392
        DataMember => 'PentaxTime',
 
393
        RawConv => '$$self{PentaxTime} = $val', # save to decrypt ShutterCount
371
394
        ValueConv => 'length($val)>=3 ? sprintf("%.2d:%.2d:%.2d",unpack("C3",$val)) : "Unknown ($val)"',
372
395
        ValueConvInv => 'pack("C3",split(/:/,$val))',
373
396
    },
374
 
    0x0008 => {
 
397
    0x0008 => { #2
375
398
        Name => 'Quality',
376
399
        Writable => 'int16u',
377
400
        PrintConv => {
463
486
        Name => 'FlashMode',
464
487
        Writable => 'int16u',
465
488
        PrintHex => 1,
466
 
        ValueConv => '$val=~s/ .*//; $val',
 
489
        ValueConv => '$val=~s/ .*//; $val', # ignore 2nd value
467
490
        PrintConv => {
468
491
            0x000 => 'Auto, Did not fire',
469
492
            0x001 => 'Off',
479
502
            0x10b => 'On, Trailing-curtain Sync',
480
503
        },
481
504
    },
482
 
    0x000d => [
 
505
    0x000d => [ #2
483
506
        {
484
507
            Condition => '$self->{CameraMake} =~ /^PENTAX/',
485
508
            Name => 'FocusMode',
527
550
        },
528
551
    },
529
552
    0x000f => { #PH
530
 
        Name => 'AutoAFPoint',
 
553
        Name => 'AFPointsInFocus',
531
554
        Writable => 'int16u',
532
555
        PrintHex => 1,
533
556
        PrintConv => {
534
557
            0xffff => 'None',
535
 
            0 => 'Multiple', #14
 
558
            0 => 'Fixed Center or Multiple', #PH/14
536
559
            1 => 'Top-left',
537
560
            2 => 'Top-center',
538
561
            3 => 'Top-right',
555
578
        Priority => 0,
556
579
        ValueConv => '$val * 1e-5',
557
580
        ValueConvInv => '$val * 1e5',
558
 
        PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
559
 
        PrintConvInv => 'eval $val',
 
581
        # value may be 0xffffffff in Bulb mode (ref 19)
 
582
        PrintConv => '$val > 42949 ? "Unknown (Bulb)" : Image::ExifTool::Exif::PrintExposureTime($val)',
 
583
        PrintConvInv => '$val=~/(unknown|bulb)/i ? $val : eval $val',
560
584
    },
561
585
    0x0013 => { #PH
562
586
        Name => 'FNumber',
960
984
        PrintConv => '$_=$val;s/ /x/;$_',
961
985
    },
962
986
    0x003c => { #7/PH
963
 
        Name => 'AFPointsUsed',
 
987
        Name => 'AFPointsInFocus',
964
988
        # not writable because I'm not decoding these 4 bytes fully:
965
989
        # Nibble pattern: XSSSYUUU
966
990
        # X = unknown (AF focused flag?, 0 or 1)
968
992
        # Y = unknown (observed 0,6,7,b,e, always 0 if SSS is 0x000 or 0x7ff)
969
993
        # UUU = af points used
970
994
        Format => 'int32u',
 
995
        Notes => '*istD only',
971
996
        ValueConv => '$val & 0x7ff', # ignore other bits for now
972
997
        PrintConv => { BITMASK => {
973
998
            0 => 'Upper-left',
989
1014
        Writable => 'int8u',
990
1015
        Count => 2,
991
1016
        SeparateTable => 1,
 
1017
        ValueConv => '$val=~s/^(\d+ \d+) 0$/$1/; $val',
 
1018
        ValueConvInv => '$val',
992
1019
        PrintConv => \%pentaxLensType,
993
1020
    },
994
1021
    # 0x0041 - increments for each cropped pic (PH)
1014
1041
    },
1015
1042
    0x004f => { #PH
1016
1043
        Name => 'ImageTone',
 
1044
        Writable => 'int16u',
1017
1045
        PrintConv => {
1018
1046
            0 => 'Natural',
1019
1047
            1 => 'Bright',
1026
1054
            TagTable => 'Image::ExifTool::Pentax::SRInfo',
1027
1055
        },
1028
1056
    },
 
1057
    0x005d => { #19/PH
 
1058
        # (used by all Pentax DSLR's except *istD and *istDS - PH)
 
1059
        # The lowest decrypted values observed are 246 for the first image from a
 
1060
        # brand new K10D, and 209 for one of the first 20 images from a new K10D,
 
1061
        # so either there are ~200 test images shot in the factory, or there is an
 
1062
        # offset of ~200 which is applied to this value before encryption
 
1063
        Name => 'ShutterCount',
 
1064
        Writable => 'undef',
 
1065
        Count => 4,
 
1066
        Notes => 'raw value is a big-endian 4-byte integer, encrypted using Date and Time',
 
1067
        RawConv => 'length($val) == 4 ? unpack("N",$val) : undef',
 
1068
        RawConvInv => q{
 
1069
            my $val = Image::ExifTool::Pentax::CryptShutterCount($val,$self);
 
1070
            return pack('N', $val);
 
1071
        },
 
1072
        ValueConv => \&CryptShutterCount,
 
1073
        ValueConvInv => '$val',
 
1074
    },
1029
1075
    0x0200 => { #5
1030
1076
        Name => 'BlackPoint',
1031
1077
        Writable => 'int16u',
1056
1102
        },
1057
1103
    },
1058
1104
    0x0209 => {
1059
 
        Name => 'AEDump',
1060
 
        Flags => ['Unknown','Binary'],
 
1105
        Name => 'AEMeteringSegments',
 
1106
        Format => 'int8u',
 
1107
        Count => 16,
 
1108
        Notes => q{
 
1109
            measurements from each of the 16 AE metering segments, converted to LV
 
1110
        },
 
1111
        # metering segment locations (ref 19):
 
1112
        # +-------------------------+
 
1113
        # |           14            |
 
1114
        # |    +---+---+---+---+    |
 
1115
        # |    | 5 | 3/1\ 2| 4 |    |
 
1116
        # |  +-+-+-+-+ - +-+-+-+-+  |
 
1117
        # +--+ 9 | 7 ||0|| 6 | 8 +--+
 
1118
        # |  +-+-+-+-+ - +-+-+-+-+  |
 
1119
        # |    |13 |11\ /10|12 |    |
 
1120
        # |    +---+---+---+---+    |
 
1121
        # |           15            |
 
1122
        # +-------------------------+
 
1123
        # convert to approximate LV equivalent (PH):
 
1124
        ValueConv => q{
 
1125
            my @a;
 
1126
            foreach (split ' ', $val) { push @a, $_ / 8 - 6; }
 
1127
            return join(' ', @a);
 
1128
        },
 
1129
        ValueConvInv => q{
 
1130
            my @a;
 
1131
            foreach (split ' ', $val) { push @a, int(($_ + 6) * 8 + 0.5); }
 
1132
            return join(' ', @a);
 
1133
        },
 
1134
        PrintConv => q{
 
1135
            my @a;
 
1136
            foreach (split ' ', $val) { push @a, sprintf('%.1f', $_); }
 
1137
            return join(' ', @a);
 
1138
        },
 
1139
        PrintConvInv => '$val',
1061
1140
    },
1062
1141
    0x020a => {
1063
1142
        Name => 'FlashADump',
1119
1198
            TagTable => 'Image::ExifTool::Pentax::BatteryInfo',
1120
1199
        },
1121
1200
    },
 
1201
    0x021f => { #19
 
1202
        Name => 'AFInfo',
 
1203
        SubDirectory => {
 
1204
            TagTable => 'Image::ExifTool::Pentax::AFInfo',
 
1205
        },
 
1206
    },
1122
1207
    0x03fe => { #PH
1123
1208
        Name => 'DataDump',
1124
1209
        Writable => 0,
1140
1225
            TagTable => 'Image::ExifTool::PrintIM::Main',
1141
1226
        },
1142
1227
    },
1143
 
    0x1000 => { #PH
1144
 
        Name => 'HometownCityCode',
1145
 
        Writable => 'undef',
1146
 
        Count => 4,
1147
 
    },
1148
 
    0x1001 => { #PH
1149
 
        Name => 'DestinationCityCode',
1150
 
        Writable => 'undef',
1151
 
        Count => 4,
1152
 
    },
1153
 
    0x2000 => { #PH (Optio 330RS)
1154
 
        Name => 'PreviewImageData',
1155
 
        Binary => 1,
1156
 
    },
1157
 
    # 0x2011 WhiteBalanceBias (ref 18)
1158
 
    # 0x2012 WhiteBalance (ref 18)
1159
 
    # 0x2022 ObjectDistance in mm (ref 18)
1160
 
    # 0x2034 FlashDistance (ref 18)
1161
 
    # 0x3000 RecordMode (ref 18)
1162
 
    # 0x3001 SelfTimer? (ref 18)
1163
 
    # 0x3002 Quality (ref 18)
1164
 
    # 0x3003 FocusMode (ref 18)
1165
 
    # 0x3006 TimeZone (ref 18)
1166
 
    # 0x3007 BestshotMode (ref 18)
1167
 
    # 0x3014 ISO (ref 18)
1168
 
    # 0x3015 ColorMode 0=off (ref 18)
1169
 
    # 0x3016 Enhancemnt 0=off (ref 18)
1170
 
    # 0x3017 Filter, 0=off (ref 18)
1171
1228
);
1172
1229
 
1173
 
# NOTE: These are from Image::MakerNotes::Pentax.pm, but they don't seem to work - PH
1174
 
#    0x0003 => {
1175
 
#        Name => 'Focus',
1176
 
#        PrintConv => {
1177
 
#            2 => 'Custom',
1178
 
#            3 => 'Auto',
1179
 
#        },
1180
 
#    },
1181
 
#    0x0004 => {
1182
 
#        Name => 'Flash',
1183
 
#        PrintConv => {
1184
 
#            1 => 'Auto',
1185
 
#            2 => 'On',
1186
 
#            4 => 'Off',
1187
 
#            6 => 'Red-eye reduction',
1188
 
#        },
1189
 
#    },
1190
 
#    0x000a => 'Zoom',
1191
 
#    0x0017 => {
1192
 
#        Name => 'Color',
1193
 
#        PrintConv => {
1194
 
#            1 => 'Full',
1195
 
#            2 => 'Black & White',
1196
 
#            3 => 'Sepia',
1197
 
#        },
1198
 
#    },
1199
 
 
1200
1230
# shake reduction information (ref PH)
1201
1231
%Image::ExifTool::Pentax::SRInfo = (
1202
1232
    PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
1203
1233
    WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
1204
1234
    CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
 
1235
    GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
1205
1236
    WRITABLE => 1,
1206
1237
    FIRST_ENTRY => 0,
1207
 
    GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
1208
1238
    NOTES => 'Shake reduction information.',
1209
1239
    0 => {
1210
1240
        Name => 'SRResult',
1211
 
        Notes => '0=not stabilized?, 1=stabilized?, 64=not ready?',
 
1241
        PrintConv => { #PH/19
 
1242
            0 => 'Not stabilized',
 
1243
            BITMASK => {
 
1244
                0 => 'Stabilized',
 
1245
                6 => 'Not ready',
 
1246
            },
 
1247
        },
1212
1248
    },
1213
1249
    1 => {
1214
1250
        Name => 'ShakeReduction',
1215
1251
        PrintConv => { 0 => 'Off', 1 => 'On' },
1216
1252
    },
1217
 
    2 => 'SR_SWSToSWRTime',
 
1253
    2 => {
 
1254
        Name => 'SR_SWSToSWRTime',
 
1255
        # SWS=photometering switch, SWR=shutter release switch
 
1256
        # (from http://www.patentstorm.us/patents/6597867-description.html)
 
1257
        Notes => q{
 
1258
            time from when the shutter button was half pressed to when the shutter was
 
1259
            released
 
1260
        },
 
1261
    },
1218
1262
);
1219
1263
 
1220
1264
# auto-exposure information (ref PH)
1222
1266
    PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
1223
1267
    WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
1224
1268
    CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
 
1269
    GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
1225
1270
    WRITABLE => 1,
1226
1271
    FIRST_ENTRY => 0,
1227
 
    GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
1228
1272
    0 => {
1229
1273
        Name => 'AEExposureTime',
1230
1274
        Notes => 'val = 24 * 2**((32-raw)/8)',
1236
1280
    1 => {
1237
1281
        Name => 'AEAperture',
1238
1282
        Notes => 'val = (2**((raw-4)/16)) / 16',
 
1283
        # (same as val=2**((raw-68)/16), but 68 isn't a nice power of 2)
1239
1284
        ValueConv => 'exp(($val-4)*log(2)/16)/16',
1240
1285
        ValueConvInv => 'log($val*16)*16/log(2)+4',
1241
1286
        PrintConv => 'sprintf("%.1f",$val)',
1249
1294
        PrintConv => 'int($val + 0.5)',
1250
1295
        PrintConvInv => '$val',
1251
1296
    },
1252
 
    3 => 'AEXv',
1253
 
    4 => 'AEBXv',
1254
 
    5 => 'AEFlashTv',
 
1297
    3 => {
 
1298
        Name => 'AEXv',
 
1299
        Notes => 'val = (raw-64)/8',
 
1300
        ValueConv => '($val-64)/8',
 
1301
        ValueConvInv => '$val * 8 + 64',
 
1302
    },
 
1303
    4 => {
 
1304
        Name => 'AEBXv',
 
1305
        Format => 'int8s',
 
1306
        Notes => 'val = raw / 8',
 
1307
        ValueConv => '$val/8',
 
1308
        ValueConvInv => '$val * 8',
 
1309
    },
 
1310
    5 => {
 
1311
        Name => 'AEFlashTv',
 
1312
        Notes => 'val = 24 * 2**((32-raw)/8)',
 
1313
        ValueConv => '24*exp(-($val-32)*log(2)/8)', #19
 
1314
        ValueConvInv => '-log($val/24)*8/log(2)+32',
 
1315
        PrintConv => 'Image::ExifTool::Exif::PrintExposureTime($val)',
 
1316
        PrintConvInv => 'eval $val',
 
1317
    },
1255
1318
    6 => {
1256
1319
        Name => 'AEProgramMode',
1257
1320
        PrintConv => {
1287
1350
    PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
1288
1351
    WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
1289
1352
    CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
 
1353
    GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
1290
1354
    WRITABLE => 1,
1291
1355
    FIRST_ENTRY => 0,
1292
1356
    # (must decode focus distance!)
1293
 
    GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
1294
1357
    0 => {
1295
1358
        Name => 'LensType',
1296
1359
        Format => 'int8u[4]',
1302
1365
        # this is a bit funny and needs testing with more lenses on the K10D
1303
1366
        ValueConv => q{
1304
1367
            my @v = split(' ',$val);
1305
 
            if ($v[0] & 0x80 or $$self{CameraModel} =~ /^PENTAX K10D\b/) {
1306
 
                $v[0] &= 0x7f;
 
1368
            if ($v[0] & 0xf0 or $$self{CameraModel} =~ /^PENTAX K10D\b/) {
 
1369
                $v[0] &= 0x0f;
1307
1370
                $v[1] = GetByteOrder() eq 'MM' ? $v[2] * 256 + $v[3] : $v[3] * 256 + $v[2];
1308
1371
            }
1309
1372
            return "$v[0] $v[1]";
1312
1375
        SeparateTable => 1,
1313
1376
    },
1314
1377
    4 => {
1315
 
        Name => 'LensCoefficients',
1316
 
        Format => 'int8u[9]',
 
1378
        Condition => '$$self{CameraModel} !~ /K10D/',
 
1379
        Name => 'LensCodes',
 
1380
        Format => 'int8u[16]',
 
1381
        Notes => 'all models but the K10D',
 
1382
    },
 
1383
    5 => {
 
1384
        Condition => '$$self{CameraModel} =~ /K10D/',
 
1385
        Name => 'LensCodes',
 
1386
        Format => 'int8u[16]',
 
1387
        Notes => 'K10D only',
1317
1388
    },
1318
1389
);
1319
1390
 
1322
1393
    PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
1323
1394
    WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
1324
1395
    CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
 
1396
    GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
1325
1397
    WRITABLE => 1,
1326
1398
    FIRST_ENTRY => 0,
1327
 
    GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
1328
1399
    0 => 'FlashStatus',
1329
1400
    1 => {
1330
1401
        Name => 'FlashModeCode',
1357
1428
    PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
1358
1429
    WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
1359
1430
    CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
 
1431
    GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
1360
1432
    WRITABLE => 1,
1361
1433
    FIRST_ENTRY => 0,
1362
1434
    FORMAT => 'int32u',
1369
1441
    1 => {
1370
1442
        Name => 'ManufactureDate',
1371
1443
        ValueConv => q{
1372
 
            $val =~ /^(\d{4})(\d{2})(\d{2})$/ and return "$1:$2:$2";
 
1444
            $val =~ /^(\d{4})(\d{2})(\d{2})$/ and return "$1:$2:$3";
1373
1445
            # Optio A10 and A20 leave "200" off the year
1374
1446
            $val =~ /^(\d)(\d{2})(\d{2})$/ and return "200$1:$2:$3";
1375
 
            return "Unknown($val)";
 
1447
            return "Unknown ($val)";
1376
1448
        },
1377
1449
        ValueConvInv => '$val=~tr/0-9//dc; $val',
1378
1450
    },
1390
1462
    PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
1391
1463
    WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
1392
1464
    CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
 
1465
    GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
1393
1466
    WRITABLE => 1,
1394
1467
    FIRST_ENTRY => 0,
1395
 
    GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
1396
1468
    0 => {
1397
1469
        Name => 'BatteryType',
1398
 
        ValueConv => '$val - 128',
1399
 
        ValueConvInv => '$val + 128',
 
1470
        ValueConv => '$val & 0x7f',
 
1471
        ValueConvInv => '$val | 0x80',  # (not sure what this bit means)
1400
1472
    },
1401
1473
    1 => {
1402
1474
        Name => 'BatteryBodyGripStates',
1403
1475
        Notes => 'body and grip battery state',
1404
 
        ValueConv => '($val >> 8) . " " . ($val & 0x0f)',
1405
 
        ValueConvInv => 'my @a=split(" ",$val); ($a[0] << 8) + $a[1]',
 
1476
        ValueConv => '($val >> 4) . " " . ($val & 0x0f)',
 
1477
        ValueConvInv => 'my @a=split(" ",$val); ($a[0] << 4) + $a[1]',
1406
1478
    },
 
1479
    # internal and grip battery voltage Analogue to Digital measurements,
 
1480
    # open circuit and under load
1407
1481
    2 => 'BatteryADBodyNoLoad',
1408
1482
    3 => 'BatteryADBodyLoad',
1409
1483
    4 => 'BatteryADGripNoLoad',
1410
1484
    5 => 'BatteryADGripLoad',
1411
1485
);
1412
1486
 
 
1487
# auto focus information (ref 19)
 
1488
%Image::ExifTool::Pentax::AFInfo = (
 
1489
    PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
 
1490
    WRITE_PROC => \&Image::ExifTool::WriteBinaryData,
 
1491
    CHECK_PROC => \&Image::ExifTool::CheckBinaryData,
 
1492
    GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
 
1493
    WRITABLE => 1,
 
1494
    FIRST_ENTRY => 0,
 
1495
    0x0b => {
 
1496
        Name => 'AFPointsInFocus',
 
1497
        Notes => q{
 
1498
            may report two points in focus even though a single AFPoint has been
 
1499
            selected, in which case the selected AFPoint is the first reported
 
1500
        },
 
1501
        PrintConv => {
 
1502
            0 => 'None',
 
1503
            1 => 'Lower-left, Bottom',
 
1504
            2 => 'Bottom',
 
1505
            3 => 'Lower-right, Bottom',
 
1506
            4 => 'Mid-left, Center',
 
1507
            5 => 'Center (horizontal)', #PH (K10D)
 
1508
            6 => 'Mid-right, Center',
 
1509
            7 => 'Upper-left, Top',
 
1510
            8 => 'Top',
 
1511
            9 => 'Upper-right, Top',
 
1512
            10 => 'Right',
 
1513
            11 => 'Lower-left, Mid-left',
 
1514
            12 => 'Upper-left, Mid-left',
 
1515
            13 => 'Bottom, Center',
 
1516
            14 => 'Top, Center',
 
1517
            15 => 'Lower-right, Mid-right',
 
1518
            16 => 'Upper-right, Mid-right',
 
1519
            17 => 'Left',
 
1520
            18 => 'Mid-left',
 
1521
            19 => 'Center (vertical)', #PH (K10D)
 
1522
            20 => 'Mid-right',
 
1523
        },
 
1524
    },
 
1525
);
 
1526
 
1413
1527
# tags in Pentax QuickTime videos (PH - tests with Optio WP)
1414
1528
# (note: very similar to information in Nikon videos)
1415
1529
%Image::ExifTool::Pentax::MOV = (
1463
1577
    },
1464
1578
);
1465
1579
 
 
1580
# Pentax type 2 (Casio-like) maker notes (ref 1)
 
1581
%Image::ExifTool::Pentax::Type2 = (
 
1582
    WRITE_PROC => \&Image::ExifTool::Exif::WriteExif,
 
1583
    CHECK_PROC => \&Image::ExifTool::Exif::CheckExif,
 
1584
    GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
 
1585
    WRITABLE => 'int16u',
 
1586
    NOTES => q{
 
1587
        These tags are used by the Pentax Optio 330 and 430, and are similar to the
 
1588
        tags used by Casio.
 
1589
    },
 
1590
    0x0001 => {
 
1591
        Name => 'RecordingMode',
 
1592
        PrintConv => {
 
1593
            0 => 'Auto',
 
1594
            1 => 'Night Scene',
 
1595
            2 => 'Manual',
 
1596
        },
 
1597
    },
 
1598
    0x0002 => {
 
1599
        Name => 'Quality',
 
1600
        PrintConv => {
 
1601
            0 => 'Good',
 
1602
            1 => 'Better',
 
1603
            2 => 'Best',
 
1604
        },
 
1605
    },
 
1606
    0x0003 => {
 
1607
        Name => 'FocusMode',
 
1608
        PrintConv => {
 
1609
            2 => 'Custom',
 
1610
            3 => 'Auto',
 
1611
        },
 
1612
    },
 
1613
    0x0004 => {
 
1614
        Name => 'FlashMode',
 
1615
        PrintConv => {
 
1616
            1 => 'Auto',
 
1617
            2 => 'On',
 
1618
            4 => 'Off',
 
1619
            6 => 'Red-eye reduction',
 
1620
        },
 
1621
    },
 
1622
    # Casio 0x0005 is FlashIntensity
 
1623
    # Casio 0x0006 is ObjectDistance
 
1624
    0x0007 => {
 
1625
        Name => 'WhiteBalance',
 
1626
        PrintConv => {
 
1627
            0 => 'Auto',
 
1628
            1 => 'Daylight',
 
1629
            2 => 'Shade',
 
1630
            3 => 'Tungsten',
 
1631
            4 => 'Fluorescent',
 
1632
            5 => 'Manual',
 
1633
        },
 
1634
    },
 
1635
    0x000a => {
 
1636
        Name => 'DigitalZoom',
 
1637
        Writable => 'int32u',
 
1638
    },
 
1639
    0x000b => {
 
1640
        Name => 'Sharpness',
 
1641
        PrintConv => {
 
1642
            0 => 'Normal',
 
1643
            1 => 'Soft',
 
1644
            2 => 'Hard',
 
1645
        },
 
1646
    },
 
1647
    0x000c => {
 
1648
        Name => 'Contrast',
 
1649
        PrintConv => {
 
1650
            0 => 'Normal',
 
1651
            1 => 'Low',
 
1652
            2 => 'High',
 
1653
        },
 
1654
    },
 
1655
    0x000d => {
 
1656
        Name => 'Saturation',
 
1657
        PrintConv => {
 
1658
            0 => 'Normal',
 
1659
            1 => 'Low',
 
1660
            2 => 'High',
 
1661
        },
 
1662
    },
 
1663
    0x0014 => {
 
1664
        Name => 'ISO',
 
1665
        Priority => 0,
 
1666
        PrintConv => {
 
1667
            10 => 100,
 
1668
            16 => 200,
 
1669
            50 => 50, #PH
 
1670
            100 => 100, #PH
 
1671
            200 => 200, #PH
 
1672
            400 => 400, #PH
 
1673
            800 => 800, #PH
 
1674
            1600 => 1600, #PH
 
1675
            3200 => 3200, #PH
 
1676
        },
 
1677
    },
 
1678
    0x0017 => {
 
1679
        Name => 'ColorFilter',
 
1680
        PrintConv => {
 
1681
            1 => 'Full',
 
1682
            2 => 'Black & White',
 
1683
            3 => 'Sepia',
 
1684
        },
 
1685
    },
 
1686
    # Casio 0x0018 is AFPoint
 
1687
    # Casio 0x0019 is FlashIntensity
 
1688
    0x0e00 => {
 
1689
        Name => 'PrintIM',
 
1690
        Description => 'Print Image Matching',
 
1691
        Writable => 0,
 
1692
        SubDirectory => {
 
1693
            TagTable => 'Image::ExifTool::PrintIM::Main',
 
1694
        },
 
1695
    },
 
1696
    0x1000 => {
 
1697
        Name => 'HometownCityCode',
 
1698
        Writable => 'undef',
 
1699
        Count => 4,
 
1700
    },
 
1701
    0x1001 => { #PH
 
1702
        Name => 'DestinationCityCode',
 
1703
        Writable => 'undef',
 
1704
        Count => 4,
 
1705
    },
 
1706
);
 
1707
 
 
1708
# ASCII-based maker notes of Optio E20 - PH
 
1709
%Image::ExifTool::Pentax::Type4 = (
 
1710
    PROCESS_PROC => \&Image::ExifTool::HP::ProcessHP,
 
1711
    GROUPS => { 0 => 'MakerNotes', 2 => 'Camera' },
 
1712
    NOTES => q{
 
1713
        The following few tags are extracted from the wealth of information
 
1714
        available in maker notes of the Optio E20.  These maker notes are stored as
 
1715
        ASCII text in a format very similar to some HP models.
 
1716
    },
 
1717
   'F/W Version' => 'FirmwareVersion',
 
1718
);
 
1719
 
 
1720
#------------------------------------------------------------------------------
 
1721
# Encrypt or decrypt Pentax ShutterCount (symmetrical encryption) - PH
 
1722
# Inputs: 0) shutter count value, 1) ExifTool object ref
 
1723
# Returns: Encrypted or decrypted ShutterCount
 
1724
sub CryptShutterCount($$)
 
1725
{
 
1726
    my ($val, $exifTool) = @_;
 
1727
    # Pentax Date and Time values are used in the encryption
 
1728
    return undef unless $$exifTool{PentaxDate} and $$exifTool{PentaxTime} and
 
1729
        length($$exifTool{PentaxDate})==4 and length($$exifTool{PentaxTime})>=3;
 
1730
    # get Date and Time as integers (after padding Time with a null byte)
 
1731
    my $date = unpack('N', $$exifTool{PentaxDate});
 
1732
    my $time = unpack('N', $$exifTool{PentaxTime} . "\0");
 
1733
    return $val ^ $date ^ (0xffffffff - $time);
 
1734
}
 
1735
 
1466
1736
 
1467
1737
1; # end
1468
1738
 
1512
1782
 
1513
1783
=item L<http://www.cybercom.net/~dcoffin/dcraw/>
1514
1784
 
1515
 
=item (...plus lots of testing with my Optio WP!)
 
1785
=item (...plus lots of testing with my Optio WP and K10D!)
1516
1786
 
1517
1787
=back
1518
1788
 
1519
1789
=head1 ACKNOWLEDGEMENTS
1520
1790
 
1521
 
Thanks to Wayne Smith, John Francis, Douglas O'Brien and Cvetan Ivanov for
1522
 
help figuring out some Pentax tags, and to Denis Bourez, Kazumichi Kawabata,
1523
 
David Buret and Barney Garrett for adding to the LensType list, and to Ger
1524
 
Vermeulen for contributing print conversion values for some tags.
 
1791
Thanks to Wayne Smith, John Francis, Douglas O'Brien Cvetan Ivanov and Jens
 
1792
Duttke for help figuring out some Pentax tags, Denis Bourez, Kazumichi
 
1793
Kawabata, David Buret, Barney Garrett and Axel Kellner for adding to the
 
1794
LensType list, and Ger Vermeulen for contributing print conversion values
 
1795
for some tags.
1525
1796
 
1526
1797
=head1 AUTHOR
1527
1798