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

Method parseQualityInt

options/parser/parse.go:181–200  ·  view source on GitHub ↗

parseQualityInt parses a quality integer option value (minQ-100)

(
	ctx context.Context,
	o *options.Options,
	key string,
	minQ int,
	args ...string,
)

Source from the content-addressed store, hash-verified

179
180// parseQualityInt parses a quality integer option value (minQ-100)
181func (p *Parser) parseQualityInt(
182 ctx context.Context,
183 o *options.Options,
184 key string,
185 minQ int,
186 args ...string,
187) error {
188 if err := p.ensureMaxArgs(ctx, key, args, 1); err != nil {
189 return err
190 }
191
192 i, err := strconv.Atoi(args[0])
193 if err != nil || i < minQ || i > 100 {
194 return newInvalidArgumentError(ctx, key, args[0], fmt.Sprintf("number in range %d-100", minQ))
195 }
196
197 o.Set(key, i)
198
199 return nil
200}
201
202// parseOpacityFloat parses an opacity float option value (0-1)
203func (p *Parser) parseOpacityFloat(

Callers 2

applyQualityOptionMethod · 0.95

Calls 3

ensureMaxArgsMethod · 0.95
newInvalidArgumentErrorFunction · 0.85
SetMethod · 0.45

Tested by

no test coverage detected