go-common/app/interface/main/upload/service/pixel.go
2019-04-22 18:49:16 +08:00

19 lines
316 B
Go

package service
import (
"image"
"io"
"go-common/library/log"
)
// Pixel get width height
func Pixel(file io.Reader) (width, height int, err error) {
var c image.Config
if c, _, err = image.DecodeConfig(file); err != nil {
log.Error("decode config error", err)
return
}
return c.Width, c.Height, err
}