Skip to content
Merged
Changes from 1 commit
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
Next Next commit
Return with and heigh of the generated images
Use case:

When using the fit image transformation, it is helpful to know the size
of the resulting image without having to either read the image locally
or do another request to the info endpoint.

Used in: nextcloud/server#24166

Signed-off-by: Carl Schwan <[email protected]>
  • Loading branch information
CarlSchwan committed Feb 11, 2022
commit b5d91cea272d6476cf20170e6bd30a33f3fb578a
7 changes: 7 additions & 0 deletions controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ func imageHandler(w http.ResponseWriter, r *http.Request, buf []byte, operation
// Expose Content-Length response header
w.Header().Set("Content-Length", strconv.Itoa(len(image.Body)))
w.Header().Set("Content-Type", image.Mime)
if image.Mime != "application/json" {
meta, err := bimg.Metadata(image.Body)
if err == nil {
w.Header().Set("X-Image-Width", strconv.Itoa(meta.Size.Width))
w.Header().Set("X-Image-Height", strconv.Itoa(meta.Size.Height))
}
}
if vary != "" {
w.Header().Set("Vary", vary)
}
Expand Down