Your pages feel slow, and heavy PNGs may be why. Here’s how to optimize PNG images for web: resize them, strip metadata, run a lossless optimizer, then try lossy palette reduction if you can accept it.
Not sure PNG is even the right pick? Start with our guide to the best image format for websites, then come back here to shrink the files you keep.
| Item | Value |
|---|---|
| Typical lossy PNG savings with pngquant | often as much as 70% |
| Sample PNG before pngquant | 75,628 bytes |
| Same sample after pngquant | 19,996 bytes |
| Size reduction on that sample | 73% |
| Oxipng default optimization level | -o 2 |
| Oxipng level range | -o 0 through -o 6 |
These figures come from the pngquant project page and the oxipng repository. They can change as the tools are updated, so check each source before you rely on them.
Why PNG file size matters for page speed
Google’s PageSpeed Insights guide says images often account for most of the downloaded bytes on a page, so trimming them tends to produce some of the biggest savings. The browser has less to fetch and can render sooner. You can read the reasoning in Google’s image optimization guide.
That same guide puts GIF, PNG and JPEG together at 96% of the Internet’s image traffic. Its own header marks the page as outdated, and it was last updated 2024-09-03, so read it as background rather than a current tool manual (source).
PNG is a lossless format, which means compression does not make any visual modification to the picture, according to the same Google page. That gives you two routes below: lossless repacking, and lossy color reduction when a small change is acceptable.
Resize and choose the format first
Compression works best on an image that is already the right size and the right type. Google’s guide asks you to weigh whether a graphic suits a vector format, whether CSS can create the effect, and how to deliver appropriately scaled assets for each type of device (source).
- Export at the largest size your layout really displays, not the original from your camera or design tool.
- Prepare smaller versions for smaller screens instead of sending one big file to everyone.
- Ask whether a flat graphic belongs in SVG rather than a bitmap.
Our png vs svg comparison explains when a vector file beats a bitmap. Our guide to png for logos covers when PNG is still the right choice for a brand mark.
Google also gives two PNG-specific rules. Remove the alpha channel if all of the pixels are opaque, and always convert a GIF to PNG unless the original is animated or tiny (source).
Lossless PNG optimization with oxipng
Oxipng is a multithreaded, lossless PNG/APNG optimizer that you can run from the command line or call as a library, as described in its repository. Because it repacks data without altering pixels, it is a low-risk first tool to try.
The README’s example for web use is: oxipng -o 4 –strip safe –alpha *.png (source). Each part of that command does a separate job:
- -o sets the effort level: higher levels aim for smaller files but take longer.
- –strip safe removes metadata that never affects how the image renders.
- –alpha improves compression of transparent images by changing the color values of fully transparent pixels.
Levels run from -o 0 through -o 6, and the default of -o 2 is quick while still compressing well (source). Higher levels bring diminishing returns, and in rare cases a lower level can give a marginally smaller file.
Treat –alpha with care. The README calls it technically a lossy transformation that may be unsuitable for some applications, even though it is generally recommended (source).
Stripping metadata can save a few kilobytes if you do not need it, per the same README. If you prefer a graphical app, ImageOptim for Mac and Squoosh on the web are both listed there as software built on oxipng.
Google adds a caution for any third-party tool: the output can come out larger than the input if your image was already very well optimized, and then you should use your original (source).
Should you try lossy compression with pngquant?
pngquant is a lossy compressor. It converts 24/32-bit PNG images to an efficient 8-bit PNG with an alpha channel, and the result is often 60-80% smaller, according to its Rust documentation. The project page says reductions are often as much as 70% while keeping full alpha transparency (source).
On the project’s own sample, a 75,628 bytes original shrank to 19,996 bytes, which the page labels 73% smaller (source). That is one showcase image, so expect your own results to vary.
The –quality option takes a minimum and a maximum on a range of 0 (worst) to 100 (perfect). pngquant then uses the fewest colors needed to meet or exceed the maximum (source).
Its adaptive dithering is designed to add less noise than the standard Floyd-Steinberg approach (source). Even so, compare the output with the original at full size before you publish, because palette reduction can shift colors.

A fair rule: if exact pixels matter, stay with lossless tools. If a slight color change is acceptable, lossy conversion usually gives the larger saving.
A repeatable PNG optimization workflow
Run these steps in order for each batch of images:
- Decide whether PNG is the right format, or whether SVG or CSS would serve better.
- Resize to the largest size the page displays, and make smaller versions for small screens.
- Remove the alpha channel from images that are fully opaque.
- If a small color change is acceptable, run pngquant with a quality range and compare the result with the original.
- Run oxipng with metadata stripping on the result.
- Compare file sizes and keep the original whenever the new file is bigger.
If you already use ImageMagick, Google’s guide shows a convert command with -strip, an optional -resize and -alpha Remove for PNG output (source).
This site is independent and has no affiliation with any of these tools or their makers. Tool mentions are editorial only.
Frequently asked questions
Is PNG optimization lossless?
Show answer
It depends on the tool. Oxipng repacks the data without touching pixels, while pngquant reduces the palette, so only the second can change colors. Oxipng’s –alpha switch is also described as technically lossy in its README.
Should I convert GIFs to PNG?
Show answer
For still images, yes: Google’s guide says PNG gets a better compression ratio with better visual quality. For animated images it suggests a video element instead of a GIF to achieve better compression (source).
Can I run pngquant and oxipng on the same file?
Show answer
Yes. The pngquant documentation lists oxipng, ImageOptim and zopflipng as ways to squeeze out more after its own pass (source).



