SquishPixel Blog · Guides

How to reduce PNG file size

PNG is lossless: it stores every pixel exactly. That makes it ideal for sharp graphics and wasteful for nearly everything else. When a PNG is too big, the cause is almost always one of three things: too many pixels, too many colours, or the wrong format for the content. The five fixes below cover all three.

1. Reduce the number of colours

This is the largest single saving, and it is what most PNG compressors do. A standard PNG can hold more than 16 million colours and spends three or four bytes on every pixel. Most graphics use a few hundred colours at most. Converting the image to a palette of 256 colours or fewer means each pixel is stored as one byte that points into the palette, and the file becomes far smaller.

The technique is called quantisation. A good quantiser chooses the palette carefully and uses dithering, a fine pattern of dots, to suggest the colours it had to drop. Transparency is kept, including soft, partly transparent edges.

  • Works well on: logos, icons, illustrations, interface screenshots.
  • Check carefully on: photographs and smooth gradients, where 256 colours can show as bands.

2. Resize it

Halving the width and height removes three quarters of the pixels. Export at twice the size the image is displayed at, which covers high-density screens, and no larger.

3. Repack it without loss

Two PNG files with identical pixels can differ in size, because the format leaves the software choices about how to filter and compress the data. Optimisers such as OxiPNG try many combinations and keep the smallest. They also remove things a web page does not need, such as embedded text and creation dates. The picture is identical, pixel for pixel.

The saving is modest for files from careful tools and larger for screenshots and exports from design software, which favour speed over size.

Two export settings are worth checking while you are there:

  • Turn interlacing off. Interlaced PNGs are larger.
  • Export 8 bits per channel, not 16, unless you need the extra depth for editing.

4. Remove transparency you do not need

A transparency channel adds a fourth byte to every pixel. If the image is always shown on the same solid background, flatten it onto that colour before you export.

5. Use a different format

Sometimes the PNG is not the problem. The choice of PNG is.

  • It is a photo. Use JPEG, WebP or AVIF. A photo saved as PNG is typically several times larger than it needs to be.
  • It is a photo with a transparent background. Use lossy WebP, which keeps the transparency.
  • It is a logo or icon made of simple shapes. Use SVG.
  • It is anything else on a web page. Lossless WebP is usually smaller than PNG with the same pixels.

Our guide to converting PNG to WebP covers when that is and is not a good idea.

Which to try first

  1. If it is a photo, change the format and stop there.
  2. Otherwise, resize it to the size you need.
  3. Reduce the colours and compare the result with the original.
  4. If you can see a difference, go back and repack it without loss instead.

Do it in your browser

SquishPixel's PNG compressor does steps 1 and 3 together: it reduces the palette, then repacks the file, and keeps transparency throughout. If you need every pixel untouched, its highest quality setting only repacks. Files are processed on your own device and nothing is uploaded.