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

Method applyWatermarkOption

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

Source from the content-addressed store, hash-verified

343}
344
345func (p *Parser) applyWatermarkOption(ctx context.Context, o *options.Options, args []string) error {
346 if err := p.ensureMaxArgs(ctx, "watermark", args, 7); err != nil {
347 return err
348 }
349
350 if err := p.parseOpacityFloat(ctx, o, keys.WatermarkOpacity, args[0]); err != nil {
351 return err
352 }
353
354 if len(args) > 1 && len(args[1]) > 0 {
355 if _, err := p.parseGravityType(
356 ctx, o, keys.WatermarkPosition, processing.WatermarkGravityTypes, args[1],
357 ); err != nil {
358 return err
359 }
360 }
361
362 if len(args) > 2 && len(args[2]) > 0 {
363 if err := p.parseFloat(ctx, o, keys.WatermarkXOffset, args[2]); err != nil {
364 return err
365 }
366 }
367
368 if len(args) > 3 && len(args[3]) > 0 {
369 if err := p.parseFloat(ctx, o, keys.WatermarkYOffset, args[3]); err != nil {
370 return err
371 }
372 }
373
374 if len(args) > 4 && len(args[4]) > 0 {
375 if err := p.parsePositiveNonZeroFloat(ctx, o, keys.WatermarkScale, args[4]); err != nil {
376 return err
377 }
378 }
379
380 return nil
381}
382
383func (p *Parser) applyFormatOption(ctx context.Context, o *options.Options, args []string) error {
384 if err := p.ensureMaxArgs(ctx, keys.Format, args, 1); err != nil {

Callers 1

applyURLOptionMethod · 0.95

Calls 5

ensureMaxArgsMethod · 0.95
parseOpacityFloatMethod · 0.95
parseGravityTypeMethod · 0.95
parseFloatMethod · 0.95

Tested by

no test coverage detected