# BuiLDING A letter Paul Sharits - Word Movie (1966)
# takes stdinput
# call script with -f [YOUR_CHARACTER_HERE] for individual results
# MATCHES WORDS THAT START WITH A GIVEN LETTER
import sys, os
from optparse import OptionParser
import Image, ImageDraw, ImageFont
width = 320
height = 240
ii = 0
myFont = ImageFont.truetype("/var/lib/defoma/fontconfig.d/D/DejaVu-Sans-Bold-Oblique.ttf", 32)
parser = OptionParser()
parser.add_option("-f", "--firstletter", dest="letter", default="d", help="print only words that begin with the given letter")
(options, args) = parser.parse_args()
# print options
matchletter = options.letter
text = sys.stdin.read()
# convert text to lower case
text = text.lower()
text = text.split()
for w in text: im = Image.new("RGB", (width, height), (128, 128, 128)) draw = ImageDraw.Draw(im) textsize = draw.textsize(w, font=myFont) # find the position of matching letter index_char = w.find(matchletter) # check if letter is present if index_char != -1: left_chunk = w[:index_char] left_size = draw.textsize(left_chunk, font=myFont) # get starting X-position of text left_pos = width/2 - left_size[0] # print w, left_pos, left_chunk, left_size draw.text((left_pos, height/2), w, fill=(255, 255, 255), font=myFont) filename = "word%06d.png" %(ii) im.save(filename) ii += 1
os.system("ffmpeg -y -r 10 -b 1800 -sameq -i word%06d.png foo.flv")
# remove old files
os.system("rm word*.png")
Link to this comment:
All Comments (0)