imgshrink

Crates.ioimgshrink
lib.rsimgshrink
version0.1.10
created_at2025-12-13 15:14:26.913245+00
updated_at2025-12-20 22:44:57.294614+00
descriptionFast CLI tool to batch-resize images
homepage
repositoryhttps://github.com/mariustz/imgshrink
max_upload_size
id1983035
size76,229
(mariustz)

documentation

README

imgshrink

A fast, cross-platform CLI tool written in Rust for batch-resizing and converting images.

imgshrink is designed to efficiently process large numbers of images using parallel CPU processing, making it ideal for photographers, developers, and automation workflows.


โœจ Features

  • ๐Ÿš€ Very fast (parallel processing with Rayon)
  • ๐Ÿ–ผ Supports common image formats (PNG, JPG, JPEG)
  • ๐Ÿ”„ Batch resize entire folders
  • ๐Ÿ“‚ Separate input and output directories
  • ๐Ÿ“ Preserve aspect ratio or force dimensions
  • ๐Ÿงต Uses all CPU cores automatically
  • ๐Ÿง Linux & ๐ŸชŸ Windows support

๐Ÿ“ฆ Installation

Option 1: Install via Cargo (recommended)

If you have Rust installed:

cargo install imgshrink

Verify:

imgshrink --help

Option 2: Download Prebuilt Binaries

Download a precompiled binary from GitHub Releases:

๐Ÿ‘‰ https://github.com/mariustz/imgshrink/releases

  • Linux: imgshrink
  • Windows: imgshrink.exe

Place it somewhere in your PATH.


๐Ÿš€ Usage

Basic resize

Resize all images in a directory:

imgshrink --input ./images --output ./out --width 800

Resize with width and height

imgshrink --input ./images --output ./out --width 800 --height 600

Convert format

Convert images to PNG (use --to-format):

imgshrink --input ./images --output ./out --to-format png

Resize + convert

imgshrink \
  --input ./images \
  --output ./out \
  --width 1024 \
  --format png

In-place processing

The --output path is required. To overwrite files in-place you can set --output to the same directory as the input (and use --overwrite), for example:

imgshrink --input ./images --output ./images --width 500 --overwrite

Note: writing into the input directory is supported but be careful โ€” using a separate output directory is safer.


โš™๏ธ Command-line Options

Resize images

Usage: imgshrink.exe [OPTIONS] --output <OUTPUT> [PATH]

Arguments:
  [PATH]

Options:
  -i, --input <INPUT>
  -o, --output <OUTPUT>
  -r, --recursive
      --ext <EXTENSIONS>             [default: jpg,jpeg,png]
      --width <WIDTH>
      --height <HEIGHT>
      --max-width <MAX_WIDTH>
      --max-height <MAX_HEIGHT>
      --scale <SCALE>
      --hq
      --overwrite
      --jpeg-quality <JPEG_QUALITY>  [default: 90]
        --to-format <TO_FORMAT>
      --no-parallel
        --jobs <JOBS>
      -v, --verbose                      Increase verbosity (use -v, -vv for more)
  -h, --help                         Print help
  -V, --version                      Print version

๐Ÿง  How it works

  • Rayon is used for CPU-bound parallel image processing
  • Images are decoded, resized, and encoded in parallel
  • The workload automatically scales to your CPU core count

Notes:

  • Use --jobs N to limit the worker threads for this run; a local Rayon thread pool is used so other libraries won't be affected.
  • Logs are produced via structured logging. Set verbosity with -v/-vv or the RUST_LOG environment variable (e.g., RUST_LOG=debug).

This makes imgshrink especially fast for large image collections.


๐Ÿงช Testing

Run all tests:

cargo test

๐Ÿ›  Development

Clone and build:

git clone https://github.com/mariustz/imgshrink.git
cd imgshrink
cargo build --release

๐Ÿ“„ License

  • Apache License, Version 2.0


๐Ÿค Contributing

Contributions, issues, and feature requests are welcome!


โญ Acknowledgements

Built with:

  • Rust ๐Ÿฆ€
  • image
  • rayon
  • clap

Happy resizing! ๐Ÿš€

Commit count: 0

cargo fmt