webp

package
v1.8.19 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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.

Types

type ALPHHeader

type ALPHHeader struct {
	Preprocessing   uint8
	FilteringMethod uint8
	Compression     uint8
}

type ANIMHeader

type ANIMHeader struct {
	BackgroundColor color.Color
	LoopCount       uint16
}

type ANMFHeader

type ANMFHeader struct {
	FrameX         uint32
	FrameY         uint32
	FrameWidth     uint32
	FrameHeight    uint32
	FrameDuration  uint32
	AlphaBlend     bool
	DisposalBitSet bool
}

type AnimatedWEBP

type AnimatedWEBP struct {
	Frames []Frame
	Header ANIMHeader
	Config image.Config
}

AnimatedWEBP is the struct of a AnimatedWEBP container and the image data contained within.

func DecodeAnimated

func DecodeAnimated(r io.Reader) (*AnimatedWEBP, error)

type Frame

type Frame struct {
	Header ANMFHeader
	Frame  image.Image
}

type SubChunkReader

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

SubChunkReader helps in reading riff data from an existing chunk which are comprised of sub-chunks. A good example would be ANMF chunks of animated webp files. These chunks can contain headers, ALPH chunks and VP8 or VP8L chunks within the main riff data chunk.

func NewSubChunkReader

func NewSubChunkReader(r io.Reader) *SubChunkReader

func (SubChunkReader) Next

func (c SubChunkReader) Next() (riff.FourCC, io.Reader, uint32, error)

Next will return the FourCC, data, and data length of a subchunk. The io.Reader returned for data will not be the same as the provided reader and is safe to discord without fully reading the contents. Will return an error if the format is invalid or an underlying read operation fails.

type VP8XHeader

type VP8XHeader struct {
	ICCProfile   bool
	Alpha        bool
	ExifMetadata bool
	XmpMetadata  bool
	Animation    bool
	CanvasWidth  uint32
	CanvasHeight uint32
}

func DecodeVP8XHeader

func DecodeVP8XHeader(r io.Reader) (*VP8XHeader, error)

DecodeVP8XHeader will return the decoded VP8XHeader if this file is in the Extended File Format as defined by the webp specification. The VP8X chunk must be the first chunk of the file. If the first chunk of the file is anything else, it is not in the extended format and this will return a nil VP8XHeader. An error is only returned if the chunk is found, but invalid or a generic io.Reader error occurs.

Jump to

Keyboard shortcuts

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