From c1a9dab40129cf41be1d7444ab3439deadb76a74 Mon Sep 17 00:00:00 2001 From: Michael Carey Date: Thu, 31 Aug 2017 13:04:10 -0700 Subject: [PATCH] Support TIFF images. --- README.md | 2 +- imageproxy.go | 2 +- transform.go | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 856f5a9..1f1b676 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ imageproxy is a caching image proxy server written in go. It features: - basic image adjustments like resizing, cropping, and rotation - access control using host whitelists or request signing (HMAC-SHA256) - - support for jpeg, png, webp (decode only), and gif image formats (including animated gifs) + - support for jpeg, png, webp & tiff (decode only), and gif image formats (including animated gifs) - on-disk caching, respecting the cache headers of the original images - easy deployment, since it's pure go diff --git a/imageproxy.go b/imageproxy.go index 4fb65b5..b06329b 100644 --- a/imageproxy.go +++ b/imageproxy.go @@ -323,7 +323,7 @@ func (t *TransformingTransport) RoundTrip(req *http.Request) (*http.Response, er resp.Header.WriteSubset(buf, map[string]bool{ "Content-Length": true, // exclude Content-Type header if the format may have changed during transformation - "Content-Type": opt.Format != "" || resp.Header.Get("Content-Type") == "image/webp", + "Content-Type": opt.Format != "" || resp.Header.Get("Content-Type") == "image/webp" || resp.Header.Get("Content-Type") == "image/tiff", }) fmt.Fprintf(buf, "Content-Length: %d\n\n", len(img)) buf.Write(img) diff --git a/transform.go b/transform.go index 0b5b993..1e00063 100644 --- a/transform.go +++ b/transform.go @@ -25,6 +25,7 @@ import ( "github.com/disintegration/imaging" _ "golang.org/x/image/webp" // register webp format + _ "golang.org/x/image/tiff" // register tiff format "willnorris.com/go/gifresize" ) @@ -64,7 +65,7 @@ func Transform(img []byte, opt Options) ([]byte, error) { if err != nil { return nil, err } - case "jpeg", "webp": // default to encoding webp as jpeg + case "jpeg", "webp", "tiff": // default to encoding webp & tiff as jpeg quality := opt.Quality if quality == 0 { quality = defaultQuality