Created
July 27, 2015 22:28
-
-
Save YellowSharkMT/1dba2b33b24b85b78214 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/env python | |
""" | |
Fetches a set of placeholder images from placehold.it. Iterates over the background colors specified, and | |
uses the same text for each slide. Image filenames contain an index, the size, and the bg color. | |
Warning: quick/dirty script. Would be cooler if options could be entered on the command-line. Also would | |
probably be cooler to use the subprocess module, instead of os.system() | |
""" | |
import os | |
# User options: | |
SLIDE_SIZE = '1280x640' | |
SLIDE_TEXT = 'Slide (1280x640)' | |
# specify an array of hex codes, each one will correspond to a resulting image. | |
colors = ['FF5050', 'CC0099', '3399FF', '00FF99', 'CC6699'] | |
# Customize this at your own risk: | |
FN_PATTERN = 'slide-%(index)s-%(size)s-%(color)s.png' | |
# You can change this if you wish, check out http://placehold.it for info on their URL structure | |
URL_PATTERN = 'http://placehold.it/%(size)s/%(color)s?text=%(text)s' | |
make_filename = lambda index, color: FN_PATTERN % dict(index=index, color=color, size=SLIDE_SIZE) | |
make_url = lambda color: URL_PATTERN % dict(size=SLIDE_SIZE, color=color, text=SLIDE_TEXT) | |
cmds = ['wget -O %s "%s"' % (make_filename(i, color), make_url(color)) for i, color in enumerate(colors)] | |
# print cmds # <--- debug statement | |
[os.system(c) for c in cmds] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment