Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package main
import (
"image"
_ "image/jpeg"
_ "image/png"
"log"
"os"
"github.com/chai2010/webp"
)
func main() {
ifile := os.Args[1]
ofile := os.Args[2]
f, err := os.Open(ifile)
defer f.Close()
if err != nil {
log.Fatal("error during open: ", err)
}
img, _, err := image.Decode(f)
if err != nil {
log.Fatal("error decoding file: ", err)
}
out, err := os.Create(ofile)
defer out.Close()
if err != nil {
log.Fatal("Unable to create a file: ", err)
}
webp.Encode(out, img, &webp.Options{true, 90})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment