Skip to content
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

fix: aspect ratios #39

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

fix: aspect ratios #39

wants to merge 1 commit into from

Conversation

lucataco
Copy link
Contributor

@lucataco lucataco commented Oct 16, 2024

Fix for the following aspect ratios:
3:2, 5:4, and 16:9

Addresses Issue#38

@lucataco lucataco requested a review from zeke October 16, 2024 22:33
@zeke zeke changed the title Fix aspect ratios fix: aspect ratios Oct 17, 2024
@zeke
Copy link
Member

zeke commented Oct 17, 2024

Thanks for jumping on this @lucataco!

But it looks like these are still not correct?

Let's calculate the decimal value for each aspect ratio and compare it to the decimal value derived from the corresponding number pairs. We'll divide the first number by the second number in each case.

"1:1": (1024, 1024)
Aspect ratio: 1 / 1 = 1
Number pair: 1024 / 1024 = 1
Match: Yes

"16:9": (1360, 768)
Aspect ratio: 16 / 9 ≈ 1.7778
Number pair: 1360 / 768 ≈ 1.7708
Match: Close, but not exact (0.39% difference)

"21:9": (1536, 640)
Aspect ratio: 21 / 9 ≈ 2.3333
Number pair: 1536 / 640 = 2.4
Match: Close, but not exact (2.86% difference)

"3:2": (1152, 768)
Aspect ratio: 3 / 2 = 1.5
Number pair: 1152 / 768 = 1.5
Match: Yes

"2:3": (768, 1152)
Aspect ratio: 2 / 3 ≈ 0.6667
Number pair: 768 / 1152 ≈ 0.6667
Match: Yes

"4:5": (896, 1120)
Aspect ratio: 4 / 5 = 0.8
Number pair: 896 / 1120 = 0.8
Match: Yes

"5:4": (1120, 896)
Aspect ratio: 5 / 4 = 1.25
Number pair: 1120 / 896 = 1.25
Match: Yes

"3:4": (896, 1152)
Aspect ratio: 3 / 4 = 0.75
Number pair: 896 / 1152 ≈ 0.7778
Match: Close, but not exact (3.7% difference)

"4:3": (1152, 896)
Aspect ratio: 4 / 3 ≈ 1.3333
Number pair: 1152 / 896 ≈ 1.2857
Match: Close, but not exact (3.57% difference)

"9:16": (768, 1360)
Aspect ratio: 9 / 16 = 0.5625
Number pair: 768 / 1360 ≈ 0.5647
Match: Close, but not exact (0.39% difference)

"9:21": (640, 1536)
Aspect ratio: 9 / 21 ≈ 0.4286
Number pair: 640 / 1536 ≈ 0.4167
Match: Close, but not exact (2.78% difference)

In conclusion, 6 out of 11 aspect ratios match exactly with their corresponding number pairs. The other 5 are close but have small differences, ranging from 0.39% to 3.7%. These small differences are likely due to rounding to fit common screen resolutions while maintaining an approximate aspect ratio.

@yorickvP
Copy link
Contributor

The numbers have the following constraints:

  • be divisible by 16
  • multiply to be as close to 1048576 as possible (but not higher)

I'll see if I can pick some better numbers.

@yorickvP
Copy link
Contributor

Here are the highest resolutions that fit the criteria:

ASPECT_RATIOS = {
    "1:1": (1024, 1024),
    "16:9": (1280, 720),
    "21:9": (1344, 576),
    "3:2": (1152, 768),
    "2:3": (768, 1152),
    "4:5": (896, 1120),
    "5:4": (1120, 896),
    "3:4": (864, 1152),
    "4:3": (1152, 864),
    "9:16": (720, 1280),
    "9:21": (576, 1344),
}

This is quite a downgrade for 9:21. Maybe we should keep the original aspect ratios (under the right label) available? Those are:
1:1, 7:4, 12:5, 19:13, 13:19, 14:17, 17:14, 7:9, 9:7, 4:7, 5:12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants