Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for encoding metadata chunks #116

Open
7 of 14 tasks
birktj opened this issue Apr 25, 2019 · 5 comments
Open
7 of 14 tasks

Support for encoding metadata chunks #116

birktj opened this issue Apr 25, 2019 · 5 comments

Comments

@birktj
Copy link
Member

birktj commented Apr 25, 2019

Currently the encoder lacks built-in support for writing metadata chunks, you can do it manually with Writer::write_chunk. However I believe that there should be a nicer high-level way of doing this.

Not all of these are equally important, however it would be nice to have support for all of them. See https://www.w3.org/TR/2003/REC-PNG-20031110/#11Ancillary-chunks for specifications on what the chunks should look like.

See also image-rs/image#911

3442853561 added a commit to 3442853561/image-png that referenced this issue Apr 29, 2019
In order to process this issue image-rs#116
HeroicKatora pushed a commit to HeroicKatora/image-png that referenced this issue May 1, 2019
Writes the dimension information before the IDAT chunks in the header of
the image. This avoids having to manually construct such a chunk which
could also violate the order restriction set by the specification. Also
adds a utility function which constructs the PixelDimensions from a
simple dpi parameter.

Addresses part of image-rs#116
@jansol
Copy link

jansol commented Nov 19, 2019

There is an addition to the spec that adds support for PQ-encoded HDR images: https://www.w3.org/TR/png-hdr-pq/ . This relies on iCCP, with fallbacks to cHRM and gAMA. Krita reportedly supports this format for HDR exports.

However adding support for HDR images is probably going to require some API redesign...

@zlstringham
Copy link
Contributor

zlstringham commented Sep 5, 2020

+1 for encoder AND decoder support of text chunks.
I'm currently working on a library to support a proprietary file format for a 2d game engine with the following specifications:

  • Image is tiled (think like a sprite sheet)
  • Each frame is specified by metadata in the zTXt chunk

Unfortunately, without access to read/write the zTXt chunk, I currently can't use this crate for my needs.
(Image format is the DMI image format used by BYOND.)

@de-vri-es
Copy link
Contributor

de-vri-es commented Nov 29, 2020

gAMA and cHRM have been merged with #244 🎉 I opened a PR #260 for the sRGB chunk. I can't tick the boxes, but it would be nice to update the list for potential contributors :)

@mainrs
Copy link

mainrs commented Jan 30, 2021

Hey!

Since I am going to use the library (especially the metadata part of it), I'd like to contribute back by working on some of the chunks here. Maybe some guidance on how to approach a PR would be nice, for example for the tEXT chunk.

Is the overall goal to add some new struct and a field to Info so that decoder/encoder can populate it? If so would the appropriate type for tEXT be Vec<NewtEXTChunkStruct>?

@de-vri-es
Copy link
Contributor

de-vri-es commented Jan 30, 2021

Is the overall goal to add some new struct and a field to Info so that decoder/encoder can populate it? If so would the appropriate type for tEXT be Vec<NewtEXTChunkStruct>?

That sounds logical to me (but note that I'm not a maintainer).

You could still wonder if you want to provide the chunk data without processing, or if you want to decompress the text during decoding. Getting decompressed data would be nice, but might allow malicious PNGs to contain small compressed text that expands to large amounts of memory.

For that reason, it might be wise to store the data compressed in the info struct, and provide an easy interface to perform the decompression as needed. That also prevents spending time and memory on decompression when the application doesn't care about the text chunk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants