← 返回命令列表

Linux command

cjpeg 命令

文本

涉及管道、覆盖或删除,执行前请先确认路径和参数。

常用示例

Compress

cjpeg [image.bmp] > [output.jpg]

Compress

cjpeg -quality [85] [image.ppm] > [output.jpg]

Create a progressive JPEG

cjpeg -progressive [image.bmp] > [output.jpg]

Compress with grayscale

cjpeg -grayscale [image.ppm] > [output.jpg]

Optimize Huffman tables

cjpeg -optimize [image.bmp] > [output.jpg]

Set output file directly

cjpeg -outfile [output.jpg] [image.bmp]

说明

cjpeg is an image compression utility from the Independent JPEG Group's (IJG) libjpeg library, also available in the optimized libjpeg-turbo variant. It compresses raster image files into JPEG/JFIF format. The utility reads input images in various formats including BMP, PPM, PGM, and Targa, then outputs compressed JPEG data. By default, output goes to standard output, allowing easy piping and redirection. Input formats are auto-detected based on file headers. For web use, the -progressive option creates images that render progressively during download. The -optimize flag reduces file size through better Huffman tables at the cost of slower encoding. Quality settings around 75-85 typically offer a good balance between file size and visual fidelity.

参数

-quality _N_
Set compression quality level (1-100). Higher values produce better quality but larger files. Default is 75.
-progressive
Create progressive JPEG file for incremental display during download.
-grayscale
Force grayscale output even if input is color.
-optimize
Optimize Huffman coding tables. Produces smaller files but slower compression.
-outfile _name_
Specify output file name instead of writing to stdout.
-targa
Input file is in Targa format (useful when auto-detection fails).
-smooth _N_
Smooth input image to reduce dithering artifacts (1-100).
-maxmemory _N_
Limit memory usage to N kilobytes.
-restart _N_
Emit restart markers every N MCU rows (or N blocks if B suffix used).
-arithmetic
Use arithmetic coding instead of Huffman coding (smaller files, less compatible).
-baseline
Force baseline JPEG output (8-bit, non-progressive).
-verbose or -debug
Enable debug output.

FAQ

What is the cjpeg command used for?

cjpeg is an image compression utility from the Independent JPEG Group's (IJG) libjpeg library, also available in the optimized libjpeg-turbo variant. It compresses raster image files into JPEG/JFIF format. The utility reads input images in various formats including BMP, PPM, PGM, and Targa, then outputs compressed JPEG data. By default, output goes to standard output, allowing easy piping and redirection. Input formats are auto-detected based on file headers. For web use, the -progressive option creates images that render progressively during download. The -optimize flag reduces file size through better Huffman tables at the cost of slower encoding. Quality settings around 75-85 typically offer a good balance between file size and visual fidelity.

How do I run a basic cjpeg example?

Run `cjpeg [image.bmp] > [output.jpg]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -quality _N_ do in cjpeg?

Set compression quality level (1-100). Higher values produce better quality but larger files. Default is 75.