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)
| 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. |
| 264 | func (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 | |
| 284 | func (po ProcessingOptions) MaxBytes() int { |
| 285 | return po.Main().GetInt(keys.MaxBytes, 0) |
no test coverage detected