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

Function extendImage

processing/extend.go:3–20  ·  view source on GitHub ↗
(c *Context, width, height int, gravity *GravityOptions)

Source from the content-addressed store, hash-verified

1package processing
2
3func extendImage(c *Context, width, height int, gravity *GravityOptions) error {
4 imgWidth := c.Img.Width()
5 imgHeight := c.Img.Height()
6
7 if width <= imgWidth && height <= imgHeight {
8 return nil
9 }
10
11 if width <= 0 {
12 width = imgWidth
13 }
14 if height <= 0 {
15 height = imgHeight
16 }
17
18 offX, offY := calcPosition(width, height, imgWidth, imgHeight, gravity, c.DprScale, false)
19 return c.Img.Embed(width, height, offX, offY)
20}
21
22func (p *Processor) extend(c *Context) error {
23 if !c.PO.ExtendEnabled() {

Callers 2

extendMethod · 0.85
extendAspectRatioMethod · 0.85

Calls 4

calcPositionFunction · 0.85
EmbedMethod · 0.80
WidthMethod · 0.45
HeightMethod · 0.45

Tested by

no test coverage detected