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 ¶
- type AdaptiveCompressStep
- type CropStep
- type DecodeStep
- type EncodeStep
- type FormatStep
- type GrayscaleStep
- type Pipeline
- func (p *Pipeline) AddHook(h core.Hook) *Pipeline
- func (p *Pipeline) Clone() *Pipeline
- func (p *Pipeline) Run(ctx context.Context, img *core.ImageData) (*core.ImageData, map[string]time.Duration, error)
- func (p *Pipeline) Use(s ...core.Step) *Pipeline
- func (p *Pipeline) WithRetry(maxRetries int, delay time.Duration) *Pipeline
- type QualityStep
- type ResizeStep
- type StripEXIFStep
- type ThumbnailStep
- type WatermarkStep
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) Name ¶
func (s *AdaptiveCompressStep) Name() string
type CropStep ¶
type CropStep struct {
X, Y, Width, Height int
}
CropStep crops a rectangle from the image.
type DecodeStep ¶
DecodeStep decodes raw bytes in img.Data into an image.Image.
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) Name ¶
func (s *EncodeStep) Name() string
type FormatStep ¶
FormatStep converts the image to a new format (sets img.Format for the subsequent encode step to pick up).
func (*FormatStep) Name ¶
func (s *FormatStep) Name() string
type GrayscaleStep ¶
type GrayscaleStep struct{}
GrayscaleStep converts the image to grayscale.
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 (*Pipeline) Clone ¶
Clone returns a shallow copy of the pipeline so templates can be reused safely across goroutines.
func (*Pipeline) Run ¶
func (p *Pipeline) Run(ctx context.Context, img *core.ImageData) (*core.ImageData, map[string]time.Duration, error)
Run executes the pipeline on img. It returns the final ImageData and a map of per-step timing observations.
type QualityStep ¶
type QualityStep struct {
Quality int
}
QualityStep records the desired encode quality. The actual quality is consumed by EncodeStep.
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) Name ¶
func (s *ResizeStep) Name() string
type StripEXIFStep ¶
type StripEXIFStep struct{}
StripEXIFStep removes EXIF metadata from the ImageData.
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) Name ¶
func (s *ThumbnailStep) Name() string
type WatermarkStep ¶
WatermarkStep composites a watermark image onto the top-left corner.
func (*WatermarkStep) Name ¶
func (s *WatermarkStep) Name() string