Explorar el Código

Add X-Result-Width and X-Result-Height to debug headers

DarthSim hace 3 años
padre
commit
91a3671f9d
Se han modificado 4 ficheros con 7 adiciones y 0 borrados
  1. 1 0
      CHANGELOG.md
  2. 2 0
      docs/configuration.md
  3. 2 0
      processing/processing.go
  4. 2 0
      processing_handler.go

+ 1 - 0
CHANGELOG.md

@@ -4,6 +4,7 @@
 ### Add
 - Add support of RLE-encoded BMP.
 - Add `IMGPROXY_ENFORCE_THUMBNAIL` config and [enforce_thumbnail](https://docs.imgproxy.net/generating_the_url?id=enforce-thumbnail) processing option.
+- Add `X-Result-Width` and `X-Result-Height` to debug headers.
 
 ### Change
 - Use thumbnail embedded to HEIC/AVIF if its size is larger than or equal to the requested.

+ 2 - 0
docs/configuration.md

@@ -49,6 +49,8 @@ echo $(xxd -g 2 -l 64 -p /dev/random | tr -d '\n')
   * `X-Origin-Content-Length`: the size of the source image
   * `X-Origin-Width`: the width of the source image
   * `X-Origin-Height`: the height of the source image
+  * `X-Result-Width`: the width of the resultant image
+  * `X-Result-Height`: the height of the resultant image
 * `IMGPROXY_SERVER_NAME`: <i class='badge badge-pro'></i> the `Server` header value. Default: `imgproxy`
 
 ## Security

+ 2 - 0
processing/processing.go

@@ -282,6 +282,8 @@ func ProcessImage(ctx context.Context, imgdata *imagedata.ImageData, po *options
 		}
 		outData.Headers["X-Origin-Width"] = strconv.Itoa(originWidth)
 		outData.Headers["X-Origin-Height"] = strconv.Itoa(originHeight)
+		outData.Headers["X-Result-Width"] = strconv.Itoa(img.Width())
+		outData.Headers["X-Result-Height"] = strconv.Itoa(img.Height())
 	}
 
 	return outData, err

+ 2 - 0
processing_handler.go

@@ -112,6 +112,8 @@ func respondWithImage(reqID string, r *http.Request, rw http.ResponseWriter, sta
 		rw.Header().Set("X-Origin-Content-Length", strconv.Itoa(len(originData.Data)))
 		rw.Header().Set("X-Origin-Width", resultData.Headers["X-Origin-Width"])
 		rw.Header().Set("X-Origin-Height", resultData.Headers["X-Origin-Height"])
+		rw.Header().Set("X-Result-Width", resultData.Headers["X-Result-Width"])
+		rw.Header().Set("X-Result-Height", resultData.Headers["X-Result-Height"])
 	}
 
 	rw.Header().Set("Content-Length", strconv.Itoa(len(resultData.Data)))