processor

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractPalette added in v0.5.0

func ExtractPalette(r io.Reader) ([]string, error)

ExtractPalette extracts dominant colors from the image.

func GenerateAnimatedThumbnail added in v0.5.0

func GenerateAnimatedThumbnail(videoURL string, duration string, width int, height int, format string) (*bytes.Buffer, error)

GenerateAnimatedThumbnail generates a 3-second animated thumbnail for a video file using ffmpeg. It extracts 3 seconds from the beginning (or timestamp).

func GenerateStoryboard added in v0.5.0

func GenerateStoryboard(videoURL string, interval string, cols, rows int, width int) (*bytes.Buffer, error)

GenerateStoryboard generates a storyboard image (grid of frames) for the video. interval: timestamp interval between frames (default "1") cols, rows: grid dimensions

func GenerateThumbnail added in v0.4.0

func GenerateThumbnail(videoURL string, timestamp string) (*bytes.Buffer, error)

GenerateThumbnail generates a thumbnail for a video file using ffmpeg. It returns a buffer containing the image data (JPEG).

func LoadCascade added in v0.4.0

func LoadCascade(path string) error

LoadCascade loads the pigo cascade file from the given path.

func Process

func Process(ctx context.Context, r io.Reader, opts ImageOptions, wmImg image.Image, wmOpacity float64, originalKey string) (*bytes.Buffer, error)

Process decodes, transforms, watermarks, and encodes the image. Note: We cannot easily pass context here without changing the signature, but typically Process is called from HandleRequest which has a context. Ideally Process should take context. For now we use Background if we can't change signature, BUT looking at where Process is called, it might be inside HandleRequest which likely has context.

func SmartCrop added in v0.5.0

func SmartCrop(img *vips.ImageRef, width, height int, detector ObjectDetector) error

SmartCrop applies the smart crop logic.

Types

type AiDetector added in v0.5.0

type AiDetector struct {
	ModelPath string
}

AiDetector uses ONNX Runtime to detect objects. It requires an ONNX model file path (e.g. YOLOv8n) and the ONNX Runtime shared library.

func (*AiDetector) Detect added in v0.5.0

func (d *AiDetector) Detect(img *vips.ImageRef) (*image.Rectangle, error)

type EntropyDetector added in v0.5.0

type EntropyDetector struct{}

EntropyDetector uses Shannon entropy to find the most "interesting" part of the image.

func (*EntropyDetector) Detect added in v0.5.0

func (d *EntropyDetector) Detect(img *vips.ImageRef) (*image.Rectangle, error)

type ImageOptions

type ImageOptions struct {
	Width            int
	Height           int
	Fit              string // cover, contain, fill, inside
	Format           string // jpeg, png, webp, jxl
	Quality          int
	Focus            string // smart, face
	Text             string
	TextColor        string
	TextSize         float64
	TextOpacity      float64
	Font             string
	Effect           string
	Brightness       float64
	Contrast         float64
	Blurhash         bool
	SmartCompression bool
	Animated         bool
	Page             int
}

type ObjectDetector added in v0.5.0

type ObjectDetector interface {
	// Detect returns a crop rectangle focused on the main object.
	// If detection fails or no object found, it returns the input rect or a center rect.
	Detect(img *vips.ImageRef) (*image.Rectangle, error)
}

ObjectDetector defines the interface for object detection logic.

Jump to

Keyboard shortcuts

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