Skip to main content

Fast, safe CLI to compress JPEG & PNG, lossless/lossy, batch or single images.

Project description

img

A fast, easy-to-use Python CLI tool for compressing JPEG and PNG images with both lossless and lossy modes.


Features

  • Compresses images individually or in bulk (folders)
  • Supports JPEG and PNG
  • Lossless mode (-l): Optimizes files without visible quality loss
  • Lossy mode (-q): Reduce file size by lowering image quality
  • Recursive directory support
  • Custom output folder
  • Prompts to delete originals after compression
  • Skips replacement if compressed file is larger
  • Cross-platform, requires Python 3.7+

Installation

  1. Install Python 3.7+
  2. Clone this repo and install:
    pip install -e .
    # Or for user-local install:
    pip install --user .
    

Usage

Compress a single image (lossy, 60% quality):

img -i myphoto.jpg -q 60

Compress a folder (lossless, best for PNG):

img -i images/ -o optimized/ -l -r

Options (Single-letter flags)

Flag Meaning Example
-i Input file or folder (required) -i mypic.jpg
-o Output file or folder (optional) -o compressed/
-q JPEG quality (default 60; ignored in lossless mode) -q 80
-l Use lossless compression -l
-r Recursively process folders -r
  • All flags are single-letter for speed and ease: -i, -o, -q, -l, -r.
  • After compressing, you will be prompted to delete the original files.
  • If the compressed file is larger, the original is kept and a warning is printed.

Requirements

  • Python 3.7+
  • Pillow (pip install Pillow)

Notes

  • Lossless for PNG is truly lossless; for JPEG, uses quality=100 with optimizations (minor effect but no further visual loss).
  • Output defaults to _compressed directory if not specified for folders.
  • Re-run with -l to optimize previously compressed images further (if possible).

Publishing to PyPI

  1. Ensure you have an account on PyPI.
  2. Install required tools:
    pip install build twine
    
  3. Build your package:
    python -m build
    
    This creates a dist/ folder with your distributable files (tar.gz and .whl).
  4. Upload to PyPI:
    python -m twine upload dist/*
    
  5. Enter your PyPI credentials when prompted.

License

MIT

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

imgcmprs-0.1.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

imgcmprs-0.1.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file imgcmprs-0.1.1.tar.gz.

File metadata

  • Download URL: imgcmprs-0.1.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for imgcmprs-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c9e63b15c89097dbcf177fbe512df05620f1f2f6caf9d97a9ee302628e02cec9
MD5 a005bc6ebab9fd758114591ca5d15855
BLAKE2b-256 fe38575d9a59edf2e021e20e296b325a577b06b773b606a51121dfb7a2c6618b

See more details on using hashes here.

File details

Details for the file imgcmprs-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: imgcmprs-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for imgcmprs-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 366ad90b74e9913460131b27fbfba6dde9cd782ef4bb04dbfdf522cb5259cf74
MD5 0bfd7ec641ffbea10a78b2dd0fa7b159
BLAKE2b-256 d44388bfee945c3257aa669ccf9801382258662045bd11f52ad12d6e62c40088

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