How to Reduce PNG File Size While Preserving Transparency
Published 3 min readBy SlimMyFile
Transparent PNGs are everywhere: logos, icons, product cut-outs, interface graphics. They are also often far larger than they need to be. The good news is that you can shrink most of them substantially without losing transparency, as long as you avoid the one format that cannot store it: JPEG.
There are three practical approaches, each with a different balance of size and fidelity.
How PNG stores transparency
A PNG pixel can include an alpha value that describes how opaque it is, from fully transparent to fully solid. Semi-transparent pixels are what make soft shadows and smooth, anti-aliased edges blend nicely into any background.
PNG compression is lossless. Before compressing, the encoder applies "filters" that predict each pixel from its neighbours, and then stores the prediction errors with Deflate compression. How well a PNG compresses therefore depends a lot on the encoder: the same pixels can produce noticeably different file sizes in different programs.
Option 1: Lossless optimisation
A lossless optimiser rewrites the file with better filter choices and stronger compression, and reduces the bit depth or switches to a palette when the image allows it without changing any pixel. SlimMyFile uses OxiPNG for this.
The result is pixel-for-pixel identical. Savings are usually modest, and a PNG that was already saved by a good optimiser may not shrink at all. In that case SlimMyFile keeps your original.
Option 2: Reduce the number of colours
A full-colour PNG can contain millions of distinct colours. Many graphics use far fewer, and even those that do not can often be represented by a carefully chosen palette of 256 colours with little visible difference. Palette PNGs store one small index per pixel instead of four full colour values, which is why they are so much smaller.
Crucially, a palette PNG can still contain transparency: each palette entry can have its own alpha value, so soft edges and shadows survive. SlimMyFile builds an optimised palette with a quantiser that takes transparency into account, applies dithering to hide banding where the image is not too large, and then saves the result losslessly with OxiPNG.
This mode is lossy, because colours are approximated. It usually works very well for logos, icons and illustrations. Photos and images with long, smooth gradients may show banding; increase the number of colours or use WebP instead.
Option 3: Convert to WebP
WebP supports transparency in both its lossy and lossless modes. Lossy WebP with transparency is often much smaller than a PNG, especially for photographic cut-outs such as product images on a transparent background. All current major browsers display WebP, but check that any other software you use accepts it. Our format comparison covers compatibility.
Step by step
- Open the PNG compressor and add your images.
- Choose Reduce colours and start with 256 colours, or Lossless if pixels must not change.
- Compress and use Compare to inspect edges and gradients against the checkerboard background, which shows transparency.
- If you see banding, increase the colour count or switch to lossless. If the file is still too large, try fewer colours.
- For photographic cut-outs, try the WebP compressor as well and keep whichever result looks best for its size.
Common mistakes
- Converting to JPEG. JPEG has no transparency, so transparent areas are filled with a solid colour. SlimMyFile asks you to choose that colour, but the transparency is gone.
- Keeping a huge canvas. A 3000-pixel logo shown at 300 pixels wastes most of its bytes; resizing first often saves more than any compression setting.
- Choosing too few colours for gradients. Very low palettes create visible bands in shadows and glows.
- Expecting big lossless savings from an already optimised file. If lossless mode cannot help, colour reduction or WebP usually can.
Frequently asked questions
Will colour reduction remove semi-transparent edges?
No. Palette entries can carry partial transparency, so anti-aliased edges and soft shadows are kept. Very low colour counts can make those edges look slightly rougher.
Is the quality slider used for PNG?
No. PNG has no quality setting in the JPEG sense. SlimMyFile instead lets you choose between lossless optimisation and colour reduction with a maximum number of colours.
Try it with SlimMyFile
Compress PNG
Lossless optimisation or smart colour reduction.
Open toolCompress WebP
Compress WebP or convert images to WebP.
Open toolRelated guides
- Images
JPG vs PNG vs WebP: Which Image Format Should You Use?
A practical comparison of JPEG, PNG and WebP: compression type, transparency, compatibility and the best format for photos, screenshots and logos.
4 min readRead guide - Compression basics
Lossy vs Lossless Compression Explained
What lossy and lossless compression actually do, which formats use each, and how to choose without damaging your files.
3 min readRead guide - Images
How to Resize Images Without Distorting Them
Aspect ratios explained, how to pick target dimensions, and why shrinking an image is safe while enlarging it is not.
3 min readRead guide