From a44c9cc3dc30b9f915a019770ca2ebf0419bdf64 Mon Sep 17 00:00:00 2001 From: Yasir Aris M Date: Mon, 29 Jul 2024 11:38:39 +0700 Subject: [PATCH] Fix --- misskaty/helper/tools.py | 8 ++------ misskaty/plugins/misc_tools.py | 2 ++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/misskaty/helper/tools.py b/misskaty/helper/tools.py index 64f2b698..0df86028 100644 --- a/misskaty/helper/tools.py +++ b/misskaty/helper/tools.py @@ -174,12 +174,9 @@ def isValidURL(str): @asyncify -async def gen_trans_image(msg, path): - # Download image - dl = await msg.download() - +def gen_trans_image(source, path): # load image - img = cv2.imread(dl) + img = cv2.imread(spurce) # convert to graky gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) @@ -210,5 +207,4 @@ async def gen_trans_image(msg, path): # save resulting masked image cv2.imwrite(path, result) - os.remove(dl) return path \ No newline at end of file diff --git a/misskaty/plugins/misc_tools.py b/misskaty/plugins/misc_tools.py index 06669f04..40e98825 100644 --- a/misskaty/plugins/misc_tools.py +++ b/misskaty/plugins/misc_tools.py @@ -179,8 +179,10 @@ async def removebg(_, ctx: Client): return await ctx.reply_msg("Please reply image.") if not ctx.reply_to_message.photo: return await ctx.reply_msg("Only support photo for remove background.") + source = await ctx.reply_to_message.download() await gen_trans_image(ctx.reply_to_message, f"transp_bckgrnd-{ctx.from_user.id}.png") await ctx.reply_photo(f"transp_bckgrnd-{ctx.from_user.id}.png") + os.remove(source) os.remove(f"transp_bckgrnd-{ctx.from_user.id}.png")