MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / Quality

Method Quality

processing/options.go:264–282  ·  view source on GitHub ↗

Quality retrieves the quality setting for a given image format. It first checks for a general quality setting, then for a format-specific setting, and finally falls back to the configured default quality.

(format imagetype.Type)

Source from the content-addressed store, hash-verified

262// It first checks for a general quality setting, then for a format-specific setting,
263// and finally falls back to the configured default quality.
264func (po ProcessingOptions) Quality(format imagetype.Type) int {
265 // First, check if quality is explicitly set in options.
266 if q := po.Main().GetInt(keys.Quality, 0); q > 0 {
267 return q
268 }
269
270 // Then, check if format-specific quality is set in options.
271 if q := po.Main().GetInt(keys.FormatQuality(format), 0); q > 0 {
272 return q
273 }
274
275 // Then, check if format-specific quality is set in config.
276 if q := po.config.FormatQuality[format]; q > 0 {
277 return q
278 }
279
280 // Finally, return the general quality setting from config.
281 return po.config.Quality
282}
283
284func (po ProcessingOptions) MaxBytes() int {
285 return po.Main().GetInt(keys.MaxBytes, 0)

Callers 1

saveImageMethod · 0.80

Calls 3

FormatQualityFunction · 0.92
MainMethod · 0.80
GetIntMethod · 0.45

Tested by

no test coverage detected