| 81 | } |
| 82 | |
| 83 | func LoadConfigFromEnv(c *Config) (*Config, error) { |
| 84 | c = ensure.Ensure(c, NewDefaultConfig) |
| 85 | |
| 86 | err := errors.Join( |
| 87 | IMGPROXY_JPEG_PROGRESSIVE.Parse(&c.JpegProgressive), |
| 88 | IMGPROXY_PNG_INTERLACED.Parse(&c.PngInterlaced), |
| 89 | IMGPROXY_PNG_QUANTIZE.Parse(&c.PngQuantize), |
| 90 | IMGPROXY_PNG_QUANTIZATION_COLORS.Parse(&c.PngQuantizationColors), |
| 91 | IMGPROXY_AVIF_SPEED.Parse(&c.AvifSpeed), |
| 92 | IMGPROXY_WEBP_EFFORT.Parse(&c.WebpEffort), |
| 93 | IMGPROXY_JXL_EFFORT.Parse(&c.JxlEffort), |
| 94 | IMGPROXY_PNG_UNLIMITED.Parse(&c.PngUnlimited), |
| 95 | IMGPROXY_SVG_UNLIMITED.Parse(&c.SvgUnlimited), |
| 96 | |
| 97 | IMGPROXY_WEBP_PRESET.Parse(&c.WebpPreset), |
| 98 | IMGPROXY_VIPS_LEAK_CHECK.Parse(&c.LeakCheck), |
| 99 | IMGPROXY_VIPS_CACHE_TRACE.Parse(&c.CacheTrace), |
| 100 | ) |
| 101 | |
| 102 | return c, err |
| 103 | } |
| 104 | |
| 105 | func (c *Config) Validate() error { |
| 106 | if c.PngQuantizationColors < 2 || c.PngQuantizationColors > 256 { |