Image Magick - 如何压缩Google页面速 度?

问题描述 投票:1回答:2

我正在尝试找到适合压缩png和jpg文件的正确命令,这些文件足以支持Google Page速度。

我在OS X终端上使用以下内容:

convert -strip -quality 85 imagesource.png imagesource_optimized.png

结果是原始版本和“优化版本”之间的文件大小没有差异。我可以使用不同的命令吗?

imagemagick imagemagick-convert
2个回答
3
投票

PNG和JPEG之间的压缩根本不同,因为PNG是无损的,JPEG是有损的。

使用JPEG-quality参数指定应保留多少质量。

使用PNG文件,-quality参数指定策略以及zlib可用于优化图像的时间/精力 - 想想gzip --bestgzip --fast.

https://www.imagemagick.org/script/command-line-options.php#quality

对于PNG,我建议使用pngcrush安装homebrew

brew install pngcrush

对于JPEG,要么使用-quality,要么指定最大尺寸:

# Specify by quality
convert input.jpg -strip -quality 75% output.jpg

# Specify maximum size
convert input.jpg -strip -define jpeg:extent=300k output.jpg

-1
投票

PNG和JPEG之间的压缩根本不同,因为PNG是无损的,JPEG是有损的。

© www.soinside.com 2019 - 2024. All rights reserved.