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 adding optional metadata to images #2213

Open
sunipkm opened this issue Apr 26, 2024 · 2 comments
Open

Support adding optional metadata to images #2213

sunipkm opened this issue Apr 26, 2024 · 2 comments

Comments

@sunipkm
Copy link

sunipkm commented Apr 26, 2024

I would like to be able to add metadata to the images, e.g. timestamp, what device was used and with what setting to acquire the image, etc. The image crate offers a really nice interface to represent image data with a variety of pixel types, and is great as a common output format for an imaging interface. This would make the image crate a great fit for a common interface, similar to the indi framework in C++.

Adding the metadata information to the image crate can be done by adding a private member meta: Option<ImageMetadata> to the ImageBuffer struct, and exposing the necessary getters and setters for ImageBuffer and DynamicImage.

Additionally, the metadata should be written to the files saved. PNG supports storing metadata, and so do JPEG, WEBP etc. where EXIF metadata headers can be attached.

@fintelia
Copy link
Contributor

fintelia commented Apr 27, 2024

Image metadata handling is an area of this crate that I'd certainly like to improve. Our lack of support for image orientation and color profiles have both been longstanding issues.

Exactly what belongs in an ImageMetadata struct will take some design. EXIF data and color metadata / ICC profiles should probably both be represented in some form, but I don't know exactly what that would look like. For instance, should they be binary blobs or further parsed?

I'd be a bit hesitant about transparently bundling the metadata into DynamicImage and ImageBuffer. It seems too likely for people accidentally write images containing out-of-date or sensitive information without realizing it. But I think it would be very workable for certain decoding methods to return a tuple of the image and the metadata, or for encoders to accept both the pixel data and image metadata separately

@sunipkm
Copy link
Author

sunipkm commented Apr 27, 2024

I can stand behind separating the image and the metadata, and instead providing the information to the encoders/decoders optionally. As for what is contained, we can probably take inspiration from existing formats and innovate in this space since there is no history of image crate supporting metadata.

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

No branches or pull requests

2 participants