mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-09-27 20:17:20 +02:00
Ability to skip processing of some formats
This commit is contained in:
21
config.go
21
config.go
@@ -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")
|
||||
|
||||
|
Reference in New Issue
Block a user