Project

General

Profile

Statistics
| Revision:

root / proj / src / media / font / split_font.py @ 373

History | View | Annotate | Download (498 Bytes)

1 180 up20180642
import os
2 188 up20180642
import sys
3 180 up20180642
import glob
4
from PIL import Image
5
6 188 up20180642
f = sys.argv[1]
7
WCHAR = int(sys.argv[2])
8
HCHAR = int(sys.argv[3])
9
Nw    = int(sys.argv[4])
10
Nh    = int(sys.argv[5])
11
i     = int(sys.argv[6])
12 180 up20180642
13 188 up20180642
os.system("mkdir -p %s/png"%f)
14
im = Image.open("%s/%s.png"%(f,f))
15 180 up20180642
W, H = im.size
16 183 up20180642
for h in range(Nh):
17 188 up20180642
    t = HCHAR*h
18
    b = HCHAR*(h+1)
19 183 up20180642
    for w in range(Nw):
20 188 up20180642
        l = WCHAR*w
21
        r = WCHAR*(w+1)
22 183 up20180642
        im1 = im.crop((l,t,r,b))
23 188 up20180642
        im1.save("%s/png/ascii%03d.png"%(f,i))
24 183 up20180642
        i += 1