Get size of a UIImage (bytes length) not height and width

后端 未结 10 2067
说谎
说谎 2020-11-28 09:00

I\'m trying to get the length of a UIImage. Not the width or height of the image, but the size of the data.

10条回答
  •  醉梦人生
    2020-11-28 09:41

    Example in Swift:

    let img: UIImage? = UIImage(named: "yolo.png")
    let imgData: NSData = UIImageJPEGRepresentation(img, 0)
    println("Size of Image: \(imgData.length) bytes")
    

提交回复
热议问题