Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Reading and writing image metadata (See related posts)

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


You need to create an account or log in to post comments to this site.


Click here to browse all 4852 code snippets

Related Posts