Skip to content

hzbd/imagekit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ImageKit

Build Status License: MIT Rust Version

ImageKit is a powerful, fast, and flexible command-line tool for batch image processing. Written in Rust, it leverages parallel processing to maximize performance, allowing you to effortlessly resize, control the quality of, and add highly customizable watermarks to entire directories of images.

中文

🌟 Features

  • Batch Processing: Recursively processes all images (.jpg, .jpeg, .png, .gif, .bmp, .webp) in a specified input directory.
  • Smart Scaling:
    • If only a width is provided, the height is calculated automatically to maintain the aspect ratio.
    • If only a height is provided, the width is calculated automatically.
  • Quality Control: Use the -q or --quality flag (1-100) to fine-tune the output quality, balancing file size and visual fidelity. Set to 100 for the best possible quality.
  • Powerful Watermarking:
    • Multi-language Support: Perfectly renders watermarks with mixed text, supporting major world scripts including Latin (for English, French, Spanish), Cyrillic (for Russian), Thai, and CJK (Chinese, Japanese, Korean)..
    • Highly Customizable: Add text watermarks in nine standard positions and freely set the font size.
    • Custom Colors: Precisely control watermark color and opacity using hex codes (e.g., RRGGBB or RRGGBBAA).
    • Intelligent Watermark Scaling: If the requested watermark is too large for an image, it is automatically scaled down to fit perfectly, ensuring it is never cropped.
  • ⚡ Blazing Fast Performance: Utilizes the Rayon library to process images in parallel, taking full advantage of multi-core CPUs.
  • Cross-Platform: Compiles and runs on Windows, macOS, and Linux.

Demo Watermark

⚙️ Installation & Build

Note

You can also directly download the pre-compiled binary package from the release page.

You will need to have Rust and Cargo installed.

  1. Clone the Repository

    git clone https://github.com/hzbd/imagekit.git
    cd imagekit
  2. Build the Project

    cargo build --release
  3. Locate the Executable

    After building, the executable will be located in the target/release/ directory.

🚀 Usage

Examples

Example 1: Add a watermark with mixed Chinese and English text

./target/release/imagekit \
    -i example/img-src \
    -o example/img-out \
    --watermark-text "你好, World! - Test Watermark"

Example 2: Resize images and save at maximum quality

If you want to resize without quality loss for JPEGs, use --quality 100.

./target/release/imagekit -i example/img-src -o example/img-out --width 1024 --quality 100

Example 3: Add an opaque black watermark (using default quality 85)

./target/release/imagekit \
    -i example/img-src \
    -o example/img-out \
    --watermark-text "Confidential" \
    --watermark-color 000000FF

📋 Command-Line Options

Option Flags Description Required/Optional Default
Input Directory -i, --input-dir The source directory containing images to process. Required -
Output Directory -o, --output-dir The directory where processed images will be saved. Required -
Width --width (Optional) Resize image width. Scales proportionally if height is omitted. Optional Original width
Height --height (Optional) Resize image height. Scales proportionally if width is omitted. Optional Original height
Watermark Text --watermark-text (Optional) The text content for the watermark. Optional -
Watermark Position --watermark-position (Optional) The position of the watermark on the image. Optional se
Font Size --font-size (Optional) The font size of the watermark text in pixels. Optional 24
Watermark Color --watermark-color (Optional) Watermark color in RRGGBB or RRGGBBAA hex format. Optional FFFFFF80 (semi-transparent white)
Quality -q, --quality (Optional) Set output quality (1-100). Affects JPEG and PNG compression. Optional 85
Output Format --output-format (Optional) Specify the output image format. Optional Original format

Available values for watermark-position:

  • nw: North-West, north: North, ne: North-East
  • west: West, center: Center, east: East
  • sw: South-West, south: South, se: South-East

Demo

./target/release/imagekit -i example/img-src \
    -o example/img-out/ \
    --height 512 \
    --watermark-text "©良辰 | ちよ | 서연 | Stella | Éléonore | แก้ว" \
    --watermark-position se \
    --font-size 18 \
    --watermark-color ffffffFF \
    --output-format png

🛠️ Development & Testing

If you'd like to contribute to the project:

  1. Clone the repository and prepare the fonts.
  2. Make your changes.
  3. Run tests to ensure all functionality is working as expected:
    cargo test

📜 License

This project is licensed under the MIT License.

About

ImageKit is a powerful and fast command-line tool for batch processing images.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages