Skip to content

Instantly share code, notes, and snippets.

@adamelliotfields
Created August 26, 2024 20:21
Show Gist options
  • Save adamelliotfields/54be9c954206ed7c1d46aeec4c0aad44 to your computer and use it in GitHub Desktop.
Save adamelliotfields/54be9c954206ed7c1d46aeec4c0aad44 to your computer and use it in GitHub Desktop.
Python Aspect Ratio
def aspect_ratio(width=0, height=0):
if width <= 0 or height <= 0:
return None
a, b = width, height
while b:
a, b = b, a % b
gcd = a
return (width // gcd, height // gcd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment