A one-file command line tool that compresses an image through the free reSmush.it API and saves the smaller file next to the original.
I wrote this in 2020 as a quick way to shrink images without opening an editor: give it a URL, get a compressed copy in the current folder. The realistic use today is the same: you have a screenshot or photo that is too big for a README, a blog post or an email attachment, and you want it 50-70% smaller in one command without installing anything heavy.
reSmush.it is a free lossy/lossless optimiser for JPEG, PNG, GIF, BMP and TIFF files up to 5 MB. It is still online (checked August 2026, API rev. 3.0.11) and needs no API key.
git clone https://github.com/joelstephen97/api_imagecompressor.git
cd api_imagecompressor
pip install -r requirements.txt
python api_resmushit.py https://www.python.org/static/img/python-logo.png
# https://www.python.org/static/img/python-logo.png -> python-logo.min.png (15770 -> 6888 bytes, 56% smaller)usage: api_resmushit.py [-h] [-o OUTPUT] [-q QUALITY] [--local] source
positional arguments:
source image URL or local file path
options:
-o, --output where to save (default: <name>.min.<ext>)
-q, --quality JPEG quality 0-100 (default: 92, the API default)
--local skip the API and re-encode with Pillow instead
Examples:
# compress a local file, upload happens as multipart
python api_resmushit.py photo.jpg
# pick the output name and a stronger quality setting
python api_resmushit.py photo.jpg -o photo-small.jpg --quality 75
# offline: no upload, just re-encode with Pillow (weaker compression, but private)
python api_resmushit.py photo.png --localReal numbers from the Python logo PNG (15,770 bytes):
| Mode | Result |
|---|---|
| API, URL | 6,888 bytes (56% smaller) |
API, local upload, --quality 80 |
6,888 bytes (56% smaller) |
--local Pillow re-encode |
13,878 bytes (12% smaller) |
The script POSTs to https://api.resmush.it/, either with ?img=<url> or with the file in a multipart files field. The API answers with JSON containing a temporary dest URL, plus src_size and dest_size. The script downloads dest with requests and prints the before/after sizes. --local skips all of that and calls PIL.Image.save(optimize=True, quality=N), which is a useful fallback when you are offline or do not want to upload the image anywhere.
Working and verified live in August 2026. Not actively maintained.
- Depends on a free third-party service. If reSmush.it goes away,
--localstill works. - Uploading means your image leaves your machine; use
--localfor anything private. - Max 5 MB per image (API limit). No batch mode: loop it in a shell if you need many files.
- The
destlink the API returns expires after a short time, which is why the script downloads it straight away.
MIT, see LICENSE.