1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-12-03 23:19:17 +02:00

Implement padding option (#358)

* Implement padding option

* Move padding `embed` to the right place

* Move padding `embed` to the right place

* Use general background option instead of specific padding's one

* Make padding options css-like and fully optional

* Add docs for new padding option

* Return error if padding embed fails

* Make padding outbounds and apply dpr for it

Co-authored-by: Ilya Melnitskiy <melnitskiy_i_m@onyx-team.com>
This commit is contained in:
ILYA
2020-04-09 12:43:56 +03:00
committed by GitHub
parent 026fb617b1
commit 12b415c9bd
3 changed files with 90 additions and 0 deletions

View File

@@ -453,6 +453,22 @@ func transformImage(ctx context.Context, img *vipsImage, data []byte, po *proces
}
}
if po.Padding.Enabled {
paddingTop := scaleInt(po.Padding.Top, po.Dpr)
paddingRight := scaleInt(po.Padding.Right, po.Dpr)
paddingBottom := scaleInt(po.Padding.Bottom, po.Dpr)
paddingLeft := scaleInt(po.Padding.Left, po.Dpr)
if err = img.Embed(
img.Width()+paddingLeft+paddingRight,
img.Height()+paddingTop+paddingBottom,
paddingLeft,
paddingTop,
po.Background,
); err != nil {
return err
}
}
checkTimeout(ctx)
if po.Watermark.Enabled && watermark != nil {