1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-02-12 11:46:10 +02:00

Offsets for replicated watermarks

This commit is contained in:
DarthSim 2021-12-07 19:04:21 +06:00
parent 4c5ae587ed
commit 3e87bd683c
3 changed files with 11 additions and 1 deletions

View File

@ -8,6 +8,7 @@
### Change
- Improved ICC profiles handling.
- Proper error message when the deprecated basic URL format is used.
- Watermark offsets can be applied to replicated watermarks.
### Fix
- (pro) Fix parsing metadata of extended sequential JPEGs.

View File

@ -414,7 +414,7 @@ Puts watermark on the processed image.
* `soea`: south-east (bottom-right corner);
* `sowe`: south-west (bottom-left corner);
* `re`: replicate watermark to fill the whole image;
* `x_offset`, `y_offset` - (optional) specify watermark offset by X and Y axes. Not applicable to `re` position;
* `x_offset`, `y_offset` - (optional) specify watermark offset by X and Y axes. For `re` position, define spacing between tiles;
* `scale` - (optional) floating point number that defines watermark size relative to the resulting image size. When set to `0` or omitted, watermark size won't be changed.
Default: disabled

View File

@ -16,6 +16,7 @@ var watermarkPipeline = pipeline{
importColorProfile,
scale,
rotateAndFlip,
padding,
finalize,
}
@ -35,6 +36,14 @@ func prepareWatermark(wm *vips.Image, wmData *imagedata.ImageData, opts *options
po.Height = imath.Max(imath.Scale(imgHeight, opts.Scale), 1)
}
if opts.Replicate {
po.Padding.Enabled = true
po.Padding.Left = int(opts.Gravity.X / 2)
po.Padding.Right = int(opts.Gravity.X) - po.Padding.Left
po.Padding.Top = int(opts.Gravity.Y / 2)
po.Padding.Bottom = int(opts.Gravity.Y) - po.Padding.Top
}
if err := watermarkPipeline.Run(context.Background(), wm, po, wmData); err != nil {
return err
}