← Back to Blog
img_utilities: A Python CLI Tool for Batch Image Processing

img_utilities: A Python CLI Tool for Batch Image Processing

·4 min read
pythoncliimage-processingopen-sourcedeveloper-toolspillow

A lightweight Python command-line tool that handles everything from resizing and smart cropping to tone matching and rounded corners — without opening a single GUI.


If you've ever found yourself opening Photoshop just to resize a folder of images, convert them to WebP, and slap rounded corners on each one — only to repeat that whole process next week — this tool was built for exactly that frustration.

img_utilities is a Python CLI tool that chains together the most common image processing tasks into a single command. No GUI, no subscription, no context-switching. Just python imgconv.py and a handful of flags.

What It Does

The tool covers the operations that come up most often in practical work:

Resize and format conversion are the basics. You can specify an exact resolution, a single dimension (letting the other scale proportionally), or a percentage. Combined with --format webp, it's a one-liner for optimizing images for the web.

python imgconv.py foto.jpg --size 1280x --format webp

Smart crop lets you target an aspect ratio — 16:9, square, or any custom ratio like 1.33 — and the tool figures out the best crop region. If you have opencv-python installed, it uses face detection to keep subjects in frame instead of naively center-cropping.

Tone presets and matching are where it gets more interesting. Seven built-in presets (warm, cool, vintage, fade, vibrant, dramatic, matte) handle the common aesthetics quickly. But the more powerful feature is --match-tone and --match-color, which let you feed in a reference image and apply its look across an entire batch. This is the feature that makes batch-processing a shoot feel coherent without touching every photo individually.

python imgconv.py *.jpg --match-tone referensi.jpg --output ./output/

Rounded corners support both pixel values and percentages. Setting --radius 50% on a square crop gives you a circle — which makes generating profile avatars straightforward:

python imgconv.py foto.jpg --crop square --size 500x500 --radius 50% --output avatar.png Manual adjustments via --brightness, --contrast, --saturation, and --temperature are there when the presets aren't quite right.

Dependencies

The core tool runs on just Pillow. Two optional dependencies extend functionality:

  • numpy — improves accuracy for tone and color matching algorithms
  • opencv-python — enables face detection during smart crop
  • Install only what you need.

    A Typical Use Case

    The flags are designed to chain together. A common pipeline for preparing a batch of blog images — consistent crop, resized for web, matched to a reference style, with rounded corners — looks like this:

    python imgconv.py *.jpg --crop 1.33 --size 381x287 --match-tone ref.jpg --radius 24 --output ./out/

    One command, whole folder processed.

    Getting Started

    pip install Pillow

    pip install numpy # optional

    pip install opencv-python # optional

    python imgconv.py <input> [options...]

    Full documentation for every argument and flag is available in DOCS.md in the repository.

    The goal with img_utilities was to keep it simple enough to remember the syntax off the top of your head, but complete enough that you rarely need to reach for anything else for routine image work. If you find a use case it doesn't cover, issues and PRs are welcome.

    zacha9990/img_utilites: various image utilities using python