Rimage
A powerful Rust image optimization CLI tool inspired by squoosh!.
Features
- Modern codecs:
- Rimage uses modern codecs optimized to produce tiny images
- Under the hood uses
zune_imagecrate that enhances performance
- Optimization operations:
- Rimage provides several image optimization operation
- Resize - uses
fast_image_resizecrate that has incredible performance - Quantization - allowing to reduce image palette
- Friendly output:
- Rimage support progressbar
- Rimage would show detailed error info to assist users
- CJK and Punctuation marks support:
- Rimage supports full CJK (Chinese, Japanese and Korean) characters input and output
- Rimage allows special punctuation characters such as
|,,&,$, etc. to be included in file names
Installation
You can download latest release from the releases tab.
If you're a Rust programmer, rimage can be installed with cargo.
Alternatively, one can use cargo binstall to install a rimage binary directly from GitHub:
Note
If you're a user who just want to use Rimage easily with a friendly GUI, Rimage_gui may be fit for you, it support both Chinese and English. Just select the version you need and download it to use.
Usage
Usage: rimage.exe [COMMAND]
Commands:
avif Encode images into AVIF format. (Small and Efficient)
farbfeld Encode images into Farbfeld format. (Bitmapped)
jpeg Encode images into JPEG format. (Progressive-able)
jpeg_xl Encode images into JpegXL format. (Big but Lossless)
mozjpeg Encode images into JPEG format using MozJpeg codec. (RECOMMENDED and Small)
oxipng Encode images into PNG format using OxiPNG codec. (Progressive-able)
png Encode images into PNG format.
ppm Encode images into PPM format. (Bitmapped)
qoi Encode images into QOI format. (Trendy and Small)
webp Encode images into WebP format. (Lossless-able)
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
Basic optimization suitable for web
To optimize images with great defaults, you can simply call rimage <command>. For example:
By default rimage will place output images right in place of precious images, resulting in overwrite if input and output has the same format. To change this behavior you can use this options:
# will place output images in `./output` directory, images may be overwritten if has the same name
# will rename all input files before processing with `@backup` suffix
# will place output images in ./output directory preserving folder structure
Preprocessing
Rimage has pipeline preprocessing options. Simple usage:
# will resize image to specified dimensions
Adjust image dimensions while maintaining the aspect ratio based on the width
# Same usage when you'd want to change pic's hight (200h for example)
If you want to run preprocessing pipeline in specific order, you can do this:
# will quantize image with 80% quality, after run resize to 64x64 pixels using the Nearest filter.
# will resize image to 64x64 pixels using the Nearest filter, and after run quantization with 80% quality.
Note that some preprocessing option are order independent. For example filter option, will apply resize filter to all resize invocations. Same for dithering, applies to every quantization invocations.
Advanced options
If you want customize optimization you can provide additional options to encoders. For mozjpeg this options are valid:
Options:
-q, --quality <NUM>
Quality, values 60-80 are recommended.
[default: 75]
--chroma_quality <NUM>
Separate chrome quality.
--baseline
Set to use baseline encoding (by default is progressive).
--no_optimize_coding
Set to make files larger for no reason.
--smoothing <NUM>
Use MozJPEG's smoothing.
--colorspace <COLOR>
Set color space of JPEG being written.
[default: ycbcr]
[possible values: ycbcr, grayscale, rgb]
--multipass
Specifies whether multiple scans should be considered during trellis quantization.
--subsample <PIX>
Sets chroma subsampling.
--qtable <TABLE>
Use a specific quantization table.
[default: NRobidoux]
[possible values: AhumadaWatsonPeterson, AnnexK, Flat, KleinSilversteinCarney, MSSSIM, NRobidoux, PSNRHVS, PetersonAhumadaWatson, WatsonTaylorBorthwick]
For more info use rimage help <command>, e.g. rimage help mozjpeg
For library usage check Docs.rs
List of supported Codecs
| Image Codecs | Decoder | Encoder | NOTE |
|---|---|---|---|
| avif | libavif | ravif | Common features only, Static only |
| bmp | zune-bmp | ❌ | Input only |
| farbfeld | zune-farbfeld | zune-farbfeld | |
| hdr | zune-hdr | zune-hdr | |
| jpeg | zune-jpeg | mozjpeg or jpeg-encoder | Multifunctional when use mozjpeg encoder |
| jpeg-xl | jxl-oxide | zune-jpegxl | Lossless only |
| png | zune-png | oxipng or zune-png | Static only, Multifunctional when use oxipng encoder |
| ppm | zune-ppm | zune-ppm | |
| psd | zune-psd | ❌ | Input only |
| qoi | zune-qoi | zune-qoi | |
| tiff | tiff | ❌ | Input only |
| webp | webp | webp | Static only |
List of supported preprocessing options
- Resize
- Quantization
- Alpha premultiply
List of supported mode for output info presenting
- No-progress (Shown on Default)
- Quiet (Show all msgs on Default)
Known bugs & Warnings
- Dir path end with
\may cause rimage crashes due to a cmd bug #72653. - Even if the value is set to 100, the quality of the image will still decrease if you use
--quantizationand(or)--ditheringoption(s). - Mozjpeg's SIMD assembly optimization code has ABI compatibility issues with code generated by the Windows GNU toolchain (MinGW/GCC) in Release mode. This can cause the program to crash, so you MUST use the MSVC toolchain for compilation according to rimage_gui#29.
Example
This will crash:
This will work as expected:
Contributing
Read the contribution guide for build instructions and guidelines.
License
Rimage is dual-licensed under Apache License 2.0 and MIT License. You can choose either license for your use.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Changelog
View the Changelog for version-specific changes.