fix(raw): fixes cropping when the image is rotated - #5424
Conversation
|
LGTM, though do you have any tests? |
|
I have added image margins and crop info to the DNG generator, seem to be working. Will add some unit tests shortly. |
Co-authored-by: Rémi Achard <remiachard@gmail.com> Signed-off-by: Anton Dukhovnikov <antond@wetafx.co.nz>
Signed-off-by: Anton Dukhovnikov <antond@wetafx.co.nz>
Signed-off-by: Anton Dukhovnikov <antond@wetafx.co.nz>
|
I have added tests |
|
I'm not sure I understand what happened with the test files. You added crop-36x32.dng, but it also looks like some of the other image test files changed, very slightly, but I'm not sure I understand what changed or why. It doesn't seem like they should be related to the crop fix, or am I misunderstanding? |
|
All test images changed, because I'd added 3 new attributes to the DNG header: DefaultCropOrigin, DefaultCropSize, ActiveArea. By default they match the image resolution, so don't affect any other tests (I had to update one of the existing test's reference output as it mentioned the file size, which had changed). In crop-36x32.dng I have manually crafted the image margins and crop insets so all numbers are different at all stages of calculation. Tests override the orientation with the |
|
testsuite/raw/src/make_malformed_dng.py is a script that creates several specific invalid dng files, to test error handling. A special script is needed because... well, they're malformed, so it's hard to create them any other way. The script was checked into the repo for reference, to document how those malfomed files were made and I guess be able to make other types of malformed files the future. But the existing malformed files are checked into the repo and I think do not need to be changed, even if you use the script to make new, different files. But is crop-36x32.dng also malformed? Or is it meant to be a legal file? Maybe if you are making special purpose valid files and need to do so with a python program, they should have their own script? |
|
crop-36x32.dng is malformed in a way that it doesn't contain all mandatory DNG attributes. It only contains the ones needed for libraw to calculate cropping. Actually I'm not aware of any other ways of generating DNG files. If I were to do that myself, I would have written a script like yours. If you think a separate script would be better, I'm happy to make it, but it would be 90% identical to |
Description
This fixes incorrectly positioned crop when the image is rotated.
Tests
I have not added any unit tests specifically for this fix. I'm planning to add some tests later on using generated DNG images, but I doubt that I will get them in time for the v3.2 release. Happy to delay this fix until the tests are ready, if we prefer.
Tested manually with images from several cameras.
Checklist:
and if I used AI coding assistants, I have an
Assisted-by: TOOL / MODELline in the pull request description above.
behavior.
PR, by pushing the changes to my fork and seeing that the automated CI
passed there. (Exceptions: If most tests pass and you can't figure out why
the remaining ones fail, it's ok to submit the PR and ask for help. Or if
any failures seem entirely unrelated to your change; sometimes things break
on the GitHub runners.)
fixed any problems reported by the clang-format CI test.
corresponding Python bindings. If altering ImageBufAlgo functions, I also
exposed the new functionality as oiiotool options.