From b3d1bd3a22110f25f3ed7393a9a5f93506983365 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Sat, 26 Jun 2021 23:11:49 -0600 Subject: [PATCH] Attempt to use embed to send resized file --- jarvis/cogs/image.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/jarvis/cogs/image.py b/jarvis/cogs/image.py index e2d99c8..8ab4191 100644 --- a/jarvis/cogs/image.py +++ b/jarvis/cogs/image.py @@ -4,7 +4,8 @@ import cv2 import aiohttp import re 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 io import BytesIO @@ -73,9 +74,17 @@ class ImageCog(commands.Cog): bufio = BytesIO(file) 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( - "New size: {}".format(convert_bytesize(len(file))) - + "\nAccuracy: {:0.2f}%".format(accuracy), + embed=embed, file=File(bufio, filename="resized.png"), )