Skip to content

Commit

Permalink
Limit number of images in galleries (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
amadejkastelic authored Oct 5, 2024
1 parent 2eed889 commit 0affc7f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bot/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,13 @@ def recover_from_db_error(exc: Exception):
django_db.close_old_connections()


def combine_images(image_fps: typing.List[str | io.BytesIO], gap: int = 10, quality: int = 85) -> io.BytesIO:
images = [pil_image.open(path) for path in image_fps]
def combine_images(
image_fps: typing.List[str | io.BytesIO],
gap: int = 10,
quality: int = 85,
max_images: int = 3,
) -> io.BytesIO:
images = [pil_image.open(path) for path in image_fps[:max_images]]
widths, heights = zip(*(im.size for im in images))

new_image = pil_image.new('RGBA', (sum(widths), max(heights)))
Expand Down

0 comments on commit 0affc7f

Please sign in to comment.