Skip to content

Instantly share code, notes, and snippets.

@jilm
Created January 27, 2019 09:44
Show Gist options
  • Save jilm/ab62a3009b46de78546ed8aa447ff8c5 to your computer and use it in GitHub Desktop.
Save jilm/ab62a3009b46de78546ed8aa447ff8c5 to your computer and use it in GitHub Desktop.
A script to show a picture with grid
import PIL.Image
import sys
filename = sys.argv[1]
im = PIL.Image.open(filename)
im = im.convert('L')
w, h = im.size
gs = min(w, h) // 12
for r in range(h // gs):
for c in range(w):
coor = (c, r * gs)
im.putpixel(coor, 255-im.getpixel(coor))
for r in range(h):
for c in range(w // gs):
coor = (c * gs, r)
im.putpixel(coor, 255-im.getpixel(coor))
im.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment