mirror of
https://github.com/willnorris/imageproxy.git
synced 2024-12-16 21:56:43 -05:00
Support TIFF images.
This commit is contained in:
parent
4533f0c68a
commit
c1a9dab401
3 changed files with 4 additions and 3 deletions
|
@ -4,7 +4,7 @@ imageproxy is a caching image proxy server written in go. It features:
|
||||||
|
|
||||||
- basic image adjustments like resizing, cropping, and rotation
|
- basic image adjustments like resizing, cropping, and rotation
|
||||||
- access control using host whitelists or request signing (HMAC-SHA256)
|
- 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
|
- on-disk caching, respecting the cache headers of the original images
|
||||||
- easy deployment, since it's pure go
|
- easy deployment, since it's pure go
|
||||||
|
|
||||||
|
|
|
@ -323,7 +323,7 @@ func (t *TransformingTransport) RoundTrip(req *http.Request) (*http.Response, er
|
||||||
resp.Header.WriteSubset(buf, map[string]bool{
|
resp.Header.WriteSubset(buf, map[string]bool{
|
||||||
"Content-Length": true,
|
"Content-Length": true,
|
||||||
// exclude Content-Type header if the format may have changed during transformation
|
// 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))
|
fmt.Fprintf(buf, "Content-Length: %d\n\n", len(img))
|
||||||
buf.Write(img)
|
buf.Write(img)
|
||||||
|
|
|
@ -25,6 +25,7 @@ import (
|
||||||
|
|
||||||
"github.com/disintegration/imaging"
|
"github.com/disintegration/imaging"
|
||||||
_ "golang.org/x/image/webp" // register webp format
|
_ "golang.org/x/image/webp" // register webp format
|
||||||
|
_ "golang.org/x/image/tiff" // register tiff format
|
||||||
"willnorris.com/go/gifresize"
|
"willnorris.com/go/gifresize"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ func Transform(img []byte, opt Options) ([]byte, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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
|
quality := opt.Quality
|
||||||
if quality == 0 {
|
if quality == 0 {
|
||||||
quality = defaultQuality
|
quality = defaultQuality
|
||||||
|
|
Loading…
Reference in a new issue