diff --git a/main.py b/main.py index 6fccfe9..3486819 100644 --- a/main.py +++ b/main.py @@ -83,22 +83,22 @@ async def send_post(post: E621Post, tag_list: List[str]): src_path.unlink() mp4_path.unlink() elif post.file.ext in ('png', 'jpg'): - if post.file.size > 10000000: - logging.warning('compressing') - dl_im = Image.open(file).convert('RGBA') - 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(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() - composite.save(file, format='JPEG') - file.seek(0) - file.name = 'file.jpg' + # if post.file.size > 10000000: + logging.warning('compressing') + dl_im = Image.open(file).convert('RGBA') + 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(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() + composite.save(file, format='JPEG') + file.seek(0) + file.name = 'file.jpg' await bot.send_photo(int(os.environ['SEND_CHAT']), file, caption=caption,