Skip to main content
George Khananaev
Case Study

py-image-compressor: batch image compression in Python

A lightweight CLI for compressing, converting, and resizing images in bulk

2 min read

Overview

py-image-compressor is a small CLI that takes a directory of images and outputs an optimized version of every file. It handles JPEG, PNG, and WebP, resizes to a target max dimension, and writes results to a parallel output directory so the originals are never touched.

Why I built it

My personal and client projects all have the same bottleneck before launch: image optimization. You have a folder of 300 raw screenshots, logos, and hero images, and you need them all resized and recompressed without losing quality. The existing options were either heavy desktop apps or one-off scripts that I rewrote every time. This tool replaced the rewriting.

What it does

  • Recursive directory scan with glob-style filters
  • Format conversion to WebP or JPEG with tunable quality
  • Resizing to a target max dimension, preserving aspect ratio
  • Structure preservation so output mirrors input
  • Progress reporting so you know the long jobs are actually progressing
  • Dry run mode for previewing what would change without writing files

Tech stack

Python, Pillow for image manipulation, Click for the CLI interface, and concurrent.futures for parallel processing across CPU cores.

The interesting bit

Pillow is fast enough per-image, but the real wins come from parallelism. A 4-core machine processing 300 images sequentially takes ~3 minutes; the same machine with a thread pool processes them in ~45 seconds. The caveat is that Python's GIL makes CPU-bound threads ineffective — you need process pools, not thread pools, for real speedup on image work.

Takeaway

Small tools earn their keep by removing small repeated friction. This one is maybe 200 lines of Python, but it has saved me hours cumulatively. Build the tool; the investment pays back faster than you expect.

Building Google Reviews Scraper Pro
Building Google Reviews Scraper Pro illustrationFeaturedGitHub
2 min172

Building Google Reviews Scraper Pro

A resilient Python web scraper for multi-language Google Maps reviews

A production-grade Google Maps review scraper that extracts multi-language reviews with images, writes to MongoDB, and handles detection countermeasures. Incremental scraping, image downloading, and URL replacement built for scale.

pythonweb-scrapingmongodbautomation
FastAPI DocShield: protect your API docs with one line
2 min13

FastAPI DocShield: protect your API docs with one line

HTTP Basic Auth on the OpenAPI docs endpoints for FastAPI

A tiny FastAPI extension that adds HTTP Basic Authentication to the Swagger UI, ReDoc, and OpenAPI JSON endpoints. Drop it in, set a username and password, and your API docs are no longer public. Useful when you want docs in production but not publicly indexable.

fastapipythonsecurityauthentication
Excel AI Assistant: AI transforms for spreadsheets
Excel AI Assistant: AI transforms for spreadsheets illustrationFeaturedGitHub
2 min64

Excel AI Assistant: AI transforms for spreadsheets

A Python desktop app that adds LLM-powered transformations to Excel and CSV files

A Python desktop application that enhances Excel and CSV files using AI transformations. Features dual AI backends (OpenAI API and local Ollama), customizable prompt templates, batch processing, and a workflow built for analysts who want AI without leaving their spreadsheet.

pythonaillmopenai