[英]How decrease the size of image jpeg/png
我通过以下两个参数使用以下方法创建图像:一个是UIImage
对象是imagdata,另一个NSString
对象是storeImage
JPG: [UIImageJPEGRepresentation(imageData, 1.0) writeToFile:storeImage atomically:YES];
或PNG: [UIImagePNGRepresentation(imageData) writeToFile:storeImage atomically:YES];
我的问题是,在我使用上述方法后,原始图像大小为2.1 MB,在模拟器中图像大小为4.2 MB。
我不想使用任何压缩方法,也不想失去任何图像质量。 我想复制图像,因为它在给定的路径。 实际尺寸。
使用图像的简单数据对象。尝试以下代码,其中NSData对象中的imageData。
[imageData writeToFile:storeImageically:YES];
你能告诉我原始尺寸和格式是什么吗?
减小尺寸的一种方法是损失一点质量。
[UIImageJPEGRepresentation(imageData, 0.5) writeToFile:storeImage atomically:YES]
另一种方法是使用ImageIO框架。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.