2024-02-27 00:05:07 +00:00
|
|
|
from PIL import Image
|
2024-02-27 00:01:47 +00:00
|
|
|
from jinja2 import Environment, BaseLoader, select_autoescape
|
|
|
|
|
|
|
|
templates = Environment(
|
|
|
|
loader=BaseLoader(),
|
|
|
|
autoescape=select_autoescape(),
|
2024-02-27 00:05:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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())
|