editing

package
v0.0.0-...-13d4585 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(changeType string, editor Editor)

Types

type Anchor

type Anchor string
const (
	AnchorTopLeft     Anchor = "top_left"
	AnchorTopRight    Anchor = "top_right"
	AnchorBottomLeft  Anchor = "bottom_left"
	AnchorBottomRight Anchor = "bottom_right"
	AnchorCenter      Anchor = "center"
)

type ApplyResult

type ApplyResult struct {
	Bytes       []byte
	MIMEType    string
	ChangesJSON []byte
}

ApplyResult holds the output of applying a ChangeSet.

func ApplyChangeSet

func ApplyChangeSet(cs ChangeSet, baseImageId string, fetchImage FetchImageFunc) (*ApplyResult, error)

ApplyChangeSet applies each Change in the ChangeSet in order, piping output bytes into the next step, then serializes the full ChangeSet.

type BlurEditor

type BlurEditor struct{}

func (*BlurEditor) Apply

func (e *BlurEditor) Apply(baseBytes []byte, cs Change, _ FetchImageFunc) ([]byte, string, error)

type BlurParams

type BlurParams struct {
	Region BlurRegion `json:"region"`
	Radius int        `json:"radius"`
}

type BlurRegion

type BlurRegion struct {
	X1 float64 `json:"x1"`
	Y1 float64 `json:"y1"`
	X2 float64 `json:"x2"`
	Y2 float64 `json:"y2"`
}

type Change

type Change struct {
	Type   string          `json:"type"`
	Params json.RawMessage `json:"params"`
}

Change represents a single named edit operation with its parameters.

func NewBlurChange

func NewBlurChange(params BlurParams) (Change, error)

func NewWatermarkChange

func NewWatermarkChange(params WatermarkParams) (Change, error)

NewWatermarkChange validates params and builds a Change.

type ChangeSet

type ChangeSet []Change

ChangeSet is an ordered list of changes applied atomically to produce one image.

type Editor

type Editor interface {
	Apply(base []byte, c Change, fetchImage FetchImageFunc) ([]byte, string, error)
}

Editor applies a Change to base image bytes, producing new image bytes.

func GetEditor

func GetEditor(changeType string) (Editor, error)

type FetchImageFunc

type FetchImageFunc func(id string) ([]byte, error)

FetchImageFunc retrieves image bytes by image ID.

func NewFetchImageFunc

func NewFetchImageFunc(
	storedImageRepo storage.StoredImageRepo,
	storageDefRepo storage.StorageDefRepo,
	maxBytes int64,
) FetchImageFunc

NewFetchImageFunc creates a FetchImageFunc that reads image bytes from storage.

type WatermarkEditor

type WatermarkEditor struct{}

func (*WatermarkEditor) Apply

func (e *WatermarkEditor) Apply(baseBytes []byte, cs Change, fetchImage FetchImageFunc) ([]byte, string, error)

type WatermarkParams

type WatermarkParams struct {
	OverlayImageID string            `json:"overlay_image_id"`
	Position       WatermarkPosition `json:"position"`
	Anchor         Anchor            `json:"anchor"`
	Opacity        float64           `json:"opacity"`
	Scale          float64           `json:"scale"`
}

type WatermarkPosition

type WatermarkPosition struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL