backend_wazero.go (694B)
1 //go:build !transpiled && !nowasm 2 3 // This file is named for wazero rather than for wasm on purpose: wasm is a 4 // valid GOARCH, so a _wasm.go suffix would apply an implicit GOARCH=wasm 5 // build constraint and silently drop the backend from every ordinary build. 6 7 package webp 8 9 import ( 10 "image" 11 "io" 12 13 wasm "git.sr.ht/~jackmordaunt/go-libwebp/v2/lib/wasm/webp" 14 ) 15 16 func init() { 17 fallbackBackend = &backend{ 18 name: "wasm", 19 // ready is deliberately nil; see the backend type. wasm.Init is 20 // sync.Once-lazy, so the module compiles on first real use only. 21 encode: func(w io.Writer, m *image.NRGBA, q float32) error { 22 return wasm.EncodeImpl(w, m, q) 23 }, 24 decode: wasm.DecodeImpl, 25 } 26 }