Reading tiff image metadata in Python

前端 未结 2 1387
感动是毒
感动是毒 2020-12-31 13:27

How can I read metada, like coordinates, from a TIFF image in Python? I tried foo._getexif() from PIL, but got the message:

AttributeErro

2条回答
  •  太阳男子
    2020-12-31 13:59

    ExifRead will do the trick for what you want. Try:

    import exifread
    # Open image file for reading (binary mode)
    f = open('image.tif', 'rb')
    
    # Return Exif tags
    tags = exifread.process_file(f)
    
    # Print the tag/ value pairs
    for tag in tags.keys():
        if tag not in ('JPEGThumbnail', 'TIFFThumbnail', 'Filename', 'EXIF MakerNote'):
            print "Key: %s, value %s" % (tag, tags[tag])
    

提交回复
热议问题