Shrinking the container even more, using cmagick + imagemagick to do iamge conversions

This commit is contained in:
Luke Robles 2022-04-12 09:25:09 -07:00
parent d7f16e8afa
commit 9fa1e2437b
4 changed files with 10 additions and 13 deletions

View File

@ -1,9 +1,9 @@
FROM python:3.8 as build
ADD app/requirements.txt /requirements.txt
RUN apt-get update && apt-get install -y --no-install-recommends libmagickwand-dev && pip install --no-cache-dir -q -r requirements.txt
RUN pip install --no-cache-dir -q -r requirements.txt
FROM python:3.8-slim
RUN apt-get update && apt-get install -y --no-install-recommends libmagickwand-dev \
RUN apt-get update && apt-get install -y --no-install-recommends imagemagick \
&& apt-get autoremove -y \
&& apt-get purge -y --auto-remove \
&& rm -rf /var/lib/apt/lists/* /root

View File

@ -1,9 +1,9 @@
FROM python:3.8 as build
ADD app/requirements.txt /requirements.txt
RUN apt-get update && apt-get install -y --no-install-recommends libmagickwand-dev && pip install --no-cache-dir -q -r requirements.txt
RUN pip install --no-cache-dir -q -r requirements.txt
FROM python:3.8-slim
RUN apt-get update && apt-get install -y --no-install-recommends libmagickwand-dev
RUN apt-get update && apt-get install -y --no-install-recommends imagemagick
COPY --from=0 /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages
ADD app /app
WORKDIR /app

View File

@ -77,7 +77,7 @@ async def based(ctx):
@bot.listen("on_message")
async def convert_heic_to_jpg(ctx):
from wand.image import Image
from cmagick import cmagick
if ctx.attachments:
for attachment in ctx.attachments:
@ -86,11 +86,8 @@ async def convert_heic_to_jpg(ctx):
jpg_file = "/tmp/converted.jpg"
await attachment.save(fp=source_file)
# Convert to jpg
img = Image(filename=source_file)
img.format = "jpg"
img.save(filename=jpg_file)
img.close()
img = cmagick.convert(source_file, jpg_file)
try:
await ctx.delete()
except Exception:

View File

@ -1,10 +1,10 @@
beautifulsoup4
cmagick
discord.py
gTTS
lxml
owotext
pandas
requests
owotext
wikipedia
wolframalpha
Wand
wolframalpha