Search code examples
pythonimagepython-3.xexif

Exif reading library


Is there an exif library out there for Python 3.x? It seems every exif library I run into is for Python 2.x only. I don't need anything too fancy. Just reading the values is enough.


Solution

  • Option 1. Use pyexiv2. See: pyexiv2 Bug #824440: Python 3 support You need boost-python for py3k and also to manually apply the patch posted at the end of the bug above, but aside from that it works. Probably easiest to get up and running under latest Ubuntu.

    Option 2. Use PIL Downside: this branch/fork doesn't seem to be actively developed.

    from PIL import Image
    from PIL.ExifTags import TAGS
    
    image = Image.open("test.jpg")
    exif = image._getexif()
    # decode exif using TAGS
    

    Option 3. Use PythonMagick

    from PythonMagick import Image
    
    img = Image("image.jpg")
    print img.attribute("EXIF:Orientation")
    

    See also: Exif manipulation library for python