Created
December 4, 2023 00:02
-
-
Save PaulGoldschmidt/53353df4a81c14d032615f25ab837855 to your computer and use it in GitHub Desktop.
Calculating the resolution needed to fill a canvas from mm with a given DPI.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convert millimeters to inches and then to pixels at given DPI | |
# Dimensions in millimeters | |
width_mm = 420 | |
height_mm = 594 | |
# Conversion factor from mm to inches | |
mm_to_inch = 1 / 25.4 | |
# Convert dimensions to inches | |
width_inch = width_mm * mm_to_inch | |
height_inch = height_mm * mm_to_inch | |
# DPI value | |
dpi = 300 | |
# Convert dimensions to pixels | |
width_px = width_inch * dpi | |
height_px = height_inch * dpi | |
(width_px, height_px) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment