A recent D-F article discussed a method for encoding machine-readable molecular structure information as image metadata. This article generated some interest among developers. For example, Noel O'Boyle posted code for reading PNG image metadata with Python. The popularity of Python in cheminformatics makes this approach especially attractive.
But how would you write PNG image metadata with Python? The obvious answer of using
Image.info followed by
Image.write doesn't appear to work. Given my limited knowledge of Python, the answer must come from elsewhere.
Fortunately, Nick Galbreath wrote in to offer a solution. Using Python, PIL, and an undocumented class, Nick has developed a small wrapper function that writes metadata for PNG images. In fact, Nick is fast on his way to becoming a PNG metadata expert, if reluctantly so. His blog is worth checking out and contains several useful techniques for image manipulation.