Clever PNG Optimization Techniques
As a web designer you might be already familiar with the PNG image format which offers a full-featured transparency. It’s a lossless, robust, very good replacement of the elder GIF image format. As a Photoshop (or any other image editor) user you might think that there is not that many options for PNG optimization, especially for truecolor PNG’s (PNG-24 in Photoshop), which doesn’t have any. Some of you may even think that this format is “unoptimizable”. Well, in this post we’ll try to debunk this myth.
This post describes some techniques that may help you optimize your PNG-images. These techniques are derived from laborious hours spent on studying how exactly the PNG encoder saves data. We’ll start with some essentials about the PNG format and will then move to advanced optimization techniques.
You may want to take a look at the following related articles:
The boring part
Before we dive into image optimization techniques, we have to learn some technical details about the PNG format. Each graphic format has its own advantages and weaknesses; knowing them will allow you to modify original image for better visual quality and compression. This is a key concept behind professional image optimization.
PNG was developed as an open-source replacement of the proprietary GIF format. They have some common features (like indexed color palette), but PNG is much better than GIF in every aspect. It introduced some cool features for image packing and compression, but for us – web-designers and developers – the most important one is the scanline filtering (also known as ‘delta filters’).
Scanline filtering
Here is how it works. For example, we have a 5×5 pixels image with horizontal gradient. Here is a schematic view of this image (each number represents a unique color):

As you can see, all identical colors spread vertically, not horizontally. Such images will have a very poor compression ratio in GIF, because it compresses colors that spread horizontally. Let’s see how this image data can be packed by scanline filtering:

Number 2 before each line represents applied filter, which is “Up” in this case. The “Up” filter sends the message to the PNG decoder: “For the current pixel take the value of the above pixel and add it to the current value.” We have 0 value for lines 2—5 because all pixels in each vertical line have the same color. And such data would be compressed better if the image was relatively large. For example, 15 pixels of value 0 can be written as 0(15) and this is much shorter than fifteen 0′s—this is how compression works in common.
I wrote “can be packed” because in this ideal test case the “Sub” filter (number 1 before each line) will give much better result:

The filter “Sub” sends the message to the decoder: “Take the value of the left pixel and add it to the current value.” In this case, it’s 1. As you may already have guessed, such data will be compressed very effectively.
Scanline filtering is important for us because we can use them: in particular, we can do some image manipulation to make filtering better. There are five filters: None (no filtering), Sub (subtract the left pixel value from the current value), Up (subtract the above pixel value), Average (subtract the average of the left and the upper pixels) and Paeth (substitute the upper, left or upper left pixel value, named after Alan Paeth).
And here’s how these filters affect the image size in comparison with the good ol’ GIF:

GIF, 2568 bytes

PNG, 372 bytes
As you can see, the GIF image is 7 times larger than the same PNG-image.
Image type
Another important thing to know about PNG is image type, the meta-data stored inside the file. As a Photoshop user, you are familiar with PNG-8 (indexed image) and PNG-24 (truecolor image). As a Fireworks user, you may know PNG-32 (truecolor with transparency), which is quite confusing, because Photoshop’s PNG-24 may also store truecolor with transparency. Well, it’s worth knowing that these names are not official, and you won’t find them in PNG specs. For your convenience we’ll use Photoshop’s naming convention of PNG image types in this article.
There are 5 available image types in PNG: Grayscale, Truecolor, Indexed-color, Grayscale with alpha and Truecolor with alpha. There are also two subtypes of indexed-color type (non-official, too): bit transparency (each pixel can be fully transparent or fully opaque) and palette transparency (each pixel can be semi-transparent). In second case each color is stored in palette with its alpha value. Thus, opaque red and 50%-transparent red are two different colors and they take 2 cells inside palette.
The worst thing is that Photoshop can save PNG with only 3 of these types: Indexed-color with bit transparency, Truecolor and Truecolor with transparency. That’s why you may find a lot of opinions that Adobe Fireworks is the best tool for PNG optimization. Personally, I don’t agree with them: Fireworks doesn’t have enough tools for image manipulation, it’s only have slightly more options for saving PNG image, but it’s a topic for another discussion.
This is where utilities such as OptiPNG or pngcrush come in handy. Essentially, these tools do the following:
- Pick up the best image type for an image (for example, truecolor can be converted to indexed-color if there aren’t too many colors in the image).
- Pick up best delta filters.
- Pick up the best compression strategy and, optionally, reduce the color depth.
All these operations do not affect image quality at all, but do reduce the file size of the PNG-images, so I highly recommend you to use such tools every time you save a PNG image.
Now enough with the boring part, let’s do some magic!
1. Posterization
This is a well-known method of the truecolor image optimization. Open up the example image in Photoshop, press the
icon in the Layers palette and choose Posterize:

Pick the smallest possible amount of Levels (usually 40 is enough) and save the image:

Original, 84 KB

Posterized, 53 KB
Here is how it works: the posterization simply reduces the amount of colors, converting similar colors to the single one, thus creating posterized regions. This helps to perform a better scanline filtering and achieve a better compression. The downside of this method is color alternation, which is especially visible if you are trying to stitch image with a HTML background:

Original image

Posterized image
2. Dirty Transparency
Take a look at the following images:

75 KB

30 KB
Both of them were saved in Photoshop without any optimization. Even if you do a per-pixel comparison of these images, you won’t notice any difference. But why is the first image 2.5x larger than the second one?
You need a special plugin for Photoshop to see hidden details. It’s called Remove Transparency and available for free download on the PhotoFreebies plugin suite. You have to install it first before proceeding with the next step.
Open both images form the example above in Photoshop and choose Filer ? Photo Wiz ? Remove Transparency. Now you can see the actual pixel data that was saved in the image:


What’s happening? How is it possible to reveal the data from the original image from a single-layered PNG image? Well, it’s quite simple. Each pixel in the truecolor image with alpha is described by four bytes: RGBA. The last one is Alpha, which controls pixel transparency: the value of 0 means fully transparent pixel and 255 means fully opaque. And this means that every pixel (with any RGB value) can be hidden with just Alpha byte set to 0. But this RGB data still exists and, moreover, it prevents PNG encoder from effectively packing and encoding the data stream. Thus, we have to remove this hidden data (fill it with solid black, for example) before saving the image. Here is a quick method how to do this:
- Open the first image from the example above in Photoshop.
- Ctrl+click (or ?+click on Mac) on image thumbnail in Layers palette to create a selection, then invert it: Select ? Inverse.

- Switch to Quick Mask mode by pressing Q key:

- We have created a mask for a semi-transparent image, but we need to leave fully transparent pixels only. Choose Image ? Adjustments ? Threshold and move Threshold Level slider to the right, thus leaving fully transparent pixels of the selection:

- Leave Quick Mask mode (press Q key again) and fill the selection with black:

- Invert the seleciton again (Select ? Inverse) and click on the
icon in the Layers palette to add mask.
That’s it, now you can save this image in PNG-24 and ensure that the 75 KB image is now 30 KB. By the way, all these steps can be easily recorded into Photoshop’s Action (download the Dirty Transparency Photoshop Action) and reused later with a single keystroke.
You might think about “dirty transparency” as some kind of a bug in image editors: if those image regions can’t be seen and take so much space, why can’t they be removed automatically before saving? Well, this “bug” can be easily turned into a “feature”. Take a look at the following pictures:

5 537 bytes

6 449 bytes
If you remove transparency from those images, you’ll see the following:


Despite the fact that the first image contains more complex image data, it’s 1Kb lighter than the second one, which was optimized as described above. The explanation of this “abnormal” behavior is simple: image data stream in the first example was effectively packed by delta filters, which works better for smooth color transitions (like gradients).
Tech geeks may look at OptiPNG’s output log and ensure that filters were not applied at all for the second image. That’s why I highly recommend you to read The boring part of this article first before using these techniques: if you don’t understand what you’re doing, you can make your image even larger.
The ultimate solution to preserve original image data is to create a mask on the image layer in Photoshop (we’ll come back to this later):

As you can see, Dirty transparency is a very powerful yet very delicate technique. You have to know how and why it works before using it. If you are saving PNG-24 images with transparent areas, the first thing you have to do is to check image data in these areas and make the right decision on clearing or leaving them as is.
3. Split by transparency
Sometimes you have to save image in the “heavy” PNG-24 because of few semi-transparent pixels. You can save extra Kbs if you split such images in two parts — one with solid pixels, the second one with semi-transparent — and save them in appropriate graphic formats. For example, you can save semi-transparent pixels in PNG-24, and solid pixels in PNG-8 or even JPEG. Here is a quick (and recordable for Actions) solution to do this. For our experiments we’ll use this elder Russian iPod ancestor:

PNG-24, 62 KB
- Ctrl+click/?+click on image thumbnail in Layers palette to create a selection:

- Go to Channels palette and create new channel from selection:

- Remove selection (Ctrl+D or ?+D), select the newly created channel and run Threshold (Image ? Adjustments ? Threshold). Move the slider to the very right:

- We’ve made a mask for selecting dead solid pixels. Now we have to split original layer by this mask. Ctrl+click/?+click on Alpha 1 channel, go to Layers palette, select the original layer and run Layer ? New ? Layer via Cut. As a result, there are two layers with separated solid and semi-transparent pixels.
Now you need to save those two images in separate files: solid pixels in PNG-8, semi-transparent ones in PNG-24. You can apply Posterization technique on semi-transparent pixels layer to make image file even smaller.

PNG-8
128 colors + dithering
17 KB

PNG-24
posterization 35
6 KB
And here is the result for comparison:

Before
63 KB

After
23 KB
This method has an obvious drawback: you get two images instead of one, which may be not so convenient to use (for instance, when making a product catalog in the CMS).
4. Influence masks
Actually, is is not a PNG-specific optimization technique, but demonstration of rarely-used Save for Web properties: Color reduction influence mask and Dithering influence mask.

Sadly, these properties were removed in Photoshop CS4, so you can try this optimization approach only in the pre-CS4 versions (I’m using CS3).
To understand how influence masks works, let’s open this demo image in PS and save it in PNG-8 with the following settings: Color reduction: Adaptive, Dither: No dithering, Colors: 256.

42 KB
The first thing I’ve noticed about this image is a very fuzzy pendulum. It is a very bright spot on the image and it attracts way too much attention. Let’s try to smooth pendulum’s color transitions by setting dithering to 100%:

46 KB
The pendulum looks better now, but we got another problems: image size increased by 4 KB and solid-color background became very noisy:

We can try to get rid of this noise by lowering dithering value, but the image quality may also be reduced.
Based on these problems, let’s try to do the incredible: increase image quality by lowering the number of colors and image size. Influence masks will help us.
Let’s start with the color. Go to Channels palette, create a new channel and name it color. We’ve already determined that the pendulum is our top priority region to improve image quality, so we need to draw a white circle right on its place (you can enable RGB channel for better precision).

Go to Save for Web dialog and set the following properties: Color reduction: Adaptive, Dither: No, Colors: 128 (as you can see, we reduced number of colors from 256 to 128). Now we have to select an influence mask: click on the
near Color reduction list and select the color channel from drop-down list: Now our image looks as follows:

You can see the influence mask in action: the pendulum looks perfect, but the other parts of image look really bad. By setting influence mask, we said to Photoshop: “Look, mate, the pendulum is very important part of image so try to preserve as much colors in this area as possible”. Influence mask works exactly the same as regular transparency mask: white color means highest priority in corresponding image region, black color means lowest priority. All intermediate shades of gray affect on image proportionally.
The pendulum now takes the highest color priority, so we have to lower the intensity of white circle to leave more colors for other areas. Close Save for Web dialog, go to Channels palette, select color channel and open Levels dialog (Image ? Adjustments ? Levels). Set the maximum output level to 50 to lower the white color intensity:

Try to save for Web again with the same properties:

Looks better now, but now we’ve got problems in other image areas:

I think you already understand how influence masks works: you provide Photoshop with some clues about important image areas with different shades of gray. With trials and errors I’ve got the following color mask (you can copy it and apply to the image):

Dithering influence mask works exactly the same, but instead of colors, it affects the dithering amount of different image areas. Lighter color means more dithering. This is a very useful feature, because dithering creates irregular pixel patterns which hinders the PNG compressor to use delta filters. You can determine the exact areas where dithering must be applied while leaving other areas intact, thus gaining better compression of image data.
My dithering channel looks like this:

Applying both color and dithering influence channels with the same optimization settings (Adaptive, 128 colors):

Pretty good for 128 colors, isn’t it? Let’s do some finishing touches: set colors to 180 and max dithering to 80%. And here is our final result compared to original, non-optimized version:

256 colors, no dithering, non-optimized
42 KB

180 colors, optimized
34 KB
Please stay tuned (RSS, Twitter) for the second part of the article where we’ll cover further techniques; we’ll talk about grayscale images, using less colors, lowering details and discuss further tips for PNG usage and optimization as well as the PNG optimization in practice.
Related posts
You may want to take a look at the following related articles:




Davin
July 16th, 2009 6:18 amAs a png novice – are they safe to use on websites in place of gifs?
Do all browsers like them?
IE6 hates PNG, but you can get some simple JS work arounds.
cancel bubble
July 16th, 2009 6:29 amFor those concerned with the time involved in manually editing possibly large amounts of images (I’m one of them), check out http://smush.it
It uses OptiPNG and pngcrush (both mentioned towards the top of this article). It’s also available in the latest YSlow (under Tools).
Tim Ward
July 16th, 2009 7:13 amLiked the Article. Been using PNG’s and the methods described here for a While.
I did want to point out one little thing that may be misleading.
Your small gradient was only 5 steps, sure – but you should not use the .gif format for something like that. Basically Gif works because it records the first bit (color), and how far that color continues until it hits a new color.
So a Solid Red square, no matter How big, will have the same file size. If you have an image with Many color changes (i.e. a photo, or even a life like illustration or a large gradient), it is best to use a .jpeg format. (I don’t want to get into the compression of .jpeg here, but it samples “clusters” of similar colors). Now, since we are discussing transparency here, Obviously, you want to use a gif, jpegs don’t have an alpha channel. and the rest of the article is great – I just didn’t want readers to straight compare a .png gradient file with a .gif gradient file, as it should have not been used in the first place. Unless it really is a Tiny file.
Keep up the Great work, and Ill keep up the great reading!
kocsmy
July 16th, 2009 7:29 amOMFG this is fuckin awesome!
Listoric
July 16th, 2009 7:38 amWow, this is an awesome article! I have to go through this several times as this is just incredible and comes so in handy. Thanks for sharing!
r_jake
July 16th, 2009 11:29 am@bryan
IE6 will work fine with PNGs, except that it won’t recognise alpha transparency out of the box (the transparent areas show as a weird opaque blue-grey colour).
There are two solutions:
1. Use Fireworks to create an 8-bit PNG with indexed alpha transparency – works fine in all browsers and just shows up as GIF-like boolean transparency in IE6. Pros – will work without any hacks or additional scripts. Cons – a bit time consuming to apply to large numbers of images.
2. Use JavaScript to invoke either the Microsoft proprietary filter effects or VML rendering to force IE6 to recognise the alpha channel. Pros – quick to implement. Cons – using filters can trigger other bugs in IE6, some scripts are incompatible with other JS frameworks (such as JQuery) that you may be using, and if end user has JS turned off they just won’t work.
Best script for this I have found so far is DD Belated PNG
JT
July 16th, 2009 3:25 pmThanks for the tips! Of all the times where I find myself fretting over filesize, flash projects (especially banners) are where optimisation has had the most immediate and practical impact.
Nick
July 16th, 2009 5:17 pmAnother interesting read. This is a great site – really – well done. Please keep it up.
graphicfood
July 16th, 2009 9:38 pmGreat article, some really handy techniques. One caveat I feel should go with the splitting the png image:
Splitting an image in 2 can become counter productive, particularly for smaller images (sub 20kb) when taking into account connection lag overhead. This is particularly important when considering the increased use of internet connections on cellular networks. By the time you go through a local wireless router to a wireless internet connection to a local exchange then to a remote server you can be looking at a significant lag in connection time in each request.
I’m not saying this isn’t a valid technique, just saying that latency should be taken into account before deciding to split images. This also depends greatly on your server and it’s something you have to assess on a case by case basis.
Hieu Vo
July 16th, 2009 10:27 pmnice tut ;)
Jaik Dean
July 16th, 2009 11:58 pmSuperb article; informative, well-written and useful. If there was more of this quality the web would be a much better place!
Gareth
July 17th, 2009 1:27 amthanks for the tut
Flak
July 17th, 2009 4:13 amIn Fireworks all this is just build in, Fireworks rule png on all ways.
aleX
July 17th, 2009 5:52 amwow this is just amazing, thx
oleg
July 17th, 2009 6:46 amIf you use PNGOUT on your best result, it compresses it even further – down to 31,957 bytes (compared to yours 34,610).
http://www.olegkikin.com/result1.png
Jake
July 17th, 2009 10:24 amThis is nice info but the point of PNG is to have lossless compression.
In all these cases, using JPG would give better results.
Musam
July 17th, 2009 6:14 pmwoahh! great style! :D
waldo
July 17th, 2009 7:03 pmI don’t understand this very well. I will have to re-read it quite alot
Yogsototh
July 18th, 2009 4:21 amGread article!
Niilo Tippler
July 18th, 2009 10:04 pmThanks for this superb article! Using the posterization technique here and the Dirty Transparency action I was able to reduce the header PNG on my site from 590K to 404K!!
Riccardo
July 20th, 2009 2:06 amSergey, thanks for an excellent post. It’s very informative and well-researched.
slice2U
July 20th, 2009 6:04 amThanks for the amazing PNG Tut :)
Slice2u.com
Conrad Chu
July 21st, 2009 9:42 amJust wanted to announce that punypng (http://www.punypng.com) now has built-in support for dirty transparency. I’ve been getting some great results with the new technique that I decided to just add it into punypng so I don’t have to even think about it.
Here’s my write-up on punypng’s implementation of dirty transparency and some side-by-side comparisons:
http://www.gracepointafterfive.com/punypng-now-supports-dirty-transparency
I’ve been in contact with Sergey Chikuyonok (the author of this smashing article) regarding the implementation of dirty transparency. He took punypng for a test drive and reported to me that his results with punypng have been very impressive … better than optipng or imageoptim (with all the libraries enabled). Give it a try as well … I’d like to hear what others are getting out of it.
coolguy
July 21st, 2009 10:41 amIn the Split by Transparency technique, how was the final image saved as one file so the file size is 18 Kb?
Thanks
Jim
January 5th, 2010 2:16 am*bump*
I’m also curious how this technique is put into practice in HTML/CSS. Layering image divs on a z-index or what?
Max B.
July 21st, 2009 10:41 pmNice article!
Last time i cared about png optimization was in 2003.
Don’t think it is necessary anymore, since the internet connections keep getting better!
Just wondering, does anyone know if Photoshop has improved their png compression options? Back then PS was the worst!
Makes me think about how few the Web has changed since then, 6 years and you still find similar issues discussed!
coolguy
July 22nd, 2009 3:12 pmNice article, I’ve learn a lot. Although the last technique didn’t really work for me. When I saved the image as PNG-8 it locked the layer and then I couldn’t draw the white circle in the channel I created. The only way to unlock the layer was to save it in a JPG format and do the changes in JPG format. So I am not sure if the instructions are not quite precise or I am doing something wrong.
feeling
July 28th, 2009 12:38 amFrom the article, I learned a lot, it helped me solve a lot of questions.
I believe that in China there are still a lot of people every day in the search “PNG”, and it troubles. Such a good article I hope to be able to help more of the front-end engineer, so I would like to have your permission to let me use the Chinese translation of this article, thank you!
pJ
August 11th, 2009 1:01 amMr. x128 has created the small program for interactive optimising records png.
This program allows to make png better quality, than that are described here in article.
http://pj2k.livejournal.com/1728.html
subcorpus
August 29th, 2009 8:55 pmawesome article …
thought i dont get whats happening in the PNG conversion part … hehe …
anyways … thanks …
Gopal Raju
September 17th, 2009 9:37 amOne of the best articles I’ve ever read!
heaven
September 29th, 2009 12:03 ammost wonderful post ! Congratuation!
ivan
January 7th, 2010 10:52 pmwow! I’ve been reading Smashing magazine for a while and this has to be one of the best and most useful articles I’ve ever read. Great work Segey!
John Macpherson
January 23rd, 2010 10:50 amOutstanding work and research. Simply, the best article iv read on SM.
ULTRABOLD
February 7th, 2010 7:48 pmThank you! That’s Awesome Post!
alone
March 10th, 2010 9:26 amAMAZING!! Cheers!
David Ryder
June 26th, 2010 9:33 amSadly most of these techniques don’t work very well in images that have a lot of transparency. The first technique worked very well though. PS is amazingly complex… Anyway, I had a 134kb image (main logo) at http://wildreason.com and I was able to get it down to 99kb using posterize. Pretty awesome. I’m a freelance website designer and I think load times is one of the most overlooked aspects of creating a highly optimized website for search engines.
But for really impressive, detailed graphics, the jury is still out. The search continues! Thanks for the tips though… bookmarked.
Anthony thyssen
July 6th, 2010 7:13 pmYou can use ImageMagick to batch process PNG images to remove Dirty transparency…
See the ImageMagick option -alpha Background
http://www.imagemagick.org/Usage/basics/#alpha_background
Also look at the discussion on the ImageMagick Forums
http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=16566&p=60757#p60757
RED
August 26th, 2010 4:18 amVery good article.
anish
August 31st, 2010 1:23 amDirty transparency rocks! works well for me. thank you so much for this post !
Henrik Kjelsberg
September 21st, 2010 5:16 amI have not used the posterize adjustment yet. Nice little tip there.
Thank you!
Valldeperas
October 7th, 2010 3:06 amSo useful!
John Lewis
October 19th, 2010 2:50 amExcellent tutorial, I have a site that’s very transparent image intensive so this is gonna save me a LOT of grief. Dirty transparency is the missing link for me. Great stuff, thanks!
Emre
December 2nd, 2010 11:21 amGreat article. Thanks.
Ryan
December 10th, 2010 1:35 amAwesome tutorial. Thank you! Definitely bookmarked.
Jaff
January 22nd, 2011 4:22 amThe ultimate tool for PNG compression optimisation (see also page2 of the thread for updates)
http://en.irfanview-forum.de/vb/showthread.php?3318-the-ultimate-tool-for-PNG-compression-optimisation
Chris Amling
February 22nd, 2011 1:47 pmGreat Tutorial. I used a few of these techniques and got my large png from 600 to 340. Thanks again.
TheAL
March 27th, 2011 4:44 pmGreat article. The “remove transparency” plugin, however, seems to be down. Bummer.
nalu
March 29th, 2011 12:28 amthanks for this amazing article.. very useful for optimize png
Luis Abarca
April 20th, 2011 8:42 amExcelente artículo!!, very clever optimization buddy
Doug C.
April 20th, 2011 11:13 amSergey, thanks for the awesome tutorial. I never knew about the posterization trick. You just saved me a few pixels :)
Thomas
April 27th, 2011 12:35 amThanks for this great article. I see it is from 2009 but didn’t stumble upon it until now. We (the company I work for) never really used big sized PNG images in our web projects, but just recently we finished a website which called for large PNG images on top of another background image. Due to the large amount of visitors there is a lot of data traffic on the server which is know casuing problems. I am looking into optimizing all the PNG images and posterization seems like it’s the only way to go since all the images contain shadows. Does anyone know an easy way to apply technique number 2 (Dirty Transparancy) to PNG images containing shadows? I hope someone can help.
Larry Byrd
May 5th, 2011 12:20 amI used posterize on Paint Shop Pro and set it to 40 as you suggested. It got a huge png from 253kb down to 161kb. I tried a number of the other programs that some suggested here. The best was Riot. It created a gif file with transparency down to 74 kb. However, it was not good enough for professional work. When I used Riot in the png format, it took very little off, and when I went to keep the transparency it actually added to the file size up t0 290 kb.
I found most of the other programs only take a little off. Very rarely do you find a help as yours which is so much better and so much easier. The posterize trick took 30 seconds. All the rest were time consuming. Great job!
~mark
June 7th, 2011 1:55 pmfrankly, i find photoshop an abysmal waste of money and time and got rid of it as PNG is the only raster platform I need for web graphics ~ i feel sorry for people like the author of this article who recognize the vaste superiority of PNG alpha layering over PSD memory rape and mental anguish ~ one of two things could correct this deplorable situation :: Adobe could finally adopt full support for Open Source PNG Alpha Transparency Layering (come on baby, talk to Ulead or Microsoft or Micrographix or or or …) :: unplugged brain drains like this article could disappear forever (that we will not miss)
Marwan Salfiti
July 7th, 2011 2:53 pmI just used this technique for a few of my websites. I build my sites with WordPress and have been hearing from my clients the the sites were slow. Granted, these are graphic rich sites, but in this day and age, that shouldn’t really matter, right? Wrong! I tried so many tips and tricks and this technique (posterizing the images) worked masterfully. On some images, I crunched more than have the size out.
To put a number to this, I eliminated over 130k in some instances on a restaurant site where image presentation is key. I posterized, reduced, masked where I could not suffer in quality and tadaaaaa! Thanks for the great tut, one definitely worth saving and referencing over and over.
Arno
July 11th, 2011 4:57 amImpressive in-depth article on png-optimization.
A few of these techniques were totaly new to me
zhangsn
August 2nd, 2011 7:10 pmGreat article! However there might be something wrong within your post.Check this: “The “Up” filter sends the message to the PNG decoder: “For the current pixel take the value of the above pixel and add it to the current value.””. Should it be ‘SUB’ not ‘add’? And same problem with the “Sub” filter. :)
trlkly
August 26th, 2011 10:09 amI don’t understand how the posterizing thing works. According to the Gimp documentation, a level of 40 means 2^40 colors, while a (no-alpha) PNG is 24-bit, which I would assume would mean 2^24 colors So why does it reduce colors?
Not that I’m complaining: It works well enough that I got an image to be smaller than a JPEG. Heck, it was almost the size it was when I made it an 8-bit PNG (which looked awful).
Jeffrey Faurillo
August 29th, 2011 4:20 pmNice info! now I know how to optimize png files :) kudos!
Phil Nelson
November 10th, 2011 7:55 amThis is a very in-depth article. For developers who want more of a turn-key solution to some of the techniques described here (or even to add a layer of optimization on top of these), try my PNG optimization application for Mac OS X, PNGPress: http://extrafuture.com/code/pngpress/
Alexis
December 12th, 2011 10:26 amTotally rocking article. I always wondered about Fireworks and Photoshop saving different sized png’s. Those examples are fantastic also, really detailed and teaches me techniques I never knew of.
Frozenbark
December 13th, 2011 6:08 amImageAlpha does these optimisations automatically!
Especially posterization can be done *much* better than in Photoshop. In the article it reduces 84KB → 53KB, but ImageAlpha can do 37KB on the same image! (or even down to 24KB with PNG8+alpha).
John
December 16th, 2011 8:15 amUnbeliveble……2. Dirty transparency
Its really works for me. Thank You