Hi all, While not well advertised, PIL 1.1.6 supports reading __and writing__ of PNG metadata. This means, you can "tag" your images with the creation data, the editor, the original source file, copyright information, anything. I know, exciting stuff.
The catch is that you can't use Image.save directly, but have to copy metadata into a "secret" object (well _I_ didn't find it documented, maybe I missed it) and pass that to Image.save. (if you use Image.save directly, all metadata is lost). http://blog.modp.com/2007/08/python-pil-and-png-metadata-take-2.html # # wrapper around PIL 1.1.6 Image.save to preserve PNG metadata # # public domain, Nick Galbreath # http://blog.modp.com/2007/08/python-pil-and-png-metadata-take-2.html # def pngsave(im, file): # these can be automatically added to Image.info dict # they are not user-added metadata reserved = ('interlace', 'gamma', 'dpi', 'transparency', 'aspect') # undocumented class from PIL import PngImagePlugin meta = PngImagePlugin.PngInfo() # copy from Image.info to new dict for k,v in im.info.iteritems(): if k in reserved: continue meta.add_text(k, v, 0) # and save im.save(file, "PNG", pnginfo=meta) Ideally, i'd love to "fix" PngImagePlugin.py to write out metadata, and/or be able to read the zTXt chunks (especially since there is code to write zTXt chunks). I'm happy to work on an "official patch" -- there is more than one way to do it and since this issue has come up a few times (see below), I'm wondering what the right protocol is, or if it's already been done in mainline? thanks, --nickg http://mail.python.org/pipermail/image-sig/2007-February/004343.html http://mail.python.org/pipermail/image-sig/1999-May/000737.html http://mail.python.org/pipermail/image-sig/1998-July/000529.html
_______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig