Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (498 Bytes)

1
import os
2
import sys
3
import glob
4
from PIL import Image
5

    
6
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

    
13
os.system("mkdir -p %s/png"%f)
14
im = Image.open("%s/%s.png"%(f,f))
15
W, H = im.size
16
for h in range(Nh):
17
    t = HCHAR*h
18
    b = HCHAR*(h+1)
19
    for w in range(Nw):
20
        l = WCHAR*w
21
        r = WCHAR*(w+1)
22
        im1 = im.crop((l,t,r,b))
23
        im1.save("%s/png/ascii%03d.png"%(f,i))
24
        i += 1