Pre-release HEIF / HEIC support (#297)

* Smaller & safer Docker build context

* Help imaginary avoid having root at runtime

* Enable libvips' support for libimagequant

* Add libheif / HEIC image support
This commit is contained in:
Daniel Dent
2020-06-06 08:56:39 -07:00
committed by GitHub
parent f4d553bd37
commit 8fa8a846e1
16 changed files with 26 additions and 21 deletions

2
.dockerignore Normal file
View File

@@ -0,0 +1,2 @@
**/*~
.git

View File

@@ -14,7 +14,7 @@ RUN DEBIAN_FRONTEND=noninteractive \
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 && \
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 && \
@@ -81,7 +81,7 @@ RUN DEBIAN_FRONTEND=noninteractive \
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 && \
libgsf-1-114 fftw3 liborc-0.4-0 librsvg2-2 libcfitsio7 libimagequant0 libheif1 && \
apt-get autoremove -y && \
apt-get autoclean && \
apt-get clean && \
@@ -90,6 +90,9 @@ RUN DEBIAN_FRONTEND=noninteractive \
# Server port to listen
ENV PORT 9000
# Drop privileges for non-UID mapped environments
USER nobody
# Run the entrypoint command by default when the container starts.
ENTRYPOINT ["/usr/local/bin/imaginary"]

View File

@@ -6,7 +6,7 @@ It's almost dependency-free and only uses [`net/http`](http://golang.org/pkg/net
Supports multiple [image operations](#supported-image-operations) exposed as a simple [HTTP API](#http-api),
with additional optional features such as **API token authorization**, **URL signature protection**, **HTTP traffic throttle** strategy and **CORS support** for web clients.
`imaginary` **can read** images **from HTTP POST payloads**, **server local path** or **remote HTTP servers**, supporting **JPEG**, **PNG**, **WEBP**, and optionally **TIFF**, **PDF**, **GIF** and **SVG** formats if `libvips@8.3+` is compiled with proper library bindings.
`imaginary` **can read** images **from HTTP POST payloads**, **server local path** or **remote HTTP servers**, supporting **JPEG**, **PNG**, **WEBP**, **HEIF**, and optionally **TIFF**, **PDF**, **GIF** and **SVG** formats if `libvips@8.3+` is compiled with proper library bindings.
`imaginary` is able to output images as JPEG, PNG and WEBP formats, including transparent conversion across them.

View File

@@ -8,8 +8,8 @@ import (
"strconv"
"strings"
"gopkg.in/h2non/bimg.v1"
"gopkg.in/h2non/filetype.v1"
"github.com/h2non/bimg"
"github.com/h2non/filetype"
)
func indexController(w http.ResponseWriter, r *http.Request) {

View File

@@ -6,7 +6,7 @@ import (
"net/http"
"strings"
"gopkg.in/h2non/bimg.v1"
"github.com/h2non/bimg"
)
const (

4
go.mod
View File

@@ -6,7 +6,7 @@ require (
github.com/garyburd/redigo v1.6.0 // indirect
github.com/hashicorp/golang-lru v0.0.0-20160813221303-0a025b7e63ad // indirect
github.com/rs/cors v0.0.0-20170727213201-7af7a1e09ba3
gopkg.in/h2non/bimg.v1 v1.0.19
gopkg.in/h2non/filetype.v1 v1.0.3
github.com/h2non/bimg v1.0.20-0.20200405220655-daafbf6d972d
github.com/h2non/filetype v1.0.12
gopkg.in/throttled/throttled.v2 v2.0.3
)

8
go.sum
View File

@@ -4,9 +4,9 @@ github.com/hashicorp/golang-lru v0.0.0-20160813221303-0a025b7e63ad h1:eMxs9EL0Pv
github.com/hashicorp/golang-lru v0.0.0-20160813221303-0a025b7e63ad/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/rs/cors v0.0.0-20170727213201-7af7a1e09ba3 h1:86ukAHRTa2CXdBnWJHcjjPPGTyLGEF488OFRsbBAuFs=
github.com/rs/cors v0.0.0-20170727213201-7af7a1e09ba3/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
gopkg.in/h2non/bimg.v1 v1.0.19 h1:Li7mgBrIvCHvShB4nyCcGJ2Z2rWR/95kgI/U2+U2eYw=
gopkg.in/h2non/bimg.v1 v1.0.19/go.mod h1:PgsZL7dLwUbsGm1NYps320GxGgvQNTnecMCZqxV11So=
gopkg.in/h2non/filetype.v1 v1.0.3 h1:EhZ9p3H8eDdFHiKljxJ59EeQ9Pu88wrgY7/B1WRK/VE=
gopkg.in/h2non/filetype.v1 v1.0.3/go.mod h1:M0yem4rwSX5lLVrkEuRRp2/NinFMD5vgJ4DlAhZcfNo=
github.com/h2non/bimg v1.0.20-0.20200405220655-daafbf6d972d h1:AhGp7Xiew8DAYGJ1MojrE11chxHVOv4NvE/y5i2IvBI=
github.com/h2non/bimg v1.0.20-0.20200405220655-daafbf6d972d/go.mod h1:R3+UiYwkK4rQl6KVFTOFJHitgLbZXBZNFh2cv3AEbp8=
github.com/h2non/filetype v1.0.12 h1:yHCsIe0y2cvbDARtJhGBTD2ecvqMSTvlIcph9En/Zao=
github.com/h2non/filetype v1.0.12/go.mod h1:319b3zT68BvV+WRj7cwy856M2ehB3HqNOt6sy1HndBY=
gopkg.in/throttled/throttled.v2 v2.0.3 h1:PGm7nfjjexecEyI2knw1akeLcrjzqxuYSU9a04R8rfU=
gopkg.in/throttled/throttled.v2 v2.0.3/go.mod h1:L4cTNZO77XKEXtn8HNFRCMNGZPtRRKAhyuJBSvK/T90=

View File

@@ -9,7 +9,7 @@ import (
"math"
"net/http"
"gopkg.in/h2non/bimg.v1"
"github.com/h2non/bimg"
)
// OperationsMap defines the allowed image transformation operations listed by name.

View File

@@ -13,7 +13,7 @@ import (
"strings"
"time"
"gopkg.in/h2non/bimg.v1"
"github.com/h2non/bimg"
)
var (

View File

@@ -10,7 +10,7 @@ import (
"time"
"github.com/rs/cors"
"gopkg.in/h2non/bimg.v1"
"github.com/h2non/bimg"
"gopkg.in/throttled/throttled.v2"
"gopkg.in/throttled/throttled.v2/store/memstore"
)

View File

@@ -4,7 +4,7 @@ import (
"strconv"
"strings"
"gopkg.in/h2non/bimg.v1"
"github.com/h2non/bimg"
)
// ImageOptions represent all the supported image transformation params as first level members

View File

@@ -9,7 +9,7 @@ import (
"strconv"
"strings"
"gopkg.in/h2non/bimg.v1"
"github.com/h2non/bimg"
)
var ErrUnsupportedValue = errors.New("unsupported value")

View File

@@ -5,7 +5,7 @@ import (
"net/url"
"testing"
"gopkg.in/h2non/bimg.v1"
"github.com/h2non/bimg"
)
const epsilon = 0.0001

View File

@@ -12,7 +12,7 @@ import (
"strings"
"testing"
"gopkg.in/h2non/bimg.v1"
"github.com/h2non/bimg"
)
func TestIndex(t *testing.T) {

View File

@@ -3,7 +3,7 @@ package main
import (
"strings"
"gopkg.in/h2non/bimg.v1"
"github.com/h2non/bimg"
)
// ExtractImageTypeFromMime returns the MIME image type.

View File

@@ -3,7 +3,7 @@ package main
import (
"testing"
"gopkg.in/h2non/bimg.v1"
"github.com/h2non/bimg"
)
func TestExtractImageTypeFromMime(t *testing.T) {