我正在尝试将来自 iPhone 相机的图像保存到文件中。我使用以下代码:
try UIImageJPEGRepresentation(toWrite, 0.8)?.write(to: tempURL, options: NSData.WritingOptions.atomicWrite)
这导致文件的分辨率是 toWrite UIImage 的两倍。我在手表表达式中确认,从 UIImageJPEGRepresentation 创建一个新的 UIImage 会使其分辨率翻倍
-> toWrite.size CGSize (width = 3264, height = 2448)
-> UIImage(data: UIImageJPEGRepresentation(toWrite, 0.8)).size CGSize? (width = 6528, height = 4896)
知道为什么会发生这种情况,以及如何避免吗?
谢谢