Skip to content

Commit

Permalink
fixed kang dimention error
Browse files Browse the repository at this point in the history
  • Loading branch information
rking32 committed Aug 3, 2020
1 parent f8f9d18 commit 0f9f029
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion init/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ declare -r pVer=$(sed -E 's/\w+ ([2-3])\.([0-9]+)\.([0-9]+)/\1.\2.\3/g' < <(pyth
log() {
local text="$*"
test ${#text} -gt 0 && test ${text::1} != '~' \
&& echo -e "[$(date +'%d-%b-%y %H:%M:%S') - INIT] - ${text#\~}"
&& echo -e "[$(date +'%d-%b-%y %H:%M:%S') - INFO] - init - ${text#\~}"
}

quit() {
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ google-api-python-client
google-auth-httplib2
google-auth-oauthlib
googletrans
hachoir==3.1.1
hachoir
heroku3
motor
nest_asyncio
Expand Down
20 changes: 11 additions & 9 deletions userge/plugins/fun/kang.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#
# All rights reserved.

import io
import os
import random
import urllib.request
Expand Down Expand Up @@ -169,7 +170,8 @@ def get_response():
await conv.get_response(mark_read=True)
await message.edit(f"`Sticker kanged successfully!`\n"
f"Pack can be found [here](t.me/addstickers/{packname})")
os.remove(photo)
if os.path.exists(str(photo)):
os.remove(photo)


@userge.on_cmd("stkrinfo", about={
Expand Down Expand Up @@ -204,18 +206,18 @@ async def sticker_pack_info_(message: Message):
await message.edit(out_str)


def resize_photo(photo: str) -> str:
def resize_photo(photo: str) -> io.BytesIO:
""" Resize the given photo to 512x512 """
image = Image.open(photo)
scale = 512 / max(image.width, image.height)
maxsize = 512
scale = maxsize / max(image.width, image.height)
new_size = (int(image.width*scale), int(image.height*scale))
image = image.resize(new_size, Image.ANTIALIAS)
image = image.resize(new_size, Image.LANCZOS)
resized_photo = io.BytesIO()
resized_photo.name = "sticker.png"
image.save(resized_photo, "PNG")
os.remove(photo)
photo = os.path.join(Config.DOWN_PATH, "sticker.png")
if os.path.exists(photo):
os.remove(photo)
image.save(photo, "PNG")
return photo
return resized_photo


KANGING_STR = (
Expand Down
1 change: 0 additions & 1 deletion userge/plugins/utils/removebg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# All rights reserved.

import os
import time
from datetime import datetime

from removebg import RemoveBg
Expand Down
1 change: 0 additions & 1 deletion userge/plugins/utils/thumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# All rights reserved.

import os
import time
from datetime import datetime
from userge import userge, Config, Message
from userge.utils import progress
Expand Down

0 comments on commit 0f9f029

Please sign in to comment.