encode

package
v0.49.8 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AVIF_HEADER_MINI      = 1
	AVIF_RESULT_OK        = 0
	AVIF_QUALITY_LOSSLESS = int32(100)

	AVIF_SPEED_DEFAULT = int32(-1)
	AVIF_SPEED_SLOWEST = int32(0)
	AVIF_SPEED_FASTEST = int32(10)
)
View Source
const (
	WebPKMin                 = 0
	WebPKMax                 = 0
	DefaultScreenDelayMillis = 50
	DefaultMaxAgeSeconds     = 0 // 0 => no max age, cache forever!
)
View Source
const (
	WebPLevelDefault = int32(6)
)

Variables

View Source
var ErrInvalidColorFilter = fmt.Errorf("invalid color filter")

Functions

func ColorFilterStrings

func ColorFilterStrings() []string

ColorFilterStrings returns a slice of all String values of the enum

func SetWebPLevel added in v0.48.0

func SetWebPLevel(level int32)

Types

type ColorFilter

type ColorFilter uint8
const (
	ColorNone ColorFilter = iota
	ColorDimmed
	ColorRedShift
	ColorWarm
	ColorSunset
	ColorSepia
	ColorVintage
	ColorDusk
	ColorCool
	ColorBW
	ColorIce
	ColorMoonlight
	ColorNeon
	ColorPastel
)

func ColorFilterString

func ColorFilterString(s string) (ColorFilter, error)

ColorFilterString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func ColorFilterValues

func ColorFilterValues() []ColorFilter

ColorFilterValues returns all values of the enum

func (ColorFilter) Description

func (f ColorFilter) Description() (string, error)

func (ColorFilter) ImageFilter

func (i ColorFilter) ImageFilter() (ImageFilter, error)

func (ColorFilter) IsAColorFilter

func (i ColorFilter) IsAColorFilter() bool

IsAColorFilter returns "true" if the value is listed in the enum definition. "false" otherwise

func (ColorFilter) MarshalText

func (i ColorFilter) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for ColorFilter

func (ColorFilter) String

func (i ColorFilter) String() string

func (*ColorFilter) UnmarshalText

func (i *ColorFilter) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for ColorFilter

type ImageFilter

type ImageFilter func(image.Image) (image.Image, error)

func Chain

func Chain(filters ...ImageFilter) ImageFilter

Chain applies a sequence of ImageFilters in order.

func ColorMatrix

func ColorMatrix(matrix [3][3]float32) ImageFilter

ColorMatrix applies a 3x3 color transformation matrix to the RGB values of an image.

func Magnify

func Magnify(factor int) ImageFilter

Magnify enlarges an image by an integer factor.

type RenderFilters

type RenderFilters struct {
	Magnify     int         `json:"magnify,omitempty"`
	ColorFilter ColorFilter `json:"color_filter,omitempty"`
}

func (RenderFilters) String

func (f RenderFilters) String() string

type Screens

type Screens struct {
	MaxAge            int32
	ShowFullAnimation bool
	// contains filtered or unexported fields
}

func ScreensFromImages

func ScreensFromImages(images ...image.Image) *Screens

func ScreensFromRoots

func ScreensFromRoots(roots []render.Root, width int, height int) *Screens

func (*Screens) Empty

func (s *Screens) Empty() bool

Empty returns true if there are no render roots or images in this screen.

func (*Screens) EncodeAVIF

func (s *Screens) EncodeAVIF(maxDuration time.Duration, filters ...ImageFilter) ([]byte, error)

Renders screens to AVIF. Optionally pass filters for postprocessing each individual frame.

func (*Screens) EncodeGIF

func (s *Screens) EncodeGIF(maxDuration time.Duration, filters ...ImageFilter) ([]byte, error)

Renders a screen to GIF. Optionally pass filters for postprocessing each individual frame.

func (*Screens) EncodeWebP

func (s *Screens) EncodeWebP(maxDuration time.Duration, filters ...ImageFilter) ([]byte, error)

Renders a screen to WebP. Optionally pass filters for postprocessing each individual frame.

func (*Screens) Hash

func (s *Screens) Hash() ([]byte, error)

Hash returns a hash of the render roots for this screen. This can be used for testing whether two render trees are exactly equivalent, without having to do the actual rendering.

Jump to

Keyboard shortcuts

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