Skip to content

Instantly share code, notes, and snippets.

@soerface
Created April 13, 2015 15:00
Show Gist options
  • Save soerface/480422edef4eceee5307 to your computer and use it in GitHub Desktop.
Save soerface/480422edef4eceee5307 to your computer and use it in GitHub Desktop.
Generate images of letters in different colors
from subprocess import call
import os
import sys
n = int(sys.argv[1])
for i in range(n):
directory = 'output/{0}'.format(i)
if not os.path.exists(directory):
os.makedirs(directory)
for letter in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
label = 'label:{0}'.format(letter)
filepath = '{0}/{1}.png'.format(directory, letter.lower())
hue = int(float(i) / (n-1) * 255)
color = 'hsb({0}, 200, 255)'.format(hue)
call(['convert', '-gravity', 'center', '-background', color, '-fill', 'black', '-size', '350x350', '-pointsize', '300', label, filepath])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment