Very poor target meeting
This commit is contained in:
parent
9a35051a71
commit
d5d23c6f2c
1 changed files with 11 additions and 7 deletions
|
@ -58,15 +58,19 @@ class ImageCog(commands.Cog):
|
||||||
|
|
||||||
ratio = tgt_size / size
|
ratio = tgt_size / size
|
||||||
|
|
||||||
buffer = np.frombuffer(file, dtype=np.uint8)
|
# TODO: Optimize to not run multiple times
|
||||||
img = cv2.imdecode(buffer, flags=-1)
|
while len(file) > tgt_size:
|
||||||
|
|
||||||
width = int(img.shape[1] * ratio)
|
buffer = np.frombuffer(file, dtype=np.uint8)
|
||||||
height = int(img.shape[0] * ratio)
|
img = cv2.imdecode(buffer, flags=-1)
|
||||||
|
|
||||||
new_img = cv2.resize(img, (width, height))
|
width = int(img.shape[1] * ratio)
|
||||||
buffer = cv2.imencode(".png", new_img)[1].tobytes()
|
height = int(img.shape[0] * ratio)
|
||||||
bufio = BytesIO(buffer)
|
|
||||||
|
new_img = cv2.resize(img, (width, height))
|
||||||
|
file = cv2.imencode(".png", new_img)[1].tobytes()
|
||||||
|
|
||||||
|
bufio = BytesIO(file)
|
||||||
await ctx.send(file=File(bufio, filename="resized.png"))
|
await ctx.send(file=File(bufio, filename="resized.png"))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue