-I want to extract the information (meta information such as shooting time, latitude and longitude, so-called ** Exif **) that the image has using Python's Pillow library. ・ When I was investigating how to use Pillow, many of the articles that hit the search were scripts that get the ** "id" ** (2 to 5 digit number) of Exif, but the ** "id" ** I couldn't find a script to get the name (what it means). ・ It may be because it is too basic, but a memo for myself
1 You can get a list of ExifTags names with the following code.
from PIL.ExifTags import TAGS
print(TAGS)
{11: 'ProcessingSoftware',
254: 'NewSubfileType',
255: 'SubfileType',
256: 'ImageWidth',
257: 'ImageLength',
258: 'BitsPerSample',
...
2 Above, TAGS
is a dictionary (dict class), so it is possible to call the corresponding name with the get () method.
Example:
from PIL import Image
im = Image.open('test.jpg')
exif = im._getexif()
for id, value in exif.items():
print(id, TAGS.get(id), value)
3 Screenshot (command prompt screen example) ・ Images taken with iPhone
・ "Exiv2-Metameta reference tables" (https://www.exiv2.org/tags.html) … It says Standard Exif Tags, but are there any tags other than Standard?
Recommended Posts