Skip to content

Instantly share code, notes, and snippets.

@gicmo
Created May 20, 2017 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gicmo/a1eb5f11cae692f8babe5f97441e1d76 to your computer and use it in GitHub Desktop.
Save gicmo/a1eb5f11cae692f8babe5f97441e1d76 to your computer and use it in GitHub Desktop.
Calculate the width, height limits for a given dpi threshold
#!/usr/bin/env python3
import sys
import numpy as np
def limit(ts, r):
return (r / ts) * 25.4
def ds(w, h):
return np.sqrt(w**2 + h**2) / 25.4
res = [(3840, 2048)]
def main():
ts = [192, 182, 181, 180] if len(sys.argv) < 2 else [int(sys.argv[1])]
for t in ts:
for r in res:
x, y = r[0], r[1]
w, h = limit(t, x), limit(t, y)
d = ds(w, h)
print("%d %d×%d => %5.2f×%5.2f [%2.2f]" % (t, x, y, w, h, d))
if __name__ == '__main__':
main()
@gicmo
Copy link
Author

gicmo commented May 20, 2017

192  3840×2048 => 508.00×270.93 [22.67]
182  3840×2048 => 535.91×285.82 [23.91]
181  3840×2048 => 538.87×287.40 [24.04]
180  3840×2048 => 541.87×289.00 [24.18]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment