149 Map the values through our func |
149 Map the values through our func |
150 """ |
150 """ |
151 |
151 |
152 return self.values_func(values) |
152 return self.values_func(values) |
153 |
153 |
|
154 class IFDTag (Tag) : |
|
155 """ |
|
156 A tag that references another IFD |
|
157 """ |
|
158 |
|
159 def __init__ (self, name, ifd_tags=None) : |
|
160 """ |
|
161 A tag that points to another IFD block. `ifd_tags`, if given, lists the tags for that block, otherwise, |
|
162 the same tags as for the current block are used. |
|
163 """ |
|
164 |
|
165 super(IFDTag, self).__init__(name) |
|
166 |
|
167 self.ifd_tags = ifd_tags |
|
168 |
154 USER_COMMENT_CHARSETS = { |
169 USER_COMMENT_CHARSETS = { |
155 'ASCII': ('ascii', 'replace' ), |
170 'ASCII': ('ascii', 'replace' ), |
156 'JIS': ('jis', 'error' ), |
171 'JIS': ('jis', 'error' ), |
157 |
172 |
158 # XXX: WTF? What kind of charset is 'Unicode' supposed to be? |
173 # XXX: WTF? What kind of charset is 'Unicode' supposed to be? |
189 # value_dict is a { value: value_name } mapping for human-readable values |
204 # value_dict is a { value: value_name } mapping for human-readable values |
190 # value_func is a `(values) -> values` mapping function which *overrides* the tag's type_func. |
205 # value_func is a `(values) -> values` mapping function which *overrides* the tag's type_func. |
191 # XXX: or does it? |
206 # XXX: or does it? |
192 # SUB_IFD_MAGIC signifies that this IFD points to |
207 # SUB_IFD_MAGIC signifies that this IFD points to |
193 # otherwise, the value is left as-is. |
208 # otherwise, the value is left as-is. |
|
209 # interoperability tags |
|
210 INTR_TAGS = { |
|
211 0x0001: Tag('InteroperabilityIndex'), |
|
212 0x0002: Tag('InteroperabilityVersion'), |
|
213 0x1000: Tag('RelatedImageFileFormat'), |
|
214 0x1001: Tag('RelatedImageWidth'), |
|
215 0x1002: Tag('RelatedImageLength'), |
|
216 } |
|
217 |
|
218 # GPS tags (not used yet, haven't seen camera with GPS) |
|
219 GPS_TAGS = { |
|
220 0x0000: Tag('GPSVersionID'), |
|
221 0x0001: Tag('GPSLatitudeRef'), |
|
222 0x0002: Tag('GPSLatitude'), |
|
223 0x0003: Tag('GPSLongitudeRef'), |
|
224 0x0004: Tag('GPSLongitude'), |
|
225 0x0005: Tag('GPSAltitudeRef'), |
|
226 0x0006: Tag('GPSAltitude'), |
|
227 0x0007: Tag('GPSTimeStamp'), |
|
228 0x0008: Tag('GPSSatellites'), |
|
229 0x0009: Tag('GPSStatus'), |
|
230 0x000A: Tag('GPSMeasureMode'), |
|
231 0x000B: Tag('GPSDOP'), |
|
232 0x000C: Tag('GPSSpeedRef'), |
|
233 0x000D: Tag('GPSSpeed'), |
|
234 0x000E: Tag('GPSTrackRef'), |
|
235 0x000F: Tag('GPSTrack'), |
|
236 0x0010: Tag('GPSImgDirectionRef'), |
|
237 0x0011: Tag('GPSImgDirection'), |
|
238 0x0012: Tag('GPSMapDatum'), |
|
239 0x0013: Tag('GPSDestLatitudeRef'), |
|
240 0x0014: Tag('GPSDestLatitude'), |
|
241 0x0015: Tag('GPSDestLongitudeRef'), |
|
242 0x0016: Tag('GPSDestLongitude'), |
|
243 0x0017: Tag('GPSDestBearingRef'), |
|
244 0x0018: Tag('GPSDestBearing'), |
|
245 0x0019: Tag('GPSDestDistanceRef'), |
|
246 0x001A: Tag('GPSDestDistance'), |
|
247 0x001D: Tag('GPSDate'), |
|
248 } |
|
249 |
|
250 |
194 EXIF_TAGS = { |
251 EXIF_TAGS = { |
195 0x0100: Tag('ImageWidth'), |
252 0x0100: Tag('ImageWidth'), |
196 0x0101: Tag('ImageLength'), |
253 0x0101: Tag('ImageLength'), |
197 0x0102: Tag('BitsPerSample'), |
254 0x0102: Tag('BitsPerSample'), |
198 0x0103: TagDict('Compression', |
255 0x0103: TagDict('Compression', |
278 0x828F: Tag('BatteryLevel'), |
335 0x828F: Tag('BatteryLevel'), |
279 0x8298: Tag('Copyright'), |
336 0x8298: Tag('Copyright'), |
280 0x829A: Tag('ExposureTime'), |
337 0x829A: Tag('ExposureTime'), |
281 0x829D: Tag('FNumber'), |
338 0x829D: Tag('FNumber'), |
282 0x83BB: Tag('IPTC/NAA'), |
339 0x83BB: Tag('IPTC/NAA'), |
283 0x8769: Tag('ExifOffset'), |
340 0x8769: IFDTag('ExifOffset', None), |
284 0x8773: Tag('InterColorProfile'), |
341 0x8773: Tag('InterColorProfile'), |
285 0x8822: TagDict('ExposureProgram', |
342 0x8822: TagDict('ExposureProgram', |
286 {0: 'Unidentified', |
343 {0: 'Unidentified', |
287 1: 'Manual', |
344 1: 'Manual', |
288 2: 'Program Normal', |
345 2: 'Program Normal', |
291 5: 'Program Creative', |
348 5: 'Program Creative', |
292 6: 'Program Action', |
349 6: 'Program Action', |
293 7: 'Portrait Mode', |
350 7: 'Portrait Mode', |
294 8: 'Landscape Mode'}), |
351 8: 'Landscape Mode'}), |
295 0x8824: Tag('SpectralSensitivity'), |
352 0x8824: Tag('SpectralSensitivity'), |
296 0x8825: Tag('GPSInfo'), |
353 0x8825: IFDTag('GPSInfo', GPS_TAGS), |
297 0x8827: Tag('ISOSpeedRatings'), |
354 0x8827: Tag('ISOSpeedRatings'), |
298 0x8828: Tag('OECF'), |
355 0x8828: Tag('OECF'), |
299 0x9000: Tag('ExifVersion'), |
356 0x9000: Tag('ExifVersion'), |
300 0x9003: Tag('DateTimeOriginal'), |
357 0x9003: Tag('DateTimeOriginal'), |
301 0x9004: Tag('DateTimeDigitized'), |
358 0x9004: Tag('DateTimeDigitized'), |
374 {1: 'sRGB', |
431 {1: 'sRGB', |
375 2: 'Adobe RGB', |
432 2: 'Adobe RGB', |
376 65535: 'Uncalibrated'}), |
433 65535: 'Uncalibrated'}), |
377 0xA002: Tag('ExifImageWidth'), |
434 0xA002: Tag('ExifImageWidth'), |
378 0xA003: Tag('ExifImageLength'), |
435 0xA003: Tag('ExifImageLength'), |
379 0xA005: Tag('InteroperabilityOffset'), |
436 0xA005: IFDTag('InteroperabilityOffset', INTR_TAGS), |
380 0xA20B: Tag('FlashEnergy'), # 0x920B in TIFF/EP |
437 0xA20B: Tag('FlashEnergy'), # 0x920B in TIFF/EP |
381 0xA20C: Tag('SpatialFrequencyResponse'), # 0x920C |
438 0xA20C: Tag('SpatialFrequencyResponse'), # 0x920C |
382 0xA20E: Tag('FocalPlaneXResolution'), # 0x920E |
439 0xA20E: Tag('FocalPlaneXResolution'), # 0x920E |
383 0xA20F: Tag('FocalPlaneYResolution'), # 0x920F |
440 0xA20F: Tag('FocalPlaneYResolution'), # 0x920F |
384 0xA210: Tag('FocalPlaneResolutionUnit'), # 0x9210 |
441 0xA210: Tag('FocalPlaneResolutionUnit'), # 0x9210 |
437 0xA40B: Tag('DeviceSettingDescription'), |
494 0xA40B: Tag('DeviceSettingDescription'), |
438 0xA40C: Tag('SubjectDistanceRange'), |
495 0xA40C: Tag('SubjectDistanceRange'), |
439 0xA500: Tag('Gamma'), |
496 0xA500: Tag('Gamma'), |
440 0xC4A5: Tag('PrintIM'), |
497 0xC4A5: Tag('PrintIM'), |
441 0xEA1C: ('Padding', None), |
498 0xEA1C: ('Padding', None), |
442 } |
|
443 |
|
444 # interoperability tags |
|
445 INTR_TAGS = { |
|
446 0x0001: Tag('InteroperabilityIndex'), |
|
447 0x0002: Tag('InteroperabilityVersion'), |
|
448 0x1000: Tag('RelatedImageFileFormat'), |
|
449 0x1001: Tag('RelatedImageWidth'), |
|
450 0x1002: Tag('RelatedImageLength'), |
|
451 } |
|
452 |
|
453 # GPS tags (not used yet, haven't seen camera with GPS) |
|
454 GPS_TAGS = { |
|
455 0x0000: Tag('GPSVersionID'), |
|
456 0x0001: Tag('GPSLatitudeRef'), |
|
457 0x0002: Tag('GPSLatitude'), |
|
458 0x0003: Tag('GPSLongitudeRef'), |
|
459 0x0004: Tag('GPSLongitude'), |
|
460 0x0005: Tag('GPSAltitudeRef'), |
|
461 0x0006: Tag('GPSAltitude'), |
|
462 0x0007: Tag('GPSTimeStamp'), |
|
463 0x0008: Tag('GPSSatellites'), |
|
464 0x0009: Tag('GPSStatus'), |
|
465 0x000A: Tag('GPSMeasureMode'), |
|
466 0x000B: Tag('GPSDOP'), |
|
467 0x000C: Tag('GPSSpeedRef'), |
|
468 0x000D: Tag('GPSSpeed'), |
|
469 0x000E: Tag('GPSTrackRef'), |
|
470 0x000F: Tag('GPSTrack'), |
|
471 0x0010: Tag('GPSImgDirectionRef'), |
|
472 0x0011: Tag('GPSImgDirection'), |
|
473 0x0012: Tag('GPSMapDatum'), |
|
474 0x0013: Tag('GPSDestLatitudeRef'), |
|
475 0x0014: Tag('GPSDestLatitude'), |
|
476 0x0015: Tag('GPSDestLongitudeRef'), |
|
477 0x0016: Tag('GPSDestLongitude'), |
|
478 0x0017: Tag('GPSDestBearingRef'), |
|
479 0x0018: Tag('GPSDestBearing'), |
|
480 0x0019: Tag('GPSDestDistanceRef'), |
|
481 0x001A: Tag('GPSDestDistance'), |
|
482 0x001D: Tag('GPSDate'), |
|
483 } |
499 } |
484 |
500 |
485 # http://tomtia.plala.jp/DigitalCamera/MakerNote/index.asp |
501 # http://tomtia.plala.jp/DigitalCamera/MakerNote/index.asp |
486 def nikon_ev_bias (seq) : |
502 def nikon_ev_bias (seq) : |
487 """ |
503 """ |