Exif reading library

后端 未结 2 883
难免孤独
难免孤独 2021-01-02 17:21

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 i

相关标签:
2条回答
  • 2021-01-02 18:03

    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

    0 讨论(0)
  • 2021-01-02 18:12

    For reference, the pyexiv2 homepage now has a deprecation warning which points to Gexiv2, a GObject-introspection based wrapper around libexiv2 (the same library pyexiv2 wraps) specifically for the purpose of Python 3.x support.

    Unfortunately, at the time of writing, installation of Gexiv2 is still painful and thus far I've been unable to get it working on Ubuntu Precise (looks like the libs are out of date - probably serves me right for sticking around on an LTS...), so PIL is still the best option for reading EXIF tags in Python 3.

    0 讨论(0)
提交回复
热议问题