Skip to content

Instantly share code, notes, and snippets.

@markcerqueira
Last active August 29, 2015 14:15
Show Gist options
  • Save markcerqueira/459fa0a3aae001d3471f to your computer and use it in GitHub Desktop.
Save markcerqueira/459fa0a3aae001d3471f to your computer and use it in GitHub Desktop.
A Python script to generate HUGE images
#!/usr/bin/python
# good luck setting up Pillow on your computer!
from PIL import Image
from PIL import ImageDraw
from random import randint
# width and height in pixels
SIZE = 200
# see available modes at: https://pillow.readthedocs.org/handbook/concepts.html#concept-modes
MODE = "RGBA"
# see file formats at: http://pillow.readthedocs.org/en/latest/handbook/image-file-formats.html
EXTENSION = "PNG"
# Mid-2012 Retina MacBook Pro, 2.7 GHz i7, 16 GB DDR3, 10.10.2
#
# RGBA, PNG at size 200 = 0m0.298s, 141 KB
# RGBA, PNG at size 2000 = 0m23.726s, 13.9 MB
# RGBA, PNG at size 8000 = 5m59.104s, 219.4 MB
# RGBA, PNG at size 12000 = 12m52.424s, 492.9 MB
# RGBA, PNG at size 14000 = 17m36.067s, 670.7 MB
# RGBA, PNG at size 16000 = 22m42.520s, 875.8 MB
# RGBA, PNG at size 20000 = 35m19.577s, 1.37 GB
# RGBA, PNG at size 30000 = 79m40.677s, 3.08 GB
# RGBA, PNG at size 34000 = 107m11.264s, 3.95 GB
image = Image.new(MODE, (SIZE, SIZE))
pixels = image.load()
for i in range (0, SIZE):
for j in range (0, SIZE):
pixels[i, j] = (randint(0, 255), randint(0, 255), randint(0, 255))
image.save(MODE + "_" + str(SIZE) + "." + EXTENSION, EXTENSION)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment