如何查找从iOS图像选择器中获取的JPEG的实际大小?

时间:2017-05-09 15:58:22

标签: ios swift uiimage jpeg

使用UIImageJPEGRepresentation转换数据并查找字节数将无效,因为压缩值未知。有没有其他方法可以做到这一点?

1 个答案:

答案 0 :(得分:0)

let assetPath = info[UIImagePickerControllerReferenceURL] as! NSURL 

let asset = PHAsset.fetchAssets(withALAssetURLs: [assetPath as URL], options: nil).lastObject

PHImageManager().requestImageData(for: asset!, options: nil) { (data, value, orientation, info) in
// data?.count will give total bytes 
print(data?.count)
}