Decode PNG from File in Go

Posted by yhuang
Public (Editable by Users)
Go
Edit
package main

import (
	"fmt"
	"image/png"
	"os"
)

func main() {
	file, err := os.Open("test.png")
	if err != nil {
		panic(err)
	}
	defer file.Close()

	image, err := png.Decode(file)
	if err != nil {
		panic(err)
	}
	fmt.Println(image)
}