<jupyter_start><jupyter_text>Get images metadataGets all .jpg images in the current folder and prints the "description" metadata, using the Python Imaging Library (PIL).<jupyter_code>import glob
import PIL
from PIL import Image
from PIL import IptcImagePlugin 
imgpaths = glob.glob('*.jpg') # change it to jpeg or anything
imgpaths
for imgpath in imgpaths:
    img = Image.open(imgpath)
    imgInfo = IptcImagePlugin.getiptcinfo(img)
    description = imgInfo[(2, 120)]
    author = imgInfo[(2, 80)]
    print(imgpath, '>')
    print('Author:', author.decode('utf-8'))
    print(description.decode('utf-8'), "\n") # str.decode('utf-8'): for compatibility with windows<jupyter_output>150206_Costa_Carolina_chaise_01.jpg >
Author: <NAME>
Genève, le 6 février 2015. Devant la cathédrale Saint-Pierre. Rencontre avec <NAME>, comédienne (assise sur la chaise de chaire de la cathédrale).Photo: Laurent Guiraud. 

160523_Elg_Aline_01.jpg >
Author: <NAME>
Genève, le 23 mai 2016. Rencontre avec <NAME>, historienne. Photo: Laurent Guiraud.
StarcoderdataJupyterStructuredCleanDedup