1
0
Fork 0
mirror of synced 2024-05-20 20:42:27 +12:00

Added a method to convert images to jpeg

This commit is contained in:
Phxntxm 2017-02-12 20:33:24 -06:00
parent 91ff56f621
commit a124eaf89a

View file

@ -1,8 +1,20 @@
import aiohttp
import io
from io import BytesIO
import inspect
from . import config
from PIL import Image
def convert_to_jpeg(pfile):
# Open the file given
img = Image.open(pfile)
# Create the BytesIO object we'll use as our new "file"
new_file = BytesIO()
# Save to this file as jpeg
img.save(new_file, format='JPEG')
# In order to use the file, we need to seek back to the 0th position
new_file.seek(0)
return new_file
def get_all_commands(bot):
"""Returns a list of all command names for the bot"""
@ -61,7 +73,7 @@ async def download_image(url):
return None
# Then wrap it in a BytesIO object, to be used like an actual file
image = io.BytesIO(bts)
image = BytesIO(bts)
return image
async def request(url, *, headers=None, payload=None, method='GET', attr='json'):