Update ratio during resizing to avoid over-resizing
This commit is contained in:
parent
8442ed57d4
commit
7b64578689
1 changed files with 2 additions and 1 deletions
|
@ -56,7 +56,7 @@ class ImageCog(commands.Cog):
|
|||
await ctx.send("Image already meets target.")
|
||||
return
|
||||
|
||||
ratio = tgt_size / size
|
||||
ratio = tgt_size / size - 0.05
|
||||
|
||||
# TODO: Optimize to not run multiple times
|
||||
while len(file) > tgt_size:
|
||||
|
@ -69,6 +69,7 @@ class ImageCog(commands.Cog):
|
|||
|
||||
new_img = cv2.resize(img, (width, height))
|
||||
file = cv2.imencode(".png", new_img)[1].tobytes()
|
||||
ratio = tgt_size / len(file) - 0.05
|
||||
|
||||
bufio = BytesIO(file)
|
||||
await ctx.send(
|
||||
|
|
Loading…
Add table
Reference in a new issue