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

Method parseHexRGBColor

options/parser/parse.go:267–285  ·  view source on GitHub ↗

parseHexRGBColor parses a hex-encoded RGB color option value

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

Source from the content-addressed store, hash-verified

265
266// parseHexRGBColor parses a hex-encoded RGB color option value
267func (p *Parser) parseHexRGBColor(
268 ctx context.Context,
269 o *options.Options,
270 key string,
271 args ...string,
272) error {
273 if err := p.ensureMaxArgs(ctx, key, args, 1); err != nil {
274 return err
275 }
276
277 c, err := color.RGBFromHex(args[0])
278 if err != nil {
279 return newInvalidArgumentError(ctx, key, args[0], "hex-encoded color")
280 }
281
282 o.Set(key, c)
283
284 return nil
285}
286
287// parseFromMap parses an option value from a map of allowed values
288func parseFromMap[T comparable](

Callers 2

applyTrimOptionMethod · 0.95
applyBackgroundOptionMethod · 0.95

Calls 4

ensureMaxArgsMethod · 0.95
RGBFromHexFunction · 0.92
newInvalidArgumentErrorFunction · 0.85
SetMethod · 0.45

Tested by

no test coverage detected