log resize dimensions
This commit is contained in:
parent
6a5d68351c
commit
e83c970717
8
main.py
8
main.py
@ -86,11 +86,13 @@ async def send_post(post: E621Post, tag_list: List[str]):
|
||||
if post.file.size > 10000000:
|
||||
logging.warning('compressing')
|
||||
dl_im = Image.open(file).convert('RGBA')
|
||||
if dl_im.size[0] > 2000 or dl_im.size[1] > 2000:
|
||||
larger_dimension = max(dl_im.size)
|
||||
size = dl_im.size
|
||||
if size[0] > 2000 or size[1] > 2000:
|
||||
larger_dimension = max(size)
|
||||
ratio = 2000 / larger_dimension
|
||||
dl_im = dl_im.resize((int(dl_im.size[0] * ratio), int(dl_im.size[1] * ratio)),
|
||||
dl_im = dl_im.resize((int(size[0] * ratio), int(size[1] * ratio)),
|
||||
Image.LANCZOS)
|
||||
print(f'Resizing from {size[0]}x{size[1]} to {dl_im.size[0]}x{dl_im.size[1]}')
|
||||
im = Image.new('RGBA', dl_im.size, (255, 255, 255))
|
||||
composite = Image.alpha_composite(im, dl_im).convert('RGB')
|
||||
file = BytesIO()
|
||||
|
Loading…
Reference in New Issue
Block a user