Skip to main content

Batch processing image files by utilizing Pillow / PIL library

Project description

batch_img

Batch processing image files by utilizing Pillow / PIL library. Resize, rotate, add border or do default actions on a single image file or all image files in a folder. Tested these image file formats (HEIC, JPG, PNG) on macOS.

Installation

One Time Setup

One time installation of the uv tool to prepare for All future Python tools installation. Install uv tool by its standalone installers:

# On macOS and Linux.
curl -LsSf https://astral.sh/uv/install.sh | sh
# On Windows.
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

Install the batch_img tool

Install the batch_img tool from PyPI:

uv pip install --upgrade batch_img

Usage

Sample command lines:

✗ batch_img --version
0.0.7

✗ batch_img rotate --degree 90 ~/Downloads/IMG_0070.HEIC
...
✅ Processed the image file(s)

Help

Top level commands help:

✗ batch_img --help
Usage: batch_img [OPTIONS] COMMAND [ARGS]...

Options:
  --version  Show this tool's version
  --help     Show this message and exit.

Commands:
  border    Add border to image file(s)
  defaults  Process image file(s) with default actions: 1) resize to...
  resize    Resize image file(s)
  rotate    Rotate image file(s)

The border sub-command CLI options:

✗ batch_img border --help
Usage: batch_img border [OPTIONS] SRC_PATH

  Add internal border to image file(s), not expand the size

Options:
  -bw, --border_width INTEGER RANGE
                                  Add border to image file(s) with the
                                  border_width. 0 - no border  [default: 5;
                                  0<=x<=30]
  -bc, --border_color TEXT        Add border to image file(s) with the
                                  border_color string  [default: gray]
  -o, --output TEXT               Output file path. If skipped, use the
                                  current dir path  [default: ""]
  --help                          Show this message and exit.

The defaults sub-command CLI options:

✗ batch_img defaults --help
Usage: batch_img defaults [OPTIONS] SRC_PATH

  Process image file(s) with default actions: 1) resize to 1280; 2) add
  5-pixel gray color border; 3) auto-rotate if needed

Options:
  -o, --output TEXT  Output file path. If skipped, use the current dir path
                     [default: ""]
  --help             Show this message and exit.

The resize sub-command CLI options:

✗ batch_img resize --help
Usage: batch_img resize [OPTIONS] SRC_PATH

  Resize image file(s)

Options:
  -l, --length INTEGER RANGE  Resize image file(s) on original aspect ratio to
                              the length. 0 - no resize  [default: 0; x>=0]
  -o, --output TEXT           Output file path. If skipped, use the current
                              dir path  [default: ""]
  --help                      Show this message and exit.

The rotate sub-command CLI options:

✗ batch_img rotate --help
Usage: batch_img rotate [OPTIONS] SRC_PATH

  Rotate image file(s)

Options:
  -a, --angle INTEGER RANGE  Rotate image file(s) to the clockwise angle. 0 -
                             no rotate  [default: 0; x>=0]
  -o, --output TEXT          Output file path. If skipped, use the current dir
                             path  [default: ""]
  --help                     Show this message and exit.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

batch_img-0.0.7.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

batch_img-0.0.7-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file batch_img-0.0.7.tar.gz.

File metadata

  • Download URL: batch_img-0.0.7.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for batch_img-0.0.7.tar.gz
Algorithm Hash digest
SHA256 eff5024b263bd72b21eabc09bc260143db192500dd005ef88aef2ca305c8da39
MD5 9a4a0ebf58fb57e78c4d69c5f6abe532
BLAKE2b-256 af233a0bce5327d29d44cbecba8ab76cf575b86e6ea7dee88a2f845c50d58ceb

See more details on using hashes here.

File details

Details for the file batch_img-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: batch_img-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for batch_img-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 dbf17cdbf5751e0a5a4d5f6032f1bf1bbebd00b7d9de9e62ddd86adecdc5ea6e
MD5 b2ecf6931b4851f23e3588d463d62861
BLAKE2b-256 008a53ed235f75956df18b96f5ccfed80471801eb68cc77c8a205fa5b4e0070b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page