Golang image.gif.DecodeConfig function example
package image/gif
Golang image.gif.DecodeConfig function usage example
package main
import (
"fmt"
"image/gif"
"os"
)
func main() {
imgfile, err := os.Open("./img.gif")
if err != nil {
fmt.Println("img.gif file not found!")
os.Exit(1)
}
defer imgfile.Close()
imgCfg, err := gif.DecodeConfig(imgfile)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
cmodel := imgCfg.ColorModel
width := imgCfg.Width
height := imgCfg.Height
fmt.Println(cmodel)
fmt.Println(width)
fmt.Println(height)
}
Reference :
Advertisement
Something interesting
Tutorials
+10.5k Swift : Convert (cast) String to Integer
+7.3k Golang : How to convert strange string to JSON with json.MarshalIndent
+32.7k Golang : Regular Expression for alphanumeric and underscore
+10.5k RPM : error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery
+9k Golang : How to use Gorilla webtoolkit context package properly
+7.4k Golang : Example of custom handler for Gorilla's Path usage.
+15k Golang : How do I get the local IP (non-loopback) address ?
+33.8k Golang : convert(cast) bytes to string
+13.8k Golang : unknown escape sequence error
+23.5k Golang : Get ASCII code from a key press(cross-platform) example
+12.3k Golang : Flush and close file created by os.Create and bufio.NewWriter example
+6.2k Golang : Extract XML attribute data with attr field tag example