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