add pillow dependencies (#258)

Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
Hayden 2021-04-03 13:23:26 -08:00 committed by GitHub
parent 764f85fb40
commit ec7fa6332d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 56 additions and 5 deletions

View file

@ -7,14 +7,39 @@ RUN npm run build
FROM python:3.9-alpine
RUN apk add --no-cache libxml2-dev libxslt-dev libxml2 caddy libffi-dev
RUN apk add --no-cache libxml2-dev \
libxslt-dev \
libxml2 caddy \
libffi-dev \
python3 \
python3-dev \
openssl \
bash \
sudo \
# freetype-dev \
# fribidi-dev \
# harfbuzz-dev \
jpeg-dev \
lcms2-dev \
openjpeg-dev \
# tcl-dev \
# tiff-dev \
# tk-dev \
zlib-dev
ADD depends /depends
RUN cd /depends \
&& chmod +x install_webp.sh \
&& chmod +x download-and-extract.sh \
&& ./install_webp.sh
ENV ENV True
EXPOSE 80
WORKDIR /app/
COPY ./pyproject.toml /app/
RUN apk add --update --no-cache --virtual .build-deps \
curl \
g++ \

View file

@ -0,0 +1,12 @@
#!/bin/sh
# Usage: ./download-and-extract.sh something https://example.com/something.tar.gz
archive=$1
url=$2
if [ ! -f $archive.tar.gz ]; then
wget -O $archive.tar.gz $url
fi
rm -r $archive
tar -xvzf $archive.tar.gz

12
depends/install_webp.sh Normal file
View file

@ -0,0 +1,12 @@
#!/bin/bash
# install webp
archive=libwebp-1.2.0
./download-and-extract.sh $archive https://raw.githubusercontent.com/python-pillow/pillow-depends/master/$archive.tar.gz
pushd $archive
./configure --prefix=/usr --enable-libwebpmux --enable-libwebpdemux && make -j4 && sudo make -j4 install
popd

File diff suppressed because one or more lines are too long

View file

@ -1,3 +1,4 @@
import shutil
from pathlib import Path
from mealie.core.config import app_dirs
@ -23,8 +24,9 @@ def minify_image(image_file: Path, min_dest: Path, tiny_dest: Path):
tiny_image = crop_center(img)
tiny_image.save(tiny_dest, quality=70)
except UnidentifiedImageError:
pass
except:
shutil.copy(image_file, min_dest)
shutil.copy(image_file, tiny_dest)
def crop_center(pil_img, crop_width=300, crop_height=300):