-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathMacAshoT.py
More file actions
32 lines (32 loc) · 1.56 KB
/
MacAshoT.py
File metadata and controls
32 lines (32 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from .. import loader,utils
from PIL import Image,ImageFilter
import io,random,string
class aMod(loader.Module):
strings={'name':'MacAshoT'}
async def maccmd(S,message):
R=True;Q='image';P='/';L='RGBA';K='<b>Image?</b>';A=message;C=await A.get_reply_message();B=io.BytesIO();M=None
if A.file:
if A.file.mime_type.split(P)[0]==Q:await A.download_media(B)
elif C:
if C.file:
if C.file.mime_type.split(P)[0]==Q:M=R;await C.download_media(B)
else:await A.edit(K);return
else:await A.edit(K);return
elif C:
if C.file:
if C.file.mime_type.split(P)[0]==Q:M=R;await C.download_media(B)
else:await A.edit(K);return
else:await A.edit(K);return
try:I=Image.open(B)
except:await A.edit(K);return
await A.edit('<b>Working...</b>');F,G=I.size;B=Image.new(L,(F,G));J=min(F//100,G//100);D=Image.new(L,(F+J*40,G+J*40),'#fff')
if I.mode==L:
B.paste(I,(0,0),I);E=Image.new(L,(F,G))
for N in range(F):
for O in range(G):
if B.getpixel((N,O))!=(0,0,0,0):E.putpixel((N,O),(0,0,0))
else:B.paste(I,(0,0));E=Image.new(L,(F,G),'black')
E=E.resize((F+J*5,G+J*5));D.paste(E,((D.width-E.width)//2,(D.height-E.height)//2),E);D=D.filter(ImageFilter.GaussianBlur(J*5));D.paste(B,((D.width-B.width)//2,(D.height-B.height)//2),B);H=io.BytesIO();H.name='-'.join([''.join([random.choice(string.hexdigits)for B in range(A)])for A in[5,4,3,2,1]])+'.png';D.save(H,'PNG');H.seek(0)
if utils.get_args_raw(A):await A.client.send_file(A.to_id,H,force_document=R);await A.delete()
elif M:await C.reply(file=H);await A.delete()
else:await A.edit(file=H,text='')