pixel.go 316 B

123456789101112131415161718
  1. package service
  2. import (
  3. "image"
  4. "io"
  5. "go-common/library/log"
  6. )
  7. // Pixel get width height
  8. func Pixel(file io.Reader) (width, height int, err error) {
  9. var c image.Config
  10. if c, _, err = image.DecodeConfig(file); err != nil {
  11. log.Error("decode config error", err)
  12. return
  13. }
  14. return c.Width, c.Height, err
  15. }