diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d201cd7..adddd7cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,14 @@ ## [Unreleased] ### Add - Add JPEL XL (JXL) support. -- Add [IMGPROXY_ENABLE_JXL_DETECTION](https://docs.imgproxy.net/latest/configuration/options#IMGPROXY_ENABLE_JXL_DETECTION), [IMGPROXY_ENFORCE_JXL](https://docs.imgproxy.net/latest/configuration/options#IMGPROXY_ENFORCE_JXL), and [IMGPROXY_JXL_EFFORT](https://docs.imgproxy.net/latest/configuration/options#IMGPROXY_JXL_EFFORT) configs. +- Add [IMGPROXY_AUTO_JXL](https://docs.imgproxy.net/latest/configuration/options#IMGPROXY_AUTO_JXL), [IMGPROXY_ENFORCE_JXL](https://docs.imgproxy.net/latest/configuration/options#IMGPROXY_ENFORCE_JXL), and [IMGPROXY_JXL_EFFORT](https://docs.imgproxy.net/latest/configuration/options#IMGPROXY_JXL_EFFORT) configs. - (pro) Add [objects_position](https://docs.imgproxy.net/latest/usage/processing#objects-position) processing and info options. - (pro) Add [IMGPROXY_OBJECT_DETECTION_SWAP_RB](https://docs.imgproxy.net/latest/configuration/options#IMGPROXY_OBJECT_DETECTION_SWAP_RB) config. +### Changed +- Rename `IMGPROXY_ENABLE_WEBP_DETECTION` to `IMGPROXY_AUTO_WEBP`. The old name is deprecated but still supported. +- Rename `IMGPROXY_ENABLE_AVIF_DETECTION` to `IMGPROXY_AUTO_AVIF`. The old name is deprecated but still supported. + ### Fixed - Fix detecting of width and height of HEIF images that include `irot` boxes. - Set `Error` status for errorred traces in OpenTelemetry. @@ -16,6 +20,10 @@ - (pro) Fix detecting of width and height when orientation is specified in EXIF but EXIF info is not requested. - (pro) Fix watermark shadow clipping. +### Deprecated +- `IMGPROXY_ENABLE_WEBP_DETECTION` config is deprecated. Use `IMGPROXY_AUTO_WEBP` instead. +- `IMGPROXY_ENABLE_AVIF_DETECTION` config is deprecated. Use `IMGPROXY_AUTO_AVIF` instead. + ## [3.26.1] - 2024-10-28 ### Changed - (pro) Improve `monochrome` and `duotone` processing options. diff --git a/config/config.go b/config/config.go index 418f0dea..9d308097 100644 --- a/config/config.go +++ b/config/config.go @@ -65,13 +65,13 @@ var ( ReturnAttachment bool SvgFixUnsupported bool - EnableWebpDetection bool - EnforceWebp bool - EnableAvifDetection bool - EnforceAvif bool - EnableJxlDetection bool - EnforceJxl bool - EnableClientHints bool + AutoWebp bool + EnforceWebp bool + AutoAvif bool + EnforceAvif bool + AutoJxl bool + EnforceJxl bool + EnableClientHints bool PreferredFormats []imagetype.Type @@ -267,11 +267,11 @@ func Reset() { ReturnAttachment = false SvgFixUnsupported = false - EnableWebpDetection = false + AutoWebp = false EnforceWebp = false - EnableAvifDetection = false + AutoAvif = false EnforceAvif = false - EnableJxlDetection = false + AutoJxl = false EnforceJxl = false EnableClientHints = false @@ -494,11 +494,20 @@ func Configure() error { configurators.Bool(&ReturnAttachment, "IMGPROXY_RETURN_ATTACHMENT") configurators.Bool(&SvgFixUnsupported, "IMGPROXY_SVG_FIX_UNSUPPORTED") - configurators.Bool(&EnableWebpDetection, "IMGPROXY_ENABLE_WEBP_DETECTION") + if _, ok := os.LookupEnv("IMGPROXY_ENABLE_WEBP_DETECTION"); ok { + log.Warning("IMGPROXY_ENABLE_WEBP_DETECTION is deprecated, use IMGPROXY_AUTO_WEBP instead") + configurators.Bool(&AutoWebp, "IMGPROXY_ENABLE_WEBP_DETECTION") + } + if _, ok := os.LookupEnv("IMGPROXY_ENABLE_AVIF_DETECTION"); ok { + log.Warning("IMGPROXY_ENABLE_AVIF_DETECTION is deprecated, use IMGPROXY_AUTO_AVIF instead") + configurators.Bool(&AutoAvif, "IMGPROXY_ENABLE_AVIF_DETECTION") + } + + configurators.Bool(&AutoWebp, "IMGPROXY_AUTO_WEBP") configurators.Bool(&EnforceWebp, "IMGPROXY_ENFORCE_WEBP") - configurators.Bool(&EnableAvifDetection, "IMGPROXY_ENABLE_AVIF_DETECTION") + configurators.Bool(&AutoAvif, "IMGPROXY_AUTO_AVIF") configurators.Bool(&EnforceAvif, "IMGPROXY_ENFORCE_AVIF") - configurators.Bool(&EnableJxlDetection, "IMGPROXY_ENABLE_JXL_DETECTION") + configurators.Bool(&AutoJxl, "IMGPROXY_AUTO_JXL") configurators.Bool(&EnforceJxl, "IMGPROXY_ENFORCE_JXL") configurators.Bool(&EnableClientHints, "IMGPROXY_ENABLE_CLIENT_HINTS") diff --git a/options/processing_options.go b/options/processing_options.go index c0bd20c0..49567253 100644 --- a/options/processing_options.go +++ b/options/processing_options.go @@ -1081,17 +1081,17 @@ func defaultProcessingOptions(headers http.Header) (*ProcessingOptions, error) { headerAccept := headers.Get("Accept") if strings.Contains(headerAccept, "image/webp") { - po.PreferWebP = config.EnableWebpDetection || config.EnforceWebp + po.PreferWebP = config.AutoWebp || config.EnforceWebp po.EnforceWebP = config.EnforceWebp } if strings.Contains(headerAccept, "image/avif") { - po.PreferAvif = config.EnableAvifDetection || config.EnforceAvif + po.PreferAvif = config.AutoAvif || config.EnforceAvif po.EnforceAvif = config.EnforceAvif } if strings.Contains(headerAccept, "image/jxl") { - po.PreferJxl = config.EnableJxlDetection || config.EnforceJxl + po.PreferJxl = config.AutoJxl || config.EnforceJxl po.EnforceJxl = config.EnforceJxl } diff --git a/options/processing_options_test.go b/options/processing_options_test.go index 9a74c04a..3106e715 100644 --- a/options/processing_options_test.go +++ b/options/processing_options_test.go @@ -478,7 +478,7 @@ func (s *ProcessingOptionsTestSuite) TestParsePathStripMetadata() { } func (s *ProcessingOptionsTestSuite) TestParsePathWebpDetection() { - config.EnableWebpDetection = true + config.AutoWebp = true path := "/plain/http://images.dev/lorem/ipsum.jpg" headers := http.Header{"Accept": []string{"image/webp"}} diff --git a/processing_handler.go b/processing_handler.go index 7522a1eb..a14ea52f 100644 --- a/processing_handler.go +++ b/processing_handler.go @@ -46,7 +46,7 @@ func initProcessingHandler() { vary := make([]string, 0) - if config.EnableWebpDetection || config.EnforceWebp || config.EnableAvifDetection || config.EnforceAvif { + if config.AutoWebp || config.EnforceWebp || config.AutoAvif || config.EnforceAvif { vary = append(vary, "Accept") }