You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
651 B
32 lines
651 B
#!/usr/bin/python3 |
|
|
|
from PIL import Image, ImageFont, ImageDraw |
|
import os |
|
import subprocess |
|
import shutil |
|
import sys |
|
|
|
directory = "output" |
|
text = sys.argv[1] |
|
outfile = sys.argv[2] |
|
|
|
fnt = ImageFont.truetype('Beeb/Beeb.ttf', 8) |
|
|
|
(pixels, height) = fnt.getsize(text) |
|
|
|
# Lead-in plus lead-out |
|
frames = pixels + 8 + 8 |
|
|
|
image = Image.new('L', (frames, 8), 0) |
|
draw = ImageDraw.Draw(image) |
|
|
|
draw.text((8, 0), text, 255, fnt) |
|
|
|
os.mkdir(directory) |
|
|
|
for frame in range(0,frames): |
|
img = image.crop((frame, 0, frame+8, 8)) |
|
img.save("%s/%04d.png" % (directory, frame)) |
|
|
|
subprocess.call(["convert", "%s/*.png" % directory, outfile]) |
|
shutil.rmtree(directory)
|
|
|