Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Move away from VIPS for bimg #14

Merged
merged 6 commits into from
Oct 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ _testmain.go
*.exe
*.test
*.prof

#ides
.vscode
35 changes: 30 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
# Start from a Debian image with the latest version of Go installed
# and a workspace (GOPATH) configured at /go.
FROM marcbachmann/libvips:latest
FROM ubuntu:14.04

# vips version
ENV LIBVIPS_VERSION_MAJOR 8
ENV LIBVIPS_VERSION_MINOR 5
ENV LIBVIPS_VERSION_PATCH 8
ENV LIBVIPS_VERSION $LIBVIPS_VERSION_MAJOR.$LIBVIPS_VERSION_MINOR.$LIBVIPS_VERSION_PATCH

# Install dependencies and vips
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
automake build-essential curl \
gobject-introspection gtk-doc-tools libglib2.0-dev libjpeg-turbo8-dev libpng12-dev \
libwebp-dev libtiff5-dev libgif-dev libexif-dev libxml2-dev libpoppler-glib-dev \
swig libmagickwand-dev libpango1.0-dev libmatio-dev libopenslide-dev libcfitsio3-dev \
libgsf-1-dev fftw3-dev liborc-0.4-dev librsvg2-dev && \
cd /tmp && \
curl -L https://github.com/jcupitt/libvips/releases/download/v$LIBVIPS_VERSION/vips-$LIBVIPS_VERSION.tar.gz | tar xz && \
cd /tmp/vips-$LIBVIPS_VERSION && \
./configure --enable-debug=no --without-python $1 && \
make && \
make install && \
ldconfig && \
apt-get remove -y curl automake build-essential && \
apt-get autoremove -y && \
apt-get autoclean && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Server port to listen
ENV PORT 8080

# Go version to use
ENV GOLANG_VERSION 1.8.1
ENV GOLANG_VERSION 1.9

# gcc for cgo
RUN apt-get update && apt-get install -y \
Expand All @@ -15,7 +40,7 @@ RUN apt-get update && apt-get install -y \
&& rm -rf /var/lib/apt/lists/*

ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz
ENV GOLANG_DOWNLOAD_SHA256 a579ab19d5237e263254f1eac5352efcf1d70b9dacadb6d6bb12b0911ede8994
ENV GOLANG_DOWNLOAD_SHA256 d70eadefce8e160638a9a6db97f7192d8463069ab33138893ad3bf31b0650a79

RUN curl -fsSL --insecure "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \
&& echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \
Expand Down
16 changes: 11 additions & 5 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ A very fast [golang](http://golang.org/) port of [thumbor](https://github.com/th
Gothumb is on k8bs. Refer to [opendoor-gothumb](https://github.com/opendoor-labs/opendoor-gothumb)

### TEST
Testing in staging:
#### LOCAL:
Run
```
$ cd .
$ go run main.go -unsafe=true
```
Call `localhost:8888/unsafe/0x500/https://listing-photos-production.s3.amazonaws.com/uploads/work_order_item-237397/1675177-g8UBAKwT8dw.jpg` from your browser.

#### STAGING:

Build the docker image by
```
Expand Down
2 changes: 1 addition & 1 deletion bin/install
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

brew install --devel go
brew install go@1.9
brew tap homebrew/science
brew install vips
if [ -z $GOPATH ]; then
Expand Down
2 changes: 1 addition & 1 deletion generate_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ def generate_signature(message, key):
signature2 = base64.urlsafe_b64encode(signature1)
return str(signature2, 'UTF-8')

generate_signature('300x0/https://mls-crawler-results-production.s3.amazonaws.com/residential_photos/5504861/armls_20161001001641857238000000-o.jpg', SECURITY_SECRET)
generate_signature('300x0/https://listing-photos-production.s3.amazonaws.com/uploads/listing-4772/1973884-RCle1Lr6Q2w.jpg', SECURITY_KEY)
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
"strings"
"time"

"github.com/DAddYE/vips"
"github.com/julienschmidt/httprouter"
"github.com/rlmcpherson/s3gof3r"
"gopkg.in/h2non/bimg.v1"
)

var (
Expand Down Expand Up @@ -200,14 +200,14 @@ func generateThumbnail(w http.ResponseWriter, rmethod, rpath string, sourceURL s
return
}

buf, err := vips.Resize(img, vips.Options{
buf, err := bimg.Resize(img, bimg.Options{
Height: int(height),
Width: int(width),
Crop: true,
Interpolator: vips.BICUBIC,
Gravity: vips.CENTRE,
Gravity: bimg.GravityCentre,
Interpolator: bimg.Bicubic,
Quality: 50,
})

if err != nil {
responseCode := 500
if err.Error() == "unknown image format" {
Expand Down
1 change: 0 additions & 1 deletion vendor/github.com/DAddYE/vips/.gitignore

This file was deleted.

149 changes: 0 additions & 149 deletions vendor/github.com/DAddYE/vips/README.md

This file was deleted.

Loading