darktable
                                
                                 darktable copied to clipboard
                                
                                    darktable copied to clipboard
                            
                            
                            
                        Export Works Incorrectly In Certain Cases
Describe the bug
The export tool seems to fail incorrectly in certain cases (see reproducing script below). It seems to be related to using exif orientation for portrait images.
Steps to reproduce
# Generate an image
convert -size 4608x3072 xc:white -draw 'rectangle 100,100 1000,2000' tmp.jpg
# Use exiftool to set the orinetation
exiftool -orientation="Rotate 90 CW" tmp.jpg
# Export one example where it works correctly
darktable-cli tmp.jpg  tmp_correct.jpg --width 44 --height 66 --core --disable-opencl
# Export one example where it beraks
darktable-cli tmp.jpg  tmp_wrong.jpg --width 42 --height 63 --core --disable-opencl
Or if you want to test in a docker container:
FROM alpine:edge
RUN apk add --no-cache imagemagick exiftool darktable libcaca-apps
RUN mkdir -p out 
RUN convert -size 4608x3072 xc:white -draw 'rectangle 100,100 1000,2000' out/tmp.jpg
RUN exiftool -orientation="Rotate 90 CW" out/tmp.jpg
RUN darktable-cli out/tmp.jpg  out/tmp_4.4_correct.jpg --width 44 --height 66 --apply-custom-presets false --core --disable-opencl -d all 
RUN darktable-cli out/tmp.jpg  out/tmp_4.4_wrong.jpg --width 42 --height 63 --apply-custom-presets false --core --disable-opencl -d all
RUN img2txt out/tmp_4.4_wrong.jpg
RUN img2txt out/tmp_4.4_correct.jpg
RUN darktable --version
Expected behavior
The exported image should show a white canvas with a black rectangle, not a parallelogram
Logfile | Screenshot | Screencast
Source file:
Incorrectly exported image
Correctly exported image
Commit
No response
Where did you install darktable from?
distro packaging
darktable version
4.4.0
What OS are you using?
Linux
What is the version of your OS?
Arch Linux
Describe your system?
My machine: Arch Linux, Intel CPU. darktable-2:4.4.0-1 exiv2-0.28.0-2 libgexiv2-0.14.1-1
Also tested in a Docker (alpine) container above.
Are you using OpenCL GPU in darktable?
No
If yes, what is the GPU card and driver?
No response
Please provide additional context if applicable. You can attach files too, but might need to rename to .txt or .zip
While I hadn't tested this exact scenario with Darktable < 4.4.0, I had some scripts that had run for a similar case (an image that was portrait after an exif rotation, converting it to a smaller size with a portrait output) correctly with Darktable < 4.4.0, which then started giving incorrect output in Darktable 4.4.0.
Docker test provided above.
This issue has been marked as stale due to inactivity for the last 60 days. It will be automatically closed in 300 days if no update occurs. Please check if the master branch has fixed it and report again or close the issue.
I have the very same issue, on a Mac OS12.7 & Darktable 4.4.2. On some images (it seems random…), not setting auto orientation (which is on by default) fixes the bug on export.
I can provide more info if needed.
With orientation not active:
Doing a slight crop fixes it.
I am affected by the same issue on portrait orientation images after upgrading from darktable 3.6 to 4.6. Windows 10, using darktable-cli.exe. Downgrading to 4.2 fixes the issue.
I cannot reproduce with the given commands, I have also changed some with/height and still cannot reproduce.
@AerysL : Do you think you could bisect the code and find the first bad commit introducing this issue?
I have generated the 121 following pictures:
for W in {40..50}; do
    for H in {60..70}; do
        darktable-cli tmp.jpg  tmp_wrong_${W}_${H}.jpg --width $W --height $H --core --disable-opencl
    done
done
None have the wrong slant rendering.
@TurboGit Just did an export from a portrait photo on 4.6, still have the same issue. What can I provide you to help?
@franck-tomek : Do you reproduce with RAW files or only JPEG?
I'm working almost exclusively with RAW files, so export from RAW (ORF).
This issue has been marked as stale due to inactivity for the last 60 days. It will be automatically closed in 300 days if no update occurs. Please check if the master branch has fixed it and report again or close the issue.
Any clue to fix this bug? A workaround for me is to slightly crop the image, then the export works as expected.
This issue has been marked as stale due to inactivity for the last 60 days. It will be automatically closed in 300 days if no update occurs. Please check if the master branch has fixed it and report again or close the issue.
@AerysL Thanks for the reproducing script. I was able to use it to reproduce the problem last year. Although at that time I did not have the time and resources to investigate what was wrong in the program code and look for the root cause. Now, on the current development snapshot, the problem is no longer reproduced. I assume that @jenshannoschwalm's recent fixes regarding the code involved in the export removed the cause of this problem.
@franck-tomek & @bencahill It is likely that the issues you reported have the same cause. So I ask you to check if your issues still occur on the current development snapshot.
It seems to be fixed with version 4.6.1. Thanks to @jenshannoschwalm!