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

Method applyFormatQualityOption

options/parser/apply.go:261–285  ·  view source on GitHub ↗
(ctx context.Context, o *options.Options, args []string)

Source from the content-addressed store, hash-verified

259}
260
261func (p *Parser) applyFormatQualityOption(ctx context.Context, o *options.Options, args []string) error {
262 argsLen := len(args)
263 if len(args)%2 != 0 {
264 return newOptionArgumentError(
265 ctx,
266 keys.PrefixFormatQuality,
267 "Missing %s for: %s",
268 keys.PrefixFormatQuality,
269 args[argsLen-1],
270 )
271 }
272
273 for i := 0; i < argsLen; i += 2 {
274 f, ok := imagetype.GetTypeByName(args[i])
275 if !ok {
276 return newOptionArgumentError(ctx, keys.PrefixFormatQuality, "Invalid image format: %s", args[i])
277 }
278
279 if err := p.parseQualityInt(ctx, o, keys.FormatQuality(f), 0, args[i+1]); err != nil {
280 return err
281 }
282 }
283
284 return nil
285}
286
287func (p *Parser) applyMaxBytesOption(ctx context.Context, o *options.Options, args []string) error {
288 return p.parsePositiveInt(ctx, o, keys.MaxBytes, args...)

Callers 1

applyURLOptionMethod · 0.95

Calls 4

parseQualityIntMethod · 0.95
GetTypeByNameFunction · 0.92
FormatQualityFunction · 0.92
newOptionArgumentErrorFunction · 0.85

Tested by

no test coverage detected