|
from PIL import Image, ImageEnhance, ImageFilter |
|
from pyrogram.enums import ChatAction |
|
import shutil |
|
import cv2 |
|
import os |
|
|
|
|
|
async def bright(client, message): |
|
try: |
|
userid = str(message.chat.id) |
|
if not os.path.isdir(f"./DOWNLOADS/{userid}"): |
|
os.makedirs(f"./DOWNLOADS/{userid}") |
|
download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" |
|
edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "brightness.jpg" |
|
if not message.reply_to_message.empty: |
|
msg = await message.reply_to_message.reply_text( |
|
"<b>π³πΎππ½π»πΎπ°π³πΈπ½πΆ πΈπΌπ°πΆπ΄....</b>", quote=True |
|
) |
|
a = await client.download_media( |
|
message=message.reply_to_message, file_name=download_location |
|
) |
|
await msg.edit("<b>ππΏπ»πΎπ°π³πΈπ½πΆ πΈπΌπ°πΆπ΄....</b>") |
|
image = Image.open(a) |
|
brightness = ImageEnhance.Brightness(image) |
|
brightness.enhance(1.5).save(edit_img_loc) |
|
await message.reply_chat_action(ChatAction.UPLOAD_PHOTO) |
|
await message.reply_to_message.reply_photo(edit_img_loc, quote=True) |
|
await msg.delete() |
|
else: |
|
await message.reply_text("Why did you delete that??") |
|
try: |
|
shutil.rmtree(f"./DOWNLOADS/{userid}") |
|
except Exception: |
|
pass |
|
except Exception as e: |
|
print("bright-error - " + str(e)) |
|
if "USER_IS_BLOCKED" in str(e): |
|
return |
|
else: |
|
try: |
|
await message.reply_to_message.reply_text( |
|
f"{e} \nSomething went wrong!", quote=True |
|
) |
|
except Exception: |
|
return |
|
|
|
|
|
async def mix(client, message): |
|
try: |
|
userid = str(message.chat.id) |
|
if not os.path.isdir(f"./DOWNLOADS/{userid}"): |
|
os.makedirs(f"./DOWNLOADS/{userid}") |
|
download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" |
|
edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "mix.jpg" |
|
if not message.reply_to_message.empty: |
|
msg = await message.reply_to_message.reply_text( |
|
"<b>π³πΎππ½π»πΎπ°π³πΈπ½πΆ πΈπΌπ°πΆπ΄....</b>", quote=True |
|
) |
|
a = await client.download_media( |
|
message=message.reply_to_message, file_name=download_location |
|
) |
|
await msg.edit("<b>ππΏπ»πΎπ°π³πΈπ½πΆ πΈπΌπ°πΆπ΄....</b>") |
|
image = Image.open(a) |
|
red, green, blue = image.split() |
|
new_image = Image.merge("RGB", (green, red, blue)) |
|
new_image.save(edit_img_loc) |
|
await message.reply_chat_action(ChatAction.UPLOAD_PHOTO) |
|
await message.reply_to_message.reply_photo(edit_img_loc, quote=True) |
|
await msg.delete() |
|
else: |
|
await message.reply_text("Why did you delete that??") |
|
try: |
|
shutil.rmtree(f"./DOWNLOADS/{userid}") |
|
except Exception: |
|
pass |
|
except Exception as e: |
|
print("mix-error - " + str(e)) |
|
if "USER_IS_BLOCKED" in str(e): |
|
return |
|
else: |
|
try: |
|
await message.reply_to_message.reply_text( |
|
"Something went wrong!", quote=True |
|
) |
|
except Exception: |
|
return |
|
|
|
|
|
async def black_white(client, message): |
|
try: |
|
userid = str(message.chat.id) |
|
if not os.path.isdir(f"./DOWNLOADS/{userid}"): |
|
os.makedirs(f"./DOWNLOADS/{userid}") |
|
download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" |
|
edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "black_white.jpg" |
|
if not message.reply_to_message.empty: |
|
msg = await message.reply_to_message.reply_text( |
|
"<b>π³πΎππ½π»πΎπ°π³πΈπ½πΆ πΈπΌπ°πΆπ΄....</b>", quote=True |
|
) |
|
a = await client.download_media( |
|
message=message.reply_to_message, file_name=download_location |
|
) |
|
await msg.edit("<b>ππΏπ»πΎπ°π³πΈπ½πΆ πΈπΌπ°πΆπ΄....</b>") |
|
image_file = cv2.imread(a) |
|
grayImage = cv2.cvtColor(image_file, cv2.COLOR_BGR2GRAY) |
|
cv2.imwrite(edit_img_loc, grayImage) |
|
await message.reply_chat_action(ChatAction.UPLOAD_PHOTO) |
|
await message.reply_to_message.reply_photo(edit_img_loc, quote=True) |
|
await msg.delete() |
|
else: |
|
await message.reply_text("Why did you delete that??") |
|
try: |
|
shutil.rmtree(f"./DOWNLOADS/{userid}") |
|
except Exception: |
|
pass |
|
except Exception as e: |
|
print("black_white-error - " + str(e)) |
|
if "USER_IS_BLOCKED" in str(e): |
|
return |
|
else: |
|
try: |
|
await message.reply_to_message.reply_text( |
|
"Something went wrong!", quote=True |
|
) |
|
except Exception: |
|
return |
|
|
|
|
|
async def normal_blur(client, message): |
|
try: |
|
userid = str(message.chat.id) |
|
if not os.path.isdir(f"./DOWNLOADS/{userid}"): |
|
os.makedirs(f"./DOWNLOADS/{userid}") |
|
download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" |
|
edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "BlurImage.jpg" |
|
if not message.reply_to_message.empty: |
|
msg = await message.reply_to_message.reply_text( |
|
"<b>π³πΎππ½π»πΎπ°π³πΈπ½πΆ πΈπΌπ°πΆπ΄....</b>", quote=True |
|
) |
|
a = await client.download_media( |
|
message=message.reply_to_message, file_name=download_location |
|
) |
|
await msg.edit("<b>ππΏπ»πΎπ°π³πΈπ½πΆ πΈπΌπ°πΆπ΄....</b>") |
|
OriImage = Image.open(a) |
|
blurImage = OriImage.filter(ImageFilter.BLUR) |
|
blurImage.save(edit_img_loc) |
|
await message.reply_chat_action(ChatAction.UPLOAD_PHOTO) |
|
await message.reply_to_message.reply_photo(edit_img_loc, quote=True) |
|
await msg.delete() |
|
else: |
|
await message.reply_text("Why did you delete that??") |
|
try: |
|
shutil.rmtree(f"./DOWNLOADS/{userid}") |
|
except Exception: |
|
pass |
|
except Exception as e: |
|
print("normal_blur-error - " + str(e)) |
|
if "USER_IS_BLOCKED" in str(e): |
|
return |
|
else: |
|
try: |
|
await message.reply_to_message.reply_text( |
|
"Something went wrong!", quote=True |
|
) |
|
except Exception: |
|
return |
|
|
|
|
|
async def g_blur(client, message): |
|
try: |
|
userid = str(message.chat.id) |
|
if not os.path.isdir(f"./DOWNLOADS/{userid}"): |
|
os.makedirs(f"./DOWNLOADS/{userid}") |
|
download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" |
|
edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "gaussian_blur.jpg" |
|
if not message.reply_to_message.empty: |
|
msg = await message.reply_to_message.reply_text( |
|
"<b>π³πΎππ½π»πΎπ°π³πΈπ½πΆ πΈπΌπ°πΆπ΄....</b>", quote=True |
|
) |
|
a = await client.download_media( |
|
message=message.reply_to_message, file_name=download_location |
|
) |
|
await msg.edit("<b>ππΏπ»πΎπ°π³πΈπ½πΆ πΈπΌπ°πΆπ΄....</b>") |
|
im1 = Image.open(a) |
|
im2 = im1.filter(ImageFilter.GaussianBlur(radius=5)) |
|
im2.save(edit_img_loc) |
|
await message.reply_chat_action(ChatAction.UPLOAD_PHOTO) |
|
await message.reply_to_message.reply_photo(edit_img_loc, quote=True) |
|
await msg.delete() |
|
else: |
|
await message.reply_text("Why did you delete that??") |
|
try: |
|
shutil.rmtree(f"./DOWNLOADS/{userid}") |
|
except Exception: |
|
pass |
|
except Exception as e: |
|
print("g_blur-error - " + str(e)) |
|
if "USER_IS_BLOCKED" in str(e): |
|
return |
|
else: |
|
try: |
|
await message.reply_to_message.reply_text( |
|
"Something went wrong!", quote=True |
|
) |
|
except Exception: |
|
return |
|
|
|
|
|
async def box_blur(client, message): |
|
try: |
|
userid = str(message.chat.id) |
|
if not os.path.isdir(f"./DOWNLOADS/{userid}"): |
|
os.makedirs(f"./DOWNLOADS/{userid}") |
|
download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg" |
|
edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "box_blur.jpg" |
|
if not message.reply_to_message.empty: |
|
msg = await message.reply_to_message.reply_text( |
|
"<b>π³πΎππ½π»πΎπ°π³πΈπ½πΆ πΈπΌπ°πΆπ΄....</b>", quote=True |
|
) |
|
a = await client.download_media( |
|
message=message.reply_to_message, file_name=download_location |
|
) |
|
await msg.edit("<b>ππΏπ»πΎπ°π³πΈπ½πΆ πΈπΌπ°πΆπ΄....</b>") |
|
im1 = Image.open(a) |
|
im2 = im1.filter(ImageFilter.BoxBlur(0)) |
|
im2.save(edit_img_loc) |
|
await message.reply_chat_action(ChatAction.UPLOAD_PHOTO) |
|
await message.reply_to_message.reply_photo(edit_img_loc, quote=True) |
|
await msg.delete() |
|
else: |
|
await message.reply_text("Why did you delete that??") |
|
try: |
|
shutil.rmtree(f"./DOWNLOADS/{userid}") |
|
except Exception: |
|
pass |
|
except Exception as e: |
|
print("box_blur-error - " + str(e)) |
|
if "USER_IS_BLOCKED" in str(e): |
|
return |
|
else: |
|
try: |
|
await message.reply_to_message.reply_text( |
|
"Something went wrong!", quote=True |
|
) |
|
except Exception: |
|
return |
|
|