golang 根据图片url获取图片尺寸

import (
    "github.com/disintegration/imageorient"
    _ "image/gif"
    _ "image/jpeg"
    _ "image/png"
)

 


func GetImage(url string) (image.Image, error) { resp, err := http.Get(url) defer resp.Body.Close() if err != nil { return nil, err } img, _, err := imageorient.Decode(resp.Body) if err != nil { return nil, err } return img, nil }

 

im,err := s.dao.Qiniu.GetImage(data["imageUrl"])

  

im.Bounds().Dx() 和 im.Bounds().Dy() 是我需要的宽和高

  

posted @ 2020-06-24 16:56  赵雪如  阅读(4386)  评论(0编辑  收藏  举报