Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶ added in v1.0.0
Decode reads a WebP image from the provided io.Reader and returns it as an image.Image.
This function is a wrapper around the underlying WebP decode package (golang.org/x/image/webp). It supports both lossy and lossless WebP formats, decoding the image accordingly.
Parameters:
r - The source io.Reader containing the WebP encoded image.
Returns:
The decoded image as image.Image or an error if the decoding fails.
func DecodeConfig ¶ added in v1.0.0
DecodeConfig reads the image configuration from the provided io.Reader without fully decoding the image.
This function is a wrapper around the underlying WebP decode package (golang.org/x/image/webp) and provides access to the image's metadata, such as its dimensions and color model. It is useful for obtaining image information before performing a full decode.
Parameters:
r - The source io.Reader containing the WebP encoded image.
Returns:
An image.Config containing the image's dimensions and color model, or an error if the configuration cannot be retrieved
func Encode ¶
Encode writes the provided image.Image to the specified io.Writer in WebP format.
This function always encodes the image using VP8L (lossless WebP). If `UseExtendedFormat` is enabled, it wraps the VP8L frame inside a VP8X container, allowing the use of metadata such as EXIF, ICC color profiles, or XMP metadata.
Note: VP8L already supports transparency, so VP8X is **not required** for alpha support.
Parameters:
w - The destination writer where the encoded WebP image will be written.
img - The input image to be encoded.
o - Pointer to Options containing encoding settings:
- UseExtendedFormat: If true, wraps the image in a VP8X container to enable
extended WebP features like metadata.
Returns:
An error if encoding fails or writing to the io.Writer encounters an issue.
Types ¶
type Options ¶ added in v0.9.3
type Options struct {
UseExtendedFormat bool
}
Options holds configuration settings for WebP encoding.
Currently, it provides a flag to enable the extended WebP format (VP8X), which allows for metadata support such as EXIF, ICC color profiles, and XMP.
Fields:
- UseExtendedFormat: If true, wraps the VP8L frame inside a VP8X container to enable metadata support. This does not affect image compression or encoding itself, as VP8L remains the encoding format.




