mirror of
				https://github.com/imgproxy/imgproxy.git
				synced 2025-10-30 23:08:02 +02:00 
			
		
		
		
	Offsets for replicated watermarks
This commit is contained in:
		| @@ -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. | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user