← 返回命令列表

Linux command

pngcrush 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Optimize PNG

pngcrush [input.png] [output.png]

Optimize in place

pngcrush -ow [image.png]

Remove metadata

pngcrush -rem alla [input.png] [output.png]

Best compression

pngcrush -brute [input.png] [output.png]

Reduce colors

pngcrush -reduce [input.png] [output.png]

Batch optimize

pngcrush -d [output_dir/] [input_dir/]*.png

Set specific compression level

pngcrush -l [9] [input.png] [output.png]

说明

pngcrush optimizes PNG files by testing multiple compression strategies and selecting the smallest result. The optimization is completely lossless - the image data is preserved exactly while reducing file size through better compression parameters. The -brute option tries all filter and compression combinations for maximum reduction at the cost of processing time. The -rem option strips metadata chunks like text comments, timestamps, and color profiles to further reduce size.

参数

-ow
Overwrite the input file in place.
-d _DIRECTORY_
Write output files to the specified directory.
-rem _CHUNK_
Remove a specified ancillary chunk. Use alla to remove all text chunks, or allb to remove all non-critical chunks.
-brute
Try all 148 filter/compression combinations for maximum reduction.
-reduce
Reduce color depth and bit depth where possible without data loss.
-l _LEVEL_
Set zlib compression level (0 = no compression, 9 = maximum).
-n
No output file; test compression without writing (useful for benchmarks).
-fix
Fix otherwise fatal conditions such as bad CRCs.

FAQ

What is the pngcrush command used for?

pngcrush optimizes PNG files by testing multiple compression strategies and selecting the smallest result. The optimization is completely lossless - the image data is preserved exactly while reducing file size through better compression parameters. The -brute option tries all filter and compression combinations for maximum reduction at the cost of processing time. The -rem option strips metadata chunks like text comments, timestamps, and color profiles to further reduce size.

How do I run a basic pngcrush example?

Run `pngcrush [input.png] [output.png]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -ow do in pngcrush?

Overwrite the input file in place.