Very poor target meeting

This commit is contained in:
Zeva Rose 2021-06-26 20:46:32 -06:00
parent 9a35051a71
commit d5d23c6f2c

View file

@ -58,6 +58,9 @@ class ImageCog(commands.Cog):
ratio = tgt_size / size ratio = tgt_size / size
# TODO: Optimize to not run multiple times
while len(file) > tgt_size:
buffer = np.frombuffer(file, dtype=np.uint8) buffer = np.frombuffer(file, dtype=np.uint8)
img = cv2.imdecode(buffer, flags=-1) img = cv2.imdecode(buffer, flags=-1)
@ -65,8 +68,9 @@ class ImageCog(commands.Cog):
height = int(img.shape[0] * ratio) height = int(img.shape[0] * ratio)
new_img = cv2.resize(img, (width, height)) new_img = cv2.resize(img, (width, height))
buffer = cv2.imencode(".png", new_img)[1].tobytes() file = cv2.imencode(".png", new_img)[1].tobytes()
bufio = BytesIO(buffer)
bufio = BytesIO(file)
await ctx.send(file=File(bufio, filename="resized.png")) await ctx.send(file=File(bufio, filename="resized.png"))