From dffdf656dc3f1fd776bca9d3239a9f6322ee86fd Mon Sep 17 00:00:00 2001 From: klemek Date: Tue, 28 Apr 2020 17:10:19 +0200 Subject: [PATCH] fixed final height not being accurate --- meme_otron/img_factory.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/meme_otron/img_factory.py b/meme_otron/img_factory.py index 46a03cb..30f7289 100644 --- a/meme_otron/img_factory.py +++ b/meme_otron/img_factory.py @@ -28,12 +28,13 @@ def load_fonts(): def compose_image(images: List[Image.Image]) -> Image.Image: width = min([img.size[0] for img in images]) + for i, img in enumerate(images): + if img.size[0] != width: + images[i] = img.resize((width, round(img.size[1] * width / img.size[0])), resample=Image.LANCZOS) height = sum([img.size[1] for img in images]) output_image = Image.new('RGB', (width, height)) current_height = 0 for img in images: - if img.size[0] != width: - img = img.resize((width, round(img.size[1] * width / img.size[0])), resample=Image.LANCZOS) output_image.paste(img, (0, current_height)) current_height += img.size[1] return output_image