How do I reduce the file size of PNG images?
Use pngquant for lossy PNG compression. Unlike standard PNG optimization tools (like optipng or ImageMagick’s -strip) that only remove metadata or recompress losslessly, pngquant applies lossy compression that can reduce file sizes by 60–80% while maintaining visual quality.
Install pngquant:
- macOS:
brew install pngquant - Linux:
apt install pngquant - Windows: Download from pngquant.org
Basic usage:
pngquant --quality=65-80 --force --output optimized.png original.png
The --quality flag sets a range (min-max) — pngquant will use the lowest quality that still looks acceptable within that range. For most web images, 65–80 is a good balance of size and visual fidelity.
Real-world results:
- A 336 KB PNG reduced to 69 KB (79% smaller)
- A 310 KB PNG reduced to 59 KB (81% smaller)
- A 231 KB PNG reduced to 44 KB (81% smaller)
Tip: For the smallest possible images, also consider converting PNGs to WebP format and serving them with the HTML <picture> element, using the PNG as a fallback for older browsers. CodeFrog’s Page Size & Performance test flags oversized images and legacy formats so you know exactly which images to optimize.