Ability to skip processing of some formats

This commit is contained in:
DarthSim
2020-08-13 19:52:35 +06:00
parent fa4dd9f346
commit 08dc814e98
4 changed files with 47 additions and 0 deletions

View File

@@ -58,6 +58,23 @@ func boolEnvConfig(b *bool, name string) {
}
}
func imageTypesEnvConfig(it *[]imageType, name string) {
*it = []imageType{}
if env := os.Getenv(name); len(env) > 0 {
parts := strings.Split(env, ",")
for _, p := range parts {
pt := strings.TrimSpace(p)
if t, ok := imageTypes[pt]; ok {
*it = append(*it, t)
} else {
logWarning("Unknown image format to skip: %s", pt)
}
}
}
}
func hexEnvConfig(b *[]securityKey, name string) error {
var err error
@@ -187,6 +204,8 @@ type config struct {
EnforceWebp bool
EnableClientHints bool
SkipProcessingFormats []imageType
UseLinearColorspace bool
DisableShrinkOnLoad bool
@@ -329,6 +348,8 @@ func configure() error {
boolEnvConfig(&conf.EnforceWebp, "IMGPROXY_ENFORCE_WEBP")
boolEnvConfig(&conf.EnableClientHints, "IMGPROXY_ENABLE_CLIENT_HINTS")
imageTypesEnvConfig(&conf.SkipProcessingFormats, "IMGPROXY_SKIP_PROCESSING_FORMATS")
boolEnvConfig(&conf.UseLinearColorspace, "IMGPROXY_USE_LINEAR_COLORSPACE")
boolEnvConfig(&conf.DisableShrinkOnLoad, "IMGPROXY_DISABLE_SHRINK_ON_LOAD")