Move the image loader to shared
This commit is contained in:
parent
72599b7d00
commit
d05e382063
@ -25,14 +25,7 @@ def main(font_name, n_glyphs, fname_png, fname_c):
|
||||
|
||||
|
||||
def load_glyphs(fname_png: str):
|
||||
with Image.open(fname_png) as im:
|
||||
width = im.width
|
||||
height = im.height
|
||||
|
||||
assert width % 8 == 0, "width must be a multiple of 8"
|
||||
assert height % 8 == 0, "height must be a multiple of 8"
|
||||
|
||||
data = list(im.convert("RGBA").getdata())
|
||||
width, height, data = shared.load_image(fname_png)
|
||||
monochrome = [pixel_to_monochrome(p) for p in data]
|
||||
|
||||
glyphs = []
|
||||
|
@ -1,6 +1,17 @@
|
||||
from PIL import Image
|
||||
from jinja2 import Environment, BaseLoader, select_autoescape
|
||||
|
||||
templates = Environment(
|
||||
loader=BaseLoader(),
|
||||
autoescape=select_autoescape(),
|
||||
)
|
||||
|
||||
def load_image(fname):
|
||||
with Image.open(fname) as im:
|
||||
width = im.width
|
||||
height = im.height
|
||||
|
||||
assert width % 8 == 0, "width must be a multiple of 8"
|
||||
assert height % 8 == 0, "height must be a multiple of 8"
|
||||
|
||||
return width, height, list(im.convert("RGBA").getdata())
|
Loading…
Reference in New Issue
Block a user