Documentation
¶
Index ¶
- Constants
- func ConvertBytes(data []byte, w io.Writer, opts *Options) error
- func ConvertFile(src, dst string, opts *Options) error
- func Decode(r io.Reader) (image.Image, error)
- func Encode(w io.Writer, img image.Image, opts *Options) error
- func EncodeAll(w io.Writer, ani *Animation, opts *Options) error
- func EncodeGIF(w io.Writer, g *gif.GIF, opts *Options) error
- func OutputPath(input, output string) (string, error)
- type Animation
- type Options
Constants ¶
View Source
const WebPMaxDimension = 16383
WebPMaxDimension is the maximum width or height supported by libwebp.
Variables ¶
This section is empty.
Functions ¶
func ConvertBytes ¶
ConvertBytes decodes image bytes and writes WebP to w.
func ConvertFile ¶
ConvertFile reads an image file and writes WebP to dst. Supported inputs: PNG, JPEG, BMP, GIF (including animated GIF).
func OutputPath ¶
OutputPath returns the default WebP output path for an input file.
Types ¶
type Animation ¶
type Animation struct {
Images []image.Image
Durations []uint // milliseconds per frame
Disposals []uint // 0=keep, 1=clear to background
LoopCount uint16 // 0 = infinite
BackgroundColor uint32 // BGRA
}
Animation holds frames for animated WebP output.
type Options ¶
type Options struct {
// Lossy enables VP8 lossy compression. Default is lossless VP8L.
Lossy bool
// Quality ranges from 0 (smallest) to 100 (best). Default 75.
Quality int
// Method controls encoder effort from 0 (fastest) to 6 (best compression).
// Default 4.
Method int
// NearLossless sets near-lossless bits for lossless mode (0-9).
// 0 means exact lossless. When Lossy is true and this is 0, quality drives compression.
NearLossless int
}
Options controls WebP encoding.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.