metadata — Phatch v0.2 documentation

### Navigation

- index
- modules |
- next |
- previous |
- Phatch v0.2 documentation »
- lib »

# metadata

class `lib.metadata.` `DumpInfo`(d=None)

  Bases: `dict`

  Dictionary like object which tracks changes.

      >>> d = DumpInfo({'hello': 'world'})
      >>> d['foo'] = 'bar'
      >>> d.changed
      ['foo']

`lib.metadata.` `Info`
  alias of `InfoZexif`

class `lib.metadata.` `InfoEXIF`(source=None, vars=None)

  Bases: `lib.metadata._InfoCache`

      >>> import pprint
      >>> filename = '../tests/input/exĩf ïptç.jpg'
      >>> info = InfoEXIF(filename)
      >>> pprint.pprint(sorted(info.dict.keys()))
      []
      >>> info['EXIF_Thumbnail_Compression']
      (0x0103) Short=JPEG (old-style) @ 3402
      >>> pprint.pprint(sorted(info.dict.keys()))
      ['EXIF_Thumbnail_Compression']
      >>> import pyexiv2
      >>> from other import EXIF
      >>> exif = EXIF.process_file(open(filename, 'rb'))
      >>> info = InfoEXIF(exif)
      >>> info['orientation']
      8
      >>> str(info['EXIF_Image_Orientation'])
      'Rotated 90 CCW'
      >>> info['EXIF_Thumbnail_Compression']
      (0x0103) Short=JPEG (old-style) @ 3402
      >>> pprint.pprint(sorted(info.dict.keys()))
      ['EXIF_Image_Orientation', 'EXIF_Thumbnail_Compression', 'orientation']
      >>> info.extract_all()
      >>> pprint.pprint(sorted(info.dict.keys()))
      ['EXIF_ApertureValue',
       'EXIF_ColorSpace',
       'EXIF_ComponentsConfiguration',
       'EXIF_CompressedBitsPerPixel',
       'EXIF_CustomRendered',
       'EXIF_DateTimeDigitized',
       'EXIF_DateTimeOriginal',
       'EXIF_DigitalZoomRatio',
       'EXIF_ExifImageLength',
       'EXIF_ExifImageWidth',
       'EXIF_ExifVersion',
       'EXIF_ExposureBiasValue',
       'EXIF_ExposureMode',
       'EXIF_ExposureTime',
       'EXIF_FNumber',
       'EXIF_FileSource',
       'EXIF_Flash',
       'EXIF_FlashPixVersion',
       'EXIF_FocalLength',
       'EXIF_FocalPlaneResolutionUnit',
       'EXIF_FocalPlaneXResolution',
       'EXIF_FocalPlaneYResolution',
       'EXIF_Image_DateTime',
       'EXIF_Image_ExifOffset',
       'EXIF_Image_Make',
       'EXIF_Image_Model',
       'EXIF_Image_Orientation',
       'EXIF_Image_ResolutionUnit',
       'EXIF_Image_XResolution',
       'EXIF_Image_YCbCrPositioning',
       'EXIF_Image_YResolution',
       'EXIF_InteroperabilityOffset',
       'EXIF_JPEGThumbnail',
       'EXIF_MakerNote',
       'EXIF_MakerNote_AFPointSelected',
       'EXIF_MakerNote_AFPointUsed',
       'EXIF_MakerNote_ContinuousDriveMode',
       'EXIF_MakerNote_Contrast',
       'EXIF_MakerNote_DigitalZoom',
       'EXIF_MakerNote_EasyShootingMode',
       'EXIF_MakerNote_ExposureMode',
       'EXIF_MakerNote_FirmwareVersion',
       'EXIF_MakerNote_FlashActivity',
       'EXIF_MakerNote_FlashBias',
       'EXIF_MakerNote_FlashDetails',
       'EXIF_MakerNote_FlashMode',
       'EXIF_MakerNote_FocalUnitsPerMM',
       'EXIF_MakerNote_FocusMode',
       'EXIF_MakerNote_FocusType',
       'EXIF_MakerNote_ISO',
       'EXIF_MakerNote_ImageNumber',
       'EXIF_MakerNote_ImageSize',
       'EXIF_MakerNote_ImageType',
       'EXIF_MakerNote_LongFocalLengthOfLensInFocalUnits',
       'EXIF_MakerNote_Macromode',
       'EXIF_MakerNote_MeteringMode',
       'EXIF_MakerNote_OwnerName',
       'EXIF_MakerNote_Quality',
       'EXIF_MakerNote_Saturation',
       'EXIF_MakerNote_SelfTimer',
       'EXIF_MakerNote_SequenceNumber',
       'EXIF_MakerNote_Sharpness',
       'EXIF_MakerNote_ShortFocalLengthOfLensInFocalUnits',
       'EXIF_MakerNote_SubjectDistance',
       'EXIF_MakerNote_Tag_0x0000',
       'EXIF_MakerNote_Tag_0x0001',
       'EXIF_MakerNote_Tag_0x0002',
       'EXIF_MakerNote_Tag_0x0003',
       'EXIF_MakerNote_Tag_0x0004',
       'EXIF_MakerNote_Tag_0x000D',
       'EXIF_MakerNote_Tag_0x0010',
       'EXIF_MakerNote_Tag_0x0013',
       'EXIF_MakerNote_Tag_0x0018',
       'EXIF_MakerNote_Tag_0x0019',
       'EXIF_MakerNote_Tag_0x001C',
       'EXIF_MakerNote_Tag_0x001D',
       'EXIF_MakerNote_Tag_0x001E',
       'EXIF_MakerNote_Tag_0x001F',
       'EXIF_MakerNote_Tag_0x0022',
       'EXIF_MakerNote_Tag_0x0023',
       'EXIF_MakerNote_Tag_0x0024',
       'EXIF_MakerNote_Tag_0x0025',
       'EXIF_MakerNote_Tag_0x0026',
       'EXIF_MakerNote_Tag_0x0027',
       'EXIF_MakerNote_Tag_0x0028',
       'EXIF_MakerNote_Unknown',
       'EXIF_MakerNote_WhiteBalance',
       'EXIF_MaxApertureValue',
       'EXIF_MeteringMode',
       'EXIF_SceneCaptureType',
       'EXIF_SensingMethod',
       'EXIF_ShutterSpeedValue',
       'EXIF_Thumbnail_Compression',
       'EXIF_Thumbnail_JPEGInterchangeFormat',
       'EXIF_Thumbnail_JPEGInterchangeFormatLength',
       'EXIF_Thumbnail_ResolutionUnit',
       'EXIF_Thumbnail_XResolution',
       'EXIF_Thumbnail_YResolution',
       'EXIF_UserComment',
       'EXIF_WhiteBalance',
       'orientation']

class `lib.metadata.` `InfoExif`(source=None, vars=None)

  Bases: `lib.metadata._InfoPyexiv2`

      >>> import pprint
      >>> filename = '../tests/input/exĩf ïptç.jpg'
      >>> info = InfoExif(filename)
      >>> info['Exif_Image_DateTime']
      DateTime('2010:03:03 11:03:08')
      >>> import pyexiv2
      >>> exif = pyexiv2.Image(filename)
      >>> exif.readMetadata()
      >>> info = InfoExif(exif)
      >>> info['Exif_Image_DateTime']
      DateTime('2010:03:03 11:03:08')
      >>> print info['Exif_Image_DateTime']
      2010:03:03 11:03:08
      >>> info['Exif_Image_Orientation']
      8
      >>> info['Exif_Photo_MaxApertureValue'].__class__ == pyexiv2.Rational
      True
      >>> print info['Exif_Photo_MaxApertureValue']
      128/32
      >>> info.extract_all()
      >>> pprint.pprint(sorted(info.dict.keys()))
      ['Exif_CanonCs_0x0000',
       'Exif_CanonCs_0x0006',
       'Exif_CanonCs_0x0008',
       'Exif_CanonCs_0x0009',
       'Exif_CanonCs_0x0015',
       'Exif_CanonCs_0x001e',
       'Exif_CanonCs_0x001f',
       'Exif_CanonCs_0x0026',
       'Exif_CanonCs_0x0027',
       'Exif_CanonCs_0x0029',
       'Exif_CanonCs_0x002b',
       'Exif_CanonCs_0x002c',
       'Exif_CanonCs_0x002d',
       'Exif_CanonCs_AESetting',
       'Exif_CanonCs_AFPoint',
       'Exif_CanonCs_ColorTone',
       'Exif_CanonCs_Contrast',
       'Exif_CanonCs_DigitalZoom',
       'Exif_CanonCs_DisplayAperture',
       'Exif_CanonCs_DriveMode',
       'Exif_CanonCs_EasyMode',
       'Exif_CanonCs_ExposureProgram',
       'Exif_CanonCs_FlashActivity',
       'Exif_CanonCs_FlashDetails',
       'Exif_CanonCs_FlashMode',
       'Exif_CanonCs_FocusContinuous',
       'Exif_CanonCs_FocusMode',
       'Exif_CanonCs_FocusType',
       'Exif_CanonCs_ISOSpeed',
       'Exif_CanonCs_ImageSize',
       'Exif_CanonCs_ImageStabilization',
       'Exif_CanonCs_Lens',
       'Exif_CanonCs_LensType',
       'Exif_CanonCs_Macro',
       'Exif_CanonCs_MaxAperture',
       'Exif_CanonCs_MeteringMode',
       'Exif_CanonCs_MinAperture',
       'Exif_CanonCs_PhotoEffect',
       'Exif_CanonCs_Quality',
       'Exif_CanonCs_Saturation',
       'Exif_CanonCs_Selftimer',
       'Exif_CanonCs_Sharpness',
       'Exif_CanonCs_ZoomSourceWidth',
       'Exif_CanonCs_ZoomTargetWidth',
       'Exif_CanonSi_0x0000',
       'Exif_CanonSi_0x0001',
       'Exif_CanonSi_0x0003',
       'Exif_CanonSi_0x0006',
       'Exif_CanonSi_0x0008',
       'Exif_CanonSi_0x000a',
       'Exif_CanonSi_0x000b',
       'Exif_CanonSi_0x000c',
       'Exif_CanonSi_0x000d',
       'Exif_CanonSi_0x0010',
       'Exif_CanonSi_0x0011',
       'Exif_CanonSi_0x0012',
       'Exif_CanonSi_0x0014',
       'Exif_CanonSi_0x0017',
       'Exif_CanonSi_0x0018',
       'Exif_CanonSi_0x0019',
       'Exif_CanonSi_0x001a',
       'Exif_CanonSi_0x001b',
       'Exif_CanonSi_0x001c',
       'Exif_CanonSi_0x001d',
       'Exif_CanonSi_0x001e',
       'Exif_CanonSi_0x001f',
       'Exif_CanonSi_0x0020',
       'Exif_CanonSi_0x0021',
       'Exif_CanonSi_AFPointUsed',
       'Exif_CanonSi_ApertureValue',
       'Exif_CanonSi_FlashBias',
       'Exif_CanonSi_ISOSpeed',
       'Exif_CanonSi_Sequence',
       'Exif_CanonSi_ShutterSpeedValue',
       'Exif_CanonSi_SubjectDistance',
       'Exif_CanonSi_TargetAperture',
       'Exif_CanonSi_TargetShutterSpeed',
       'Exif_CanonSi_WhiteBalance',
       'Exif_Canon_0x0000',
       'Exif_Canon_0x0003',
       'Exif_Canon_0x000d',
       'Exif_Canon_0x0013',
       'Exif_Canon_0x0018',
       'Exif_Canon_0x0019',
       'Exif_Canon_0x001c',
       'Exif_Canon_0x001d',
       'Exif_Canon_0x001e',
       'Exif_Canon_0x001f',
       'Exif_Canon_0x0022',
       'Exif_Canon_0x0023',
       'Exif_Canon_0x0024',
       'Exif_Canon_0x0025',
       'Exif_Canon_0x0026',
       'Exif_Canon_0x0027',
       'Exif_Canon_0x0028',
       'Exif_Canon_FirmwareVersion',
       'Exif_Canon_FocalLength',
       'Exif_Canon_ImageNumber',
       'Exif_Canon_ImageType',
       'Exif_Canon_ModelID',
       'Exif_Canon_OwnerName',
       'Exif_Image_DateTime',
       'Exif_Image_ExifTag',
       'Exif_Image_Make',
       'Exif_Image_Model',
       'Exif_Image_Orientation',
       'Exif_Image_ResolutionUnit',
       'Exif_Image_XResolution',
       'Exif_Image_YCbCrPositioning',
       'Exif_Image_YResolution',
       'Exif_Iop_InteroperabilityIndex',
       'Exif_Iop_InteroperabilityVersion',
       'Exif_Iop_RelatedImageLength',
       'Exif_Iop_RelatedImageWidth',
       'Exif_MakerNote_ByteOrder',
       'Exif_MakerNote_Offset',
       'Exif_Photo_ApertureValue',
       'Exif_Photo_ColorSpace',
       'Exif_Photo_ComponentsConfiguration',
       'Exif_Photo_CompressedBitsPerPixel',
       'Exif_Photo_CustomRendered',
       'Exif_Photo_DateTimeDigitized',
       'Exif_Photo_DateTimeOriginal',
       'Exif_Photo_DigitalZoomRatio',
       'Exif_Photo_ExifVersion',
       'Exif_Photo_ExposureBiasValue',
       'Exif_Photo_ExposureMode',
       'Exif_Photo_ExposureTime',
       'Exif_Photo_FNumber',
       'Exif_Photo_FileSource',
       'Exif_Photo_Flash',
       'Exif_Photo_FlashpixVersion',
       'Exif_Photo_FocalLength',
       'Exif_Photo_FocalPlaneResolutionUnit',
       'Exif_Photo_FocalPlaneXResolution',
       'Exif_Photo_FocalPlaneYResolution',
       'Exif_Photo_InteroperabilityTag',
       'Exif_Photo_MakerNote',
       'Exif_Photo_MaxApertureValue',
       'Exif_Photo_MeteringMode',
       'Exif_Photo_PixelXDimension',
       'Exif_Photo_PixelYDimension',
       'Exif_Photo_SceneCaptureType',
       'Exif_Photo_SensingMethod',
       'Exif_Photo_ShutterSpeedValue',
       'Exif_Photo_UserComment',
       'Exif_Photo_WhiteBalance',
       'Exif_Thumbnail_Compression',
       'Exif_Thumbnail_JPEGInterchangeFormat',
       'Exif_Thumbnail_JPEGInterchangeFormatLength',
       'Exif_Thumbnail_ResolutionUnit',
       'Exif_Thumbnail_XResolution',
       'Exif_Thumbnail_YResolution',
       'orientation']

class `lib.metadata.` `InfoExtract`(filename=None, vars=None, sources=None)

  Create an info like dictionary which uses a collection of several info instances and can evaluate Python expressions.

      >>> import Image
      >>> import pprint
      >>> list(InfoExtract.get_vars_by_info(['mode'])[0].values())
      [['mode', 'orientation']]
      >>> list(InfoExtract.get_vars_by_info(['width'])[0].values())
      [['width', 'orientation']]
      >>> vars = ['format', 'width', 'subfolder', 'orientation', 'crazy']
      >>> filename = '../tests/input/exĩf ïptç.jpg'
      >>> image = Image.open(filename)
      >>> info = InfoExtract(filename, vars + ['Pexif_DateTimeOriginal'])
      >>> info.types()
      ['File', 'Exif', 'Pil', 'Pexif']
      >>> info.vars_unknown
      ['crazy']
      >>> info['format']
      'JPEG'
      >>> pprint.pprint(sorted(info.dump(expand=False).items()))
      [('Pexif_DateTimeOriginal', DateTime('2010:03:03 11:03:08')),
       ('format', 'JPEG'),
       ('height', 640),
       ('orientation', 8),
       ('size', (480, 640)),
       ('subfolder', u''),
       ('width', 480)]
      >>> info['size']  # uses orientation
      (480, 640)
      >>> image.size  # ignores orientation
      (640, 480)
      >>> info['Pexif_DateTimeOriginal']
      DateTime('2010:03:03 11:03:08')
      >>> pprint.pprint(sorted(info.dump(expand=True).items()))
      [('Pexif_DateTimeOriginal', DateTime('2010:03:03 11:03:08')),
       ('Pexif_DateTimeOriginal.day', 3),
       ('Pexif_DateTimeOriginal.hour', 11),
       ('Pexif_DateTimeOriginal.microsecond', 0),
       ('Pexif_DateTimeOriginal.minute', 3),
       ('Pexif_DateTimeOriginal.month', 3),
       ('Pexif_DateTimeOriginal.monthname', 'March'),
       ('Pexif_DateTimeOriginal.second', 8),
       ('Pexif_DateTimeOriginal.weekday', 2),
       ('Pexif_DateTimeOriginal.weekdayname', 'Wednesday'),
       ('Pexif_DateTimeOriginal.year', 2010),
       ('format', 'JPEG'),
       ('height', 640),
       ('orientation', 8),
       ('size', (480, 640)),
       ('size[0]', 480),
       ('size[1]', 640),
       ('subfolder', u''),
       ('width', 480)]
      >>> info.extract_all()
      >>> pprint.pprint(sorted(info.dump(expand=False).keys()))
      ['Exif_CanonCs_0x0000',
       'Exif_CanonCs_0x0006',
       'Exif_CanonCs_0x0008',
       'Exif_CanonCs_0x0009',
       'Exif_CanonCs_0x0015',
       'Exif_CanonCs_0x001e',
       'Exif_CanonCs_0x001f',
       'Exif_CanonCs_0x0026',
       'Exif_CanonCs_0x0027',
       'Exif_CanonCs_0x0029',
       'Exif_CanonCs_0x002b',
       'Exif_CanonCs_0x002c',
       'Exif_CanonCs_0x002d',
       'Exif_CanonCs_AESetting',
       'Exif_CanonCs_AFPoint',
       'Exif_CanonCs_ColorTone',
       'Exif_CanonCs_Contrast',
       'Exif_CanonCs_DigitalZoom',
       'Exif_CanonCs_DisplayAperture',
       'Exif_CanonCs_DriveMode',
       'Exif_CanonCs_EasyMode',
       'Exif_CanonCs_ExposureProgram',
       'Exif_CanonCs_FlashActivity',
       'Exif_CanonCs_FlashDetails',
       'Exif_CanonCs_FlashMode',
       'Exif_CanonCs_FocusContinuous',
       'Exif_CanonCs_FocusMode',
       'Exif_CanonCs_FocusType',
       'Exif_CanonCs_ISOSpeed',
       'Exif_CanonCs_ImageSize',
       'Exif_CanonCs_ImageStabilization',
       'Exif_CanonCs_Lens',
       'Exif_CanonCs_LensType',
       'Exif_CanonCs_Macro',
       'Exif_CanonCs_MaxAperture',
       'Exif_CanonCs_MeteringMode',
       'Exif_CanonCs_MinAperture',
       'Exif_CanonCs_PhotoEffect',
       'Exif_CanonCs_Quality',
       'Exif_CanonCs_Saturation',
       'Exif_CanonCs_Selftimer',
       'Exif_CanonCs_Sharpness',
       'Exif_CanonCs_ZoomSourceWidth',
       'Exif_CanonCs_ZoomTargetWidth',
       'Exif_CanonSi_0x0000',
       'Exif_CanonSi_0x0001',
       'Exif_CanonSi_0x0003',
       'Exif_CanonSi_0x0006',
       'Exif_CanonSi_0x0008',
       'Exif_CanonSi_0x000a',
       'Exif_CanonSi_0x000b',
       'Exif_CanonSi_0x000c',
       'Exif_CanonSi_0x000d',
       'Exif_CanonSi_0x0010',
       'Exif_CanonSi_0x0011',
       'Exif_CanonSi_0x0012',
       'Exif_CanonSi_0x0014',
       'Exif_CanonSi_0x0017',
       'Exif_CanonSi_0x0018',
       'Exif_CanonSi_0x0019',
       'Exif_CanonSi_0x001a',
       'Exif_CanonSi_0x001b',
       'Exif_CanonSi_0x001c',
       'Exif_CanonSi_0x001d',
       'Exif_CanonSi_0x001e',
       'Exif_CanonSi_0x001f',
       'Exif_CanonSi_0x0020',
       'Exif_CanonSi_0x0021',
       'Exif_CanonSi_AFPointUsed',
       'Exif_CanonSi_ApertureValue',
       'Exif_CanonSi_FlashBias',
       'Exif_CanonSi_ISOSpeed',
       'Exif_CanonSi_Sequence',
       'Exif_CanonSi_ShutterSpeedValue',
       'Exif_CanonSi_SubjectDistance',
       'Exif_CanonSi_TargetAperture',
       'Exif_CanonSi_TargetShutterSpeed',
       'Exif_CanonSi_WhiteBalance',
       'Exif_Canon_0x0000',
       'Exif_Canon_0x0003',
       'Exif_Canon_0x000d',
       'Exif_Canon_0x0013',
       'Exif_Canon_0x0018',
       'Exif_Canon_0x0019',
       'Exif_Canon_0x001c',
       'Exif_Canon_0x001d',
       'Exif_Canon_0x001e',
       'Exif_Canon_0x001f',
       'Exif_Canon_0x0022',
       'Exif_Canon_0x0023',
       'Exif_Canon_0x0024',
       'Exif_Canon_0x0025',
       'Exif_Canon_0x0026',
       'Exif_Canon_0x0027',
       'Exif_Canon_0x0028',
       'Exif_Canon_FirmwareVersion',
       'Exif_Canon_FocalLength',
       'Exif_Canon_ImageNumber',
       'Exif_Canon_ImageType',
       'Exif_Canon_ModelID',
       'Exif_Canon_OwnerName',
       'Exif_Image_DateTime',
       'Exif_Image_ExifTag',
       'Exif_Image_Make',
       'Exif_Image_Model',
       'Exif_Image_Orientation',
       'Exif_Image_ResolutionUnit',
       'Exif_Image_XResolution',
       'Exif_Image_YCbCrPositioning',
       'Exif_Image_YResolution',
       'Exif_Iop_InteroperabilityIndex',
       'Exif_Iop_InteroperabilityVersion',
       'Exif_Iop_RelatedImageLength',
       'Exif_Iop_RelatedImageWidth',
       'Exif_MakerNote_ByteOrder',
       'Exif_MakerNote_Offset',
       'Exif_Photo_ApertureValue',
       'Exif_Photo_ColorSpace',
       'Exif_Photo_ComponentsConfiguration',
       'Exif_Photo_CompressedBitsPerPixel',
       'Exif_Photo_CustomRendered',
       'Exif_Photo_DateTimeDigitized',
       'Exif_Photo_DateTimeOriginal',
       'Exif_Photo_DigitalZoomRatio',
       'Exif_Photo_ExifVersion',
       'Exif_Photo_ExposureBiasValue',
       'Exif_Photo_ExposureMode',
       'Exif_Photo_ExposureTime',
       'Exif_Photo_FNumber',
       'Exif_Photo_FileSource',
       'Exif_Photo_Flash',
       'Exif_Photo_FlashpixVersion',
       'Exif_Photo_FocalLength',
       'Exif_Photo_FocalPlaneResolutionUnit',
       'Exif_Photo_FocalPlaneXResolution',
       'Exif_Photo_FocalPlaneYResolution',
       'Exif_Photo_InteroperabilityTag',
       'Exif_Photo_MakerNote',
       'Exif_Photo_MaxApertureValue',
       'Exif_Photo_MeteringMode',
       'Exif_Photo_PixelXDimension',
       'Exif_Photo_PixelYDimension',
       'Exif_Photo_SceneCaptureType',
       'Exif_Photo_SensingMethod',
       'Exif_Photo_ShutterSpeedValue',
       'Exif_Photo_UserComment',
       'Exif_Photo_WhiteBalance',
       'Exif_Thumbnail_Compression',
       'Exif_Thumbnail_JPEGInterchangeFormat',
       'Exif_Thumbnail_JPEGInterchangeFormatLength',
       'Exif_Thumbnail_ResolutionUnit',
       'Exif_Thumbnail_XResolution',
       'Exif_Thumbnail_YResolution',
       'Pexif_ApertureValue',
       'Pexif_ColorSpace',
       'Pexif_ComponentsConfiguration',
       'Pexif_CompressedBitsPerPixel',
       'Pexif_DateTime',
       'Pexif_DateTimeDigitized',
       'Pexif_DateTimeOriginal',
       'Pexif_ExifImageHeight',
       'Pexif_ExifImageWidth',
       'Pexif_ExifInteroperabilityOffset',
       'Pexif_ExifOffset',
       'Pexif_ExifVersion',
       'Pexif_ExposureTime',
       'Pexif_FNumber',
       'Pexif_FileSource',
       'Pexif_Flash',
       'Pexif_FlashPixVersion',
       'Pexif_FocalLength',
       'Pexif_FocalPlaneResolutionUnit',
       'Pexif_FocalPlaneXResolution',
       'Pexif_FocalPlaneYResolution',
       'Pexif_Make',
       'Pexif_MakerNote',
       'Pexif_MaxApertureValue',
       'Pexif_MeteringMode',
       'Pexif_Model',
       'Pexif_Orientation',
       'Pexif_ResolutionUnit',
       'Pexif_SensingMethod',
       'Pexif_UserComment',
       'Pexif_XResolution',
       'Pexif_YCbCrPositioning',
       'Pexif_YResolution',
       'aspect',
       'compression',
       'day',
       'desktop',
       'dpi',
       'filename',
       'filesize',
       'folder',
       'foldername',
       'format',
       'formatdescription',
       'gamma',
       'height',
       'hour',
       'interlace',
       'minute',
       'mode',
       'month',
       'monthname',
       'orientation',
       'path',
       'root',
       'second',
       'size',
       'subfolder',
       'transparency',
       'type',
       'weekday',
       'weekdayname',
       'width',
       'year']
      >>> info.set(filename='../tests/input/exĩf ïptç.jpg',
      ...     vars=vars) #exclude Pexif.* vars
      >>> pprint.pprint(sorted(info.dump(expand=False).items()))
      [('format', 'JPEG'),
       ('height', 640),
       ('orientation', 8),
       ('size', (480, 640)),
       ('subfolder', u''),
       ('width', 480)]
      >>> info['root']
      u'../tests'
      >>> d = info.dump(expand=False)
      >>> pprint.pprint(sorted(d.items()))
      [('foldername', u'input'),
       ('format', 'JPEG'),
       ('height', 640),
       ('orientation', 8),
       ('root', u'../tests'),
       ('size', (480, 640)),
       ('subfolder', u''),
       ('width', 480)]
      >>> type(d) == dict
      True
      >>> info.set(vars=vars + ['Iptc_Application2_Copyright'])
      >>> info.extract_all()
      >>> pprint.pprint(sorted(info.dump(expand=False).keys()))
      ['Exif_CanonCs_0x0000',
       'Exif_CanonCs_0x0006',
       'Exif_CanonCs_0x0008',
       'Exif_CanonCs_0x0009',
       'Exif_CanonCs_0x0015',
       'Exif_CanonCs_0x001e',
       'Exif_CanonCs_0x001f',
       'Exif_CanonCs_0x0026',
       'Exif_CanonCs_0x0027',
       'Exif_CanonCs_0x0029',
       'Exif_CanonCs_0x002b',
       'Exif_CanonCs_0x002c',
       'Exif_CanonCs_0x002d',
       'Exif_CanonCs_AESetting',
       'Exif_CanonCs_AFPoint',
       'Exif_CanonCs_ColorTone',
       'Exif_CanonCs_Contrast',
       'Exif_CanonCs_DigitalZoom',
       'Exif_CanonCs_DisplayAperture',
       'Exif_CanonCs_DriveMode',
       'Exif_CanonCs_EasyMode',
       'Exif_CanonCs_ExposureProgram',
       'Exif_CanonCs_FlashActivity',
       'Exif_CanonCs_FlashDetails',
       'Exif_CanonCs_FlashMode',
       'Exif_CanonCs_FocusContinuous',
       'Exif_CanonCs_FocusMode',
       'Exif_CanonCs_FocusType',
       'Exif_CanonCs_ISOSpeed',
       'Exif_CanonCs_ImageSize',
       'Exif_CanonCs_ImageStabilization',
       'Exif_CanonCs_Lens',
       'Exif_CanonCs_LensType',
       'Exif_CanonCs_Macro',
       'Exif_CanonCs_MaxAperture',
       'Exif_CanonCs_MeteringMode',
       'Exif_CanonCs_MinAperture',
       'Exif_CanonCs_PhotoEffect',
       'Exif_CanonCs_Quality',
       'Exif_CanonCs_Saturation',
       'Exif_CanonCs_Selftimer',
       'Exif_CanonCs_Sharpness',
       'Exif_CanonCs_ZoomSourceWidth',
       'Exif_CanonCs_ZoomTargetWidth',
       'Exif_CanonSi_0x0000',
       'Exif_CanonSi_0x0001',
       'Exif_CanonSi_0x0003',
       'Exif_CanonSi_0x0006',
       'Exif_CanonSi_0x0008',
       'Exif_CanonSi_0x000a',
       'Exif_CanonSi_0x000b',
       'Exif_CanonSi_0x000c',
       'Exif_CanonSi_0x000d',
       'Exif_CanonSi_0x0010',
       'Exif_CanonSi_0x0011',
       'Exif_CanonSi_0x0012',
       'Exif_CanonSi_0x0014',
       'Exif_CanonSi_0x0017',
       'Exif_CanonSi_0x0018',
       'Exif_CanonSi_0x0019',
       'Exif_CanonSi_0x001a',
       'Exif_CanonSi_0x001b',
       'Exif_CanonSi_0x001c',
       'Exif_CanonSi_0x001d',
       'Exif_CanonSi_0x001e',
       'Exif_CanonSi_0x001f',
       'Exif_CanonSi_0x0020',
       'Exif_CanonSi_0x0021',
       'Exif_CanonSi_AFPointUsed',
       'Exif_CanonSi_ApertureValue',
       'Exif_CanonSi_FlashBias',
       'Exif_CanonSi_ISOSpeed',
       'Exif_CanonSi_Sequence',
       'Exif_CanonSi_ShutterSpeedValue',
       'Exif_CanonSi_SubjectDistance',
       'Exif_CanonSi_TargetAperture',
       'Exif_CanonSi_TargetShutterSpeed',
       'Exif_CanonSi_WhiteBalance',
       'Exif_Canon_0x0000',
       'Exif_Canon_0x0003',
       'Exif_Canon_0x000d',
       'Exif_Canon_0x0013',
       'Exif_Canon_0x0018',
       'Exif_Canon_0x0019',
       'Exif_Canon_0x001c',
       'Exif_Canon_0x001d',
       'Exif_Canon_0x001e',
       'Exif_Canon_0x001f',
       'Exif_Canon_0x0022',
       'Exif_Canon_0x0023',
       'Exif_Canon_0x0024',
       'Exif_Canon_0x0025',
       'Exif_Canon_0x0026',
       'Exif_Canon_0x0027',
       'Exif_Canon_0x0028',
       'Exif_Canon_FirmwareVersion',
       'Exif_Canon_FocalLength',
       'Exif_Canon_ImageNumber',
       'Exif_Canon_ImageType',
       'Exif_Canon_ModelID',
       'Exif_Canon_OwnerName',
       'Exif_Image_DateTime',
       'Exif_Image_ExifTag',
       'Exif_Image_Make',
       'Exif_Image_Model',
       'Exif_Image_Orientation',
       'Exif_Image_ResolutionUnit',
       'Exif_Image_XResolution',
       'Exif_Image_YCbCrPositioning',
       'Exif_Image_YResolution',
       'Exif_Iop_InteroperabilityIndex',
       'Exif_Iop_InteroperabilityVersion',
       'Exif_Iop_RelatedImageLength',
       'Exif_Iop_RelatedImageWidth',
       'Exif_MakerNote_ByteOrder',
       'Exif_MakerNote_Offset',
       'Exif_Photo_ApertureValue',
       'Exif_Photo_ColorSpace',
       'Exif_Photo_ComponentsConfiguration',
       'Exif_Photo_CompressedBitsPerPixel',
       'Exif_Photo_CustomRendered',
       'Exif_Photo_DateTimeDigitized',
       'Exif_Photo_DateTimeOriginal',
       'Exif_Photo_DigitalZoomRatio',
       'Exif_Photo_ExifVersion',
       'Exif_Photo_ExposureBiasValue',
       'Exif_Photo_ExposureMode',
       'Exif_Photo_ExposureTime',
       'Exif_Photo_FNumber',
       'Exif_Photo_FileSource',
       'Exif_Photo_Flash',
       'Exif_Photo_FlashpixVersion',
       'Exif_Photo_FocalLength',
       'Exif_Photo_FocalPlaneResolutionUnit',
       'Exif_Photo_FocalPlaneXResolution',
       'Exif_Photo_FocalPlaneYResolution',
       'Exif_Photo_InteroperabilityTag',
       'Exif_Photo_MakerNote',
       'Exif_Photo_MaxApertureValue',
       'Exif_Photo_MeteringMode',
       'Exif_Photo_PixelXDimension',
       'Exif_Photo_PixelYDimension',
       'Exif_Photo_SceneCaptureType',
       'Exif_Photo_SensingMethod',
       'Exif_Photo_ShutterSpeedValue',
       'Exif_Photo_UserComment',
       'Exif_Photo_WhiteBalance',
       'Exif_Thumbnail_Compression',
       'Exif_Thumbnail_JPEGInterchangeFormat',
       'Exif_Thumbnail_JPEGInterchangeFormatLength',
       'Exif_Thumbnail_ResolutionUnit',
       'Exif_Thumbnail_XResolution',
       'Exif_Thumbnail_YResolution',
       'Iptc_Application2_Byline',
       'Iptc_Application2_Caption',
       'Iptc_Application2_Copyright',
       'Iptc_Application2_ObjectName',
       'Iptc_Application2_RecordVersion',
       'aspect',
       'compression',
       'day',
       'desktop',
       'dpi',
       'filename',
       'filesize',
       'folder',
       'foldername',
       'format',
       'formatdescription',
       'gamma',
       'height',
       'hour',
       'interlace',
       'minute',
       'mode',
       'month',
       'monthname',
       'orientation',
       'path',
       'root',
       'second',
       'size',
       'subfolder',
       'transparency',
       'type',
       'weekday',
       'weekdayname',
       'width',
       'year']

  `clear`()
    Clear alfl info types.
  `clear_cache`()
    Clears the look up cache.
  `dump`(filename=None, expand=False, free=False)

    Dump as a dictionary.

    Parameter: | vars (list) – list of variables as arguments

  classmethod `expand`(d)
  classmethod `expand_var`(d, key, value)
  `extract_all`()
    Extract all variables provided by the info types.
  classmethod `get_vars_by_info`(vars, old_vars=None, filename='test.png')

    Organizes vars in a dictionary by Info class (e.g. `InfoPil`, `InfoExif`, ...).

    As this is a class method, `old_vars` has to be passed explicitly instead of being obtained from the instance.

    Parameters: | vars (list of strings) – variables old_vars (list of strings) – previous variables

  `open`(filename, sources=None)

    Feeds a new file as source for all info types.

    Parameter: | filename (string) – filename of the source file

    Note

    This will clear the cache.

  `provides`(var)

    Whether this info provides this variable.

    Parameter: | var (string) – name of the variable
    Returns: | if `var` is provided
    Return type: | bool

  classmethod `scan_infos`(vars)

    Scan which info types the variables `vars` require.

    Parameter: | vars (list) – variables which have to be provided
    Returns: | variables by required info types
    Return type: | dict of lists

  `set`(filename=None, vars=None, sources=None)

    Set new parameters for the info.

    Parameters: | filename (string) – filename of the source file vars (list) – variables that have to be extracted (e.g. orientation)

  `set_orientation`(orientation=None)
  `set_source`(d)

    Set source of an info from the collection. Raises an `UnknownTypeError` in case an unknown type is given.

    Parameter: | d (dict/str) – dictionary {type: source} or type

  `set_vars`(vars, filename='test.png')

    Limit the range of the possible variables which might be looked up.

    Parameter: | vars (list) – variables that have to be extracted (e.g. orientation)

  `types`()

    Which info types are used by this instance.

    Returns: | info types
    Return type: | list

class `lib.metadata.` `InfoFile`(source=None, vars=None)

  Bases: `lib.metadata._InfoCache`

  Wraps a lazy file path access around an image filename.

      >>> info = InfoFile('/home/phatch/test.png')
      >>> info['foldername']
      u'phatch'
      >>> sorted(info.dict.keys())
      ['foldername', 'root']
      >>> info['type']
      u'png'
      >>> sorted(info.dict.keys())
      ['filename', 'foldername', 'root', 'type']
      >>> info.set_source('/home/gimp/world.jpg')
      >>> info['type']
      u'jpg'
      >>> sorted(info.dict.keys())
      ['filename', 'type']

  classmethod `split_vars`(vars)

class `lib.metadata.` `InfoIptc`(source=None, vars=None)

  Bases: `lib.metadata._InfoPyexiv2`

      >>> import pprint
      >>> filename = '../tests/input/exĩf ïptç.jpg'
      >>> info = InfoIptc(filename)
      >>> info['Iptc_Application2_RecordVersion']
      0
      >>> import pyexiv2
      >>> exif = pyexiv2.Image(filename)
      >>> exif.readMetadata()
      >>> info = InfoIptc(exif)
      >>> info['Iptc_Application2_RecordVersion']
      0
      >>> info['Iptc_Application2_Copyright']
      'Copyright 2010, www.stani.be'
      >>> pprint.pprint(sorted(info.dict.keys()))
      ['Iptc_Application2_Copyright', 'Iptc_Application2_RecordVersion']
      >>> info.extract_all()
      >>> pprint.pprint(sorted(info.dict.keys()))
      ['Iptc_Application2_Byline',
       'Iptc_Application2_Caption',
       'Iptc_Application2_Copyright',
       'Iptc_Application2_ObjectName',
       'Iptc_Application2_RecordVersion']

class `lib.metadata.` `InfoPexif`(source=None, vars=None)

  Bases: `lib.metadata._InfoPilMetadata`

  Wraps a lazy PIL exif var access to an image.

      >>> import pprint
      >>> filename = '../tests/input/exĩf ïptç.jpg'
      >>> info = InfoPexif(filename)
      >>> info['orientation']
      8
      >>> info['Pexif_DateTimeOriginal']
      DateTime('2010:03:03 11:03:08')
      >>> pprint.pprint(info.dict.keys())
      ['Pexif_DateTimeOriginal', 'orientation']
      >>> import Image
      >>> image = Image.open(filename)
      >>> info = InfoPexif(image)
      >>> info['Pexif_DateTimeOriginal']
      DateTime('2010:03:03 11:03:08')
      >>> pprint.pprint(info.dict.keys())
      ['Pexif_DateTimeOriginal']
      >>> info.extract_all()
      >>> info['Pexif_DateTimeOriginal']
      DateTime('2010:03:03 11:03:08')
      >>> pprint.pprint(info.dict.keys())
      ['orientation',
       'Pexif_Make',
       'Pexif_Flash',
       'Pexif_YResolution',
       'Pexif_DateTimeDigitized',
       'Pexif_ExifImageWidth',
       'Pexif_FocalPlaneYResolution',
       'Pexif_MaxApertureValue',
       'Pexif_MeteringMode',
       'Pexif_ExifVersion',
       'Pexif_MakerNote',
       'Pexif_FNumber',
       'Pexif_FocalPlaneResolutionUnit',
       'Pexif_SensingMethod',
       'Pexif_Orientation',
       'Pexif_FocalLength',
       'Pexif_XResolution',
       'Pexif_ExifOffset',
       'Pexif_FileSource',
       'Pexif_CompressedBitsPerPixel',
       'Pexif_ExifImageHeight',
       'Pexif_ResolutionUnit',
       'Pexif_ExifInteroperabilityOffset',
       'Pexif_ApertureValue',
       'Pexif_ExposureTime',
       'Pexif_ColorSpace',
       'Pexif_YCbCrPositioning',
       'Pexif_Model',
       'Pexif_DateTime',
       'Pexif_ComponentsConfiguration',
       'Pexif_FlashPixVersion',
       'Pexif_FocalPlaneXResolution',
       'Pexif_DateTimeOriginal',
       'Pexif_UserComment']

  classmethod `provides`(var)

class `lib.metadata.` `InfoPil`(source=None, vars=None)

  Bases: `lib.metadata._InfoPil`

  Wraps a lazy PIL var access to an image.

  Parameter: | image (Pil.Image/function) – Pil.Image or callable to retrieve it

      >>> import pprint
      >>> import Image
      >>> image = Image.new('L',(1,2))
      >>> info = InfoPil(image)
      >>> info['format']
      >>> info.provides('formatdescription')
      True
      >>> pprint.pprint(info.possible_vars)
      ['aspect',
       'compression',
       'dpi',
       'format',
       'formatdescription',
       'gamma',
       'height',
       'interlace',
       'mode',
       'size',
       'transparency',
       'width']
      >>> sorted(info.dict.keys())
      ['format', 'orientation']
      >>> info['mode']
      'L'
      >>> info['height']
      2
      >>> info['format']
      >>> info['dpi']
      72
      >>> sorted(info.dict.keys())
      ['dpi', 'format', 'height', 'mode', 'orientation', 'size', 'width']
      >>> info.reset_geometry()
      >>> sorted(info.dict.keys())
      ['dpi', 'format', 'mode', 'orientation']
      >>> info.extract_all()
      >>> pprint.pprint(sorted(info.dict.keys()))
      ['aspect',
       'compression',
       'dpi',
       'format',
       'formatdescription',
       'gamma',
       'height',
       'interlace',
       'mode',
       'orientation',
       'size',
       'transparency',
       'width']

  classmethod `needs_orientation`(vars)

    InfoPil always needs to know the orientation.

    Returns: | True
    Return type: | bool

  `reset_geometry`()
  `set_orientation`(orientation)

exception `lib.metadata.` `InfoProvideError`

  Bases: `exceptions.Exception`

  When the variable can’t be provided by the current info instances.

class `lib.metadata.` `InfoTest`
  classmethod `provides`(var)

class `lib.metadata.` `InfoZexif`(source=None, vars=None)

  Bases: `lib.metadata._InfoPilMetadata`

  Wraps a lazy PIL exif var access to an image.

      >>> import pprint
      >>> filename = '../tests/input/exĩf ïptç.jpg'
      >>> info = InfoZexif(filename)
      >>> info['Zexif_0x9202']
      (128, 32)
      >>> import Image
      >>> image = Image.open(filename)
      >>> info = InfoZexif(image)
      >>> info['Zexif_0x9202']
      (128, 32)
      >>> pprint.pprint(info.dict.keys())
      ['Zexif_0x9202']
      >>> info.extract_all()
      >>> pprint.pprint(info.dict.keys())
      ['Zexif_0x9202',
       'Zexif_0x0128',
       'orientation',
       'Zexif_0x9205',
       'Zexif_0x9101',
       'Zexif_0xa001',
       'Zexif_0xa002',
       'Zexif_0x9209',
       'Zexif_0xa20f',
       'Zexif_0xa005',
       'Zexif_0xa20e',
       'Zexif_0x9000',
       'Zexif_0xa217',
       'Zexif_0x9003',
       'Zexif_0x9004',
       'Zexif_0xa210',
       'Zexif_0x011b',
       'Zexif_0x9286',
       'Zexif_0x9207',
       'Zexif_0x829d',
       'Zexif_0x829a',
       'Zexif_0xa404',
       'Zexif_0xa406',
       'Zexif_0xa401',
       'Zexif_0xa402',
       'Zexif_0xa403',
       'Zexif_0xa000',
       'Zexif_0x9102',
       'Zexif_0x0110',
       'Zexif_0x0112',
       'Zexif_0x0132',
       'Zexif_0x920a',
       'Zexif_0x8769',
       'Zexif_0x010f',
       'Zexif_0x927c',
       'Zexif_0xa300',
       'Zexif_0x0213',
       'Zexif_0x011a',
       'Zexif_0xa003']

  classmethod `provides`(var)

exception `lib.metadata.` `UnknownTypeError`
  Bases: `exceptions.Exception`

`lib.metadata.` `convert_from_string`(value)

  If value is recongized as a datetime string, convert value into `DateTime` instance.

  Parameter: | value (string) – any value
  Returns: | same value or converted in date
  Return type: | string/`DateTime`

`lib.metadata.` `get_vars_by_info`(filename)

`lib.metadata.` `info`
  alias of `InfoZexif`

`lib.metadata.` `is_editable_tag`(tag)

`lib.metadata.` `is_writable_tag`(tag)

`lib.metadata.` `is_writeable_not_exif_tag`(tag, mode)

### Navigation

- index
- modules |
- next |
- previous |
- Phatch v0.2 documentation »
- lib »