Rimage
A powerful Rust image optimization CLI tool and library inspired by squoosh!.
Overview
Rimage simplifies and enhances your image optimization workflows. Optimize images effortlessly, set quality levels, and apply advanced techniques with ease. Ideal for web apps, mobile apps, and desktop software.
Features
- Flexible Format Conversion: Supports modern image formats: JPEG, JPEG XL, PNG, AVIF, WebP.
- Quality Control: Fine-tune image quality with an intuitive interface.
- Parallel Optimization: Optimize multiple images in parallel.
- Quantization and Dithering: Advanced control for experts.
- Image Resizing: Easy resizing with the
resizecrate.
Installation
Dependencies:
On x86_64 macos requires libjxl installed.
You can download latest release from the releases tab.
Alternatively you can build rimage from source if you have rust, cargo, nasm and cmake installed:
Note
-
Jxl(JpegXL) format on Microsoft Windows® is not support, because of its complexity.
-
If you met the error of "Could not find libstdc++-6.dll", etc., please download all 3 DLLs from HERE and put these 3 DLLs near Rimage.
-
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 [OPTIONS] <FILES>...
Arguments:
<FILES>... Input file(s) to process
Options:
-h, --help Print help
-V, --version Print version
General:
-q, --quality <QUALITY> Optimization image quality
[range: 1 - 100] [default: 75]
-f, --codec <CODEC> Image codec to use, jxl feature is disabled on Microsoft Windows®
[default: jpg] [possible values: png, oxipng, jpegxl, webp, avif]
-o, --output <DIR> Write output file(s) to <DIR>, if "-r" option is not used
-r, --recursive Saves output file(s) preserving folder structure
-s, --suffix [<SUFFIX>] Appends suffix to output file(s) names
-b, --backup Appends ".backup" suffix to input file(s) extension
-t, --threads Number of threads to use, more will run faster, but too many may crash
[range: 1 - 16] [integer only] [default: number of cores]
Quantization:
--quantization [<QUALITY>] Enables quantization with optional quality
[range: 1 - 100] [default: 75]
--dithering [<QUALITY>] Enables dithering with optional quality
[range: 1 - 100] [default: 75]
Resizing:
--width <WIDTH> Resize image with specified width
[integer only]
--height <HEIGHT> Resize image with specified height
[integer only]
--filter <FILTER> Filter used for image resizing
[possible values: point, triangle, catrom, mitchell] [default: lanczos3]
Note that image formats may wary from features that are used when building rimage.
List of supported codecs with all features:
mozjpeg,jpeg,jpg=> mozjpeg codec (common and small)png=> browser png codec without compressionoxipng=> oxipng codec with compressionjpegxl,jxl=> jpeg xl codecwebp=> webp codecavif=> avif codec
List of available resize filters:
point=> Point resizingtriangle=> Triangle (bilinear) resizingcatmull-rom,catrom=> Catmull-Rom (bicubic) resizingmitchell=> Resize using Mitchell-Netravali filterlanczos3=> Resize using Sinc-windowed Sinc with radius of 3
Example
png => jpg & quality => 90 & backup
| Image Path | Quality | Out Format | Out Dir | Backup |
|---|---|---|---|---|
| "D:\Desktop\input [text].png" | 90 | jpg | "D:\Desktop\OutputTest" | True |
suffix & recursive & quantization & dithering
| Image Path | Quality | Out Format | Suffix | Recursive | Quantization | Dithering |
|---|---|---|---|---|---|---|
| "C:\中 文\ソフトウェア.PNG" | 40 | png | _문자 | True | 95 | 85 |
jpg => webp & threads &resize width and height (both are opinional)
| Image Path | Quality | Out Format | Out Dir | Threads | Width | Height |
|---|---|---|---|---|---|---|
| "C:\Docs\justfortest.JPG" | 40 | webp | "C:\Desktop\Test" | 4 | 60 | 10 |
Library Installation
Add Rimage to your project with Cargo:
Or add this to your Cargo.toml:
[]
= "0.10.0"
Library Usage
Decoding
use Decoder;
let path = from;
let decoder = from_path?;
let image = decoder.decode?;
// Handle the image...
Encoding
use ;
let image_data = vec!;
let image = new;
let config = new.with_quality.unwrap;
let file = create.expect;
let encoder = new.with_config;
encoder.encode?; // Writes image data to the file.
For full API documentation, visit docs.rs page.
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.