Browse Source

Fix shots sizing.

txlyre 3 years ago
parent
commit
da131eacdc
1 changed files with 2 additions and 6 deletions
  1. 2 6
      makeshot.py

+ 2 - 6
makeshot.py

@@ -2,7 +2,7 @@ from sys import stdin
 from textwrap import fill, shorten
 
 from ujson import loads
-from PIL import Image, ImageDraw, ImageFont
+from PIL import Image, ImageDraw, ImageFont, ImageOps
 from emoji import demojize
 
 COLORS = [
@@ -73,10 +73,6 @@ draw.multiline_text((margin + avatar_width + hpadding, margin + username_height
 
 message.paste(tail, (margin + avatar_width - tail_width + 8, image_height - margin - tail_height + 1), tail)
 
-ratio = image_width / image_height
-new_width = 512 if image_width >= image_height else min(int(512 / ratio), 512)
-new_height = 512 if image_height >= image_width else min(int(512 / ratio), 512)
-
-message = message.resize((new_width, new_height))
+message = ImageOps.contain(message, (512, 512))
 
 message.save(output_path)