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

后端 未结 10 2078
说谎
说谎 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:29

    Swift 3:

    let image = UIImage(named: "example.jpg")
    if let data = UIImageJPEGRepresentation(image, 1.0) {
        print("Size: \(data.count) bytes")
    }
    

提交回复
热议问题