Closed Potass closed 5 years ago
That's an invalid cast, and for a good reason. The ChunksList
of a reader is not writable.
The PngWriter instead has a ChunksListForWrite
, and you can write to them.
I cannot imagine why you would want to write to the chunks of a just read PNG image,
if you are trying to add a chunk to write a new PNG, you should use pngw.copyChunksFrom(pngr.getChunksList());
as in the Flip horizontally an image
snippet
https://github.com/leonbloy/pngj/wiki/Snippets
When I simply try to write something to metadata, ClassCastException is thrown.
My code:
PngReader pngReader = new PngReader(new File("path to png image"));
pngReader.getMetadata().setText("my key", "my data");
pngReader.end();
Exception is thrown when setText() is called from getChunkListW() method in PngMetadata class by this cast:
return (ChunksListForWrite) chunkList;
Could you, please, fix it?