You've already forked imgproxy
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:
16
process.go
16
process.go
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user