PHP » GoLang |
login |
register |
about
|
getimagesizegetimagesize[code=golang] import ( "image" _ "image/gif" _ "image/jpeg" _ "image/png" "os" ) func GetImageSize(filename string) (int, int, error) { file, err := os.Open(filename) if err != nil { return 0, 0, err } defer file.Close() config, _, err := image.DecodeConfig(file) if err != nil { return 0, 0, err } return config.Width, config.Height, nil } [/code] |