Skip to content

Commit

Permalink
Use mozjpeg instead of libjpeg; Fixes #88
Browse files Browse the repository at this point in the history
  • Loading branch information
danpersa committed Nov 1, 2018
1 parent 780a1c2 commit 809dfab
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM danpersa/alpine-vips:8.7.0
FROM danpersa/alpine-mozjpeg-vips:3.3.1-8.7.0

ARG ROUTES_FILE

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ docker:
docker-run:
rm -rf "$$(pwd)"/mylocalfilecache
mkdir "$$(pwd)"/mylocalfilecache
docker run --rm -v "$$(pwd)"/images:/images -v "$$(pwd)"/mylocalfilecache:/mylocalfilecache -p 9090:9090 zalando-stups/skrop -verbose
docker run --rm -v "$$(pwd)"/images:/images -v "$$(pwd)"/mylocalfilecache:/mylocalfilecache -e STRIP_METADATA='TRUE' -p 9090:9090 zalando-stups/skrop -verbose

test: build test-only

Expand Down Expand Up @@ -63,5 +63,5 @@ else
endif

build-docker-vips:
docker build -f Dockerfile-Vips -t danpersa/alpine-vips:8.7.0 .
docker push danpersa/alpine-vips:8.7.0
docker build -f Dockerfile-Vips -t danpersa/alpine-mozjpeg-vips:3.3.1-8.7.0 .
docker push danpersa/alpine-mozjpeg-vips:3.3.1-8.7.0
9 changes: 9 additions & 0 deletions eskip/sample.eskip
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
small: Path("/images/S/:image")
-> modPath("^/images/S", "/images")
-> finalizeResponse()
-> quality(67)
-> longerEdgeResize(800)
-> "http://localhost:9090";

small90: Path("/images/S90/:image")
-> modPath("^/images/S90", "/images")
-> finalizeResponse()
-> quality(90)
-> longerEdgeResize(800)
-> "http://localhost:9090";

Expand Down Expand Up @@ -42,6 +50,7 @@ medium: Path("/images/M/:image")
large: Path("/images/L/:image")
-> modPath("^/images/L", "/images")
-> finalizeResponse()
-> quality(67)
-> longerEdgeResize(1920)
-> "http://localhost:9090";

Expand Down
33 changes: 27 additions & 6 deletions packaging/install-vips.sh
Original file line number Diff line number Diff line change
@@ -1,39 +1,60 @@
#!/usr/bin/env bash

readonly VIPS_VERSION="8.7.0"
readonly MOZJPEG_VERSION="3.3.1"
readonly VIPS_SOURCE="https://github.com/libvips/libvips/releases/download"
readonly MOZJPEG_SOURCE="https://github.com/mozilla/mozjpeg/archive"

readonly IS_UBUNTU=$(cat /etc/*-release | grep -o -m 1 ubuntu)
readonly IS_ALPINE=$(cat /etc/*-release | grep -o -m 1 alpine)

function install_on_alpine {
apk add --update \
automake \
autoconf \
libtool \
nasm \
ca-certificates \
wget \
build-base \
glib-dev \
libxml2-dev \
libjpeg-turbo-dev \
libexif-dev \
tiff-dev \
libgsf-dev \
libpng-dev \
expat-dev \
&& wget ${MOZJPEG_SOURCE}/v${MOZJPEG_VERSION}.tar.gz \
&& tar -zxf v${MOZJPEG_VERSION}.tar.gz \
&& wget ${VIPS_SOURCE}/v${VIPS_VERSION}/vips-${VIPS_VERSION}.tar.gz \
&& ls \
&& cd mozjpeg-${MOZJPEG_VERSION} \
&& autoreconf -fiv \
&& ./configure --prefix=/usr/local/opt/mozjpeg \
&& make install \
&& cd ../ \
&& rm -rf mozjpeg-${MOZJPEG_VERSION}/ \
&& rm v${MOZJPEG_VERSION}.tar.gz \
&& tar -zxf vips-${VIPS_VERSION}.tar.gz \
&& cd vips-${VIPS_VERSION}/ \
&& ./configure \
--prefix=/usr \
--enable-shared \
--disable-debug \
--disable-static \
--disable-introspection \
--disable-dependency-tracking \
--enable-silent-rules \
--without-python \
--enable-shared \
--without-orc \
--without-fftw \
&& make -s \
&& make install \
--without-pangoft2 \
--without-ppm \
--without-analyze \
--without-radiance \
--without-magick \
--with-jpeg-includes=/usr/local/opt/mozjpeg/include --with-jpeg-libraries=/usr/local/opt/mozjpeg/lib \
&& make \
&& make install-strip \
&& ldd `which vips` | grep jpeg \
&& cd ../ \
&& rm -rf vips-${VIPS_VERSION}/ \
&& rm vips-${VIPS_VERSION}.tar.gz
Expand Down

0 comments on commit 809dfab

Please sign in to comment.