IMG-49: Get rid of global watermark image and fetcher (#1515)

* Get rid of global watermark image

* imagedata.Factory, removed global Fetcher
This commit is contained in:
Victor Sokolov
2025-09-05 16:22:57 +02:00
committed by GitHub
parent 6f11d950fb
commit 37a6ea2bf7
20 changed files with 270 additions and 197 deletions

View File

@@ -3,6 +3,7 @@ package processing
import (
"context"
"github.com/imgproxy/imgproxy/v3/auximageprovider"
"github.com/imgproxy/imgproxy/v3/imagedata"
"github.com/imgproxy/imgproxy/v3/imagetype"
"github.com/imgproxy/imgproxy/v3/options"
@@ -15,6 +16,9 @@ type pipelineContext struct {
imgtype imagetype.Type
// The watermark image provider, if any watermarking is to be done.
watermarkProvider auximageprovider.Provider
trimmed bool
srcWidth int
@@ -67,7 +71,13 @@ type pipelineContext struct {
type pipelineStep func(pctx *pipelineContext, img *vips.Image, po *options.ProcessingOptions, imgdata imagedata.ImageData) error
type pipeline []pipelineStep
func (p pipeline) Run(ctx context.Context, img *vips.Image, po *options.ProcessingOptions, imgdata imagedata.ImageData) error {
func (p pipeline) Run(
ctx context.Context,
img *vips.Image,
po *options.ProcessingOptions,
imgdata imagedata.ImageData,
watermark auximageprovider.Provider,
) error {
pctx := pipelineContext{
ctx: ctx,
@@ -77,7 +87,8 @@ func (p pipeline) Run(ctx context.Context, img *vips.Image, po *options.Processi
dprScale: 1.0,
vectorBaseScale: 1.0,
cropGravity: po.Crop.Gravity,
cropGravity: po.Crop.Gravity,
watermarkProvider: watermark,
}
if pctx.cropGravity.Type == options.GravityUnknown {