From e99241aea0040647b27151a61b3a87069591843a Mon Sep 17 00:00:00 2001 From: DarthSim Date: Thu, 4 Apr 2019 21:57:44 +0600 Subject: [PATCH] Disable processing in linear colorspace by default --- config.go | 2 ++ docs/configuration.md | 1 + process.go | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/config.go b/config.go index a61027e4..41f416e0 100644 --- a/config.go +++ b/config.go @@ -152,6 +152,7 @@ type config struct { EnforceWebp bool EnableClientHints bool + UseLinearColorspace bool DisableShrinkOnLoad bool Keys []securityKey @@ -269,6 +270,7 @@ func init() { boolEnvConfig(&conf.EnforceWebp, "IMGPROXY_ENFORCE_WEBP") boolEnvConfig(&conf.EnableClientHints, "IMGPROXY_ENABLE_CLIENT_HINTS") + boolEnvConfig(&conf.UseLinearColorspace, "IMGPROXY_USE_LINEAR_COLORSPACE") boolEnvConfig(&conf.DisableShrinkOnLoad, "IMGPROXY_DISABLE_SHRINK_ON_LOAD") hexEnvConfig(&conf.Keys, "IMGPROXY_KEY") diff --git a/docs/configuration.md b/docs/configuration.md index 42ddd220..3c593199 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -200,4 +200,5 @@ imgproxy can send logs to syslog, but this feature is disabled by default. To en ### Miscellaneous * `IMGPROXY_BASE_URL`: base URL prefix that will be added to every requested image URL. For example, if the base URL is `http://example.com/images` and `/path/to/image.png` is requested, imgproxy will download the source image from `http://example.com/images/path/to/image.png`. Default: blank. +* `IMGPROXY_USE_LINEAR_COLORSPACE`: when `true`, imgproxy will process images in linear colorspace. This will slow down processing. Note that images won't be fully processed in linear colorspace while shrink-on-load is enabled (see below). * `IMGPROXY_DISABLE_SHRINK_ON_LOAD`: when `true`, disables shrink-on-load for JPEG and WebP. Allows to process the whole image in linear colorspace but dramatically slows down resizing and increases memory usage when working with large images. diff --git a/process.go b/process.go index 92b5aac6..f3334727 100644 --- a/process.go +++ b/process.go @@ -316,7 +316,7 @@ func transformImage(ctx context.Context, img **C.VipsImage, data []byte, po *pro return err } - convertToLinear := scale != 1 || po.Dpr != 1 + convertToLinear := conf.UseLinearColorspace && (scale != 1 || po.Dpr != 1) if convertToLinear { if err = vipsLinearColourspace(img); err != nil {