change thumbnail to resize

This commit is contained in:
bakatrouble 2023-03-30 22:20:36 +03:00
parent af5991cf77
commit 454629e1c3

View File

@ -68,7 +68,11 @@ async def check_updates():
if post.file.size > 10000000: if post.file.size > 10000000:
logging.warning('compressing') logging.warning('compressing')
dl_im = Image.open(file).convert('RGBA') dl_im = Image.open(file).convert('RGBA')
dl_im.thumbnail((1500, 1500), Image.LANCZOS) if dl_im.size[0] > 2000 or dl_im.size[1] > 2000:
larger_dimension = max(dl_im.size)
ratio = 2000 / larger_dimension
dl_im = dl_im.resize((int(dl_im.size[0] * ratio), int(dl_im.size[1] * ratio)),
Image.LANCZOS)
im = Image.new('RGBA', dl_im.size, (255, 255, 255)) im = Image.new('RGBA', dl_im.size, (255, 255, 255))
composite = Image.alpha_composite(im, dl_im).convert('RGB') composite = Image.alpha_composite(im, dl_im).convert('RGB')
file.truncate(0) file.truncate(0)