Browse Source

Disable processing in linear colorspace by default

DarthSim 6 years ago
parent
commit
e99241aea0
3 changed files with 4 additions and 1 deletions
  1. 2 0
      config.go
  2. 1 0
      docs/configuration.md
  3. 1 1
      process.go

+ 2 - 0
config.go

@@ -152,6 +152,7 @@ type config struct {
 	EnforceWebp         bool
 	EnforceWebp         bool
 	EnableClientHints   bool
 	EnableClientHints   bool
 
 
+	UseLinearColorspace bool
 	DisableShrinkOnLoad bool
 	DisableShrinkOnLoad bool
 
 
 	Keys          []securityKey
 	Keys          []securityKey
@@ -269,6 +270,7 @@ func init() {
 	boolEnvConfig(&conf.EnforceWebp, "IMGPROXY_ENFORCE_WEBP")
 	boolEnvConfig(&conf.EnforceWebp, "IMGPROXY_ENFORCE_WEBP")
 	boolEnvConfig(&conf.EnableClientHints, "IMGPROXY_ENABLE_CLIENT_HINTS")
 	boolEnvConfig(&conf.EnableClientHints, "IMGPROXY_ENABLE_CLIENT_HINTS")
 
 
+	boolEnvConfig(&conf.UseLinearColorspace, "IMGPROXY_USE_LINEAR_COLORSPACE")
 	boolEnvConfig(&conf.DisableShrinkOnLoad, "IMGPROXY_DISABLE_SHRINK_ON_LOAD")
 	boolEnvConfig(&conf.DisableShrinkOnLoad, "IMGPROXY_DISABLE_SHRINK_ON_LOAD")
 
 
 	hexEnvConfig(&conf.Keys, "IMGPROXY_KEY")
 	hexEnvConfig(&conf.Keys, "IMGPROXY_KEY")

+ 1 - 0
docs/configuration.md

@@ -200,4 +200,5 @@ imgproxy can send logs to syslog, but this feature is disabled by default. To en
 ### Miscellaneous
 ### 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_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.
 * `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.

+ 1 - 1
process.go

@@ -316,7 +316,7 @@ func transformImage(ctx context.Context, img **C.VipsImage, data []byte, po *pro
 		return err
 		return err
 	}
 	}
 
 
-	convertToLinear := scale != 1 || po.Dpr != 1
+	convertToLinear := conf.UseLinearColorspace && (scale != 1 || po.Dpr != 1)
 
 
 	if convertToLinear {
 	if convertToLinear {
 		if err = vipsLinearColourspace(img); err != nil {
 		if err = vipsLinearColourspace(img); err != nil {