Question

With the IPTCInfo module under Python (http://snippets.dzone.com/posts/show/768 for more info) it's possible to read, modify and write IPTC info to pictures.

However, if a JPG doesn't already have IPTC information, the module simply raises an exception. It doesn't seem to be able to create and add this metadata information itself.

What alternatives are there? I've googled for the past hour but to no avail whatsoever.

Was it helpful?

Solution

Try pyexiv2. It's a wrapper of exiv2, the C++ picture metadata (EXIF, IPTC, XMP) library licensed under GPL. It works pretty well.

OTHER TIPS

Use force=True option when creating IPTCInfo object. Then IPTC data will be written even if it is missing in the original file.

info = IPTCInfo(input_file, force=True, inp_charset='utf8')

From the docs in the source file:

If force==True, than forces an object to always be returned. This allows you to start adding stuff to files that don't have IPTC info and then save it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top