darktable icon indicating copy to clipboard operation
darktable copied to clipboard

Export Works Incorrectly In Certain Cases

Open AerysL opened this issue 2 years ago • 11 comments

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: tmp

Incorrectly exported image tmp_wrong

Correctly exported image tmp_correct

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.

AerysL avatar Jun 23 '23 22:06 AerysL

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.

github-actions[bot] avatar Sep 09 '23 00:09 github-actions[bot]

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.

franck-tomek avatar Oct 08 '23 23:10 franck-tomek

P7310413

With orientation not active:

P7310413_02

franck-tomek avatar Oct 29 '23 13:10 franck-tomek

Doing a slight crop fixes it.

franck-tomek avatar Oct 29 '23 13:10 franck-tomek

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.

bencahill avatar Dec 22 '23 15:12 bencahill

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?

TurboGit avatar Dec 22 '23 15:12 TurboGit

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 avatar Dec 22 '23 15:12 TurboGit

@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 avatar Dec 26 '23 14:12 franck-tomek

@franck-tomek : Do you reproduce with RAW files or only JPEG?

TurboGit avatar Dec 26 '23 16:12 TurboGit

I'm working almost exclusively with RAW files, so export from RAW (ORF).

franck-tomek avatar Dec 26 '23 18:12 franck-tomek

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.

github-actions[bot] avatar Feb 25 '24 00:02 github-actions[bot]

Any clue to fix this bug? A workaround for me is to slightly crop the image, then the export works as expected.

franck-tomek avatar Mar 25 '24 20:03 franck-tomek

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.

github-actions[bot] avatar May 25 '24 00:05 github-actions[bot]

@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.

victoryforce avatar May 26 '24 16:05 victoryforce

It seems to be fixed with version 4.6.1. Thanks to @jenshannoschwalm!

franck-tomek avatar Jun 10 '24 21:06 franck-tomek