webp

package module
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 18 Imported by: 15

README

webp

Status Go Reference

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

Based on libwebp 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 webp implements an WEBP image decoder based on libwebp compiled to WASM.

Index

Constants

View Source
const DefaultQuality = 75

DefaultQuality is the default quality encoding parameter.

Variables

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

Errors .

Functions

func Decode

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

Decode reads a WEBP 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 WEBP image without decoding the entire image.

func Dynamic added in v0.2.2

func Dynamic() error

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

func Encode added in v0.2.4

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

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

Types

type Options added in v0.2.4

type Options struct {
	// Quality in the range [0,100]. Quality of 100 implies Lossless. Default is 75.
	Quality int
	// Lossless indicates whether to use the lossless compression. Lossless will ignore quality.
	Lossless bool
}

Options are the encoding parameters.

type WEBP

type WEBP struct {
	// Decoded images.
	Image []*image.NRGBA
	// Delay times, one per frame, in milliseconds.
	Delay []int
}

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

func DecodeAll

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

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

Jump to

Keyboard shortcuts

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