How to extract metadata from a image using python?

后端 未结 4 447
执念已碎
执念已碎 2020-12-13 15:08

Hi im working on a program that will open an image and then extract the metadata from it How do i extract metadata using python ?

Thanks

4条回答
  •  渐次进展
    2020-12-13 15:29

    You can use following python code for this.

    #!/bin/python
    import os
    import sys
    from PIL import Image
    from PIL.ExifTags import TAGS
    
    image = sys.argv[1]
    
    for (tag,value) in Image.open(image)._getexif().iteritems():
            print '%s = %s' % (TAGS.get(tag), value)
    

    Here is the sample output.

提交回复
热议问题