Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
import os
# The range of images to generate, which also controls the number of gradient 'stops'
imageCount = 30
# How far to increment red for each image, currently tied to imageCount as you can see
colorIncrement = 255 / imageCount
# Output folder for the images
outputDir = "output"
# Path to a TTF
trueTypeFontPath = "VT323-Regular.ttf"
if not os.path.exists(outputDir):
currentColor = 20
for x in range(imageCount):
img ='RGB', (32, 32), (int(currentColor), 0, 0))
currentColor += colorIncrement
draw = ImageDraw.Draw(img)
font = ImageFont.truetype(trueTypeFontPath, 32)
draw.text((0, 0), str(x),(255,255,255),font=font) + "/" + str(x) + ".png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment