images

package
v0.2.50 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

These encoding hints are currently only relevant for Webp.

View Source
var ImageFilters = map[string]gift.Resampling{
	strings.ToLower("NearestNeighbor"):   gift.NearestNeighborResampling,
	strings.ToLower("Box"):               gift.BoxResampling,
	strings.ToLower("Linear"):            gift.LinearResampling,
	strings.ToLower("Hermite"):           hermiteResampling,
	strings.ToLower("MitchellNetravali"): mitchellNetravaliResampling,
	strings.ToLower("CatmullRom"):        catmullRomResampling,
	strings.ToLower("BSpline"):           bSplineResampling,
	strings.ToLower("Gaussian"):          gaussianResampling,
	strings.ToLower("Lanczos"):           gift.LanczosResampling,
	strings.ToLower("Hann"):              hannResampling,
	strings.ToLower("Hamming"):           hammingResampling,
	strings.ToLower("Blackman"):          blackmanResampling,
	strings.ToLower("Bartlett"):          bartlettResampling,
	strings.ToLower("Welch"):             welchResampling,
	strings.ToLower("Cosine"):            cosineResampling,
}

Functions

func AddColorToPalette

func AddColorToPalette(c color.Color, p color.Palette) color.Palette

AddColorToPalette adds c as the first color in p if not already there. Note that it does no additional checks, so callers must make sure that the palette is valid for the relevant format.

func ColorToHexString

func ColorToHexString(c color.Color) string

ColorToHexString converts a color to a hex string.

func GetContentType added in v0.1.27

func GetContentType(extension string) string

func GetImageDimensions added in v0.1.27

func GetImageDimensions(absPath string) (int, int, error)

func HexStringToColor

func HexStringToColor(s string) (color.Color, error)

func ReplaceColorInPalette

func ReplaceColorInPalette(c color.Color, p color.Palette)

ReplaceColorInPalette will replace the color in palette p closest to c in Euclidean R,G,B,A space with c.

Types

type Cache added in v0.1.27

type Cache = cache.Auto

Cache is an image cache

func NewCache added in v0.1.27

func NewCache(tracer *tracing.Tracer, cacheProvider cache.Provider, storageProvider storage.Provider) *Cache

NewCache instantiates a new cache

type OutputFormat added in v0.1.27

type OutputFormat int

OutputFormat is the image format to output to

const (
	// JPEG represents the JPEG format
	JPEG OutputFormat = iota
	// WebP represents the WebP format
	WebP
)

func GetOutputFormat added in v0.1.27

func GetOutputFormat(extension string) OutputFormat

type Processor added in v0.1.27

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

Processor is an image processor that uses vips to process images

func New added in v0.1.27

func New(ctx context.Context, log *logger.Logger, tracer *tracing.Tracer, workers int, cache *Cache) (*Processor, error)

New initializes a new processor instance

func (*Processor) ProcessImage added in v0.1.27

func (p *Processor) ProcessImage(ctx context.Context, task *Task) (processedImage []byte, err error)

ProcessImage loads an image from a byte buffer, processes it, and returns a buffer containing the processed image

func (*Processor) Shutdown added in v0.1.27

func (p *Processor) Shutdown()

Shutdown shuts down the image processor and deinitialises vips

type Task added in v0.1.27

type Task struct {
	ImageID        string
	Width          int
	Height         int
	ApplyBlur      bool
	BlurAmount     int
	ApplyGrayscale bool
	UserComment    string
	OutputFormat   OutputFormat
}

Task is an image processing task

func NewTask added in v0.1.27

func NewTask(imageID string, width int, height int, userComment string, format OutputFormat) *Task

NewTask creates a new image processing task

func (*Task) Blur added in v0.1.27

func (t *Task) Blur(amount int) *Task

Blur applies gaussian blur to the image

func (*Task) Grayscale added in v0.1.27

func (t *Task) Grayscale() *Task

Grayscale turns the image into grayscale

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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