diff --git a/.travis.yml b/.travis.yml index 0f30d10..a4e9671 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,8 @@ language: go dist: xenial sudo: required -go: - # - "1.13" - - "1.14" +services: + - docker env: # - LIBVIPS=7.42.3 @@ -29,118 +28,15 @@ cache: directories: - $HOME/libvips -addons: - apt: - update: true - sources: - # use a more recent imagemagick instead of 6.8.9-9 - - sourceline: 'ppa:cran/imagemagick' - - sourceline: 'ppa:strukturag/libheif' - - sourceline: 'ppa:strukturag/libde265' - packages: - - curl - - automake - - gtk-doc-tools - - gobject-introspection - - python3-pip - - python3-setuptools - - python3-wheel - - libfftw3-dev - - libexif-dev - - libjpeg-turbo8-dev - - libpng12-dev - - libwebp-dev - # missing on xenial, unfortunately - # - libwebpmux2 - - libtiff5-dev - - libheif-dev - - libexpat1-dev - - libmagick++-dev - - libcfitsio3-dev - - libgsl0-dev - - libmatio-dev - - liborc-0.4-dev - - liblcms2-dev - - libpoppler-glib-dev - - librsvg2-dev - - libgif-dev - - libopenexr-dev - - libpango1.0-dev - - libgsf-1-dev - - libopenslide-dev - - libffi-dev +before_install: + - docker build -t bimg:testing --build-arg LIBVIPS_VERSION=$LIBVIPS . script: - - > - cd /tmp && \ - curl -fsSLO https://github.com/libvips/libvips/releases/download/v${LIBVIPS}/vips-${LIBVIPS}.tar.gz && \ - tar zvxf vips-${LIBVIPS}.tar.gz && \ - cd /tmp/vips-${LIBVIPS} && \ - test -f autogen.sh && ./autogen.sh || ./bootstrap.sh && \ - CFLAGS="-g -O3" CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0 -g -O3" \ - ./configure \ - --disable-debug \ - --disable-dependency-tracking \ - --disable-introspection \ - --disable-static \ - --enable-gtk-doc-html=no \ - --enable-gtk-doc=no \ - --enable-pyvips8=no \ - --without-orc \ - --without-python \ - --prefix=$HOME/libvips $1 && \ - make && \ - make install && \ - ldconfig - - cd .. - - export PATH=$PATH:$HOME/libvips/bin - - export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/libvips/lib/pkgconfig - - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/libvips/lib - - vips --vips-version - - go get -u golang.org/x/lint/golint - - # - > - # test "$LIBVIPS" != "master" -a "$LIBVIPS" \< "8.4" \ - # && wget http://www.vips.ecs.soton.ac.uk/supported/${LIBVIPS%.*}/vips-${LIBVIPS}.tar.gz -O vips.tgz \ - # || echo ":-)" - # - > - # test "$LIBVIPS" != "master" -a "$LIBVIPS" \> "8.4" \ - # && wget https://github.com/libvips/libvips/archive/v${LIBVIPS}.tar.gz -O vips.tgz \ - # || echo ":-)" - # - > - # test $LIBVIPS == "master" \ - # && wget https://github.com/libvips/libvips/archive/${LIBVIPS}.tar.gz -O vips.tgz \ - # || echo ":-)" - # - mkdir libvips - # - tar xf vips.tgz -C libvips --strip-components 1 - # - cd libvips - # - test -f autogen.sh && ./autogen.sh || ./bootstrap.sh - # - > - # CXXFLAGS=-D_GLIBCXX_USE_CXX11_ABI=0 - # ./configure - # --disable-debug - # --disable-dependency-tracking - # --disable-introspection - # --disable-static - # --enable-gtk-doc-html=no - # --enable-gtk-doc=no - # --enable-pyvips8=no - # --without-orc - # --without-python - # --prefix=$HOME/libvips - # $1 - # - make - # - make install - # - cd .. - # - export PATH=$PATH:$HOME/libvips/bin - # - export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/libvips/lib/pkgconfig - # - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/libvips/lib - # - vips --vips-version - # script: - - diff -u <(echo -n) <(gofmt -s -d ./) - - diff -u <(echo -n) <(go vet ./) - - diff -u <(echo -n) <(golint ./) - - go test -v -race -covermode=atomic -coverprofile=coverage.out - -after_success: - - goveralls -coverprofile=coverage.out -service=travis-ci + - docker run bimg:testing sh -c 'go vet . && golint . && go test -v -race -covermode=atomic -coverprofile=coverage.out' + # - diff -u <(echo -n) <(gofmt -s -d ./) + # - diff -u <(echo -n) <(go vet ./) + # - diff -u <(echo -n) <(golint ./) + # - go test -v -race -covermode=atomic -coverprofile=coverage.out + +# after_success: +# - goveralls -coverprofile=coverage.out -service=travis-ci diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9e0c686 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,65 @@ +FROM golang:1.14 +LABEL maintainer "tomas@aparicio.me" + +ARG LIBVIPS_VERSION=8.9.2 +ARG GOLANGCILINT_VERSION=1.23.3 + +# Installs libvips + required libraries +RUN DEBIAN_FRONTEND=noninteractive \ + apt-get update && \ + apt-get install --no-install-recommends -y \ + ca-certificates \ + automake build-essential curl \ + gobject-introspection gtk-doc-tools libglib2.0-dev libjpeg62-turbo-dev libpng-dev \ + libwebp-dev libtiff5-dev libgif-dev libexif-dev libxml2-dev libpoppler-glib-dev \ + swig libmagickwand-dev libpango1.0-dev libmatio-dev libopenslide-dev libcfitsio-dev \ + libgsf-1-dev fftw3-dev liborc-0.4-dev librsvg2-dev libimagequant-dev libheif-dev && \ + cd /tmp && \ + curl -fsSLO https://github.com/libvips/libvips/releases/download/v${LIBVIPS_VERSION}/vips-${LIBVIPS_VERSION}.tar.gz && \ + tar zvxf vips-${LIBVIPS_VERSION}.tar.gz && \ + cd /tmp/vips-${LIBVIPS_VERSION} && \ + CFLAGS="-g -O3" CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0 -g -O3" \ + ./configure \ + --disable-debug \ + --disable-dependency-tracking \ + --disable-introspection \ + --disable-static \ + --enable-gtk-doc-html=no \ + --enable-gtk-doc=no \ + --enable-pyvips8=no \ + --prefix=/vips && \ + make && \ + make install && \ + ldconfig + +# Install runtime dependencies +# RUN DEBIAN_FRONTEND=noninteractive \ +# apt-get update && \ +# apt-get install --no-install-recommends -y \ +# libglib2.0-0 libjpeg62-turbo libpng16-16 libopenexr23 \ +# libwebp6 libwebpmux3 libwebpdemux2 libtiff5 libgif7 libexif12 libxml2 libpoppler-glib8 \ +# libmagickwand-6.q16-6 libpango1.0-0 libmatio4 libopenslide0 \ +# libgsf-1-114 fftw3 liborc-0.4-0 librsvg2-2 libcfitsio7 libimagequant0 libheif1 && \ +# apt-get autoremove -y && \ +# apt-get autoclean && \ +# apt-get clean && \ +# rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# Install Go lint +RUN go get -u golang.org/x/lint/golint + +ENV LD_LIBRARY_PATH="/vips/lib:$LD_LIBRARY_PATH" +ENV PKG_CONFIG_PATH="/vips/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:/usr/X11/lib/pkgconfig" + +WORKDIR ${GOPATH}/src/github.com/h2non/bimg +COPY . . + +# RUN \ +# # Clean up +# apt-get remove -y automake curl build-essential && \ +# apt-get autoremove -y && \ +# apt-get autoclean && \ +# apt-get clean && \ +# rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +CMD [ "/bin/bash" ] \ No newline at end of file diff --git a/options.go b/options.go index 2bd0c83..dd59031 100644 --- a/options.go +++ b/options.go @@ -224,5 +224,5 @@ type Options struct { Threshold float64 Gamma float64 OutputICC string - InputICC string + InputICC string } diff --git a/resizer.go b/resizer.go index 55eaf4b..461af5e 100644 --- a/resizer.go +++ b/resizer.go @@ -172,7 +172,7 @@ func saveImage(image *C.VipsImage, o Options) ([]byte, error) { Interlace: o.Interlace, NoProfile: o.NoProfile, Interpretation: o.Interpretation, - InputICC: o.InputICC, + InputICC: o.InputICC, OutputICC: o.OutputICC, StripMetadata: o.StripMetadata, Lossless: o.Lossless, diff --git a/resizer_test.go b/resizer_test.go index 7dff7ab..9d34485 100644 --- a/resizer_test.go +++ b/resizer_test.go @@ -591,22 +591,22 @@ func TestIfBothSmartCropOptionsAreIdentical(t *testing.T) { } func TestSkipCropIfTooSmall(t *testing.T) { - testCases := [] struct { - name string + testCases := []struct { + name string options Options - } { - { - name: "smart crop", - options: Options{ - Width: 140, - Height: 140, - Crop: true, - Gravity: GravitySmart, - }, + }{ + { + name: "smart crop", + options: Options{ + Width: 140, + Height: 140, + Crop: true, + Gravity: GravitySmart, }, + }, { name: "centre crop", - options: Options{ + options: Options{ Width: 140, Height: 140, Crop: true, @@ -615,19 +615,19 @@ func TestSkipCropIfTooSmall(t *testing.T) { }, { name: "embed", - options: Options{ - Width: 140, - Height: 140, + options: Options{ + Width: 140, + Height: 140, Embed: true, }, }, { name: "extract", - options: Options{ - Top: 0, - Left: 0, - AreaWidth: 140, - AreaHeight: 140, + options: Options{ + Top: 0, + Left: 0, + AreaWidth: 140, + AreaHeight: 140, }, }, } diff --git a/vips.go b/vips.go index 315204b..77dd7ac 100644 --- a/vips.go +++ b/vips.go @@ -52,7 +52,7 @@ type vipsSaveOptions struct { NoProfile bool StripMetadata bool Lossless bool - InputICC string // Absolute path to the input ICC profile + InputICC string // Absolute path to the input ICC profile OutputICC string // Absolute path to the output ICC profile Interpretation Interpretation }