问题
How does the compressionQuality
parameter in UIImageJPEGRepresentation
related to similar parameters in other encoders such as libjpeg or ImageMagick?
When I try to use the same values in both ImageMagick and UIImageJPEGRepresentation
I get totally different images sizes. I even tried WebP and it's size is much smaller that the UIImageJPEGRepresentation
result.
回答1:
You are likely to get smaller image sizes with ImageMagick because it is a desktop program that can utilize the higher computing power to give you better compression without sacrificing too much image quality. If you want smaller sizes in UIImageJPEGRepresentation, you will have to lower the quality parameter:
UIImageJPEGRepresentation(img, 0.5)];
WebP is a completely different, and much newer compressed image format, so it is likely to product smaller files as well. If size is so much of a concern, you will also see huge size decreases if you can scale down the image before converting it to JPEG.
来源:https://stackoverflow.com/questions/25293972/uiimagejpegrepresentation-compressionquality-vs-other-encoders