change thumbnail to resize
This commit is contained in:
parent
af5991cf77
commit
454629e1c3
6
main.py
6
main.py
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user