fixed final height not being accurate

This commit is contained in:
klemek
2020-04-28 17:10:19 +02:00
parent 27b1d422a6
commit dffdf656dc
+3 -2
View File
@@ -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