title: Writing image metadata in Java, preferably PNG
body: <p>I would like to write metadata to a PNG image that I create.</p>
  
  <p>My understanding of Java Advanced Image API is that I should use <code>IIOMetadata</code>, but code snippets I found seem overly complicated. Then I searched for a library and found <a href="https://commons.apache.org/proper/commons-imaging/javadocs/api-release/org/apache/sanselan/Sanselan.html" rel="nofollow noreferrer">Sanselan</a> but it seems a bit old, and not very handy for <em>writing</em> metadata.</p>
  
  <p>To actually create the image, I use</p>
  
  <pre><code>ImageIO.write(image, "png", baos);
  </code></pre>
  
  <p>I understand image metadatas are complex to handle due to its XML-like structure. Could anybody point me to a tutorial, solution, or library that will help?</p>