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

Method applyPaddingOption

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

Source from the content-addressed store, hash-verified

147}
148
149func (p *Parser) applyPaddingOption(ctx context.Context, o *options.Options, args []string) error {
150 if err := p.ensureMaxArgs(ctx, "padding", args, 4); err != nil {
151 return err
152 }
153
154 if len(args) > 0 && len(args[0]) > 0 {
155 if err := p.parsePositiveInt(ctx, o, keys.PaddingTop, args[0]); err != nil {
156 return err
157 }
158 }
159
160 if len(args) > 1 && len(args[1]) > 0 {
161 if err := p.parsePositiveInt(ctx, o, keys.PaddingRight, args[1]); err != nil {
162 return err
163 }
164 } else {
165 o.CopyValue(keys.PaddingTop, keys.PaddingRight)
166 }
167
168 if len(args) > 2 && len(args[2]) > 0 {
169 if err := p.parsePositiveInt(ctx, o, keys.PaddingBottom, args[2]); err != nil {
170 return err
171 }
172 } else {
173 o.CopyValue(keys.PaddingTop, keys.PaddingBottom)
174 }
175
176 if len(args) > 3 && len(args[3]) > 0 {
177 if err := p.parsePositiveInt(ctx, o, keys.PaddingLeft, args[3]); err != nil {
178 return err
179 }
180 } else {
181 o.CopyValue(keys.PaddingRight, keys.PaddingLeft)
182 }
183
184 return nil
185}
186
187func (p *Parser) applyTrimOption(ctx context.Context, o *options.Options, args []string) error {
188 if err := p.ensureMaxArgs(ctx, "trim", args, 4); err != nil {

Callers 1

applyURLOptionMethod · 0.95

Calls 3

ensureMaxArgsMethod · 0.95
parsePositiveIntMethod · 0.95
CopyValueMethod · 0.80

Tested by

no test coverage detected