PIL and IPTC

Scott SA pydev at rscorp.ab.ca
Wed Apr 30 19:09:23 CEST 2008


On 4/30/08, Jumping Arne (arnlen at mac.com) wrote:

>I'm completely new to PIL and I'm trying to read IPTC info, I understand that 
>it's possible but I can't find out how (and for once Google doesn't seem to 
>be able to help). Does anyone have an example of how it's done?

Some basic PIL info:
<http://www.pythonware.com/library/pil/handbook/index.htm>
<http://effbot.org/imagingbook/> has a tutorial and more info

It has been a while since I had to do it but effectively, you need to open the image before you can extract the IPTC as I recall.

This should give you a starting point:
    from PIL import IptcImagePlugin
    
    dir(IptcImagePlugin)
    
    then...
    
    help(IptcImagePlugin.getiptcinfo)
    


A Google Search for 'how-to' gives some insight
<http://www.google.ca/search?q=how-to+read+iptc+python-imaging-library>

The process is similar to reading EXIF info, I suggest you look there and modify as necessary. So a modified search to include EXIF
<http://www.google.ca/search?q=how-to+read+iptc+%7C+exif+python-imaging-library>

While not PIL exclusive, the following should be useful:
<http://www.velocityreviews.com/forums/t592465-ann-phatch-photo-batch-processor-and-renamer-based-on-pil.html>

There are also separate libraries for IPTC with Python bindings. One is called libiptcdata. It lives here:
<http://libiptcdata.sourceforge.net/>

Another example using IPTCInfo:
<http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/500266>

And another python-based (non PIL) one here:
<http://www.jfroche.be/open-source/python-iptc-parser/iptc.py/view>

While not a direct answer, I hope this is helpful,

Scott






More information about the Python-list mailing list