aurelienpierreeng / ansel

A darktable fork minus the bloat plus some design vision.
https://ansel.photos
GNU General Public License v3.0
688 stars 22 forks source link

Simpified resizing in export #368

Open AlynxZhou opened 2 months ago

AlynxZhou commented 2 months ago

This is based on those 2 rules:

So the actual logic on determine final size is simple:

  1. If user set value <= 0, this means don't resize and use the original image size.
  2. If user set value > original image size, this also means don't resize and use the original image size.
  3. For max size, if user does not set the value according to image ratio, we will recalculate the value to keep image ratio and make sure the calculated size is smaller than user's max size.
  4. If by scaling factor, calculate max size according to scaling factor. If by max size, calculate scaling factor according to max size.
  5. Limit size by max size, and pass correct size and scaling factor to pixelpipe.

Fixes https://github.com/aurelienpierreeng/ansel/issues/362.

AlynxZhou commented 2 months ago

Fixed coding style, added missing round().

AlynxZhou commented 2 months ago

There are mistakes when shrinking user's max size to image ratio, let me fix it.

AlynxZhou commented 2 months ago

There are mistakes when shrinking user's max size to image ratio, let me fix it.

Fixed, the final output size will always be smaller than user's max size and has the same ratio with the original image.

Jiyone commented 2 months ago

I tried and it works :) 👍🏻

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
4 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud