master
Aevann1 2022-01-22 20:41:47 +02:00
parent b3afde2926
commit 2f021fa766
2 changed files with 8 additions and 6 deletions

View File

@ -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

View File

@ -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)