-
Notifications
You must be signed in to change notification settings - Fork 12
Add Canon CR3 raw file support #41
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
base: main
Are you sure you want to change the base?
Conversation
As more file formats are added, it gets messy if exif.rs has code that handles the specific internals of each file format. Move most of the logic from heif_extract_exif() into heif::extract_exif_data() in heif.rs.
One question: CR3 files have more useful EXIF data in a second "CMT2" box (in addition to the CMT1 box that holds the most basic info). What would be the best way to handle merging two discontiguous TIFF structures when parsing a single file? |
There are some code formatting issues; please refer to the output of |
|
Thanks, I took all the changes suggested by "cargo fmt" and pushed that out. Will look at using the ifds member of ExifIter to handle the EXIF data in the CMT2 box as well, but I think this is ready to land if you think it would be useful. |
Looking more at the ExifIter implementation, I do see how it handles multiple IfdIters in the ifds member, but it seems we need a new way of constructing an ExifIter that takes something like a Vec<&[u8]> instead of an Option<&[u8]> to handle multiple discontiguous boxes with EXIF data in them? Does that make sense as a way to proceed? |
If you want to process all IFDs in CR3, I think the relatively straightforward approach for now would be to parse all CMT* boxes, extract all the necessary Exif data, and then merge them into a single |
Just to be clear - CR3 handling should copy the EXIF data into a new consolidated buffer and then parse that with the existing code? |
Hi @rolandd After studying the structure of CR3 files, I found that it differs somewhat from my initial understanding. The CMT1/CMT2 sections here are independent TIFF structures. Therefore, I have added a Additionally, I have implemented Note that the current implementation of The code has been submitted to the PR branch. Other issues:
|
Thanks, will look at this code and work on it. Meanwhile I updated the branch with a minimized CR3 file (down to ~400K) that still has all the metadata and is accepted by exiftool. I looked back at https://github.com/lclevy/canon_cr3 and think it's safe to hard-code CMT1/CMT2/CMT3/CMT4 (CMT4 is not in my code but seems to be used for GPS info, I'll try to get a test file with GPS data in it). But anyway I think Canon has probably frozen the file structure for now. |
See https://github.com/lclevy/canon_cr3 for information about the CR3 file format. - Add testdata/canon-r6.cr3: minimized valid CR3 file based on an image from a Canon R6 camera - Update to detect CR3 files in file.rs based on brand name 'crx ' - Add bbox/cr3_moov.rs to handle 'moov' boxes and bbox/uuid.rs to handle Canon UUID sub-boxes that contain EXIF data for CR3 files - Add cr3.rs to handle extracting EXIF from CR3 files - Add basic test cases for CR3 parsing
Sorry, just getting back to this, I'm a little confused what the intention is with MultiExifIter. Is the idea that the consumer of the library needs to know which file types are multi-exif and which are fully parsed with a simple ExifIter? Wouldn't it be more ergonomic to extend the ExifIter internals to allow for multiple TIFF / IFD structures as in CR3 files, but leave a unified API for consumers parsing image files? |
Yes, reusing and extending
Under the current design, even if users continue to use These are my thoughts. Feel free to discuss and share your ideas anytime. Thank you. |
I have a Canon camera that produces CR3 raw files and I wanted nom-exif support
for EXIF extraction so I hacked this up. I tried to imitate the HEIC/HEIF handling
since CR3 files also use ISOBMFF, but I definitely don't have a deep understanding
of the right way to implement this, so please let me know if anything needs to be
fixed up.