Over a million developers have joined DZone.

Reading And Writing Image Metadata

·
The IPTCInfo module allows you to add/edit metadata 
to your image. You can download it from here.

Reading

from iptcinfo import IPTCInfo
info = IPTCInfo('test.jpg')
print info.keywords, info.supplementalCategories, info.contacts
caption = info.data['caption/abstract']

Add/Edit

info = IPTCInfo('test.jpg')
info.data['caption/abstract'] = 'Witty caption here'
info.data['supplemental category'] = ['portrait']
info.save()
info.saveAs('test_out.jpg')  # keep original safe

Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}