Add image resizing
Some checks reported errors
continuous-integration/drone/push Build was killed

This commit is contained in:
Michel Roux 2023-01-12 17:31:27 +01:00
parent 594f59529b
commit d350e48bd5

View File

@ -1,6 +1,6 @@
from asyncio import gather, get_event_loop, run from asyncio import gather, get_event_loop, run
from functools import partial, wraps from functools import partial, wraps
from os import makedirs from os import makedirs, path
from typing import List from typing import List
from PIL import Image from PIL import Image
@ -58,6 +58,9 @@ class MyChapter(Chapter):
for img in self.etree.xpath(".//img"): for img in self.etree.xpath(".//img"):
if img.attrib["src"].startswith("http"): if img.attrib["src"].startswith("http"):
img.getparent().remove(img) img.getparent().remove(img)
else:
image = Image.open(f"{path.dirname(image_dir)}/{img.attrib['src']}")
image.thumbnail((1000, 2000))
def async_wrap(func): def async_wrap(func):