golang webp图片转jpg

package main

import (
    "bytes"
    "image/jpeg"
    "io/ioutil"
    "log"
    "os"

    "github.com/chai2010/webp"
)

func main() {
    // var buf bytes.Buffer
    var data []byte
    var err error

    // Load file data
    if data, err = ioutil.ReadFile("./aaaa.webp"); err != nil {
        log.Println(err)
    }

    // Decode webp
    m, err := webp.Decode(bytes.NewReader(data))
    if err != nil {
        log.Println(err)
    }

    //生成新图片new.jpg,并设置图片质量..
    imgw, _ := os.Create("./aaaa.jpg")
    jpeg.Encode(imgw, m, &jpeg.Options{100})

}

添加新评论