From 2f021fa766dffc5f17af0e82f923207d3b13b7d2 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 22 Jan 2022 20:41:47 +0200 Subject: [PATCH] vxcvxc --- Dockerfile | 2 +- files/helpers/images.py | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index c79d4b6b3..a9bd66a9e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ RUN mkdir -p ./service COPY requirements.txt ./service/requirements.txt -RUN cd ./service && pip3 install -r requirements.txt +RUN cd ./service && pip3 install -r requirements.txt && mkdir /images && mkdir /songs EXPOSE 80/tcp diff --git a/files/helpers/images.py b/files/helpers/images.py index b46309170..b227e3ba2 100644 --- a/files/helpers/images.py +++ b/files/helpers/images.py @@ -5,9 +5,13 @@ import time def process_image(file=None, filename=None, resize=0): if not filename: filename = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp' - - if file: i = IImage.open(file) - else: i = IImage.open(filename) + + try: + if file: + file.save(filename) + i = IImage.open(file) + else: i = IImage.open(filename) + except: abort(400) if resize: size = resize, resize @@ -26,8 +30,6 @@ def process_image(file=None, filename=None, resize=0): om.save(filename, format="WEBP", save_all=True, append_images=list(frames), loop=0, method=6, allow_mixed=True) elif i.format.lower() != "webp": if i.format.lower() == "gif": - file.save(filename) - time.sleep(0.1) gifwebp(input_image=filename, output_image=filename, option="-mixed -metadata none -f 100 -mt -m 6") else: i.save(filename, format="WEBP", method=6)