author | Tero Marttila <terom@fixme.fi> |
Sat, 13 Jun 2009 20:31:51 +0300 | |
branch | new-exif |
changeset 104 | 6afe59e5ffae |
parent 103 | 63e89dc2d6f1 |
child 105 | effae6f38749 |
permissions | -rw-r--r-- |
102 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
4 |
""" |
|
5 |
EXIF file format data, including tag names, types, etc. |
|
6 |
||
7 |
Most of this was copied with modifications from EXIFpy: |
|
8 |
# Library to extract EXIF information from digital camera image files |
|
9 |
# http://sourceforge.net/projects/exif-py/ |
|
10 |
# |
|
11 |
# VERSION 1.1.0 |
|
12 |
# |
|
13 |
# Copyright (c) 2002-2007 Gene Cash All rights reserved |
|
14 |
# Copyright (c) 2007-2008 Ianaré Sévi All rights reserved |
|
15 |
# |
|
16 |
# Redistribution and use in source and binary forms, with or without |
|
17 |
# modification, are permitted provided that the following conditions |
|
18 |
# are met: |
|
19 |
# |
|
20 |
# 1. Redistributions of source code must retain the above copyright |
|
21 |
# notice, this list of conditions and the following disclaimer. |
|
22 |
# |
|
23 |
# 2. Redistributions in binary form must reproduce the above |
|
24 |
# copyright notice, this list of conditions and the following |
|
25 |
# disclaimer in the documentation and/or other materials provided |
|
26 |
# with the distribution. |
|
27 |
# |
|
28 |
# 3. Neither the name of the authors nor the names of its contributors |
|
29 |
# may be used to endorse or promote products derived from this |
|
30 |
# software without specific prior written permission. |
|
31 |
# |
|
32 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
33 |
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
34 |
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
35 |
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
36 |
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
37 |
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
38 |
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
39 |
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
40 |
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
41 |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
42 |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
43 |
||
44 |
""" |
|
45 |
||
103
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
46 |
import decimal, itertools |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
47 |
|
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
48 |
def filter_ascii (values) : |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
49 |
""" |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
50 |
Default post-filter for ASCII values. |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
51 |
|
104 | 52 |
This takes a single item of string data, splits it up into strings by ASCII-NUL. |
53 |
||
54 |
These sub-strings are then decoded into unicode as ASCII, and stripped. |
|
103
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
55 |
""" |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
56 |
|
104 | 57 |
return [string.decode('ascii', 'replace').rstrip() for string in values[0].split('\x00') if string] |
103
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
58 |
|
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
59 |
def build_ratio (num, denom) : |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
60 |
""" |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
61 |
Builds a Decimal ratio out of the given numerator and denominator |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
62 |
""" |
104 | 63 |
|
64 |
# XXX: this may be slow |
|
103
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
65 |
return decimal.Decimal(num) / decimal.Decimal(denom) |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
66 |
|
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
67 |
def filter_ratio (values) : |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
68 |
""" |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
69 |
Default post-filter for Ratio values. |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
70 |
|
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
71 |
This takes the pairs of numerator/denominator values and builds Decimals out of them |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
72 |
""" |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
73 |
|
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
74 |
return [build_ratio(values[i], values[i + 1]) for i in xrange(0, len(values), 2)] |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
75 |
|
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
76 |
|
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
77 |
# IFD Tag type information, indexed by code |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
78 |
# { type_code: (type_fmt, name, filter_func) } |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
79 |
# |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
80 |
# type_fmt's that are one char will be prefixed with the count for use with struct.unpack, those with more chars will |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
81 |
# be repeated as many times for use with struct.unpack. |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
82 |
FIELD_TYPES = { |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
83 |
# 0x0000: (None, 'Proprietary' ), # ??? no such type |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
84 |
0x0001: ('B', 'Byte', None ), |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
85 |
0x0002: ('s', 'ASCII', filter_ascii ), |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
86 |
0x0003: ('H', 'Short', None ), |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
87 |
0x0004: ('L', 'Long', None ), |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
88 |
0x0005: ('LL', 'Ratio', filter_ratio ), |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
89 |
0x0006: ('b', 'Signed Byte', None ), |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
90 |
0x0007: ('s', 'Undefined', None ), |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
91 |
0x0008: ('h', 'Signed Short', None ), |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
92 |
0x0009: ('l', 'Signed Long', None ), |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
93 |
0x000A: ('ll', 'Signed Ratio', filter_ratio ), |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
94 |
} |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
95 |
|
104 | 96 |
def map_values (spec, values) : |
103
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
97 |
""" |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
98 |
Map the given tag value to a printable string using the given value spec. |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
99 |
""" |
63e89dc2d6f1
new exif.py seems to work now, although still missing sub-IFDs
Tero Marttila <terom@fixme.fi>
parents:
102
diff
changeset
|
100 |
|
104 | 101 |
# XXX: ensure that this always returns a str/unicode |
102 | 102 |
|
104 | 103 |
if spec is None : |
104 |
# nothing to map |
|
105 |
return ", ".join(str(value) for value in values) |
|
102 | 106 |
|
104 | 107 |
elif callable(spec): |
108 |
# call mapping function |
|
109 |
return spec(values) |
|
110 |
||
111 |
elif isinstance(spec, dict) : |
|
112 |
# lookup value, default to repr |
|
113 |
return ", ".join(spec.get(value, repr(value)) for value in values) |
|
102 | 114 |
|
115 |
else : |
|
104 | 116 |
# unknown kind of spec |
117 |
raise ValueError(spec) |
|
102 | 118 |
|
104 | 119 |
USER_COMMENT_CHARSETS = { |
120 |
'ASCII': ('ascii', 'replace' ), |
|
121 |
'JIS': ('jis', 'error' ), |
|
122 |
||
123 |
# XXX: WTF? What kind of charset is 'Unicode' supposed to be? |
|
124 |
# UTF-16? Little-endian? Big-endian? |
|
125 |
# Confusing reigns: http://www.cpanforum.com/threads/7329 |
|
126 |
'UNICODE': ('utf16', 'error' ), |
|
127 |
} |
|
128 |
||
129 |
||
130 |
def decode_UserComment (values) : |
|
102 | 131 |
""" |
104 | 132 |
A UserComment field starts with an eight-byte encoding designator. |
102 | 133 |
""" |
134 |
||
104 | 135 |
# single binary string |
136 |
value, = values |
|
137 |
||
138 |
# split up |
|
139 |
charset, comment_raw = value[:8], value[8:] |
|
102 | 140 |
|
104 | 141 |
# strip NILs |
142 |
charset = charset.rstrip('\x00') |
|
143 |
||
144 |
# map |
|
145 |
encoding, replace = USER_COMMENT_CHARSETS.get(charset, ('ascii', 'replace')) |
|
146 |
||
147 |
# decode |
|
148 |
return [comment_raw.decode(encoding, replace)] |
|
149 |
||
150 |
# Mappings of Exif tag codes to name and decoding information. |
|
151 |
# { tag : (name, value_dict/value_func/None) } |
|
152 |
# |
|
153 |
# name is the official Exif tag name |
|
154 |
# value_dict is a { value: value_name } mapping for human-readable values |
|
155 |
# value_func is a `(values) -> values` mapping function which *overrides* the tag's type_func. |
|
156 |
# XXX: or does it? |
|
157 |
# otherwise, the value is left as-is. |
|
102 | 158 |
EXIF_TAGS = { |
104 | 159 |
0x0100: ('ImageWidth', None), |
160 |
0x0101: ('ImageLength', None), |
|
161 |
0x0102: ('BitsPerSample', None), |
|
102 | 162 |
0x0103: ('Compression', |
163 |
{1: 'Uncompressed', |
|
164 |
2: 'CCITT 1D', |
|
165 |
3: 'T4/Group 3 Fax', |
|
166 |
4: 'T6/Group 4 Fax', |
|
167 |
5: 'LZW', |
|
168 |
6: 'JPEG (old-style)', |
|
169 |
7: 'JPEG', |
|
170 |
8: 'Adobe Deflate', |
|
171 |
9: 'JBIG B&W', |
|
172 |
10: 'JBIG Color', |
|
173 |
32766: 'Next', |
|
174 |
32769: 'Epson ERF Compressed', |
|
175 |
32771: 'CCIRLEW', |
|
176 |
32773: 'PackBits', |
|
177 |
32809: 'Thunderscan', |
|
178 |
32895: 'IT8CTPAD', |
|
179 |
32896: 'IT8LW', |
|
180 |
32897: 'IT8MP', |
|
181 |
32898: 'IT8BL', |
|
182 |
32908: 'PixarFilm', |
|
183 |
32909: 'PixarLog', |
|
184 |
32946: 'Deflate', |
|
185 |
32947: 'DCS', |
|
186 |
34661: 'JBIG', |
|
187 |
34676: 'SGILog', |
|
188 |
34677: 'SGILog24', |
|
189 |
34712: 'JPEG 2000', |
|
190 |
34713: 'Nikon NEF Compressed', |
|
191 |
65000: 'Kodak DCR Compressed', |
|
192 |
65535: 'Pentax PEF Compressed'}), |
|
104 | 193 |
0x0106: ('PhotometricInterpretation', None), |
194 |
0x0107: ('Thresholding', None), |
|
195 |
0x010A: ('FillOrder', None), |
|
196 |
0x010D: ('DocumentName', None), |
|
197 |
0x010E: ('ImageDescription', None), |
|
198 |
0x010F: ('Make', None), |
|
199 |
0x0110: ('Model', None), |
|
200 |
0x0111: ('StripOffsets', None), |
|
102 | 201 |
0x0112: ('Orientation', |
202 |
{1: 'Horizontal (normal)', |
|
203 |
2: 'Mirrored horizontal', |
|
204 |
3: 'Rotated 180', |
|
205 |
4: 'Mirrored vertical', |
|
206 |
5: 'Mirrored horizontal then rotated 90 CCW', |
|
207 |
6: 'Rotated 90 CW', |
|
208 |
7: 'Mirrored horizontal then rotated 90 CW', |
|
209 |
8: 'Rotated 90 CCW'}), |
|
104 | 210 |
0x0115: ('SamplesPerPixel', None), |
211 |
0x0116: ('RowsPerStrip', None), |
|
212 |
0x0117: ('StripByteCounts', None), |
|
213 |
0x011A: ('XResolution', None), |
|
214 |
0x011B: ('YResolution', None), |
|
215 |
0x011C: ('PlanarConfiguration', None), |
|
216 |
0x011D: ('PageName', None), |
|
102 | 217 |
0x0128: ('ResolutionUnit', |
218 |
{1: 'Not Absolute', |
|
219 |
2: 'Pixels/Inch', |
|
220 |
3: 'Pixels/Centimeter'}), |
|
104 | 221 |
0x012D: ('TransferFunction', None), |
222 |
0x0131: ('Software', None), |
|
223 |
0x0132: ('DateTime', None), |
|
224 |
0x013B: ('Artist', None), |
|
225 |
0x013E: ('WhitePoint', None), |
|
226 |
0x013F: ('PrimaryChromaticities', None), |
|
227 |
0x0156: ('TransferRange', None), |
|
228 |
0x0200: ('JPEGProc', None), |
|
229 |
0x0201: ('JPEGInterchangeFormat', None), |
|
230 |
0x0202: ('JPEGInterchangeFormatLength', None), |
|
231 |
0x0211: ('YCbCrCoefficients', None), |
|
232 |
0x0212: ('YCbCrSubSampling', None), |
|
102 | 233 |
0x0213: ('YCbCrPositioning', |
234 |
{1: 'Centered', |
|
235 |
2: 'Co-sited'}), |
|
104 | 236 |
0x0214: ('ReferenceBlackWhite', None), |
102 | 237 |
|
104 | 238 |
0x4746: ('Rating', None), |
239 |
||
240 |
0x828D: ('CFARepeatPatternDim', None), |
|
241 |
0x828E: ('CFAPattern', None), |
|
242 |
0x828F: ('BatteryLevel', None), |
|
243 |
0x8298: ('Copyright', None), |
|
244 |
0x829A: ('ExposureTime', None), |
|
245 |
0x829D: ('FNumber', None), |
|
246 |
0x83BB: ('IPTC/NAA', None), |
|
247 |
0x8769: ('ExifOffset', None), |
|
248 |
0x8773: ('InterColorProfile', None), |
|
102 | 249 |
0x8822: ('ExposureProgram', |
250 |
{0: 'Unidentified', |
|
251 |
1: 'Manual', |
|
252 |
2: 'Program Normal', |
|
253 |
3: 'Aperture Priority', |
|
254 |
4: 'Shutter Priority', |
|
255 |
5: 'Program Creative', |
|
256 |
6: 'Program Action', |
|
257 |
7: 'Portrait Mode', |
|
258 |
8: 'Landscape Mode'}), |
|
104 | 259 |
0x8824: ('SpectralSensitivity', None), |
260 |
0x8825: ('GPSInfo', None), |
|
261 |
0x8827: ('ISOSpeedRatings', None), |
|
262 |
0x8828: ('OECF', None), |
|
263 |
0x9000: ('ExifVersion', None), |
|
264 |
0x9003: ('DateTimeOriginal', None), |
|
265 |
0x9004: ('DateTimeDigitized', None), |
|
102 | 266 |
0x9101: ('ComponentsConfiguration', |
267 |
{0: '', |
|
268 |
1: 'Y', |
|
269 |
2: 'Cb', |
|
270 |
3: 'Cr', |
|
271 |
4: 'Red', |
|
272 |
5: 'Green', |
|
273 |
6: 'Blue'}), |
|
104 | 274 |
0x9102: ('CompressedBitsPerPixel', None), |
275 |
0x9201: ('ShutterSpeedValue', None), |
|
276 |
0x9202: ('ApertureValue', None), |
|
277 |
0x9203: ('BrightnessValue', None), |
|
278 |
0x9204: ('ExposureBiasValue', None), |
|
279 |
0x9205: ('MaxApertureValue', None), |
|
280 |
0x9206: ('SubjectDistance', None), |
|
102 | 281 |
0x9207: ('MeteringMode', |
282 |
{0: 'Unidentified', |
|
283 |
1: 'Average', |
|
284 |
2: 'CenterWeightedAverage', |
|
285 |
3: 'Spot', |
|
286 |
4: 'MultiSpot', |
|
287 |
5: 'Pattern'}), |
|
288 |
0x9208: ('LightSource', |
|
289 |
{0: 'Unknown', |
|
290 |
1: 'Daylight', |
|
291 |
2: 'Fluorescent', |
|
292 |
3: 'Tungsten', |
|
293 |
9: 'Fine Weather', |
|
294 |
10: 'Flash', |
|
295 |
11: 'Shade', |
|
296 |
12: 'Daylight Fluorescent', |
|
297 |
13: 'Day White Fluorescent', |
|
298 |
14: 'Cool White Fluorescent', |
|
299 |
15: 'White Fluorescent', |
|
300 |
17: 'Standard Light A', |
|
301 |
18: 'Standard Light B', |
|
302 |
19: 'Standard Light C', |
|
303 |
20: 'D55', |
|
304 |
21: 'D65', |
|
305 |
22: 'D75', |
|
306 |
255: 'Other'}), |
|
307 |
0x9209: ('Flash', |
|
308 |
{0: 'No', |
|
309 |
1: 'Fired', |
|
310 |
5: 'Fired (?)', # no return sensed |
|
311 |
7: 'Fired (!)', # return sensed |
|
312 |
9: 'Fill Fired', |
|
313 |
13: 'Fill Fired (?)', |
|
314 |
15: 'Fill Fired (!)', |
|
315 |
16: 'Off', |
|
316 |
24: 'Auto Off', |
|
317 |
25: 'Auto Fired', |
|
318 |
29: 'Auto Fired (?)', |
|
319 |
31: 'Auto Fired (!)', |
|
320 |
32: 'Not Available'}), |
|
104 | 321 |
0x920A: ('FocalLength', None), |
322 |
0x9214: ('SubjectArea', None), |
|
323 |
0x927C: ('MakerNote', None), |
|
324 |
0x9286: ('UserComment', decode_UserComment), |
|
325 |
0x9290: ('SubSecTime', None), |
|
326 |
0x9291: ('SubSecTimeOriginal', None), |
|
327 |
0x9292: ('SubSecTimeDigitized', None), |
|
102 | 328 |
|
329 |
# used by Windows Explorer |
|
104 | 330 |
0x9C9B: ('XPTitle', None), |
331 |
0x9C9C: ('XPComment', None), |
|
332 |
0x9C9D: ('XPAuthor', None), #(ignored by Windows Explorer if Artist exists) |
|
333 |
0x9C9E: ('XPKeywords', None), |
|
334 |
0x9C9F: ('XPSubject', None), |
|
102 | 335 |
|
104 | 336 |
0xA000: ('FlashPixVersion', None), |
102 | 337 |
0xA001: ('ColorSpace', |
338 |
{1: 'sRGB', |
|
339 |
2: 'Adobe RGB', |
|
340 |
65535: 'Uncalibrated'}), |
|
104 | 341 |
0xA002: ('ExifImageWidth', None), |
342 |
0xA003: ('ExifImageLength', None), |
|
343 |
0xA005: ('InteroperabilityOffset', None), |
|
344 |
0xA20B: ('FlashEnergy', None), # 0x920B in TIFF/EP |
|
345 |
0xA20C: ('SpatialFrequencyResponse', None), # 0x920C |
|
346 |
0xA20E: ('FocalPlaneXResolution', None), # 0x920E |
|
347 |
0xA20F: ('FocalPlaneYResolution', None), # 0x920F |
|
348 |
0xA210: ('FocalPlaneResolutionUnit', None), # 0x9210 |
|
349 |
0xA214: ('SubjectLocation', None), # 0x9214 |
|
350 |
0xA215: ('ExposureIndex', None), # 0x9215 |
|
102 | 351 |
0xA217: ('SensingMethod', # 0x9217 |
352 |
{1: 'Not defined', |
|
353 |
2: 'One-chip color area', |
|
354 |
3: 'Two-chip color area', |
|
355 |
4: 'Three-chip color area', |
|
356 |
5: 'Color sequential area', |
|
357 |
7: 'Trilinear', |
|
358 |
8: 'Color sequential linear'}), |
|
359 |
0xA300: ('FileSource', |
|
360 |
{1: 'Film Scanner', |
|
361 |
2: 'Reflection Print Scanner', |
|
362 |
3: 'Digital Camera'}), |
|
363 |
0xA301: ('SceneType', |
|
364 |
{1: 'Directly Photographed'}), |
|
104 | 365 |
0xA302: ('CVAPattern', None), |
102 | 366 |
0xA401: ('CustomRendered', |
367 |
{0: 'Normal', |
|
368 |
1: 'Custom'}), |
|
369 |
0xA402: ('ExposureMode', |
|
370 |
{0: 'Auto Exposure', |
|
371 |
1: 'Manual Exposure', |
|
372 |
2: 'Auto Bracket'}), |
|
373 |
0xA403: ('WhiteBalance', |
|
374 |
{0: 'Auto', |
|
375 |
1: 'Manual'}), |
|
104 | 376 |
0xA404: ('DigitalZoomRatio', None), |
377 |
0xA405: ('FocalLengthIn35mmFilm', None), |
|
102 | 378 |
0xA406: ('SceneCaptureType', |
379 |
{0: 'Standard', |
|
380 |
1: 'Landscape', |
|
381 |
2: 'Portrait', |
|
382 |
3: 'Night)'}), |
|
383 |
0xA407: ('GainControl', |
|
384 |
{0: 'None', |
|
385 |
1: 'Low gain up', |
|
386 |
2: 'High gain up', |
|
387 |
3: 'Low gain down', |
|
388 |
4: 'High gain down'}), |
|
389 |
0xA408: ('Contrast', |
|
390 |
{0: 'Normal', |
|
391 |
1: 'Soft', |
|
392 |
2: 'Hard'}), |
|
393 |
0xA409: ('Saturation', |
|
394 |
{0: 'Normal', |
|
395 |
1: 'Soft', |
|
396 |
2: 'Hard'}), |
|
397 |
0xA40A: ('Sharpness', |
|
398 |
{0: 'Normal', |
|
399 |
1: 'Soft', |
|
400 |
2: 'Hard'}), |
|
104 | 401 |
0xA40B: ('DeviceSettingDescription', None), |
402 |
0xA40C: ('SubjectDistanceRange', None), |
|
403 |
0xA500: ('Gamma', None), |
|
404 |
0xC4A5: ('PrintIM', None), |
|
405 |
0xEA1C: ('Padding', None), |
|
102 | 406 |
} |
407 |
||
408 |
# interoperability tags |
|
409 |
INTR_TAGS = { |
|
104 | 410 |
0x0001: ('InteroperabilityIndex', None), |
411 |
0x0002: ('InteroperabilityVersion', None), |
|
412 |
0x1000: ('RelatedImageFileFormat', None), |
|
413 |
0x1001: ('RelatedImageWidth', None), |
|
414 |
0x1002: ('RelatedImageLength', None), |
|
102 | 415 |
} |
416 |
||
417 |
# GPS tags (not used yet, haven't seen camera with GPS) |
|
418 |
GPS_TAGS = { |
|
104 | 419 |
0x0000: ('GPSVersionID', None), |
420 |
0x0001: ('GPSLatitudeRef', None), |
|
421 |
0x0002: ('GPSLatitude', None), |
|
422 |
0x0003: ('GPSLongitudeRef', None), |
|
423 |
0x0004: ('GPSLongitude', None), |
|
424 |
0x0005: ('GPSAltitudeRef', None), |
|
425 |
0x0006: ('GPSAltitude', None), |
|
426 |
0x0007: ('GPSTimeStamp', None), |
|
427 |
0x0008: ('GPSSatellites', None), |
|
428 |
0x0009: ('GPSStatus', None), |
|
429 |
0x000A: ('GPSMeasureMode', None), |
|
430 |
0x000B: ('GPSDOP', None), |
|
431 |
0x000C: ('GPSSpeedRef', None), |
|
432 |
0x000D: ('GPSSpeed', None), |
|
433 |
0x000E: ('GPSTrackRef', None), |
|
434 |
0x000F: ('GPSTrack', None), |
|
435 |
0x0010: ('GPSImgDirectionRef', None), |
|
436 |
0x0011: ('GPSImgDirection', None), |
|
437 |
0x0012: ('GPSMapDatum', None), |
|
438 |
0x0013: ('GPSDestLatitudeRef', None), |
|
439 |
0x0014: ('GPSDestLatitude', None), |
|
440 |
0x0015: ('GPSDestLongitudeRef', None), |
|
441 |
0x0016: ('GPSDestLongitude', None), |
|
442 |
0x0017: ('GPSDestBearingRef', None), |
|
443 |
0x0018: ('GPSDestBearing', None), |
|
444 |
0x0019: ('GPSDestDistanceRef', None), |
|
445 |
0x001A: ('GPSDestDistance', None), |
|
446 |
0x001D: ('GPSDate', None), |
|
102 | 447 |
} |
448 |
||
449 |
# http://tomtia.plala.jp/DigitalCamera/MakerNote/index.asp |
|
104 | 450 |
def nikon_ev_bias (seq) : |
451 |
""" |
|
452 |
# First digit seems to be in steps of 1/6 EV. |
|
453 |
# Does the third value mean the step size? It is usually 6, |
|
454 |
# but it is 12 for the ExposureDifference. |
|
455 |
""" |
|
456 |
||
457 |
# check for an error condition that could cause a crash. |
|
458 |
# this only happens if something has gone really wrong in |
|
102 | 459 |
# reading the Nikon MakerNote. |
104 | 460 |
if len(seq) < 4 : |
461 |
return "" |
|
462 |
||
102 | 463 |
if seq == [252, 1, 6, 0]: |
464 |
return "-2/3 EV" |
|
104 | 465 |
|
102 | 466 |
if seq == [253, 1, 6, 0]: |
467 |
return "-1/2 EV" |
|
104 | 468 |
|
102 | 469 |
if seq == [254, 1, 6, 0]: |
470 |
return "-1/3 EV" |
|
104 | 471 |
|
102 | 472 |
if seq == [0, 1, 6, 0]: |
473 |
return "0 EV" |
|
104 | 474 |
|
102 | 475 |
if seq == [2, 1, 6, 0]: |
476 |
return "+1/3 EV" |
|
104 | 477 |
|
102 | 478 |
if seq == [3, 1, 6, 0]: |
479 |
return "+1/2 EV" |
|
104 | 480 |
|
102 | 481 |
if seq == [4, 1, 6, 0]: |
482 |
return "+2/3 EV" |
|
104 | 483 |
|
484 |
# handle combinations not in the table. |
|
102 | 485 |
a = seq[0] |
104 | 486 |
|
487 |
# causes headaches for the +/- logic, so special case it. |
|
102 | 488 |
if a == 0: |
489 |
return "0 EV" |
|
104 | 490 |
|
102 | 491 |
if a > 127: |
492 |
a = 256 - a |
|
493 |
ret_str = "-" |
|
494 |
else: |
|
495 |
ret_str = "+" |
|
104 | 496 |
|
497 |
b = seq[2] # assume third value means the step size |
|
498 |
||
102 | 499 |
whole = a / b |
104 | 500 |
|
102 | 501 |
a = a % b |
104 | 502 |
|
503 |
if whole != 0 : |
|
102 | 504 |
ret_str = ret_str + str(whole) + " " |
104 | 505 |
|
506 |
if a == 0 : |
|
102 | 507 |
ret_str = ret_str + "EV" |
104 | 508 |
else : |
102 | 509 |
r = Ratio(a, b) |
510 |
ret_str = ret_str + r.__repr__() + " EV" |
|
104 | 511 |
|
102 | 512 |
return ret_str |
513 |
||
514 |
# Nikon E99x MakerNote Tags |
|
515 |
MAKERNOTE_NIKON_NEWER_TAGS={ |
|
104 | 516 |
0x0001: ('MakernoteVersion', None), # Sometimes binary |
517 |
0x0002: ('ISOSetting', None), |
|
518 |
0x0003: ('ColorMode', None), |
|
519 |
0x0004: ('Quality', None), |
|
520 |
0x0005: ('Whitebalance', None), |
|
521 |
0x0006: ('ImageSharpening', None), |
|
522 |
0x0007: ('FocusMode', None), |
|
523 |
0x0008: ('FlashSetting', None), |
|
524 |
0x0009: ('AutoFlashMode', None), |
|
525 |
0x000B: ('WhiteBalanceBias', None), |
|
526 |
0x000C: ('WhiteBalanceRBCoeff', None), |
|
102 | 527 |
0x000D: ('ProgramShift', nikon_ev_bias), |
528 |
# Nearly the same as the other EV vals, but step size is 1/12 EV (?) |
|
529 |
0x000E: ('ExposureDifference', nikon_ev_bias), |
|
104 | 530 |
0x000F: ('ISOSelection', None), |
531 |
0x0011: ('NikonPreview', None), |
|
102 | 532 |
0x0012: ('FlashCompensation', nikon_ev_bias), |
104 | 533 |
0x0013: ('ISOSpeedRequested', None), |
534 |
0x0016: ('PhotoCornerCoordinates', None), |
|
102 | 535 |
# 0x0017: Unknown, but most likely an EV value |
536 |
0x0018: ('FlashBracketCompensationApplied', nikon_ev_bias), |
|
104 | 537 |
0x0019: ('AEBracketCompensationApplied', None), |
538 |
0x001A: ('ImageProcessing', None), |
|
539 |
0x001B: ('CropHiSpeed', None), |
|
540 |
0x001D: ('SerialNumber', None), # Conflict with 0x00A0 ? |
|
541 |
0x001E: ('ColorSpace', None), |
|
542 |
0x001F: ('VRInfo', None), |
|
543 |
0x0020: ('ImageAuthentication', None), |
|
544 |
0x0022: ('ActiveDLighting', None), |
|
545 |
0x0023: ('PictureControl', None), |
|
546 |
0x0024: ('WorldTime', None), |
|
547 |
0x0025: ('ISOInfo', None), |
|
548 |
0x0080: ('ImageAdjustment', None), |
|
549 |
0x0081: ('ToneCompensation', None), |
|
550 |
0x0082: ('AuxiliaryLens', None), |
|
551 |
0x0083: ('LensType', None), |
|
552 |
0x0084: ('LensMinMaxFocalMaxAperture', None), |
|
553 |
0x0085: ('ManualFocusDistance', None), |
|
554 |
0x0086: ('DigitalZoomFactor', None), |
|
102 | 555 |
0x0087: ('FlashMode', |
556 |
{0x00: 'Did Not Fire', |
|
557 |
0x01: 'Fired, Manual', |
|
558 |
0x07: 'Fired, External', |
|
559 |
0x08: 'Fired, Commander Mode ', |
|
560 |
0x09: 'Fired, TTL Mode'}), |
|
561 |
0x0088: ('AFFocusPosition', |
|
562 |
{0x0000: 'Center', |
|
563 |
0x0100: 'Top', |
|
564 |
0x0200: 'Bottom', |
|
565 |
0x0300: 'Left', |
|
566 |
0x0400: 'Right'}), |
|
567 |
0x0089: ('BracketingMode', |
|
568 |
{0x00: 'Single frame, no bracketing', |
|
569 |
0x01: 'Continuous, no bracketing', |
|
570 |
0x02: 'Timer, no bracketing', |
|
571 |
0x10: 'Single frame, exposure bracketing', |
|
572 |
0x11: 'Continuous, exposure bracketing', |
|
573 |
0x12: 'Timer, exposure bracketing', |
|
574 |
0x40: 'Single frame, white balance bracketing', |
|
575 |
0x41: 'Continuous, white balance bracketing', |
|
576 |
0x42: 'Timer, white balance bracketing'}), |
|
104 | 577 |
0x008A: ('AutoBracketRelease', None), |
578 |
0x008B: ('LensFStops', None), |
|
579 |
0x008C: ('NEFCurve1', None), # ExifTool calls this 'ContrastCurve' |
|
580 |
0x008D: ('ColorMode', None), |
|
581 |
0x008F: ('SceneMode', None), |
|
582 |
0x0090: ('LightingType', None), |
|
583 |
0x0091: ('ShotInfo', None), # First 4 bytes are a version number in ASCII |
|
584 |
0x0092: ('HueAdjustment', None), |
|
102 | 585 |
# ExifTool calls this 'NEFCompression', should be 1-4 |
104 | 586 |
0x0093: ('Compression', None), |
102 | 587 |
0x0094: ('Saturation', |
588 |
{-3: 'B&W', |
|
589 |
-2: '-2', |
|
590 |
-1: '-1', |
|
591 |
0: '0', |
|
592 |
1: '1', |
|
593 |
2: '2'}), |
|
104 | 594 |
0x0095: ('NoiseReduction', None), |
595 |
0x0096: ('NEFCurve2', None), # ExifTool calls this 'LinearizationTable' |
|
596 |
0x0097: ('ColorBalance', None), # First 4 bytes are a version number in ASCII |
|
597 |
0x0098: ('LensData', None), # First 4 bytes are a version number in ASCII |
|
598 |
0x0099: ('RawImageCenter', None), |
|
599 |
0x009A: ('SensorPixelSize', None), |
|
600 |
0x009C: ('Scene Assist', None), |
|
601 |
0x009E: ('RetouchHistory', None), |
|
602 |
0x00A0: ('SerialNumber', None), |
|
603 |
0x00A2: ('ImageDataSize', None), |
|
102 | 604 |
# 00A3: unknown - a single byte 0 |
605 |
# 00A4: In NEF, looks like a 4 byte ASCII version number ('0200') |
|
104 | 606 |
0x00A5: ('ImageCount', None), |
607 |
0x00A6: ('DeletedImageCount', None), |
|
608 |
0x00A7: ('TotalShutterReleases', None), |
|
102 | 609 |
# First 4 bytes are a version number in ASCII, with version specific |
610 |
# info to follow. Its hard to treat it as a string due to embedded nulls. |
|
104 | 611 |
0x00A8: ('FlashInfo', None), |
612 |
0x00A9: ('ImageOptimization', None), |
|
613 |
0x00AA: ('Saturation', None), |
|
614 |
0x00AB: ('DigitalVariProgram', None), |
|
615 |
0x00AC: ('ImageStabilization', None), |
|
616 |
0x00AD: ('Responsive AF', None), # 'AFResponse' |
|
617 |
0x00B0: ('MultiExposure', None), |
|
618 |
0x00B1: ('HighISONoiseReduction', None), |
|
619 |
0x00B7: ('AFInfo', None), |
|
620 |
0x00B8: ('FileInfo', None), |
|
102 | 621 |
# 00B9: unknown |
104 | 622 |
0x0100: ('DigitalICE', None), |
102 | 623 |
0x0103: ('PreviewCompression', |
624 |
{1: 'Uncompressed', |
|
625 |
2: 'CCITT 1D', |
|
626 |
3: 'T4/Group 3 Fax', |
|
627 |
4: 'T6/Group 4 Fax', |
|
628 |
5: 'LZW', |
|
629 |
6: 'JPEG (old-style)', |
|
630 |
7: 'JPEG', |
|
631 |
8: 'Adobe Deflate', |
|
632 |
9: 'JBIG B&W', |
|
633 |
10: 'JBIG Color', |
|
634 |
32766: 'Next', |
|
635 |
32769: 'Epson ERF Compressed', |
|
636 |
32771: 'CCIRLEW', |
|
637 |
32773: 'PackBits', |
|
638 |
32809: 'Thunderscan', |
|
639 |
32895: 'IT8CTPAD', |
|
640 |
32896: 'IT8LW', |
|
641 |
32897: 'IT8MP', |
|
642 |
32898: 'IT8BL', |
|
643 |
32908: 'PixarFilm', |
|
644 |
32909: 'PixarLog', |
|
645 |
32946: 'Deflate', |
|
646 |
32947: 'DCS', |
|
647 |
34661: 'JBIG', |
|
648 |
34676: 'SGILog', |
|
649 |
34677: 'SGILog24', |
|
650 |
34712: 'JPEG 2000', |
|
651 |
34713: 'Nikon NEF Compressed', |
|
652 |
65000: 'Kodak DCR Compressed', |
|
653 |
65535: 'Pentax PEF Compressed',}), |
|
104 | 654 |
0x0201: ('PreviewImageStart', None), |
655 |
0x0202: ('PreviewImageLength', None), |
|
102 | 656 |
0x0213: ('PreviewYCbCrPositioning', |
657 |
{1: 'Centered', |
|
658 |
2: 'Co-sited'}), |
|
104 | 659 |
0x0010: ('DataDump', None), |
102 | 660 |
} |
661 |
||
662 |
MAKERNOTE_NIKON_OLDER_TAGS = { |
|
663 |
0x0003: ('Quality', |
|
664 |
{1: 'VGA Basic', |
|
665 |
2: 'VGA Normal', |
|
666 |
3: 'VGA Fine', |
|
667 |
4: 'SXGA Basic', |
|
668 |
5: 'SXGA Normal', |
|
669 |
6: 'SXGA Fine'}), |
|
670 |
0x0004: ('ColorMode', |
|
671 |
{1: 'Color', |
|
672 |
2: 'Monochrome'}), |
|
673 |
0x0005: ('ImageAdjustment', |
|
674 |
{0: 'Normal', |
|
675 |
1: 'Bright+', |
|
676 |
2: 'Bright-', |
|
677 |
3: 'Contrast+', |
|
678 |
4: 'Contrast-'}), |
|
679 |
0x0006: ('CCDSpeed', |
|
680 |
{0: 'ISO 80', |
|
681 |
2: 'ISO 160', |
|
682 |
4: 'ISO 320', |
|
683 |
5: 'ISO 100'}), |
|
684 |
0x0007: ('WhiteBalance', |
|
685 |
{0: 'Auto', |
|
686 |
1: 'Preset', |
|
687 |
2: 'Daylight', |
|
688 |
3: 'Incandescent', |
|
689 |
4: 'Fluorescent', |
|
690 |
5: 'Cloudy', |
|
691 |
6: 'Speed Light'}), |
|
692 |
} |
|
693 |
||
104 | 694 |
def olympus_special_mode (values) : |
695 |
""" |
|
696 |
Decode Olympus SpecialMode tag in MakerNote |
|
697 |
""" |
|
698 |
||
699 |
a = { |
|
102 | 700 |
0: 'Normal', |
701 |
1: 'Unknown', |
|
702 |
2: 'Fast', |
|
104 | 703 |
3: 'Panorama' |
704 |
} |
|
705 |
||
706 |
b = { |
|
102 | 707 |
0: 'Non-panoramic', |
708 |
1: 'Left to right', |
|
709 |
2: 'Right to left', |
|
710 |
3: 'Bottom to top', |
|
104 | 711 |
4: 'Top to bottom' |
712 |
} |
|
713 |
||
102 | 714 |
if v[0] not in a or v[2] not in b: |
104 | 715 |
return values |
716 |
||
102 | 717 |
return '%s - sequence %d - %s' % (a[v[0]], v[1], b[v[2]]) |
718 |
||
719 |
MAKERNOTE_OLYMPUS_TAGS={ |
|
720 |
# ah HAH! those sneeeeeaky bastids! this is how they get past the fact |
|
721 |
# that a JPEG thumbnail is not allowed in an uncompressed TIFF file |
|
104 | 722 |
0x0100: ('JPEGThumbnail', None), |
102 | 723 |
0x0200: ('SpecialMode', olympus_special_mode), |
724 |
0x0201: ('JPEGQual', |
|
725 |
{1: 'SQ', |
|
726 |
2: 'HQ', |
|
727 |
3: 'SHQ'}), |
|
728 |
0x0202: ('Macro', |
|
729 |
{0: 'Normal', |
|
730 |
1: 'Macro', |
|
731 |
2: 'SuperMacro'}), |
|
732 |
0x0203: ('BWMode', |
|
733 |
{0: 'Off', |
|
734 |
1: 'On'}), |
|
104 | 735 |
0x0204: ('DigitalZoom', None), |
736 |
0x0205: ('FocalPlaneDiagonal', None), |
|
737 |
0x0206: ('LensDistortionParams', None), |
|
738 |
0x0207: ('SoftwareRelease', None), |
|
739 |
0x0208: ('PictureInfo', None), |
|
740 |
0x0209: ('CameraID', None), # print as string |
|
741 |
0x0F00: ('DataDump', None), |
|
742 |
0x0300: ('PreCaptureFrames', None), |
|
743 |
0x0404: ('SerialNumber', None), |
|
744 |
0x1000: ('ShutterSpeedValue', None), |
|
745 |
0x1001: ('ISOValue', None), |
|
746 |
0x1002: ('ApertureValue', None), |
|
747 |
0x1003: ('BrightnessValue', None), |
|
748 |
0x1004: ('FlashMode', None), |
|
102 | 749 |
0x1004: ('FlashMode', |
750 |
{2: 'On', |
|
751 |
3: 'Off'}), |
|
752 |
0x1005: ('FlashDevice', |
|
753 |
{0: 'None', |
|
754 |
1: 'Internal', |
|
755 |
4: 'External', |
|
756 |
5: 'Internal + External'}), |
|
104 | 757 |
0x1006: ('ExposureCompensation', None), |
758 |
0x1007: ('SensorTemperature', None), |
|
759 |
0x1008: ('LensTemperature', None), |
|
102 | 760 |
0x100b: ('FocusMode', |
761 |
{0: 'Auto', |
|
762 |
1: 'Manual'}), |
|
104 | 763 |
0x1017: ('RedBalance', None), |
764 |
0x1018: ('BlueBalance', None), |
|
765 |
0x101a: ('SerialNumber', None), |
|
766 |
0x1023: ('FlashExposureComp', None), |
|
102 | 767 |
0x1026: ('ExternalFlashBounce', |
768 |
{0: 'No', |
|
769 |
1: 'Yes'}), |
|
104 | 770 |
0x1027: ('ExternalFlashZoom', None), |
771 |
0x1028: ('ExternalFlashMode', None), |
|
102 | 772 |
0x1029: ('Contrast int16u', |
773 |
{0: 'High', |
|
774 |
1: 'Normal', |
|
775 |
2: 'Low'}), |
|
104 | 776 |
0x102a: ('SharpnessFactor', None), |
777 |
0x102b: ('ColorControl', None), |
|
778 |
0x102c: ('ValidBits', None), |
|
779 |
0x102d: ('CoringFilter', None), |
|
780 |
0x102e: ('OlympusImageWidth', None), |
|
781 |
0x102f: ('OlympusImageHeight', None), |
|
782 |
0x1034: ('CompressionRatio', None), |
|
102 | 783 |
0x1035: ('PreviewImageValid', |
784 |
{0: 'No', |
|
785 |
1: 'Yes'}), |
|
104 | 786 |
0x1036: ('PreviewImageStart', None), |
787 |
0x1037: ('PreviewImageLength', None), |
|
102 | 788 |
0x1039: ('CCDScanMode', |
789 |
{0: 'Interlaced', |
|
790 |
1: 'Progressive'}), |
|
791 |
0x103a: ('NoiseReduction', |
|
792 |
{0: 'Off', |
|
793 |
1: 'On'}), |
|
104 | 794 |
0x103b: ('InfinityLensStep', None), |
795 |
0x103c: ('NearLensStep', None), |
|
102 | 796 |
|
797 |
# TODO - these need extra definitions |
|
798 |
# http://search.cpan.org/src/EXIFTOOL/Image-ExifTool-6.90/html/TagNames/Olympus.html |
|
104 | 799 |
0x2010: ('Equipment', None), |
800 |
0x2020: ('CameraSettings', None), |
|
801 |
0x2030: ('RawDevelopment', None), |
|
802 |
0x2040: ('ImageProcessing', None), |
|
803 |
0x2050: ('FocusInfo', None), |
|
804 |
0x3000: ('RawInfo ', None), |
|
102 | 805 |
} |
806 |
||
807 |
# 0x2020 CameraSettings |
|
808 |
MAKERNOTE_OLYMPUS_TAG_0x2020={ |
|
809 |
0x0100: ('PreviewImageValid', |
|
810 |
{0: 'No', |
|
811 |
1: 'Yes'}), |
|
104 | 812 |
0x0101: ('PreviewImageStart', None), |
813 |
0x0102: ('PreviewImageLength', None), |
|
102 | 814 |
0x0200: ('ExposureMode', |
815 |
{1: 'Manual', |
|
816 |
2: 'Program', |
|
817 |
3: 'Aperture-priority AE', |
|
818 |
4: 'Shutter speed priority AE', |
|
819 |
5: 'Program-shift'}), |
|
820 |
0x0201: ('AELock', |
|
821 |
{0: 'Off', |
|
822 |
1: 'On'}), |
|
823 |
0x0202: ('MeteringMode', |
|
824 |
{2: 'Center Weighted', |
|
825 |
3: 'Spot', |
|
826 |
5: 'ESP', |
|
827 |
261: 'Pattern+AF', |
|
828 |
515: 'Spot+Highlight control', |
|
829 |
1027: 'Spot+Shadow control'}), |
|
830 |
0x0300: ('MacroMode', |
|
831 |
{0: 'Off', |
|
832 |
1: 'On'}), |
|
833 |
0x0301: ('FocusMode', |
|
834 |
{0: 'Single AF', |
|
835 |
1: 'Sequential shooting AF', |
|
836 |
2: 'Continuous AF', |
|
837 |
3: 'Multi AF', |
|
838 |
10: 'MF'}), |
|
839 |
0x0302: ('FocusProcess', |
|
840 |
{0: 'AF Not Used', |
|
841 |
1: 'AF Used'}), |
|
842 |
0x0303: ('AFSearch', |
|
843 |
{0: 'Not Ready', |
|
844 |
1: 'Ready'}), |
|
104 | 845 |
0x0304: ('AFAreas', None), |
846 |
0x0401: ('FlashExposureCompensation', None), |
|
102 | 847 |
0x0500: ('WhiteBalance2', |
848 |
{0: 'Auto', |
|
849 |
16: '7500K (Fine Weather with Shade)', |
|
850 |
17: '6000K (Cloudy)', |
|
851 |
18: '5300K (Fine Weather)', |
|
852 |
20: '3000K (Tungsten light)', |
|
853 |
21: '3600K (Tungsten light-like)', |
|
854 |
33: '6600K (Daylight fluorescent)', |
|
855 |
34: '4500K (Neutral white fluorescent)', |
|
856 |
35: '4000K (Cool white fluorescent)', |
|
857 |
48: '3600K (Tungsten light-like)', |
|
858 |
256: 'Custom WB 1', |
|
859 |
257: 'Custom WB 2', |
|
860 |
258: 'Custom WB 3', |
|
861 |
259: 'Custom WB 4', |
|
862 |
512: 'Custom WB 5400K', |
|
863 |
513: 'Custom WB 2900K', |
|
864 |
514: 'Custom WB 8000K', }), |
|
104 | 865 |
0x0501: ('WhiteBalanceTemperature', None), |
866 |
0x0502: ('WhiteBalanceBracket', None), |
|
867 |
0x0503: ('CustomSaturation', None), # (3 numbers: 1. CS Value, 2. Min, 3. Max) |
|
102 | 868 |
0x0504: ('ModifiedSaturation', |
869 |
{0: 'Off', |
|
870 |
1: 'CM1 (Red Enhance)', |
|
871 |
2: 'CM2 (Green Enhance)', |
|
872 |
3: 'CM3 (Blue Enhance)', |
|
873 |
4: 'CM4 (Skin Tones)'}), |
|
104 | 874 |
0x0505: ('ContrastSetting', None), # (3 numbers: 1. Contrast, 2. Min, 3. Max) |
875 |
0x0506: ('SharpnessSetting', None), # (3 numbers: 1. Sharpness, 2. Min, 3. Max) |
|
102 | 876 |
0x0507: ('ColorSpace', |
877 |
{0: 'sRGB', |
|
878 |
1: 'Adobe RGB', |
|
879 |
2: 'Pro Photo RGB'}), |
|
880 |
0x0509: ('SceneMode', |
|
881 |
{0: 'Standard', |
|
882 |
6: 'Auto', |
|
883 |
7: 'Sport', |
|
884 |
8: 'Portrait', |
|
885 |
9: 'Landscape+Portrait', |
|
886 |
10: 'Landscape', |
|
887 |
11: 'Night scene', |
|
888 |
13: 'Panorama', |
|
889 |
16: 'Landscape+Portrait', |
|
890 |
17: 'Night+Portrait', |
|
891 |
19: 'Fireworks', |
|
892 |
20: 'Sunset', |
|
893 |
22: 'Macro', |
|
894 |
25: 'Documents', |
|
895 |
26: 'Museum', |
|
896 |
28: 'Beach&Snow', |
|
897 |
30: 'Candle', |
|
898 |
35: 'Underwater Wide1', |
|
899 |
36: 'Underwater Macro', |
|
900 |
39: 'High Key', |
|
901 |
40: 'Digital Image Stabilization', |
|
902 |
44: 'Underwater Wide2', |
|
903 |
45: 'Low Key', |
|
904 |
46: 'Children', |
|
905 |
48: 'Nature Macro'}), |
|
906 |
0x050a: ('NoiseReduction', |
|
907 |
{0: 'Off', |
|
908 |
1: 'Noise Reduction', |
|
909 |
2: 'Noise Filter', |
|
910 |
3: 'Noise Reduction + Noise Filter', |
|
911 |
4: 'Noise Filter (ISO Boost)', |
|
912 |
5: 'Noise Reduction + Noise Filter (ISO Boost)'}), |
|
913 |
0x050b: ('DistortionCorrection', |
|
914 |
{0: 'Off', |
|
915 |
1: 'On'}), |
|
916 |
0x050c: ('ShadingCompensation', |
|
917 |
{0: 'Off', |
|
918 |
1: 'On'}), |
|
104 | 919 |
0x050d: ('CompressionFactor', None), |
102 | 920 |
0x050f: ('Gradation', |
921 |
{'-1 -1 1': 'Low Key', |
|
922 |
'0 -1 1': 'Normal', |
|
923 |
'1 -1 1': 'High Key'}), |
|
924 |
0x0520: ('PictureMode', |
|
925 |
{1: 'Vivid', |
|
926 |
2: 'Natural', |
|
927 |
3: 'Muted', |
|
928 |
256: 'Monotone', |
|
929 |
512: 'Sepia'}), |
|
104 | 930 |
0x0521: ('PictureModeSaturation', None), |
931 |
0x0522: ('PictureModeHue?', None), |
|
932 |
0x0523: ('PictureModeContrast', None), |
|
933 |
0x0524: ('PictureModeSharpness', None), |
|
102 | 934 |
0x0525: ('PictureModeBWFilter', |
935 |
{0: 'n/a', |
|
936 |
1: 'Neutral', |
|
937 |
2: 'Yellow', |
|
938 |
3: 'Orange', |
|
939 |
4: 'Red', |
|
940 |
5: 'Green'}), |
|
941 |
0x0526: ('PictureModeTone', |
|
942 |
{0: 'n/a', |
|
943 |
1: 'Neutral', |
|
944 |
2: 'Sepia', |
|
945 |
3: 'Blue', |
|
946 |
4: 'Purple', |
|
947 |
5: 'Green'}), |
|
104 | 948 |
0x0600: ('Sequence', None), # 2 or 3 numbers: 1. Mode, 2. Shot number, 3. Mode bits |
949 |
0x0601: ('PanoramaMode', None), # (2 numbers: 1. Mode, 2. Shot number) |
|
102 | 950 |
0x0603: ('ImageQuality2', |
951 |
{1: 'SQ', |
|
952 |
2: 'HQ', |
|
953 |
3: 'SHQ', |
|
954 |
4: 'RAW'}), |
|
104 | 955 |
0x0901: ('ManometerReading', None), |
102 | 956 |
} |
957 |
||
958 |
||
959 |
MAKERNOTE_CASIO_TAGS={ |
|
960 |
0x0001: ('RecordingMode', |
|
961 |
{1: 'Single Shutter', |
|
962 |
2: 'Panorama', |
|
963 |
3: 'Night Scene', |
|
964 |
4: 'Portrait', |
|
965 |
5: 'Landscape'}), |
|
966 |
0x0002: ('Quality', |
|
967 |
{1: 'Economy', |
|
968 |
2: 'Normal', |
|
969 |
3: 'Fine'}), |
|
970 |
0x0003: ('FocusingMode', |
|
971 |
{2: 'Macro', |
|
972 |
3: 'Auto Focus', |
|
973 |
4: 'Manual Focus', |
|
974 |
5: 'Infinity'}), |
|
975 |
0x0004: ('FlashMode', |
|
976 |
{1: 'Auto', |
|
977 |
2: 'On', |
|
978 |
3: 'Off', |
|
979 |
4: 'Red Eye Reduction'}), |
|
980 |
0x0005: ('FlashIntensity', |
|
981 |
{11: 'Weak', |
|
982 |
13: 'Normal', |
|
983 |
15: 'Strong'}), |
|
104 | 984 |
0x0006: ('Object Distance', None), |
102 | 985 |
0x0007: ('WhiteBalance', |
986 |
{1: 'Auto', |
|
987 |
2: 'Tungsten', |
|
988 |
3: 'Daylight', |
|
989 |
4: 'Fluorescent', |
|
990 |
5: 'Shade', |
|
991 |
129: 'Manual'}), |
|
992 |
0x000B: ('Sharpness', |
|
993 |
{0: 'Normal', |
|
994 |
1: 'Soft', |
|
995 |
2: 'Hard'}), |
|
996 |
0x000C: ('Contrast', |
|
997 |
{0: 'Normal', |
|
998 |
1: 'Low', |
|
999 |
2: 'High'}), |
|
1000 |
0x000D: ('Saturation', |
|
1001 |
{0: 'Normal', |
|
1002 |
1: 'Low', |
|
1003 |
2: 'High'}), |
|
1004 |
0x0014: ('CCDSpeed', |
|
1005 |
{64: 'Normal', |
|
1006 |
80: 'Normal', |
|
1007 |
100: 'High', |
|
1008 |
125: '+1.0', |
|
1009 |
244: '+3.0', |
|
1010 |
250: '+2.0'}), |
|
1011 |
} |
|
1012 |
||
1013 |
MAKERNOTE_FUJIFILM_TAGS={ |
|
104 | 1014 |
0x0000: ('NoteVersion', None), |
1015 |
0x1000: ('Quality', None), |
|
102 | 1016 |
0x1001: ('Sharpness', |
1017 |
{1: 'Soft', |
|
1018 |
2: 'Soft', |
|
1019 |
3: 'Normal', |
|
1020 |
4: 'Hard', |
|
1021 |
5: 'Hard'}), |
|
1022 |
0x1002: ('WhiteBalance', |
|
1023 |
{0: 'Auto', |
|
1024 |
256: 'Daylight', |
|
1025 |
512: 'Cloudy', |
|
1026 |
768: 'DaylightColor-Fluorescent', |
|
1027 |
769: 'DaywhiteColor-Fluorescent', |
|
1028 |
770: 'White-Fluorescent', |
|
1029 |
1024: 'Incandescent', |
|
1030 |
3840: 'Custom'}), |
|
1031 |
0x1003: ('Color', |
|
1032 |
{0: 'Normal', |
|
1033 |
256: 'High', |
|
1034 |
512: 'Low'}), |
|
1035 |
0x1004: ('Tone', |
|
1036 |
{0: 'Normal', |
|
1037 |
256: 'High', |
|
1038 |
512: 'Low'}), |
|
1039 |
0x1010: ('FlashMode', |
|
1040 |
{0: 'Auto', |
|
1041 |
1: 'On', |
|
1042 |
2: 'Off', |
|
1043 |
3: 'Red Eye Reduction'}), |
|
104 | 1044 |
0x1011: ('FlashStrength', None), |
102 | 1045 |
0x1020: ('Macro', |
1046 |
{0: 'Off', |
|
1047 |
1: 'On'}), |
|
1048 |
0x1021: ('FocusMode', |
|
1049 |
{0: 'Auto', |
|
1050 |
1: 'Manual'}), |
|
1051 |
0x1030: ('SlowSync', |
|
1052 |
{0: 'Off', |
|
1053 |
1: 'On'}), |
|
1054 |
0x1031: ('PictureMode', |
|
1055 |
{0: 'Auto', |
|
1056 |
1: 'Portrait', |
|
1057 |
2: 'Landscape', |
|
1058 |
4: 'Sports', |
|
1059 |
5: 'Night', |
|
1060 |
6: 'Program AE', |
|
1061 |
256: 'Aperture Priority AE', |
|
1062 |
512: 'Shutter Priority AE', |
|
1063 |
768: 'Manual Exposure'}), |
|
1064 |
0x1100: ('MotorOrBracket', |
|
1065 |
{0: 'Off', |
|
1066 |
1: 'On'}), |
|
1067 |
0x1300: ('BlurWarning', |
|
1068 |
{0: 'Off', |
|
1069 |
1: 'On'}), |
|
1070 |
0x1301: ('FocusWarning', |
|
1071 |
{0: 'Off', |
|
1072 |
1: 'On'}), |
|
1073 |
0x1302: ('AEWarning', |
|
1074 |
{0: 'Off', |
|
1075 |
1: 'On'}), |
|
1076 |
} |
|
1077 |
||
1078 |
MAKERNOTE_CANON_TAGS = { |
|
104 | 1079 |
0x0006: ('ImageType', None), |
1080 |
0x0007: ('FirmwareVersion', None), |
|
1081 |
0x0008: ('ImageNumber', None), |
|
1082 |
0x0009: ('OwnerName', None), |
|
102 | 1083 |
} |
1084 |
||
1085 |
# this is in element offset, name, optional value dictionary format |
|
1086 |
MAKERNOTE_CANON_TAG_0x001 = { |
|
1087 |
1: ('Macromode', |
|
1088 |
{1: 'Macro', |
|
1089 |
2: 'Normal'}), |
|
104 | 1090 |
2: ('SelfTimer', None), |
102 | 1091 |
3: ('Quality', |
1092 |
{2: 'Normal', |
|
1093 |
3: 'Fine', |
|
1094 |
5: 'Superfine'}), |
|
1095 |
4: ('FlashMode', |
|
1096 |
{0: 'Flash Not Fired', |
|
1097 |
1: 'Auto', |
|
1098 |
2: 'On', |
|
1099 |
3: 'Red-Eye Reduction', |
|
1100 |
4: 'Slow Synchro', |
|
1101 |
5: 'Auto + Red-Eye Reduction', |
|
1102 |
6: 'On + Red-Eye Reduction', |
|
1103 |
16: 'external flash'}), |
|
1104 |
5: ('ContinuousDriveMode', |
|
1105 |
{0: 'Single Or Timer', |
|
1106 |
1: 'Continuous'}), |
|
1107 |
7: ('FocusMode', |
|
1108 |
{0: 'One-Shot', |
|
1109 |
1: 'AI Servo', |
|
1110 |
2: 'AI Focus', |
|
1111 |
3: 'MF', |
|
1112 |
4: 'Single', |
|
1113 |
5: 'Continuous', |
|
1114 |
6: 'MF'}), |
|
1115 |
10: ('ImageSize', |
|
1116 |
{0: 'Large', |
|
1117 |
1: 'Medium', |
|
1118 |
2: 'Small'}), |
|
1119 |
11: ('EasyShootingMode', |
|
1120 |
{0: 'Full Auto', |
|
1121 |
1: 'Manual', |
|
1122 |
2: 'Landscape', |
|
1123 |
3: 'Fast Shutter', |
|
1124 |
4: 'Slow Shutter', |
|
1125 |
5: 'Night', |
|
1126 |
6: 'B&W', |
|
1127 |
7: 'Sepia', |
|
1128 |
8: 'Portrait', |
|
1129 |
9: 'Sports', |
|
1130 |
10: 'Macro/Close-Up', |
|
1131 |
11: 'Pan Focus'}), |
|
1132 |
12: ('DigitalZoom', |
|
1133 |
{0: 'None', |
|
1134 |
1: '2x', |
|
1135 |
2: '4x'}), |
|
1136 |
13: ('Contrast', |
|
1137 |
{0xFFFF: 'Low', |
|
1138 |
0: 'Normal', |
|
1139 |
1: 'High'}), |
|
1140 |
14: ('Saturation', |
|
1141 |
{0xFFFF: 'Low', |
|
1142 |
0: 'Normal', |
|
1143 |
1: 'High'}), |
|
1144 |
15: ('Sharpness', |
|
1145 |
{0xFFFF: 'Low', |
|
1146 |
0: 'Normal', |
|
1147 |
1: 'High'}), |
|
1148 |
16: ('ISO', |
|
1149 |
{0: 'See ISOSpeedRatings Tag', |
|
1150 |
15: 'Auto', |
|
1151 |
16: '50', |
|
1152 |
17: '100', |
|
1153 |
18: '200', |
|
1154 |
19: '400'}), |
|
1155 |
17: ('MeteringMode', |
|
1156 |
{3: 'Evaluative', |
|
1157 |
4: 'Partial', |
|
1158 |
5: 'Center-weighted'}), |
|
1159 |
18: ('FocusType', |
|
1160 |
{0: 'Manual', |
|
1161 |
1: 'Auto', |
|
1162 |
3: 'Close-Up (Macro)', |
|
1163 |
8: 'Locked (Pan Mode)'}), |
|
1164 |
19: ('AFPointSelected', |
|
1165 |
{0x3000: 'None (MF)', |
|
1166 |
0x3001: 'Auto-Selected', |
|
1167 |
0x3002: 'Right', |
|
1168 |
0x3003: 'Center', |
|
1169 |
0x3004: 'Left'}), |
|
1170 |
20: ('ExposureMode', |
|
1171 |
{0: 'Easy Shooting', |
|
1172 |
1: 'Program', |
|
1173 |
2: 'Tv-priority', |
|
1174 |
3: 'Av-priority', |
|
1175 |
4: 'Manual', |
|
1176 |
5: 'A-DEP'}), |
|
104 | 1177 |
23: ('LongFocalLengthOfLensInFocalUnits', None), |
1178 |
24: ('ShortFocalLengthOfLensInFocalUnits', None), |
|
1179 |
25: ('FocalUnitsPerMM', None), |
|
102 | 1180 |
28: ('FlashActivity', |
1181 |
{0: 'Did Not Fire', |
|
1182 |
1: 'Fired'}), |
|
1183 |
29: ('FlashDetails', |
|
1184 |
{14: 'External E-TTL', |
|
1185 |
13: 'Internal Flash', |
|
1186 |
11: 'FP Sync Used', |
|
1187 |
7: '2nd("Rear")-Curtain Sync Used', |
|
1188 |
4: 'FP Sync Enabled'}), |
|
1189 |
32: ('FocusMode', |
|
1190 |
{0: 'Single', |
|
1191 |
1: 'Continuous'}), |
|
1192 |
} |
|
1193 |
||
1194 |
MAKERNOTE_CANON_TAG_0x004 = { |
|
1195 |
7: ('WhiteBalance', |
|
1196 |
{0: 'Auto', |
|
1197 |
1: 'Sunny', |
|
1198 |
2: 'Cloudy', |
|
1199 |
3: 'Tungsten', |
|
1200 |
4: 'Fluorescent', |
|
1201 |
5: 'Flash', |
|
1202 |
6: 'Custom'}), |
|
104 | 1203 |
9: ('SequenceNumber', None), |
1204 |
14: ('AFPointUsed', None), |
|
102 | 1205 |
15: ('FlashBias', |
1206 |
{0xFFC0: '-2 EV', |
|
1207 |
0xFFCC: '-1.67 EV', |
|
1208 |
0xFFD0: '-1.50 EV', |
|
1209 |
0xFFD4: '-1.33 EV', |
|
1210 |
0xFFE0: '-1 EV', |
|
1211 |
0xFFEC: '-0.67 EV', |
|
1212 |
0xFFF0: '-0.50 EV', |
|
1213 |
0xFFF4: '-0.33 EV', |
|
1214 |
0x0000: '0 EV', |
|
1215 |
0x000C: '0.33 EV', |
|
1216 |
0x0010: '0.50 EV', |
|
1217 |
0x0014: '0.67 EV', |
|
1218 |
0x0020: '1 EV', |
|
1219 |
0x002C: '1.33 EV', |
|
1220 |
0x0030: '1.50 EV', |
|
1221 |
0x0034: '1.67 EV', |
|
1222 |
0x0040: '2 EV'}), |
|
104 | 1223 |
19: ('SubjectDistance', None), |
102 | 1224 |
} |
1225 |
||
1226 |
# ratio object that eventually will be able to reduce itself to lowest |
|
1227 |
# common denominator for printing |
|
104 | 1228 |
# XXX: unused |
102 | 1229 |
def gcd(a, b): |
1230 |
if b == 0: |
|
1231 |
return a |
|
1232 |
else: |
|
1233 |
return gcd(b, a % b) |
|
1234 |
||
1235 |
class Ratio: |
|
1236 |
def __init__(self, num, den): |
|
1237 |
self.num = num |
|
1238 |
self.den = den |
|
1239 |
||
1240 |
def __repr__(self): |
|
1241 |
self.reduce() |
|
1242 |
if self.den == 1: |
|
1243 |
return str(self.num) |
|
1244 |
return '%d/%d' % (self.num, self.den) |
|
1245 |
||
1246 |
def reduce(self): |
|
1247 |
div = gcd(self.num, self.den) |
|
1248 |
if div > 1: |
|
1249 |
self.num = self.num / div |
|
1250 |
self.den = self.den / div |
|
1251 |
||
1252 |