For years I've been annoyed at websites having big beautiful PNGs taking monumental amount of time to load. Over the years, I've created this method to vastly cut down the size of PNGs while both retaining quality and maintaining alpha transparency.
These instructions show how to optimize PNGs for display on the web.
- These instructions are created for Mac users. Windows optimizations will be similar, but with different programs
- Download and install the following 2 open-source programs:
- In PhotoShop or other image editing software, load the image you'd' to optimize.
- Remove any background so you have a transparent image
- Trim the image so there is absolutely no padding between the image side and the actual image
- Save for Web
- Save as a PNG-24 transparent PNG. DO NOT save it as a 256 color, 8-bit PNG.
- After saving, open the image in ImageAlpha:
- On the left hand side of ImageAlpha, you'll see the following areas:
- Media Cut (pngquant) Leave this setting alone
- Colors This is the setting to change. Only change with the slider and not by finite numbers (ie, stay at 2,4,8,16,32,64,128,256 colors). Do not go above 256 colors as that defeats the purpose of optimization.
- Dithered Keep checked. Only uncheck if there is an unintentional gradient you'd like to remove
- IE6-friendly alpha_ Always keep unchecked. Nobody uses IE6 anymore.
- Backgrounds Used to test how the PNG will look on different backgrounds. The green usually work best but depends on the image.
- On the bottom you'll see the following areas:
- Image Size Shows your image optimization success
- Smooth scaling Always keep checked
- zoom slider Move to ½x on Retina systems to see the image Retinafied
- To optimize image:
- Choose a contrasting background to fully see the outlines
- Move the Colors slider as far left as possible without a noticeable loss in quality
- Take special note on how the image outlines look against the background
- More complex, non-gradient PNGs can look good down to 16 colors
- Very simple non-gradient PNGs can look good down to 4 colors
- Gradient PNGs may have to go as high as 128 colors and sometimes (rarely) 256 colors
- When satisfied, save the image:
- Name it the same or overwrite the original file (I usually overwrite it)
- Check Optimize with ImageOptim
- ImageOptim will now optimize the image
Try it yourself!
Practice on the logo-monkey-with-a-banana-before.png and match it to the logo-monkey-with-a-banana-after.png
- Monkey is reduced and trimmed with PhotoShop.
- Monkey is optimized in ImageAlpha at 16 colors (8 colors show aberrations on the monkey's outline)
- After optimization, Monkey is 95% smaller with virtually no loss in quality