Attempt to use embed to send resized file
This commit is contained in:
parent
40dee2102d
commit
b3d1bd3a22
1 changed files with 12 additions and 3 deletions
|
@ -4,7 +4,8 @@ import cv2
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import re
|
import re
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from jarvis.utils import convert_bytesize, unconvert_bytesize
|
from jarvis.utils import convert_bytesize, unconvert_bytesize, build_embed
|
||||||
|
from jarvis.utils.field import Field
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
|
@ -73,9 +74,17 @@ class ImageCog(commands.Cog):
|
||||||
|
|
||||||
bufio = BytesIO(file)
|
bufio = BytesIO(file)
|
||||||
accuracy = (len(file) / tgt_size) * 100
|
accuracy = (len(file) / tgt_size) * 100
|
||||||
|
fields = [
|
||||||
|
Field("Original Size", convert_bytesize(size), False),
|
||||||
|
Field("New Size", convert_bytesize(len(file)), False),
|
||||||
|
Field("Accuracy", f"{accuracy:.02f}%", False),
|
||||||
|
]
|
||||||
|
embed = build_embed(
|
||||||
|
title="Image Resize Utility", desc=None, fields=fields
|
||||||
|
)
|
||||||
|
embed.set_image(url="attachment://resized.png")
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
"New size: {}".format(convert_bytesize(len(file)))
|
embed=embed,
|
||||||
+ "\nAccuracy: {:0.2f}%".format(accuracy),
|
|
||||||
file=File(bufio, filename="resized.png"),
|
file=File(bufio, filename="resized.png"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue