mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2025-12-29 09:44:50 +00:00
Fix
This commit is contained in:
parent
7efa2f83ba
commit
a44c9cc3dc
2 changed files with 4 additions and 6 deletions
|
|
@ -174,12 +174,9 @@ def isValidURL(str):
|
||||||
|
|
||||||
|
|
||||||
@asyncify
|
@asyncify
|
||||||
async def gen_trans_image(msg, path):
|
def gen_trans_image(source, path):
|
||||||
# Download image
|
|
||||||
dl = await msg.download()
|
|
||||||
|
|
||||||
# load image
|
# load image
|
||||||
img = cv2.imread(dl)
|
img = cv2.imread(spurce)
|
||||||
|
|
||||||
# convert to graky
|
# convert to graky
|
||||||
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
||||||
|
|
@ -210,5 +207,4 @@ async def gen_trans_image(msg, path):
|
||||||
|
|
||||||
# save resulting masked image
|
# save resulting masked image
|
||||||
cv2.imwrite(path, result)
|
cv2.imwrite(path, result)
|
||||||
os.remove(dl)
|
|
||||||
return path
|
return path
|
||||||
|
|
@ -179,8 +179,10 @@ async def removebg(_, ctx: Client):
|
||||||
return await ctx.reply_msg("Please reply image.")
|
return await ctx.reply_msg("Please reply image.")
|
||||||
if not ctx.reply_to_message.photo:
|
if not ctx.reply_to_message.photo:
|
||||||
return await ctx.reply_msg("Only support photo for remove background.")
|
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 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")
|
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")
|
os.remove(f"transp_bckgrnd-{ctx.from_user.id}.png")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue