master
DebuggerX 5 years ago
commit 45ec1ade2e

20
.gitignore vendored

@ -0,0 +1,20 @@
# Created by .ignore support plugin (hsz.mobi)
### Go template
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
vendor/
.idea/

@ -0,0 +1,5 @@
module webp2png_server
go 1.15
require golang.org/x/image v0.0.0-20200927104501-e162460cd6b5

@ -0,0 +1,3 @@
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5 h1:QelT11PB4FXiDEXucrfNckHoFxwt8USGY1ajP1ZF5lM=
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

@ -0,0 +1,40 @@
package main
import (
"golang.org/x/image/webp"
"image/png"
"io"
"log"
"os"
)
func main() {
var (
inFile io.Reader
outFile io.Writer
)
iFile, err := os.OpenFile("/home/debuggerx/Pictures/test.webp", os.O_RDONLY, 0)
if err != nil {
log.Fatal(err)
}
defer iFile.Close()
inFile = iFile
oFile, err := os.OpenFile("/home/debuggerx/Pictures/test.png", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 666)
if err != nil {
log.Fatal(err)
}
defer oFile.Close()
outFile = oFile
m, err := webp.Decode(inFile)
if err != nil {
log.Fatal(err)
}
err = png.Encode(outFile, m)
if err != nil {
log.Fatal(err)
}
}
Loading…
Cancel
Save