UIImageJPEGRepresentation compressionQuality vs ot

2019-06-11 17:29发布

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条回答
Summer. ? 凉城
2楼-- · 2019-06-11 17:55

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.

查看更多
登录 后发表回答