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

  

原文地址:https://www.cnblogs.com/zhaoxueru/p/13188464.html