Decimal rounding (?) makes XnView MP's search function miss certain aspect ratios

Older bugs which are supposed to be fixed in 0.84. *** Please try to reproduce your bug and confirm the bug fix. ***

Moderators: XnTriq, helmut, xnview, Dreamer

KLE-France
Posts: 59
Joined: Mon Jan 14, 2019 3:00 pm

Decimal rounding (?) makes XnView MP's search function miss certain aspect ratios

Post by KLE-France »

Ante-scriptum: Not sure if this should be reported as a bug, or perhaps a suggestion?

In XnView MP's search function, there is the choice to search by "ratio". Adding that condition presents a dropdown list with numerous common ratios: "1.00 (1:1)," "1.20 (12:10)," and so on.

I noticed however that when I search for 16:9 aspect ratio images, the search function does not pull up images cropped to the 16:9 aspect ratio in post-processing software (either RawTherapee or Affinity Photo in my case). It does however find images that came out of the camera as 16:9, that is, a number of my images taken with a cell phone.

I think this is a mathematical rounding issue. In the dropdown menu, the 16:9 ratio is presented as "1.78 (16:9)".

Very precisely, the 16:9 aspect ratio, converted to a decimal value, is 1.7777∞ (determined simply by converting the ratio to a fraction (16/9) then dividing the numerator by the denominator). So, XnView MP's rounding is correct: brought down to two digits after the decimal, this indeed becomes 1.78.

However, both of the programs I use for post-processing appear to be cropping to as close as they can get to that 1.7777∞.

For example, if I take an image measuring 5553 X 3702 pixels and crop it to 16:9 in either RawTherapee or Affinity Photo, the resulting image measures 5553 X 3124 pixels. Thus, 5553 divided by 3124 gives a decimal ratio of 1.7775288.

One more example: an image measuring 3919 X 2799 pixels and cropped to 16:9 gives an image measuring 3919 X 2205 pixels. Thus, 3919 divided by 2205 gives a decimal ratio of 1.7773242.

I cannot speak for any other post-processing software, but I do hope someone can confirm this in e.g., Lightroom, Photoshop, etc.

Neither of the above cropped images are found by a search for the condition "Ratio" set to "1.78 (16:9)".

EDIT: I did the calculations for a few images that the search does find, e.g.: 2592 X 1456 px, i.e. a decimal ratio of 1.7802197 // 859 X 482 px, i.e. a decimal ratio of 1.7821576 // 3264 X 1832 px, i.e. a decimal ratio of 1.7816593.

So, I'm wondering if it seems as if XnView MP is looking only for images with specifically a two-decimal ratio of 1.78 and thus missing all of those that are close to, but not exactly 1.78.

If indeed this is the case, is there a way to engineer into XnView MP a greater ability to detect 16:9 ratios that are close to but not exactly 1.78? Would it be possible to reset the parameter to read any decimal from, say, 1.777 to 1.787 as 16:9? Definitely, a better math mind than mine is needed!

Thanks in advance for any info you can give!
User avatar
xnview
Author of XnView
Posts: 45065
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Decimal rounding (?) makes XnView MP's search function miss certain aspect ratios

Post by xnview »

:bugconfirmed: Thanks to your detailed description I can reproduce the problem.
Pierre.
KLE-France
Posts: 59
Joined: Mon Jan 14, 2019 3:00 pm

Re: Decimal rounding (?) makes XnView MP's search function miss certain aspect ratios

Post by KLE-France »

EDIT: Ah! Merci Pierre! Looks like we were both typing at the same moment. :P

A few other observations:

as stated yesterday, for the 16:9 aspect ratio, the true decimal equivalent is 1.7777∞, but in the Ratio search condition, this was rounded up to 1.78.

Note that this doesn't seem to be the case for other recurring or irrational decimal ratios that would normally round up (those that would round down are not concerned by this issue):

9:7 ratio: expressed as "1.28 (9:7)": real decimal equivalent (to eight digits) is 1.2857142 (would round to 1.29)

5:3 ratio: expressed as "1.66 (5:3): real decimal equivalent in 1.6666∞ (would round to 1.67)

For these 9:7 and 5:3 ratios, it thus seems that no rounding was done; the first two digits after the decimal were simply kept as is and the others ignored.

If this is so, should the 16:9 ratio be reset to 1.77 (first two digits after the decimal were simply kept as is)?
KLE-France
Posts: 59
Joined: Mon Jan 14, 2019 3:00 pm

Re: Decimal rounding (?) makes XnView MP's search function miss certain aspect ratios

Post by KLE-France »

Perhaps a bit "after the fact," but to continue this, I just realized that this might indeed affect pretty much all of the aspect ratios, in any case, this happens with the 2:3 aspect ratio as well.

In decimals, this becomes 1.50, and the condition is indeed expressed as "Ratio 1.50 (3:2)".

All of my images with such decimal values as 1.5, 1.5021459, 1.5001348, 1.5003965, etc. are picked up by the condition "Ratio 1.50 (3:2)".

However, those coming up just short of it, but that would round up to 1.5, e.g., 1.4997093, 1.4998437, 1.4998524, are not picked up by it.

I only found one "larger than": 1.5100478, and it too was not picked up by the condition "Ratio 1.50 (3:2)".

Thanks again, and I hope that this extra info can be helpful.
User avatar
xnview
Author of XnView
Posts: 45065
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Decimal rounding (?) makes XnView MP's search function miss certain aspect ratios

Post by xnview »

This problem is supposed to be fixed in XnView MP 1.8.3. Please check and confirm the bug fix here.
Pierre.
KLE-France
Posts: 59
Joined: Mon Jan 14, 2019 3:00 pm

Re: Decimal rounding (?) makes XnView MP's search function miss certain aspect ratios

Post by KLE-France »

xnview wrote: Tue Nov 12, 2024 3:59 pm This problem is supposed to be fixed in XnView MP 1.8.3. Please check and confirm the bug fix here.
Bonsoir Pierre,

Just downloaded 1.8.3 and yesssss!, this appears to be working correctly now, at least for the 16:9 and 3:2 ratios that I tested.

Indeed the ratio search conditions now find both the "at it" decimal values, e.g. "1.7821576" (16:9) or1.5021459 (3:2) and the "rounds up to it" decimal values, e.g. 1.7773242 or 1.4997093.

I can't speak for "rounds down to it" values, as I haven't encountered any while exploring the issue, but that may not even be a thing? For example, the 1.5100478 value that I had found when discussing the 3:2 ratio wouldn't round down to 1.50; it would just stay at 1.51...

En tout cas, merci beaucoup pour cette correction de bogue, et par ailleurs pour tout ce que vous faites pour XnView MP !