功能复制图像缩略图?

时间:2017-04-18 09:21:50

标签: ios objective-c image duplicates compression

我正在制作照片库应用。

我压缩图像

NSData *imageData = UIImageJPEGRepresentation(image,0.5)

然后想要创建一个副本(用于缩略图),我将进一步压缩

NSData *imageData = UIImageJPEGRepresentation(image,0.2)

我有点卡在如何创建副本的中间步骤,任何人都知道是否有这个函数?

1 个答案:

答案 0 :(得分:0)

您可以将NSData转换为UIImage

Swift3:

let imageData = UIImageJPEGRepresentation(thumbImage,0.5)
let thumbImage = UIImage(data:UIImageJPEGRepresentation(UIImage(data: imageData),0.2))

目标C:

NSData *imageData = UIImageJPEGRepresentation(image,0.5)
UIImage *thumb = [UIImage imageWithData: UIImageJPEGRepresentation([UIImage imageWithData: imageData],0.5)];