Open abhay-agarwal opened 1 week ago
Of course, I will consider including PNG support in future versions. Thank you for the feedback!
I am happy to take a shot at working on this feature, though there is a peculiarity of PNG files that is worth discussing before I start on a feature branch.
PNG files have several kinds of metadata chunks: EXIF -- this encodes standard exif data that can be read as a normal exif block tEXt -- this is a single block that encodes a single key-value pair, basically two ascii bytestrings itxt, ztxt -- these are more complex, internationalized, compressed string blocks
How would you like to deal with these kinds of blocks? The tEXt metadata is quite common for PNG files, but doesn't fit neatly into the IFD format.
In my own little library, I simply treat the tEXt blocks as a set of custom exif tags with IFD 0. However, the logic for that requires a separate iterator to handle that. Secondly, the tEXT blocks are just ascii strings, which may hinder them fitting into the EXIF system, which usually has much more scoped data representations.
Thank you! I'm glad you're willing to get involved!
I think it could be done like this:
Exif
information is present in the PNG, MediaSource::has_exif
should return true, and the MimeImage::Png
support should be extended in the exif::extract_exif_with_mime
function.If the PNG contains tEXt, itxt, or ztxt, then MediaSource::has_txt_key_values
(a new method) should return true.
Additionally, a data type TxtKeyValues
should be added, and ParseOutput
/AsyncParseOutput
traits should be implemented for TxtKeyValues
.
This is just an initial idea and might not have been thoroughly thought through (including naming), so it's for your reference. If you decide to adopt this approach, please add the necessary documentation for the has_txt_key_values
method and specify the supported file types.
The library we have been using for exif data, exif-rs, seems to have issues parsing png files, and breaks with some kinds of IFD issues on many images. Do you have any plans to support png files?