From 7b645786895e185dc074ddd4ff59a4115461b76d Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Sat, 26 Jun 2021 22:50:02 -0600 Subject: [PATCH] Update ratio during resizing to avoid over-resizing --- jarvis/cogs/image.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jarvis/cogs/image.py b/jarvis/cogs/image.py index daac58b..da8a1c3 100644 --- a/jarvis/cogs/image.py +++ b/jarvis/cogs/image.py @@ -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(