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() 是我需要的宽和高

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM