Skip to main content

Python Script to optimise images for websites

Project description

Logo

PyPI GitHub Actions Workflow Status

Img-Tool is a versatile CLI tool designed to convert standard (baseline) JPEG images into progressive JPEGs. It streamlines the process of handling large batches of images, offering additional features like thumbnail creation, compression control, metadata management, and more.

Installation

To install the tool, simply run the following command:

pip install todo

Usage

After installation, you can start using JPEG Converter by executing:

jpeg-converter [OPTIONS] INPUT_PATH

Features

JPEG Converter comes with a variety of features to manage and optimize your JPEG images efficiently:

  • Convert Baseline to Progressive JPEG: Easily convert single images or entire directories from baseline to progressive JPEG format.
  • Batch Processing: Handle multiple images at once, with support for recursive directory traversal.
  • Thumbnail Generation: Create thumbnails with various specifications, including cropping and resizing.
  • Compression Control: Adjust compression levels to balance image quality and file size.
  • Metadata Management: Remove EXIF metadata to protect privacy or embed custom copyright information.

Configuration

JPEG Converter can be configured using command-line options. Below is a table of available options:

Option Description
--output-dir PATH Directory to save the output images. If not specified, original images will be overwritten after confirmation.
--thumb TEXT Thumbnail specification. Formats:
- WxH (e.g., 100x300) - Crop to WxH from center
- WxHt (e.g., 100x300t) - Crop from top
- WxHb (e.g., 100x300b) - Crop from bottom
- WxHf (e.g., 100x300f) - Fit inside WxH without cropping
- 0xH (e.g., 0x300) - Resize to height H, preserving aspect ratio
- Wx0 (e.g., 100x0) - Resize to width W, preserving aspect ratio
--thumb-dir PATH Directory to save thumbnails. Required when --thumb is used.
--compress [low, medium, high] Compression level for the output images.
--verbose Enable verbose output during processing.
--recursive Process directories recursively, including subdirectories.
--remove-metadata Remove EXIF metadata from images.
--copyright-text TEXT Add copyright text to the image metadata. Note: Ignored if --remove-metadata is used.

Examples

Examples

Basic Conversion

Convert a single image and overwrite the original after confirmation:

jpeg-converter path/to/image.jpg

Convert All Images in a Directory

Convert all JPEG images in a directory and save the outputs to another directory:

jpeg-converter path/to/input_directory --output-dir path/to/output_directory

Batch Conversion with Compression and Metadata Removal

Convert all images with high compression and remove EXIF metadata:

jpeg-converter path/to/input_directory --compress=high --remove-metadata

Create Thumbnails

Create thumbnails with center cropping:

jpeg-converter path/to/input_directory --thumb=100x300 --thumb-dir path/to/thumbnails/

Combine Multiple Options

Convert images, create thumbnails, set compression level, enable verbose output, process directories recursively, and add copyright:

jpeg-converter path/to/input_directory \
  --output-dir path/to/output_directory \
  --thumb=150x150f \
  --thumb-dir path/to/thumbnails/ \
  --compress=medium \
  --recursive \
  --verbose \
  --remove-metadata \
  --copyright-text="© 2024 Your Name"

License

Distributed under the MIT License. See LICENSE for more information.

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

jpegger-1.0.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

jpegger-1.0.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file jpegger-1.0.0.tar.gz.

File metadata

  • Download URL: jpegger-1.0.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/24.2.0

File hashes

Hashes for jpegger-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2d2b182719cf93345a2cf3370241858531da268add680a519d64aad30b371813
MD5 a05d010dbb923fa6d2619a07b2e6193f
BLAKE2b-256 a09e016a6b9c31a488bdb422883751f34ee979bb294de07c1891d9d511ace56e

See more details on using hashes here.

File details

Details for the file jpegger-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: jpegger-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/24.2.0

File hashes

Hashes for jpegger-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 530633ffdbb28c428b5489497b63d6d3862ca220482c382c11264de2b3f50a1d
MD5 322f11bbfc4c64e4ce541222db1f1626
BLAKE2b-256 b8b23eea33b92e95db5fed5d7cbd21365ade6e5dcca3e9aba75a9fa89276152d

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