UIImageJPEG表示压缩质量与其他编码器的比较 [英] UIImageJPEGRepresentation compressionQuality vs other encoders
问题描述
UIImageJPEGRepresentation
中的compressionQuality
参数与libjpeg或ImageMagick等其他编码器中的相似参数有何关系?
How does the compressionQuality
parameter in UIImageJPEGRepresentation
related to similar parameters in other encoders such as libjpeg or ImageMagick?
当我尝试在ImageMagick和UIImageJPEGRepresentation
中使用相同的值时,得到的图像大小完全不同.我什至尝试过WebP,它的大小比UIImageJPEGRepresentation
结果小得多.
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.
推荐答案
使用ImageMagick可能会获得较小的图像尺寸,因为它是一个桌面程序,可以利用较高的计算能力为您提供更好的压缩效果,而不会牺牲太多图像质量.如果要在UIImageJPEGRepresentation中使用较小的尺寸,则必须降低quality参数:
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是完全不同的,并且是更新得多的压缩图像格式,因此它也可能产生较小的文件.如果尺寸太大,那么如果在将图像转换为JPEG之前可以缩小图像的尺寸,那么您还会看到尺寸的减小.
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.
这篇关于UIImageJPEG表示压缩质量与其他编码器的比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!