🎉 Welcome! This is the new version of my website. It’s still in beta, and some articles and sections are not fully completed yet.
Thumbnail Generator

Thumbnail Generator

This is a simple Python script that create thumbnails for all images in a directory. It uses the Python Imaging Library (PIL).

This script support batch processing, it keeps the original file name and directory structure.

Installation

You need to have Python 3 installed in your system.

Create a virtual environment

python -m venv .venv
source .venv/bin/activate

Install required libraries

pip install -r requirements.txt

Usage

This script will overwrite the output files if they already exist.

For creating a single thumbnail, you can run the script with the following command:

python ./thumbnail_generator.py -i ./input_path/file.png -o ./output_path/ -q 30 -s 1000

For batch processing, you can run the script with the following command:

python ./thumbnail_generator.py -i ./input_path/ -o ./output_path/ -q 30 -s 1000

Arguments

  • -i or --input: Path to the input file or directory.
  • -o or --output: Path to the output directory.
  • --log-level (optional): Log level for the script. Default is WARNING. Possible values are DEBUG, INFO, WARNING, ERROR, CRITICAL.
  • -p or --process (optional): Number of process to use. Default is auto.
  • -q or --quality (optional): Quality of the output image. Default is 30.
  • -s or --size (optional): Size of the output image. Default is 1000.
Last updated on