Compress JPG, PNG, WebP, and PDF files down to a size you choose, keeping the same file type.
pip install -r requirements.txtPDF compression uses Ghostscript, so install it if you want PDF support:
# macOS
brew install ghostscript
# Debian / Ubuntu
sudo apt install ghostscript
# Windows: download from https://ghostscript.com/releases/gsdnld.htmlImages work with no extra installs.
python app.pyOpen http://localhost:5000, upload a file to squash. Pick a target file size and click Compress & download.
- Analyze (
POST /api/analyze): compresses the file at maximum settings once to find the floor, and returns{original_size, min_size, file_type}. - Compress (
POST /api/compress, fieldsfile+targetin bytes):- JPEG / WebP — binary-searches the quality setting (1–95) for the highest quality that fits under the target.
- PNG — PNG is lossless, so the search runs over palette size (8–256 colors) with optimized encoding instead.
- PDF — tries Ghostscript.
- If the file is already under the target size, it's returned untouched.
Resulting compressed file is named <name>-compressed.<ext> and auto-downloaded.
- Upload cap is 100 MB (
MAX_CONTENT_LENGTHinapp.py).