convert heic to jpg and reupload the imgage
This commit is contained in:
parent
d282263348
commit
7d0604dc9c
@ -1,8 +1,9 @@
|
||||
FROM python:3.8 as build
|
||||
ADD app/requirements.txt /requirements.txt
|
||||
RUN pip install -r requirements.txt
|
||||
RUN apt-get update && apt-get install -y libmagickwand-dev && pip install -r requirements.txt
|
||||
|
||||
FROM python:3.8-slim
|
||||
RUN apt-get update && apt-get install -y libmagickwand-dev
|
||||
COPY --from=0 /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages
|
||||
ADD app /app
|
||||
CMD python /app/bot.py
|
||||
WORKDIR /app
|
||||
|
@ -1,8 +1,9 @@
|
||||
FROM python:3.8 as build
|
||||
ADD app/requirements.txt /requirements.txt
|
||||
RUN pip install -r requirements.txt
|
||||
RUN apt-get update && apt-get install -y libmagickwand-dev && pip install -r requirements.txt
|
||||
|
||||
FROM python:3.8-slim
|
||||
RUN apt-get update && apt-get install -y libmagickwand-dev
|
||||
COPY --from=0 /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages
|
||||
ADD app /app
|
||||
WORKDIR /app
|
||||
|
17
app/bot.py
17
app/bot.py
@ -55,7 +55,24 @@ async def react_with_dale(ctx):
|
||||
await ctx.add_reaction(emoji)
|
||||
return
|
||||
|
||||
@bot.listen('on_message')
|
||||
async def convert_heic_to_jpg(ctx):
|
||||
from wand.image import Image
|
||||
if ctx.attachments:
|
||||
for attachment in ctx.attachments:
|
||||
if attachment.filename.lower().endswith('heic'):
|
||||
heic_file = '/tmp/heic'
|
||||
jpg_file = '/tmp/jpg.jpg'
|
||||
await attachment.save(fp=heic_file)
|
||||
|
||||
# Convert heic to jpg
|
||||
img=Image(filename=heic_file)
|
||||
img.format='jpg'
|
||||
img.save(filename=jpg_file)
|
||||
img.close()
|
||||
await ctx.delete()
|
||||
await ctx.channel.send(file=discord.File(jpg_file))
|
||||
return
|
||||
|
||||
|
||||
@bot.event
|
||||
|
@ -7,3 +7,4 @@ requests
|
||||
owotext
|
||||
wikipedia
|
||||
wolframalpha
|
||||
Wand
|
Loading…
x
Reference in New Issue
Block a user