go-libwebp

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

commit 156db145c43d831d7b9b5378e02b23503ebd35bd
parent 0bdc61d161006630b031bee57a0c9034712bd323
Author: Jack Mordaunt <jackmordaunt.dev@gmail.com>
Date:   Thu, 29 Feb 2024 15:14:37 +0800

webp.Decode: attempt to use shared library if available

Mirror the Encode logic, where we try to use a shared object if one is
available.

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

Diffstat:
Mwebp/decode.go | 4++++
1 file changed, 4 insertions(+), 0 deletions(-)

diff --git a/webp/decode.go b/webp/decode.go @@ -5,6 +5,7 @@ import ( "image" "io" + dynamic "git.sr.ht/~jackmordaunt/go-libwebp/lib/dynamic/webp" transpiled "git.sr.ht/~jackmordaunt/go-libwebp/lib/transpiled/webp" stdwebp "golang.org/x/image/webp" ) @@ -15,6 +16,9 @@ func Decode(r io.Reader) (image.Image, error) { if err != nil { return nil, fmt.Errorf("buffering data: %w", err) } + if err := dynamic.Init(); err == nil { + return dynamic.DecodeImpl(by) + } return transpiled.DecodeImpl(by) }