pipeline

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package pipeline wires steps together, runs hooks, and handles retries.

Package pipeline provides built-in pipeline steps and the extensible Step API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdaptiveCompressStep

type AdaptiveCompressStep struct {
	Registry        core.Registry
	TargetSizeBytes int64
	MinQuality      int
	MaxQuality      int
	StepSize        int
}

AdaptiveCompressStep iteratively adjusts JPEG/WebP quality to hit a target file size.

func (*AdaptiveCompressStep) Execute

func (*AdaptiveCompressStep) Name

func (s *AdaptiveCompressStep) Name() string

type CropStep

type CropStep struct {
	X, Y, Width, Height int
}

CropStep crops a rectangle from the image.

func (*CropStep) Execute

func (s *CropStep) Execute(ctx context.Context, img *core.ImageData) (*core.ImageData, error)

func (*CropStep) Name

func (s *CropStep) Name() string

type DecodeStep

type DecodeStep struct {
	Registry core.Registry
}

DecodeStep decodes raw bytes in img.Data into an image.Image.

func (*DecodeStep) Execute

func (s *DecodeStep) Execute(ctx context.Context, img *core.ImageData) (*core.ImageData, error)

func (*DecodeStep) Name

func (s *DecodeStep) Name() string

type EncodeStep

type EncodeStep struct {
	Registry    core.Registry
	BaseOptions core.EncodeOptions
}

EncodeStep serialises the image.Image into encoded bytes using the registry.

func (*EncodeStep) Execute

func (s *EncodeStep) Execute(ctx context.Context, img *core.ImageData) (*core.ImageData, error)

func (*EncodeStep) Name

func (s *EncodeStep) Name() string

type FormatStep

type FormatStep struct {
	Format core.Format
}

FormatStep converts the image to a new format (sets img.Format for the subsequent encode step to pick up).

func (*FormatStep) Execute

func (s *FormatStep) Execute(_ context.Context, img *core.ImageData) (*core.ImageData, error)

func (*FormatStep) Name

func (s *FormatStep) Name() string

type GrayscaleStep

type GrayscaleStep struct{}

GrayscaleStep converts the image to grayscale.

func (*GrayscaleStep) Execute

func (s *GrayscaleStep) Execute(_ context.Context, img *core.ImageData) (*core.ImageData, error)

func (*GrayscaleStep) Name

func (s *GrayscaleStep) Name() string

type Pipeline

type Pipeline struct {
	// contains filtered or unexported fields
}

Pipeline executes a sequence of Steps with hook and retry support.

func New

func New() *Pipeline

New returns an empty Pipeline.

func (*Pipeline) AddHook

func (p *Pipeline) AddHook(h core.Hook) *Pipeline

AddHook registers an observer.

func (*Pipeline) Clone

func (p *Pipeline) Clone() *Pipeline

Clone returns a shallow copy of the pipeline so templates can be reused safely across goroutines.

func (*Pipeline) Run

Run executes the pipeline on img. It returns the final ImageData and a map of per-step timing observations.

func (*Pipeline) Use

func (p *Pipeline) Use(s ...core.Step) *Pipeline

Use appends a step to the pipeline. Returns the same Pipeline for chaining.

func (*Pipeline) WithRetry

func (p *Pipeline) WithRetry(maxRetries int, delay time.Duration) *Pipeline

WithRetry sets the maximum retry count and delay for transient failures.

type QualityStep

type QualityStep struct {
	Quality int
}

QualityStep records the desired encode quality. The actual quality is consumed by EncodeStep.

func (*QualityStep) Execute

func (s *QualityStep) Execute(_ context.Context, img *core.ImageData) (*core.ImageData, error)

func (*QualityStep) Name

func (s *QualityStep) Name() string

type ResizeStep

type ResizeStep struct {
	Width, Height int
	// Resampler controls quality vs speed.  Defaults to draw.BiLinear.
	Resampler xdraw.Interpolator
}

ResizeStep resizes the image to the given dimensions, preserving aspect ratio when one axis is 0.

func (*ResizeStep) Execute

func (s *ResizeStep) Execute(ctx context.Context, img *core.ImageData) (*core.ImageData, error)

func (*ResizeStep) Name

func (s *ResizeStep) Name() string

type StripEXIFStep

type StripEXIFStep struct{}

StripEXIFStep removes EXIF metadata from the ImageData.

func (*StripEXIFStep) Execute

func (s *StripEXIFStep) Execute(_ context.Context, img *core.ImageData) (*core.ImageData, error)

func (*StripEXIFStep) Name

func (s *StripEXIFStep) Name() string

type ThumbnailStep

type ThumbnailStep struct {
	Size int // square size in pixels
}

ThumbnailStep is a convenience step that combines Resize with square cropping.

func (*ThumbnailStep) Execute

func (s *ThumbnailStep) Execute(ctx context.Context, img *core.ImageData) (*core.ImageData, error)

func (*ThumbnailStep) Name

func (s *ThumbnailStep) Name() string

type WatermarkStep

type WatermarkStep struct {
	Watermark image.Image
	OffsetX   int
	OffsetY   int
}

WatermarkStep composites a watermark image onto the top-left corner.

func (*WatermarkStep) Execute

func (s *WatermarkStep) Execute(_ context.Context, img *core.ImageData) (*core.ImageData, error)

func (*WatermarkStep) Name

func (s *WatermarkStep) Name() string

Jump to

Keyboard shortcuts

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