[Image-SIG] Textual data inside PNGs: not supported?

Andrew M. Kuchling akuchlin@cnri.reston.va.us
Fri, 7 May 1999 10:58:50 -0400 (EDT)


Looking at PngImagePlugin.py, it seems that while tEXt chunks are
supported on reading in a PNG file, it doesn't look as if they're
written on saving a PNG file.  

	I really need the ability to add comments to PNG files, in
order to add annotations to microscope images (date taken, who took
it, other meta-info), so I'm willing to implement this with a bit of
guidance.  My questions are:
	
	* Am I actually correct in thinking that comments aren't saved
in PNG file?

	* It looks like the fix is fairly simple: loop over the
contents of the im.info dictionary and write out a tEXt chunk for each
key/value pair.  This is complicated a bit by the PngImagePlugin
storing other things in the info dictionary, like 'interlace' and
'gamma' keys.  Is it enough to just ignore those two keys, or are
there more keys that should be ignored?

	* According to the PNG Recommendation, 'tEXt' chunks shouldn't
be copied if the image is modified in any way (indicated by the
lower-case fourth letter).  I'm not sure what to do about this; I
don't care for my application because I'm generating new images, not
modifying a pre-existing image, but Fredrik will probably want some
solution for this.  /F, any ideas about what to do?

-- 
A.M. Kuchling			http://starship.python.net/crew/amk/
Monty Python's usual schoolboy humour is here let loose on a period of history
appropriately familiar to every schoolboy in the West, and a faith which could
be shaken by such good-humoured ribaldry would be a very precarious faith
indeed.
    -- The British Board Of Film Censors, in their report on _Life of Brian_