Repository navigation
Conversation
C++ fails a directory whose size tags do not read, writes every size it reads, and does not read NewSubfileType for DNG. The port ignored a size that did not read, kept only a larger one, and skipped reduced-size DNG directories.
C++'s GetFullDimension32 writes the width into full_width before it reads the height, so a directory whose ImageWidth reads and whose ImageLength does not fails with full_width already written. The port's get_full_dimension32 returns both values or neither. C++'s Get(tag, uint32*) reads only SHORT and LONG entries. get_u32 also reads IFD, so a width typed IFD was written where C++ writes nothing.
This was referenced Nov 4, 2026
Collaborator
|
I believe this is outdated with the recent C++ code update. Please reopen if not. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Write full_width before failing on the height, as GetFullDimension32 does
Problem
This PR builds on #12, which makes a directory whose size tags do not read fail, as in C++. With that change one difference is left in how the size is read.
GetFullDimension32(C++, Rust) reads the full image's width and height:&preview_image_data->full_widthand&preview_image_data->full_heightbyFillPreviewImageDataand reads the width intofull_width, then the height. When ImageWidth reads and ImageLength (the height) does not (for example, it has more than one value, whichGetrefuses), the directory fails withfull_widthalready written. The same holds for the Exif width and height.fill_preview_image_datawrites nothing.For example, a NEF whose IFD0 has ImageWidth 40 (one LONG) and an ImageLength LONG with 107 values. Both sides return kFail, but a caller that reads the fields afterwards sees
full_width40 from C++ and 0 from the port:full_width×full_heightQuestion
Which behaviour do we want: C++'s or the Rust port's? Specifically, when a directory's width reads and its height does not, should
full_widthkeep the width it read (like the C++ library), or be left as it was (like the Rust port)?This PR implements C++'s behaviour.
Fix
When
get_full_dimension32fails with anything butTagNotFound,fill_preview_image_datanow writesfull_widthas C++ would have before failing:GetFullDimension32reads first, the Exif width or else ImageWidth. With DefaultCropSize there is none, because C++ reads its width and height together.Getreads it. The port'sget_u32also takes type IFD, so an IFD-typed width is skipped.The example above then returns what C++ returns. Replayed before and after:
full_width×full_heightNotes for review:
output_type), C++ and the port agree on all 82. Without this PR,full_width(40 against 0) is the one field left on all of them.full_width0. The other PRs' examples give the same results with and without this change.