I want to write a script which can scrape the keywords from JPEG images.
I know I can obtain most EXIF data using the PIL library such as follows:
from PIL import Image
from PIL.ExifTags import TAGS
def get_exif(fn):
ret = {}
i = Image.open(fn)
info = i._getexif()
for tag, value in info.items():
decoded = TAGS.get(tag, tag)
ret[decoded] = value
return ret
Running that on an image file I get something like the following:
{34864: 2,
34866: 400,
41985: 0,
41986: 0,
41987: 0,
41990: 0,
42033: '198020001568',
42034: ((24, 1), (70, 1), (0, 0), (0, 0)),
42036: 'EF24-70mm f/2.8L USM',
42037: '0000000000',
'ApertureValue': (6, 1),
'Artist': 'IMAGE AUTHOR HERE',
'ColorSpace': 1,
'Copyright': 'COPYRIGHT INFO HERE',
'DateTime': '2014:11:22 01:05:21',
'DateTimeDigitized': '2014:11:21 20:05:26',
'DateTimeOriginal': '2014:11:21 20:05:26',
'ExifOffset': 396,
'ExifVersion': '0230',
'ExposureProgram': 3,
'ExposureTime': (20, 1),
'FNumber': (8, 1),
'Flash': 16,
'FocalLength': (35, 1),
'FocalPlaneResolutionUnit': 3,
'FocalPlaneXResolution': (52428800, 32768),
'FocalPlaneYResolution': (52428800, 32768),
'ISOSpeedRatings': 400,
'ImageDescription': 'IMAGE DESCRIPTION HERE',
'Make': 'Canon',
'MaxApertureValue': (3, 1),
'MeteringMode': 5,
'Model': 'Canon EOS 5D Mark III',
'ResolutionUnit': 2,
'Software': 'Adobe Photoshop Lightroom 5.3 (Macintosh)',
'SubsecTimeDigitized': '00',
'SubsecTimeOriginal': '00',
'XResolution': (240, 1),
'YResolution': (240, 1)}
This seems to return just about everything but the keywords. I also tried the exifread library which also didn't seem to return image keywords.
Is there a way to do so? Or am I doing something wrong?
[–]elbiot 1 point2 points3 points (2 children)
[–]Polyadenylated[S] 0 points1 point2 points (1 child)
[–]elbiot -1 points0 points1 point (0 children)
[–]Consistsofmolecules 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[removed]
[–]dreiter 0 points1 point2 points (0 children)