webp

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: BSD-3-Clause Imports: 7 Imported by: 1

Documentation

Overview

Package webp is an idiomatic Go wrapper for libwebp codec.

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.

func Encode

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

Encode an image into webp with default settings.

Types

type EncodeOption

type EncodeOption func(*Encoder)

EncodeOption configures the encoder.

func Lossless

func Lossless() EncodeOption

Lossless will ignore quality.

func Quality

func Quality(q float32) EncodeOption

Quality in the range (0,1]. Quality of 1 implies Lossless.

type Encoder

type Encoder struct {
	// Quality is in the range (0,1]. Values outside of this
	// range will be treated as 1. Default 0.9.
	Quality float32
	// Lossless indicates whether to use the lossless compression
	// strategy. If true, the Quality field is ignored.
	Lossless bool
}

Encoder implements webp encoding of an image.

func (*Encoder) Encode

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

Encode specified image as webp to w. If the image is NRGBA, the pixel buffer will be encoded directly. If the image is not NRGBA, it will be converted to NRGBA first.

Jump to

Keyboard shortcuts

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