go-libwebp

Experimental translation from libwebp to Go source.
Log | Files | Refs | README | LICENSE

commit 82741fa8693af21b7c819edd160275b50302b60e
parent 8b9f86c3cf35e5319469a98f6a6a0a707757aadd
Author: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Date:   Wed,  3 Jan 2024 16:37:13 +0800

webp: use webp decoder

Instead of the stdlib decoder.

Signed-off-by: Jack Mordaunt <jackmordaunt.dev@gmail.com>

Diffstat:
Mwebp/decode.go | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/webp/decode.go b/webp/decode.go @@ -1,15 +1,21 @@ package webp import ( + "fmt" "image" "io" + transpiled "git.sr.ht/~jackmordaunt/go-libwebp/lib/transpiled/webp" stdwebp "golang.org/x/image/webp" ) // Decode reads a WEBP image from r and returns it as an image.Image. func Decode(r io.Reader) (image.Image, error) { - return stdwebp.Decode(r) + by, err := io.ReadAll(r) + if err != nil { + return nil, fmt.Errorf("buffering data: %w", err) + } + return transpiled.DecodeImpl(by) } // DecodeConfig returns the color model and dimensions of a WEBP image without