Help us shape the future of Go! Take the 2026 Go Developer Survey

webp

package
v1.9.5 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package webp encodes images in the lossless WebP (VP8L) format.

WebP's lossless mode routinely produces smaller files than PNG for the same pixels. This encoder implements the subtract-green transform, LZ77 backward references, a colour cache and canonical Huffman coding. It does not implement the predictor or cross-colour transforms, so on photographic content it will not match libwebp; on flat, palettised or synthetic images it is competitive.

Lossy WebP (VP8) encoding is out of scope: that is a separate intra-frame video codec rather than a variation on this one.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

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

Encode writes m to w in the lossless WebP format.

The image is encoded exactly: decoding the result reproduces the original pixels. An image wider or taller than 16384 pixels cannot be represented and returns an error.

func EncodeToBytes

func EncodeToBytes(m image.Image) ([]byte, error)

EncodeToBytes returns the lossless WebP encoding of m.

It is the allocation-friendly form of Encode for callers that need the bytes themselves, such as size comparisons against another encoder.

Types

This section is empty.

Jump to

Keyboard shortcuts

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