Documentation
¶
Index ¶
- func ExtractPalette(r io.Reader) ([]string, error)
- func GenerateAnimatedThumbnail(videoURL string, duration string, width int, height int, format string) (*bytes.Buffer, error)
- func GenerateStoryboard(videoURL string, interval string, cols, rows int, width int) (*bytes.Buffer, error)
- func GenerateThumbnail(videoURL string, timestamp string) (*bytes.Buffer, error)
- func LoadCascade(path string) error
- func Process(ctx context.Context, r io.Reader, opts ImageOptions, wmImg image.Image, ...) (*bytes.Buffer, error)
- func SmartCrop(img *vips.ImageRef, width, height int, detector ObjectDetector) error
- type AiDetector
- type EntropyDetector
- type ImageOptions
- type ObjectDetector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractPalette ¶ added in v0.5.0
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
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
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.
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.
type EntropyDetector ¶ added in v0.5.0
type EntropyDetector struct{}
EntropyDetector uses Shannon entropy to find the most "interesting" part of the image.
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.