From d350e48bd5fe87917ec1003ac48128ea8a630c73 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Thu, 12 Jan 2023 17:31:27 +0100 Subject: [PATCH] Add image resizing --- books.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/books.py b/books.py index 8b56fa9..a2c4587 100644 --- a/books.py +++ b/books.py @@ -1,6 +1,6 @@ from asyncio import gather, get_event_loop, run from functools import partial, wraps -from os import makedirs +from os import makedirs, path from typing import List from PIL import Image @@ -58,6 +58,9 @@ class MyChapter(Chapter): for img in self.etree.xpath(".//img"): if img.attrib["src"].startswith("http"): img.getparent().remove(img) + else: + image = Image.open(f"{path.dirname(image_dir)}/{img.attrib['src']}") + image.thumbnail((1000, 2000)) def async_wrap(func):