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