func TestEncodeRGBA(t *testing.T) { img := util.ReadPNG("yellow-rose-3.png") config := webp.Config{ Preset: webp.PresetDefault, Quality: 100, Method: 6, } f := util.CreateFile("TestEncodeRGBA.webp") w := bufio.NewWriter(f) defer func() { w.Flush() f.Close() }() if err := webp.EncodeRGBA(w, img, config); err != nil { t.Errorf("Got Error: %v", err) return } }
func main() { img := util.ReadPNG("cosmos.png") // Create file and buffered writer io := util.CreateFile("encoded_cosmos.webp") w := bufio.NewWriter(io) defer func() { w.Flush() io.Close() }() config := webp.Config{ Preset: webp.PresetDefault, Quality: 90, Method: 6, } // Encode into WebP if err := webp.EncodeRGBA(w, img.(*image.RGBA), config); err != nil { panic(err) } }