Closed adam-snyder closed 4 years ago
Could you show me a PNG file with such chunks? Are they frequent? Is there useful data in these chunks?
These chunks are similar to tEXt but take advantage of compression. They would only be present for specific use cases. In our case, we were embedding per-pixel data as text content (JSON) and, because of the size of these PNGs, we needed to compress the chunks for performance. I can't really provide an example, but it is part of the spec: https://www.w3.org/TR/PNG-Chunks.html
I know what zTXt is and how it works. But I have never seen a PNG with such data. I don't like making my library 500 Bytes larger becaus of something, what is never used in a real world.
If you need to decode a PNG with zTXt chunk, could you share it with me? I am used to test an implementation, even if it is simple and seems to be correct.
I concur to the usefulness of supporting compressed text chunks, not only zTXt chunks but also iTXt chunks with compressionFlag set to true.
As I said, I have never seen a PNG with a zTXt and iTXt chung. So I think nobody uses it. Do you have such PNGs?
Many libraries allow to set the compressionFlag to true when generating iTXt chunks, so such PNGs can easily be generated. If you do not want to add decompression you should at least consider adding a flag in the case of iTXt so the user can decide to deflate compressed content. Or maybe use an ArrayBuffer as the value instead of a string.
Do you need to create PNGs with these chunks with UPNG.js , or to parse them?
I would be happy to implement it, but could you share such PNG with me? I do not use native apps other than a browser and a notepad (I develop in Javascript).
Hi, my need is to be able to read compressed iTXt chunks using UPNG.js. Here is a data URL for a 1x1 PNG with an iTXt chunk with keyword 'UPNG.js' and a zlib compressed text associated with it:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAUmlUWHRVUE5HLmpzAAEAAAB4nAvJyCxWAKLi/NxUheT83IKi1OLi1BSFktSKEoXE4uL85MzEEiC/PLMkQ6EkI1UhNMDPXS+rWCE7tbI8vyhFDwAcphfYZIu9eAAAAAtJREFUeNpjYAACAAAFAAHp+tzYAAAAAElFTkSuQmCC
It is implemented now :)
Awesome!
thanks for sharing a PNG with us.
Although, I still doubt anybody will use this chunk. It is more convenient to store metadata in exif or xmp chunks.
Supporting zTXt chunks should be as easy then, they are basically tEXt chunks except the text is deflated see https://www.w3.org/TR/PNG-Chunks.html
XMP data is stored in iTXt chunks when taking a snapshot on MacOS, depending on data length maybe it may be compressed.
I would like to make UPNG.js for files, which are made in practice. There exist e.g. a lossless JPG format, which was defined together with a lossy JPG, but is not supported by any decoder, as nobody ever used it. Are you sure zTXt are used in practice?
Support reading compressed data from the zTXt chunk