I\'m trying to get the length of a UIImage. Not the width or height of the image, but the size of the data.
If needed in human readable form we can use ByteCountFormatter
if let data = UIImageJPEGRepresentation(image, 1.0) {
let fileSizeStr = ByteCountFormatter.string(fromByteCount: Int64(data.count), countStyle: ByteCountFormatter.CountStyle.memory)
print(fileSizeStr)
}
Where Int64(data.count) is what you need in numeric format.