From 9fa1e2437b20d49318d532e796cbc22e362f21ce Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Tue, 12 Apr 2022 09:25:09 -0700 Subject: [PATCH] Shrinking the container even more, using cmagick + imagemagick to do iamge conversions --- Dockerfile | 4 ++-- Dockerfile-test-env | 4 ++-- app/bot.py | 9 +++------ app/requirements.txt | 6 +++--- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index e425ccf2..2e8f035d 100755 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/Dockerfile-test-env b/Dockerfile-test-env index 423cfaf7..a0b1ec64 100755 --- a/Dockerfile-test-env +++ b/Dockerfile-test-env @@ -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 diff --git a/app/bot.py b/app/bot.py index 1c207dd9..560bef65 100755 --- a/app/bot.py +++ b/app/bot.py @@ -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: diff --git a/app/requirements.txt b/app/requirements.txt index faf477f0..8eb27850 100755 --- a/app/requirements.txt +++ b/app/requirements.txt @@ -1,10 +1,10 @@ beautifulsoup4 +cmagick discord.py gTTS lxml +owotext pandas requests -owotext wikipedia -wolframalpha -Wand \ No newline at end of file +wolframalpha \ No newline at end of file