avif

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 20 Imported by: 1

README

avif

Status Go Reference

Go encoder/decoder for AV1 Image File Format (AVIF) with support for animated AVIF images (decode only).

Based on libavif and aom compiled to WASM and used with wazero runtime (CGo-free).

The library will first try to use a dynamic/shared library (if installed) via purego and will fall back to WASM.

Documentation

Overview

Package avif implements an AVIF image decoder based on libavif compiled to WASM.

Index

Constants

View Source
const DefaultQuality = 60

DefaultQuality is the default quality encoding parameter.

View Source
const DefaultSpeed = 10

DefaultSpeed is the default speed encoding parameter.

Variables

View Source
var (
	ErrMemRead  = errors.New("avif: mem read failed")
	ErrMemWrite = errors.New("avif: mem write failed")
	ErrDecode   = errors.New("avif: decode failed")
	ErrEncode   = errors.New("avif: encode failed")
)

Errors .

Functions

func Decode

func Decode(r io.Reader) (image.Image, error)

Decode reads a AVIF image from r and returns it as an image.Image.

func DecodeConfig

func DecodeConfig(r io.Reader) (image.Config, error)

DecodeConfig returns the color model and dimensions of a AVIF image without decoding the entire image.

func Dynamic added in v0.2.1

func Dynamic() error

Dynamic returns error (if there was any) during opening dynamic/shared library.

func Encode added in v0.2.5

func Encode(w io.Writer, m image.Image, o ...Options) error

Encode writes the image m to w with the given options.

Types

type AVIF added in v0.1.5

type AVIF struct {
	// Decoded images, NRGBA or NRGBA64.
	Image []image.Image
	// Delay times, one per frame, in seconds.
	Delay []float64
}

AVIF represents the possibly multiple images stored in a AVIF file.

func DecodeAll added in v0.1.4

func DecodeAll(r io.Reader) (*AVIF, error)

DecodeAll reads a AVIF image from r and returns the sequential frames and timing information.

type Options added in v0.2.5

type Options struct {
	// Quality in the range [0,100]. Quality of 100 implies lossless. Default is 60.
	Quality int
	// Quality in the range [0,100].
	QualityAlpha int
	// Speed in the range [0,10]. Slower should make for a better quality image in less bytes.
	Speed int
	// Chroma subsampling, 444|422|420.
	ChromaSubsampling image.YCbCrSubsampleRatio
}

Options are the encoding parameters.

Jump to

Keyboard shortcuts

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