summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2021-04-17 00:00:32 +0200
committerJulian T <julian@jtle.dk>2021-04-17 00:00:32 +0200
commit2f752f51de99eb82fb953290b4e1289ca7a5e15f (patch)
tree8e1f91fd1e7ae01d73d558504dd0db357c5976d7
parentcb8d6760edc39fc49015129d5e42b7e14e250e95 (diff)
Keep correct aspect on pictures
-rwxr-xr-xbuild.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/build.py b/build.py
index 42d8390..e627f8f 100755
--- a/build.py
+++ b/build.py
@@ -9,7 +9,6 @@ import hashlib
import glob
imagereg = re.compile("([a-z0-9]*)\\..*")
-resreg = re.compile("([0-9]*)x([0-9]*)")
def hashfile(fname):
@@ -23,8 +22,7 @@ def hashfile(fname):
def parse_res(res):
- m = resreg.match(res)
- return (int(m.group(1)), int(m.group(2)))
+ return int(res)
class FileLoader(jinja2.BaseLoader):
@@ -79,7 +77,10 @@ class ImageLocation:
print(f"Converting file {imgname} to {fname}")
im = PIL.Image.open(imgname)
- im = im.resize(settings["res"], PIL.Image.ANTIALIAS)
+
+ width = settings["res"]
+ res = (width, int((im.size[1] / im.size[0]) * width))
+ im = im.resize(res, PIL.Image.ANTIALIAS)
tmpname = f"{self.tmpname}.{settings['ext']}"
im.save(tmpname)
@@ -196,7 +197,7 @@ class Renderer:
parser = argparse.ArgumentParser()
parser.add_argument("--dest", "-d", default="build", help="where to put resulting files")
-parser.add_argument("--size", "-s", default="1920x1080", help="size to scale web images to")
+parser.add_argument("--size", "-s", default="1920", help="size to scale web images to")
parser.add_argument("--commit", "-g", help="git commit hash to announce")
parser.add_argument("--clean", help="clean unused image files", action="store_true")
parser.add_argument("--config", "-c", default="imginfo.yml", help="where to load image definitions from")