java - How can I write metadata to png Image -


I am trying to find a method to write a meta data to PNG and I have tried a lot.

I can read the data using the library:

  PngReader pngr = new PngReader (file); Pngr.readSkippingAllRows (); // Only read metadata (PngChunk c: pngr.getChunksList (). GetChunks ()) {If (! ChunkHelper.isText (c)) is released; PngChunkTextVar CT = (PngChunkTextVar) c; String key = ct.getKey (); String val = whistle .getVal (); System.out.print (key + "+ + + + wal +" \ n ");} Pngr.close ();  

And this works great but I have to write it.

I have tried:

  write public boolean custom data (string key, string value) exception {PngReader pngr = new PngReader (current image); PngWriter png = new PngWriter (New FileOutputStream (current image), pngr.imgInfo); Png.getMetadata (). SetText (key, value); Back true;}  

But this is nothing.

And I tried to use the answer

This work (th I can not see my studies work

If you add image If you want a part of, you should read and write the whole image Example

  PngReader pngr = new PngReader (origFile); PngWriter pngw = new PngWriter (destFile, pngr.imgInfo, true); Instructions to the author for copying all supporting sections from the source // pngw.copyChunksFrom (pngr.getChunksList (), ChunkCopyBehaviour.COPY_ALL); // Add a new text block (can be done even after writing rows) pngw.getMetadata (). SetText ("my key", "my val"); // Copy all the rows (int line = 0; line & lt; pngr.imgInfo.rows; row ++) {IImageLine l1 = pngr.readRow (); Pngw.writeRow (L1); } Pngr.end (); Pngw.end ();  

If you need more performance, you can read / see part at a low level.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -