diff --git a/docs/getting_the_image_info.md b/docs/getting_the_image_info.md index efc44c99..c1c025ea 100644 --- a/docs/getting_the_image_info.md +++ b/docs/getting_the_image_info.md @@ -29,7 +29,7 @@ The source URL can be provided as is, prepended by `/plain/` part: /plain/http://example.com/images/curiosity.jpg ``` -**📝Note:** If the sorce URL contains query string or `@`, you need to escape it. +**📝Note:** If the source URL contains query string or `@`, you need to escape it. #### Base64 encoded @@ -67,7 +67,7 @@ imgproxy responses with JSON body and returns the following info: } ``` -#### Exampple (mp4) +#### Example (mp4) ```json { diff --git a/download.go b/download.go index df764d62..97ddab9a 100644 --- a/download.go +++ b/download.go @@ -1,6 +1,7 @@ package main import ( + "compress/gzip" "context" "crypto/tls" "fmt" @@ -196,7 +197,22 @@ func downloadImage(imageURL string) (*imageData, error) { return nil, err } - imgdata, err := readAndCheckImage(res.Body, int(res.ContentLength)) + body := res.Body + contentLength := int(res.ContentLength) + + if res.Header.Get("Content-Encoding") == "gzip" { + gzipBody, errGzip := gzip.NewReader(res.Body) + if gzipBody != nil { + defer gzipBody.Close() + } + if errGzip != nil { + return nil, err + } + body = gzipBody + contentLength = 0 + } + + imgdata, err := readAndCheckImage(body, contentLength) if err != nil { return nil, err } diff --git a/imagemeta/heif.go b/imagemeta/heif.go index dd338091..f54346e0 100644 --- a/imagemeta/heif.go +++ b/imagemeta/heif.go @@ -210,8 +210,6 @@ func heifReadBoxes(d *heifData, r io.Reader) error { if w > d.Width || h > d.Height { d.Width, d.Height = w, h } - case "mdat": - return errors.New("mdat box occurred before meta box") default: if err := heifDiscardN(r, boxDataSize); err != nil { return err