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
Image export size doesn't respect crop aspect ratio #16638
Comments
Tried your export settings (3840x3840) - result is the same: 3840x2158 |
The same behaviour is when i select square aspect ratio 1:1. The result image is 3840x3837 |
Same issue, I believe it originates with the crop module. Probably related to #16133 Behavior:
I've been cropping to 1:1 and exporting at 2048x2048, and just realized I'm getting files that are as wrong as 2047x2045. |
Allow upscale in export should fix it. |
@jenshannoschwalm Problem is still there with allow upscaling enabled. This workaround would also upscale undersized images which against my intent. |
Another similar report: https://discuss.pixls.us/t/bug-with-set-size-in-pixel-for-export/43283 |
Can confirm (#16671) that issue is there in 4.6.1, even with upscaling enabled. For anyone looking for a workaround for the time being: Export the images just a few pixels larger, e.g. 3846px and then run find ./ -type f -iname '*.jpg' -exec identify -format '%w %i\n' '{}' \; | awk '$1 >= 3000 { system("convert " $2 " -crop 3840x2160+0+0 " $2) }' |
Sorry about the confusion i might have added above with a somewhat misleading comment. The crop module and other modules like rotate do some rounding and "position corrections" that are essential for the pixelpipe thus they will simply not be able to keep an pixel exact dimension while processing all the pixels in the pipe. (In theory we could do that but that would lead to significant differences and artifacts while processing, simply because all scaling methods use maths that could introduce blurring, moire ...) So we rely on the interpolator while exporting and that gets width&height not exactly matching the 16:9 ratio as desired. You might look into lengthy discussions for ImageMagick, GraphicsMagick or GIMP about difficulties to find an optimal scaling operator that is safe for photo images and synthetic graphics and ... So for now the best suggestion would be to export in HQ without downscaling and make use of specialist tools like the above mentioned. |
Yes i get. Its hard to implement rounding etc. But how about this workaround: Having a check executed at the end of jpg export, that analyzes, whether targeted aspect ratio is preserved -> if not, it cuts those extra pixels, so that we get exact 4K dimensions without that extra fiddling with extra tools, that btw. doesn't exist on Windows. The thing is: this 'minor' problem could be an actual deal breaker to many people. I recently moved from CaptureOne (btw. it doesn't have this prob.) in order to try smth. different., and now i'm forced to go back, because batch export respects aspect ratio and i still have a valid license. I'm mostly exporting timelapse photos (1000+ per batch), and this already takes a lot of time. In order to build a video - i have to have exact 4K dimensions. Having additional processing on top of this is not a valid solution. At least in my case. |
https://imagemagick.org/archive/binaries/ImageMagick-7.1.1-31-Q16-x64-static.exe https://download.gimp.org/gimp/v2.10/windows/gimp-2.10.36-setup-1.exe You can also get GIMP from the Microsoft Store. |
Why? Does the video creation software not work unless the pixels are exact. On a 75" 4K TV, 2158 pixels vs 2160 pixels works out to a .034 inch difference. Is there a visible difference?
We could do this with a Lua script. I already have one that does something similar (in terms of processing), exporting images then using convert from Imagemagick to sharpen the image. We could pad the export a few pixels in both directions, then do a final crop. It shows up as another export option and doesn't require any user intervention after the initial setup. |
@jenshannoschwalm thank you for the in-depth explanation! While I understand that apparently there are some hurdles that would be tricky to overcome, I keep wondering how other software (Capture One, literally every Adobe product, Pixelmator, Affinity, etc) does it? To me (the uninformed user) it sounds like there is a logical way to solve this issue, but other issues specifically within darktable's pipeline prevent from doing so. Kindly correct me if I'm wrong. |
We'll never know for sure since they are all closed source, but I suspect they all crop as the last step. That would also be why using convert yields the exact size since that's the only thing it's doing. darktable crops early in the pipe so it's possible for rounding errors to be present. In every discrepancy example presented here the difference was discovered when the exported image was loaded in another program that told the dimensions. No one was able to visually detect the difference. If you do the math on the difference then darktable is 99.91% or more accurate. If you print the image at 300dpi, 2 pixels isn't going to make a difference. Unless you zoom to 100% and pixel peep you can't detect the difference. |
Describe the bug
When exporting image (for example downsizing to 3840x2160) there's a rounding issue, where end result jpg is 3840x2158. Crop aspect ratio is set to 16:9, HDTV, 1.78.
Steps to reproduce
Expected behavior
It should respect the target size set
Logfile | Screenshot | Screencast
No response
Commit
No response
Where did you obtain darktable from?
downloaded from www.darktable.org
darktable version
4.6.1
What OS are you using?
Windows
What is the version of your OS?
Win 11 23H2
Describe your system?
No response
Are you using OpenCL GPU in darktable?
Yes
If yes, what is the GPU card and driver?
NVidia GeForce RTX 3070 Ti
Please provide additional context if applicable. You can attach files too, but might need to rename to .txt or .zip
No response
The text was updated successfully, but these errors were encountered: