Skip to content

Instantly share code, notes, and snippets.

@andreyvital
Created April 2, 2019 23:36
Show Gist options
  • Save andreyvital/94fa73caa5eb018d1d339d868b7ac1aa to your computer and use it in GitHub Desktop.
Save andreyvital/94fa73caa5eb018d1d339d868b7ac1aa to your computer and use it in GitHub Desktop.
def ar_with_boundary(source_width, source_height, desired_width, desired_height):
ratio = min(desired_width / source_width, desired_height / source_height)
return source_width * ratio, source_height * ratio
p = 8
print(ar_with_boundary(110, 24, 72 - p * 2, 72 - p * 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment