Fix loop to account for accuracy

This commit is contained in:
Zeva Rose 2021-06-26 23:26:57 -06:00
parent 2c4cefd1f8
commit 04d2d6ef55

View file

@ -69,7 +69,7 @@ class ImageCog(commands.Cog):
accuracy = 0.0
# TODO: Optimize to not run multiple times
while len(file) > tgt_size:
while len(file) > tgt_size or accuracy < 0.50:
old_file = file
buffer = np.frombuffer(file, dtype=np.uint8)
@ -83,7 +83,7 @@ class ImageCog(commands.Cog):
accuracy = (len(file) / tgt_size) * 100
if accuracy <= 0.50:
file = old_file
ratio = ratio + 0.1
ratio += 0.1
else:
ratio = tgt_size / len(file) - 0.02