Skip to content

Instantly share code, notes, and snippets.

@nicksherman
Created June 6, 2019 10:56
Show Gist options
  • Save nicksherman/0af8e58e8cf4350bb53064f863621565 to your computer and use it in GitHub Desktop.
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
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