This is an automated archive.
The original was posted on /r/golang by /u/benjiro3000 on 2023-09-01 14:27:23+00:00.
Almost all of the Webp Encoding solutions for Go, seem to be CGo solutions that link to a C library.
Found this hidden little gem that uses CCGO. The cross compiler from cznic (know for native SQlite ~ ), that is used to compile C code to native Go version.
The source for the native libwebp is located here: https://git.sr.ht/~jackmordaunt/go-libwebp
Some code how to use it …
file, _ := os.Open(srcPath)
img, _ := jpeg.Decode(file)
output, _ := os.Create(dstPath)
defer output.Close()
_ := webp.Encode(output, img, webp.Quality(0.90))
So far it seems to be working properly. And best of all, no cGO needed! I hope this helps out people, who are searching for WebP encoders but are only finding the CGO/CLib variants.
You must log in or register to comment.