I needed to read comments from JPEG files for a photo gallery project
application I wrote. I used the Python Imaging Library
(PIL), which needed a small modification to support JPEG comments.
Since a few people have asked for the diffs over the years, I'll post
them here.
A patch
to support reading JPEG comments for the Python Imaging Library.
Once your PIL is patched, you can access a JPEG's comments like so:
from PIL import Image
jpeg = Image.open('example.jpg')
comment = jpeg.info.get('comment', '')
print 'Jpeg comments: ', comment
Take care. |