Back to index

moin  1.9.0~rc2
Classes | Functions | Variables
MoinMoin.filter.EXIF Namespace Reference

Classes

class  Ratio
class  IFD_Tag
class  EXIF_header

Functions

def make_string
def make_string_uc
def nikon_ev_bias
def olympus_special_mode
def s2n_motorola
def s2n_intel
def gcd
def process_file

Variables

tuple FIELD_TYPES
dictionary EXIF_TAGS
dictionary INTR_TAGS
dictionary GPS_TAGS
tuple IGNORE_TAGS = (0x9286, 0x927C)
dictionary MAKERNOTE_NIKON_OLDER_TAGS
dictionary MAKERNOTE_CANON_TAGS
dictionary MAKERNOTE_CANON_TAG_0x001
dictionary MAKERNOTE_CANON_TAG_0x004
int fileNamesStart = 2
 detailed = False
tuple file = open(filename, 'rb')
tuple data = process_file(file, details=detailed)
tuple x = data.keys()

Function Documentation

def MoinMoin.filter.EXIF.gcd (   a,
  b 
)

Definition at line 1096 of file EXIF.py.

01096 
01097 def gcd(a, b):
01098     if b == 0:
01099         return a
01100     else:
01101         return gcd(b, a % b)

Here is the caller graph for this function:

Definition at line 139 of file EXIF.py.

00139 
00140 def make_string(seq):
00141     str = ""
00142     for c in seq:
00143         # Screen out non-printing characters
00144         if 32 <= c and c < 256:
00145             str += chr(c)
00146     # If no printing chars
00147     if not str:
00148         return seq
00149     return str
00150 
# Special version to deal with the code in the first 8 bytes of a user comment.

Here is the caller graph for this function:

Definition at line 151 of file EXIF.py.

00151 
00152 def make_string_uc(seq):
00153     code = seq[0:8]
00154     seq = seq[8:]
00155     # Of course, this is only correct if ASCII, and the standard explicitly
00156     # allows JIS and Unicode.
00157     return make_string(seq)
00158 
# field type descriptions as (length, abbreviation, full name) tuples

Here is the call graph for this function:

Definition at line 388 of file EXIF.py.

00388 
00389 def nikon_ev_bias(seq):
00390     # First digit seems to be in steps of 1/6 EV.
00391     # Does the third value mean the step size?  It is usually 6,
00392     # but it is 12 for the ExposureDifference.
00393     #
00394     if seq == [252, 1, 6, 0]:
00395         return "-2/3 EV"
00396     if seq == [253, 1, 6, 0]:
00397         return "-1/2 EV"
00398     if seq == [254, 1, 6, 0]:
00399         return "-1/3 EV"
00400     if seq == [0, 1, 6, 0]:
00401         return "0 EV"
00402     if seq == [2, 1, 6, 0]:
00403         return "+1/3 EV"
00404     if seq == [3, 1, 6, 0]:
00405         return "+1/2 EV"
00406     if seq == [4, 1, 6, 0]:
00407         return "+2/3 EV"
00408     # Handle combinations not in the table.
00409     a = seq[0]
00410     # Causes headaches for the +/- logic, so special case it.
00411     if a == 0:
00412         return "0 EV"
00413     if a > 127:
00414         a = 256 - a
00415         ret_str = "-"
00416     else:
00417         ret_str = "+"
00418     b = seq[2]       # Assume third value means the step size
00419     whole = a / b
00420     a = a % b
00421     if whole != 0:
00422         ret_str = ret_str + str(whole) + " "
00423     if a == 0:
00424         ret_str = ret_str + "EV"
00425     else:
00426         r = Ratio(a, b)
00427         ret_str = ret_str + r.__repr__() + " EV"
00428     return ret_str
00429 
00430 # Nikon E99x MakerNote Tags
00431 MAKERNOTE_NIKON_NEWER_TAGS={
00432     0x0001: ('MakernoteVersion', make_string),   # Sometimes binary
00433     0x0002: ('ISOSetting', ),
00434     0x0003: ('ColorMode', ),
00435     0x0004: ('Quality', ),
00436     0x0005: ('Whitebalance', ),
00437     0x0006: ('ImageSharpening', ),
00438     0x0007: ('FocusMode', ),
00439     0x0008: ('FlashSetting', ),
00440     0x0009: ('AutoFlashMode', ),
00441     0x000B: ('WhiteBalanceBias', ),
00442     0x000C: ('WhiteBalanceRBCoeff', ),
00443     0x000D: ('ProgramShift', nikon_ev_bias),
00444     # Nearly the same as the other EV vals, but step size is 1/12 EV (?)
00445     0x000E: ('ExposureDifference', nikon_ev_bias),
00446     0x000F: ('ISOSelection', ),
00447     0x0011: ('NikonPreview', ),
00448     0x0012: ('FlashCompensation', nikon_ev_bias),
00449     0x0013: ('ISOSpeedRequested', ),
00450     0x0016: ('PhotoCornerCoordinates', ),
00451     # 0x0017: Unknown, but most likely an EV value
00452     0x0018: ('FlashBracketCompensationApplied', nikon_ev_bias),
00453     0x0019: ('AEBracketCompensationApplied', ),
00454     0x001A: ('ImageProcessing', ),
00455     0x0080: ('ImageAdjustment', ),
00456     0x0081: ('ToneCompensation', ),
00457     0x0082: ('AuxiliaryLens', ),
00458     0x0083: ('LensType', ),
00459     0x0084: ('LensMinMaxFocalMaxAperture', ),
00460     0x0085: ('ManualFocusDistance', ),
00461     0x0086: ('DigitalZoomFactor', ),
00462     0x0087: ('FlashMode',
00463              {0x00: 'Did Not Fire',
00464               0x01: 'Fired, Manual',
00465               0x07: 'Fired, External',
00466               0x08: 'Fired, Commander Mode ',
00467               0x09: 'Fired, TTL Mode'}),
00468     0x0088: ('AFFocusPosition',
00469              {0x0000: 'Center',
00470               0x0100: 'Top',
00471               0x0200: 'Bottom',
00472               0x0300: 'Left',
00473               0x0400: 'Right'}),
00474     0x0089: ('BracketingMode',
00475              {0x00: 'Single frame, no bracketing',
00476               0x01: 'Continuous, no bracketing',
00477               0x02: 'Timer, no bracketing',
00478               0x10: 'Single frame, exposure bracketing',
00479               0x11: 'Continuous, exposure bracketing',
00480               0x12: 'Timer, exposure bracketing',
00481               0x40: 'Single frame, white balance bracketing',
00482               0x41: 'Continuous, white balance bracketing',
00483               0x42: 'Timer, white balance bracketing'}),
00484     0x008A: ('AutoBracketRelease', ),
00485     0x008B: ('LensFStops', ),
00486     0x008C: ('NEFCurve2', ),
00487     0x008D: ('ColorMode', ),
00488     0x008F: ('SceneMode', ),
00489     0x0090: ('LightingType', ),
00490     0x0091: ('ShotInfo', ), # First 4 bytes are probably a version number in ASCII
00491     0x0092: ('HueAdjustment', ),
00492     # 0x0093: ('SaturationAdjustment', ),
00493     0x0094: ('Saturation',  # Name conflict with 0x00AA !!
00494              {-3: 'B&W',
00495               -2: '-2',
00496               -1: '-1',
00497               0: '0',
00498               1: '1',
00499               2: '2'}),
00500     0x0095: ('NoiseReduction', ),
00501     0x0096: ('NEFCurve2', ),
00502     0x0097: ('ColorBalance', ),
00503     0x0098: ('LensData', ), # First 4 bytes are a version number in ASCII
00504     0x0099: ('RawImageCenter', ),
00505     0x009A: ('SensorPixelSize', ),
00506     0x009C: ('Scene Assist', ),
00507     0x00A0: ('SerialNumber', ),
00508     0x00A2: ('ImageDataSize', ),
00509     # A4: In NEF, looks like a 4 byte ASCII version number
00510     0x00A5: ('ImageCount', ),
00511     0x00A6: ('DeletedImageCount', ),
00512     0x00A7: ('TotalShutterReleases', ),
00513     # A8: ExposureMode?  JPG: First 4 bytes are probably a version number in ASCII
00514     # But in a sample NEF, its 8 zeros, then the string "NORMAL"
00515     0x00A9: ('ImageOptimization', ),
00516     0x00AA: ('Saturation', ),
00517     0x00AB: ('DigitalVariProgram', ),
00518     0x00AC: ('ImageStabilization', ),
00519     0x00AD: ('Responsive AF', ),   # 'AFResponse'
00520     0x0010: ('DataDump', ),
00521     }

Definition at line 555 of file EXIF.py.

00555 
00556 def olympus_special_mode(v):
00557     a={
00558         0: 'Normal',
00559         1: 'Unknown',
00560         2: 'Fast',
00561         3: 'Panorama'}
00562     b={
00563         0: 'Non-panoramic',
00564         1: 'Left to right',
00565         2: 'Right to left',
00566         3: 'Bottom to top',
00567         4: 'Top to bottom'}
00568     if v[0] not in a or v[2] not in b:
00569         return v
00570     return '%s - sequence %d - %s' % (a[v[0]], v[1], b[v[2]])
00571 
00572 MAKERNOTE_OLYMPUS_TAGS={
00573     # ah HAH! those sneeeeeaky bastids! this is how they get past the fact
00574     # that a JPEG thumbnail is not allowed in an uncompressed TIFF file
00575     0x0100: ('JPEGThumbnail', ),
00576     0x0200: ('SpecialMode', olympus_special_mode),
00577     0x0201: ('JPEGQual',
00578              {1: 'SQ',
00579               2: 'HQ',
00580               3: 'SHQ'}),
00581     0x0202: ('Macro',
00582              {0: 'Normal',
00583              1: 'Macro',
00584              2: 'SuperMacro'}),
00585     0x0203: ('BWMode',
00586              {0: 'Off',
00587              1: 'On'}),
00588     0x0204: ('DigitalZoom', ),
00589     0x0205: ('FocalPlaneDiagonal', ),
00590     0x0206: ('LensDistortionParams', ),
00591     0x0207: ('SoftwareRelease', ),
00592     0x0208: ('PictureInfo', ),
00593     0x0209: ('CameraID', make_string), # print as string
00594     0x0F00: ('DataDump', ),
00595     0x0300: ('PreCaptureFrames', ),
00596     0x0404: ('SerialNumber', ),
00597     0x1000: ('ShutterSpeedValue', ),
00598     0x1001: ('ISOValue', ),
00599     0x1002: ('ApertureValue', ),
00600     0x1003: ('BrightnessValue', ),
00601     0x1004: ('FlashMode', ),
00602     0x1004: ('FlashMode',
00603        {2: 'On',
00604         3: 'Off'}),
00605     0x1005: ('FlashDevice',
00606        {0: 'None',
00607         1: 'Internal',
00608         4: 'External',
00609         5: 'Internal + External'}),
00610     0x1006: ('ExposureCompensation', ),
00611     0x1007: ('SensorTemperature', ),
00612     0x1008: ('LensTemperature', ),
00613     0x100b: ('FocusMode',
00614        {0: 'Auto',
00615         1: 'Manual'}),
00616     0x1017: ('RedBalance', ),
00617     0x1018: ('BlueBalance', ),
00618     0x101a: ('SerialNumber', ),
00619     0x1023: ('FlashExposureComp', ),
00620     0x1026: ('ExternalFlashBounce',
00621        {0: 'No',
00622         1: 'Yes'}),
00623     0x1027: ('ExternalFlashZoom', ),
00624     0x1028: ('ExternalFlashMode', ),
00625     0x1029: ('Contrast      int16u',
00626        {0: 'High',
00627         1: 'Normal',
00628         2: 'Low'}),
00629     0x102a: ('SharpnessFactor', ),
00630     0x102b: ('ColorControl', ),
00631     0x102c: ('ValidBits', ),
00632     0x102d: ('CoringFilter', ),
00633     0x102e: ('OlympusImageWidth', ),
00634     0x102f: ('OlympusImageHeight', ),
00635     0x1034: ('CompressionRatio', ),
00636     0x1035: ('PreviewImageValid',
00637        {0: 'No',
00638         1: 'Yes'}),
00639     0x1036: ('PreviewImageStart', ),
00640     0x1037: ('PreviewImageLength', ),
00641     0x1039: ('CCDScanMode',
00642        {0: 'Interlaced',
00643         1: 'Progressive'}),
00644     0x103a: ('NoiseReduction',
00645        {0: 'Off',
00646         1: 'On'}),
00647     0x103b: ('InfinityLensStep', ),
00648     0x103c: ('NearLensStep', ),
00649 
00650     # TODO - these need extra definitions
00651     # http://search.cpan.org/src/EXIFTOOL/Image-ExifTool-6.90/html/TagNames/Olympus.html
00652     0x2010: ('Equipment', ),
00653     0x2020: ('CameraSettings', ),
00654     0x2030: ('RawDevelopment', ),
00655     0x2040: ('ImageProcessing', ),
00656     0x2050: ('FocusInfo', ),
00657     0x3000: ('RawInfo ', ),
00658     }
00659 
00660 # 0x2020 CameraSettings
00661 MAKERNOTE_OLYMPUS_TAG_0x2020={
00662     0x0100: ('PreviewImageValid',
00663         {0: 'No',
00664          1: 'Yes'}),
00665     0x0101: ('PreviewImageStart', ),
00666     0x0102: ('PreviewImageLength', ),
00667     0x0200: ('ExposureMode', {
00668         1: 'Manual',
00669         2: 'Program',
00670         3: 'Aperture-priority AE',
00671         4: 'Shutter speed priority AE',
00672         5: 'Program-shift'}),
00673     0x0201: ('AELock',
00674        {0: 'Off',
00675         1: 'On'}),
00676     0x0202: ('MeteringMode',
00677        {2: 'Center Weighted',
00678         3: 'Spot',
00679         5: 'ESP',
00680         261: 'Pattern+AF',
00681         515: 'Spot+Highlight control',
00682         1027: 'Spot+Shadow control'}),
00683     0x0300: ('MacroMode',
00684        {0: 'Off',
00685         1: 'On'}),
00686     0x0301: ('FocusMode',
00687        {0: 'Single AF',
00688         1: 'Sequential shooting AF',
00689         2: 'Continuous AF',
00690         3: 'Multi AF',
00691         10: 'MF'}),
00692     0x0302: ('FocusProcess',
00693        {0: 'AF Not Used',
00694         1: 'AF Used'}),
00695     0x0303: ('AFSearch',
00696        {0: 'Not Ready',
00697         1: 'Ready'}),
00698     0x0304: ('AFAreas', ),
00699     0x0401: ('FlashExposureCompensation', ),
00700     0x0500: ('WhiteBalance2',
00701        {0: 'Auto',
00702         16: '7500K (Fine Weather with Shade)',
00703         17: '6000K (Cloudy)',
00704         18: '5300K (Fine Weather)',
00705         20: '3000K (Tungsten light)',
00706         21: '3600K (Tungsten light-like)',
00707         33: '6600K (Daylight fluorescent)',
00708         34: '4500K (Neutral white fluorescent)',
00709         35: '4000K (Cool white fluorescent)',
00710         48: '3600K (Tungsten light-like)',
00711         256: 'Custom WB 1',
00712         257: 'Custom WB 2',
00713         258: 'Custom WB 3',
00714         259: 'Custom WB 4',
00715         512: 'Custom WB 5400K',
00716         513: 'Custom WB 2900K',
00717         514: 'Custom WB 8000K', }),
00718     0x0501: ('WhiteBalanceTemperature', ),
00719     0x0502: ('WhiteBalanceBracket', ),
00720     0x0503: ('CustomSaturation', ), # (3 numbers: 1. CS Value, 2. Min, 3. Max)
00721     0x0504: ('ModifiedSaturation',
00722        {0: 'Off',
00723         1: 'CM1 (Red Enhance)',
00724         2: 'CM2 (Green Enhance)',
00725         3: 'CM3 (Blue Enhance)',
00726         4: 'CM4 (Skin Tones)'}),
00727     0x0505: ('ContrastSetting', ), # (3 numbers: 1. Contrast, 2. Min, 3. Max)
00728     0x0506: ('SharpnessSetting', ), # (3 numbers: 1. Sharpness, 2. Min, 3. Max)
00729     0x0507: ('ColorSpace',
00730        {0: 'sRGB',
00731         1: 'Adobe RGB',
00732         2: 'Pro Photo RGB'}),
00733     0x0509: ('SceneMode',
00734        {0: 'Standard',
00735         6: 'Auto',
00736         7: 'Sport',
00737         8: 'Portrait',
00738         9: 'Landscape+Portrait',
00739         10: 'Landscape',
00740         11: 'Night scene',
00741         13: 'Panorama',
00742         16: 'Landscape+Portrait',
00743         17: 'Night+Portrait',
00744         19: 'Fireworks',
00745         20: 'Sunset',
00746         22: 'Macro',
00747         25: 'Documents',
00748         26: 'Museum',
00749         28: 'Beach&Snow',
00750         30: 'Candle',
00751         35: 'Underwater Wide1',
00752         36: 'Underwater Macro',
00753         39: 'High Key',
00754         40: 'Digital Image Stabilization',
00755         44: 'Underwater Wide2',
00756         45: 'Low Key',
00757         46: 'Children',
00758         48: 'Nature Macro'}),
00759     0x050a: ('NoiseReduction',
00760        {0: 'Off',
00761         1: 'Noise Reduction',
00762         2: 'Noise Filter',
00763         3: 'Noise Reduction + Noise Filter',
00764         4: 'Noise Filter (ISO Boost)',
00765         5: 'Noise Reduction + Noise Filter (ISO Boost)'}),
00766     0x050b: ('DistortionCorrection',
00767        {0: 'Off',
00768         1: 'On'}),
00769     0x050c: ('ShadingCompensation',
00770        {0: 'Off',
00771         1: 'On'}),
00772     0x050d: ('CompressionFactor', ),
00773     0x050f: ('Gradation',
00774        {'-1 -1 1': 'Low Key',
00775         '0 -1 1': 'Normal',
00776         '1 -1 1': 'High Key'}),
00777     0x0520: ('PictureMode',
00778        {1: 'Vivid',
00779         2: 'Natural',
00780         3: 'Muted',
00781         256: 'Monotone',
00782         512: 'Sepia'}),
00783     0x0521: ('PictureModeSaturation', ),
00784     0x0522: ('PictureModeHue?', ),
00785     0x0523: ('PictureModeContrast', ),
00786     0x0524: ('PictureModeSharpness', ),
00787     0x0525: ('PictureModeBWFilter',
00788        {0: 'n/a',
00789         1: 'Neutral',
00790         2: 'Yellow',
00791         3: 'Orange',
00792         4: 'Red',
00793         5: 'Green'}),
00794     0x0526: ('PictureModeTone',
00795        {0: 'n/a',
00796         1: 'Neutral',
00797         2: 'Sepia',
00798         3: 'Blue',
00799         4: 'Purple',
00800         5: 'Green'}),
00801     0x0600: ('Sequence', ), # 2 or 3 numbers: 1. Mode, 2. Shot number, 3. Mode bits
00802     0x0601: ('PanoramaMode', ), # (2 numbers: 1. Mode, 2. Shot number)
00803     0x0603: ('ImageQuality2',
00804        {1: 'SQ',
00805         2: 'HQ',
00806         3: 'SHQ',
00807         4: 'RAW'}),
00808     0x0901: ('ManometerReading', ),
00809     }
00810 
00811 
00812 MAKERNOTE_CASIO_TAGS={
00813     0x0001: ('RecordingMode',
00814              {1: 'Single Shutter',
00815               2: 'Panorama',
00816               3: 'Night Scene',
00817               4: 'Portrait',
00818               5: 'Landscape'}),
00819     0x0002: ('Quality',
00820              {1: 'Economy',
00821               2: 'Normal',
00822               3: 'Fine'}),
00823     0x0003: ('FocusingMode',
00824              {2: 'Macro',
00825               3: 'Auto Focus',
00826               4: 'Manual Focus',
00827               5: 'Infinity'}),
00828     0x0004: ('FlashMode',
00829              {1: 'Auto',
00830               2: 'On',
00831               3: 'Off',
00832               4: 'Red Eye Reduction'}),
00833     0x0005: ('FlashIntensity',
00834              {11: 'Weak',
00835               13: 'Normal',
00836               15: 'Strong'}),
00837     0x0006: ('Object Distance', ),
00838     0x0007: ('WhiteBalance',
00839              {1: 'Auto',
00840               2: 'Tungsten',
00841               3: 'Daylight',
00842               4: 'Fluorescent',
00843               5: 'Shade',
00844               129: 'Manual'}),
00845     0x000B: ('Sharpness',
00846              {0: 'Normal',
00847               1: 'Soft',
00848               2: 'Hard'}),
00849     0x000C: ('Contrast',
00850              {0: 'Normal',
00851               1: 'Low',
00852               2: 'High'}),
00853     0x000D: ('Saturation',
00854              {0: 'Normal',
00855               1: 'Low',
00856               2: 'High'}),
00857     0x0014: ('CCDSpeed',
00858              {64: 'Normal',
00859               80: 'Normal',
00860               100: 'High',
00861               125: '+1.0',
00862               244: '+3.0',
00863               250: '+2.0'}),
00864     }
00865 
00866 MAKERNOTE_FUJIFILM_TAGS={
00867     0x0000: ('NoteVersion', make_string),
00868     0x1000: ('Quality', ),
00869     0x1001: ('Sharpness',
00870              {1: 'Soft',
00871               2: 'Soft',
00872               3: 'Normal',
00873               4: 'Hard',
00874               5: 'Hard'}),
00875     0x1002: ('WhiteBalance',
00876              {0: 'Auto',
00877               256: 'Daylight',
00878               512: 'Cloudy',
00879               768: 'DaylightColor-Fluorescent',
00880               769: 'DaywhiteColor-Fluorescent',
00881               770: 'White-Fluorescent',
00882               1024: 'Incandescent',
00883               3840: 'Custom'}),
00884     0x1003: ('Color',
00885              {0: 'Normal',
00886               256: 'High',
00887               512: 'Low'}),
00888     0x1004: ('Tone',
00889              {0: 'Normal',
00890               256: 'High',
00891               512: 'Low'}),
00892     0x1010: ('FlashMode',
00893              {0: 'Auto',
00894               1: 'On',
00895               2: 'Off',
00896               3: 'Red Eye Reduction'}),
00897     0x1011: ('FlashStrength', ),
00898     0x1020: ('Macro',
00899              {0: 'Off',
00900               1: 'On'}),
00901     0x1021: ('FocusMode',
00902              {0: 'Auto',
00903               1: 'Manual'}),
00904     0x1030: ('SlowSync',
00905              {0: 'Off',
00906               1: 'On'}),
00907     0x1031: ('PictureMode',
00908              {0: 'Auto',
00909               1: 'Portrait',
00910               2: 'Landscape',
00911               4: 'Sports',
00912               5: 'Night',
00913               6: 'Program AE',
00914               256: 'Aperture Priority AE',
00915               512: 'Shutter Priority AE',
00916               768: 'Manual Exposure'}),
00917     0x1100: ('MotorOrBracket',
00918              {0: 'Off',
00919               1: 'On'}),
00920     0x1300: ('BlurWarning',
00921              {0: 'Off',
00922               1: 'On'}),
00923     0x1301: ('FocusWarning',
00924              {0: 'Off',
00925               1: 'On'}),
00926     0x1302: ('AEWarning',
00927              {0: 'Off',
00928               1: 'On'}),
00929     }

def MoinMoin.filter.EXIF.process_file (   f,
  name = 'UNDEF',
  details = True,
  debug = 0 
)

Definition at line 1462 of file EXIF.py.

01462 
01463 def process_file(f, name='UNDEF', details=True, debug=0):
01464     # yah it's cheesy...
01465     global detailed
01466     detailed = details
01467 
01468     # by default do not fake an EXIF beginning
01469     fake_exif = 0
01470 
01471     # determine whether it's a JPEG or TIFF
01472     data = f.read(12)
01473     if data[0:4] in ['II*\x00', 'MM\x00*']:
01474         # it's a TIFF file
01475         f.seek(0)
01476         endian = f.read(1)
01477         f.read(1)
01478         offset = 0
01479     elif data[0:2] == '\xFF\xD8':
01480         # it's a JPEG file
01481         while data[2] == '\xFF' and data[6:10] in ('JFIF', 'JFXX', 'OLYM', 'Phot'):
01482             length = ord(data[4])*256+ord(data[5])
01483             f.read(length-8)
01484             # fake an EXIF beginning of file
01485             data = '\xFF\x00'+f.read(10)
01486             fake_exif = 1
01487         if data[2] == '\xFF' and data[6:10] == 'Exif':
01488             # detected EXIF header
01489             offset = f.tell()
01490             endian = f.read(1)
01491         else:
01492             # no EXIF information
01493             return {}
01494     else:
01495         # file format not recognized
01496         return {}
01497 
01498     # deal with the EXIF info we found
01499     if debug:
01500         print {'I': 'Intel', 'M': 'Motorola'}[endian], 'format'
01501     hdr = EXIF_header(f, endian, offset, fake_exif, debug)
01502     ifd_list = hdr.list_IFDs()
01503     ctr = 0
01504     for i in ifd_list:
01505         if ctr == 0:
01506             IFD_name = 'Image'
01507         elif ctr == 1:
01508             IFD_name = 'Thumbnail'
01509             thumb_ifd = i
01510         else:
01511             IFD_name = 'IFD %d' % ctr
01512         if debug:
01513             print ' IFD %d (%s) at offset %d:' % (ctr, IFD_name, i)
01514         hdr.dump_IFD(i, IFD_name, name=name)
01515         # EXIF IFD
01516         exif_off = hdr.tags.get(IFD_name+' ExifOffset')
01517         if exif_off:
01518             if debug:
01519                 print ' EXIF SubIFD at offset %d:' % exif_off.values[0]
01520             hdr.dump_IFD(exif_off.values[0], 'EXIF', name=name)
01521             # Interoperability IFD contained in EXIF IFD
01522             intr_off = hdr.tags.get('EXIF SubIFD InteroperabilityOffset')
01523             if intr_off:
01524                 if debug:
01525                     print ' EXIF Interoperability SubSubIFD at offset %d:' \
01526                           % intr_off.values[0]
01527                 hdr.dump_IFD(intr_off.values[0], 'EXIF Interoperability',
01528                              dict=INTR_TAGS, name=name)
01529         # GPS IFD
01530         gps_off = hdr.tags.get(IFD_name+' GPSInfo')
01531         if gps_off:
01532             if debug:
01533                 print ' GPS SubIFD at offset %d:' % gps_off.values[0]
01534             hdr.dump_IFD(gps_off.values[0], 'GPS', dict=GPS_TAGS, name=name)
01535         ctr += 1
01536 
01537     # extract uncompressed TIFF thumbnail
01538     thumb = hdr.tags.get('Thumbnail Compression')
01539     if thumb and thumb.printable == 'Uncompressed TIFF':
01540         hdr.extract_TIFF_thumbnail(thumb_ifd)
01541 
01542     # JPEG thumbnail (thankfully the JPEG data is stored as a unit)
01543     thumb_off = hdr.tags.get('Thumbnail JPEGInterchangeFormat')
01544     if thumb_off:
01545         f.seek(offset+thumb_off.values[0])
01546         size = hdr.tags['Thumbnail JPEGInterchangeFormatLength'].values[0]
01547         hdr.tags['JPEGThumbnail'] = f.read(size)
01548 
01549     # deal with MakerNote contained in EXIF IFD
01550     if 'EXIF MakerNote' in hdr.tags and detailed:
01551         hdr.decode_maker_note()
01552 
01553     # Sometimes in a TIFF file, a JPEG thumbnail is hidden in the MakerNote
01554     # since it's not allowed in a uncompressed TIFF IFD
01555     if 'JPEGThumbnail' not in hdr.tags:
01556         thumb_off=hdr.tags.get('MakerNote JPEGThumbnail')
01557         if thumb_off:
01558             f.seek(offset+thumb_off.values[0])
01559             hdr.tags['JPEGThumbnail']=file.read(thumb_off.field_length)
01560 
01561     return hdr.tags
01562 
01563 
# library test/debug function (dump given files)

Definition at line 1086 of file EXIF.py.

01086 
01087 def s2n_intel(str):
01088     x = 0
01089     y = 0L
01090     for c in str:
01091         x = x | (ord(c) << y)
01092         y = y + 8
01093     return x
01094 
01095 # ratio object that eventually will be able to reduce itself to lowest
# common denominator for printing

Here is the caller graph for this function:

Definition at line 1079 of file EXIF.py.

01079 
01080 def s2n_motorola(str):
01081     x = 0
01082     for c in str:
01083         x = (x << 8) | ord(c)
01084     return x
01085 
# extract multibyte integer in Intel format (big endian)

Here is the caller graph for this function:


Variable Documentation

Definition at line 1587 of file EXIF.py.

Definition at line 1573 of file EXIF.py.

Definition at line 176 of file EXIF.py.

Initial value:
00001 (
00002     (0, 'X', 'Proprietary'), # no such type
00003     (1, 'B', 'Byte'),
00004     (1, 'A', 'ASCII'),
00005     (2, 'S', 'Short'),
00006     (4, 'L', 'Long'),
00007     (8, 'R', 'Ratio'),
00008     (1, 'SB', 'Signed Byte'),
00009     (1, 'U', 'Undefined'),
00010     (2, 'SS', 'Signed Short'),
00011     (4, 'SL', 'Signed Long'),
00012     (8, 'SR', 'Signed Ratio'),
00013     )

Definition at line 159 of file EXIF.py.

tuple MoinMoin.filter.EXIF.file = open(filename, 'rb')

Definition at line 1580 of file EXIF.py.

Definition at line 1572 of file EXIF.py.

Initial value:
00001 {
00002     0x0000: ('GPSVersionID', ),
00003     0x0001: ('GPSLatitudeRef', ),
00004     0x0002: ('GPSLatitude', ),
00005     0x0003: ('GPSLongitudeRef', ),
00006     0x0004: ('GPSLongitude', ),
00007     0x0005: ('GPSAltitudeRef', ),
00008     0x0006: ('GPSAltitude', ),
00009     0x0007: ('GPSTimeStamp', ),
00010     0x0008: ('GPSSatellites', ),
00011     0x0009: ('GPSStatus', ),
00012     0x000A: ('GPSMeasureMode', ),
00013     0x000B: ('GPSDOP', ),
00014     0x000C: ('GPSSpeedRef', ),
00015     0x000D: ('GPSSpeed', ),
00016     0x000E: ('GPSTrackRef', ),
00017     0x000F: ('GPSTrack', ),
00018     0x0010: ('GPSImgDirectionRef', ),
00019     0x0011: ('GPSImgDirection', ),
00020     0x0012: ('GPSMapDatum', ),
00021     0x0013: ('GPSDestLatitudeRef', ),
00022     0x0014: ('GPSDestLatitude', ),
00023     0x0015: ('GPSDestLongitudeRef', ),
00024     0x0016: ('GPSDestLongitude', ),
00025     0x0017: ('GPSDestBearingRef', ),
00026     0x0018: ('GPSDestBearing', ),
00027     0x0019: ('GPSDestDistanceRef', ),
00028     0x001A: ('GPSDestDistance', ),
00029     }

Definition at line 352 of file EXIF.py.

tuple MoinMoin.filter.EXIF.IGNORE_TAGS = (0x9286, 0x927C)

Definition at line 385 of file EXIF.py.

Initial value:
00001 {
00002     0x0001: ('InteroperabilityIndex', ),
00003     0x0002: ('InteroperabilityVersion', ),
00004     0x1000: ('RelatedImageFileFormat', ),
00005     0x1001: ('RelatedImageWidth', ),
00006     0x1002: ('RelatedImageLength', ),
00007     }

Definition at line 343 of file EXIF.py.

Definition at line 938 of file EXIF.py.

Definition at line 1046 of file EXIF.py.

Initial value:
00001 {
00002     0x0006: ('ImageType', ),
00003     0x0007: ('FirmwareVersion', ),
00004     0x0008: ('ImageNumber', ),
00005     0x0009: ('OwnerName', ),
00006     }

Definition at line 930 of file EXIF.py.

Definition at line 522 of file EXIF.py.

tuple MoinMoin.filter.EXIF.x = data.keys()

Definition at line 1592 of file EXIF.py.