Created
June 6, 2019 10:56
-
-
Save nicksherman/0af8e58e8cf4350bb53064f863621565 to your computer and use it in GitHub Desktop.
Generate images matching the physical size of a US dollar bill on that display
This file contains hidden or 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
from AppKit import NSScreen, NSDeviceSize, NSDeviceResolution | |
from Quartz import CGDisplayScreenSize | |
for i, screen in enumerate(NSScreen.screens(), 1): | |
description = screen.deviceDescription() | |
pw, ph = description[NSDeviceSize].sizeValue() | |
mmw, mmh = CGDisplayScreenSize(description["NSScreenNumber"]) | |
ppiX = pw/mmw | |
ppiY = ph/mmh | |
dollarMmWidth = 155.956 | |
dollarMmHeight = 66.294 | |
dollarPxWidth = dollarMmWidth*ppiX | |
dollarPxHeight = dollarMmHeight*ppiY | |
newPage(dollarPxWidth,dollarPxHeight) | |
saveImage(f'dollar-{i}.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment