Lossy PNG
pngmini.com
pngmini.com
There is a reason why jpg has survived the test of time. It delivers a good balance of quality, performance, and is well supported. Challengers like JPEG 2000 have not gained much traction because jpg gets the job done. http://en.wikipedia.org/wiki/JPEG_2000
I've chosen Lenna as an example image because it's a classic, rather than as an example where lossy PNG can't be beaten.
But take any transparent image from Apple.com, and you can halve its size: http://imgur.com/a/VLlqG
(and images from pngquant2 are even smaller, but there are few that become too lossy).
But once you open the "I can accept information loss" door, it might be worthwhile to experiment with other image manipulations also. For example, consider dropping color depth. Some images survive that process well.
Here's a 1-minute experiment... take the lenna.png image from the article... open in GIMP, posterize to 27 levels (or whatever you think is acceptable), export back to PNG... 43% savings.
For photos (like lenna.png), jpg is nearly always a better choice if you're ok with lossless, even better than png with the tricks mentioned in the article.
Of course there are some situations where png simply has features you want, like an alpha-channel, but some people even work around that (eg. in some videogames) by encoding the image part as jpg and a separate 8-bit alpha map in a lossless format to go with it and these are merged back together at load time. Not really suitable for the web, though (possible, but wildly inefficient compared to just letting the browser do the compositing).
Last time I checked GIMP's palette generation wasn't very good - it supported only binary transparency and truncated bits unnecessarily.
I've wanted to replace GIMP's old algorithm, but haven't even managed to compile all the prerequisites for the monstrous codebase :(
One more thing I do in pngquant2 and haven't seen it done anywhere else is dithering only areas that need it, rather than dithering entire image. This minimizes noise added and makes files look and compress better.
A lossy codec would take advantage of limits in human perception and encode LightBlue-MediumBlue-DarkBlue as 2LightBlue-DarkBlue. On a large enough image, you wouldn't notice the difference.
Various techniques are used to accomplish this. One side of the scale is to simply degrade the quality of the original. The other is to use visual/acoustic changes humans have difficulty in recognizing. For instance, the human hear has a minimum distance between frequency and loudness of two tones. The softer tone is dropped in MP3 depending on "compression" level; thus, from a source fidelity standpoint, the quality is "lossy" since the encoded form no longer has the original's content. From a human ear quality standpoint, the quality is barely noticeable to most people.
However, you are right that 'lossy' is usually used to describe its intended use rather than its actual formal limit. For example, you can (probably!) non-lossily encode an image as a jpeg, but it won't be as good a compression ratio as you would get from a format which was specifically designed for use with lossless compression. It might even cause the file to get bigger.
The correct mathematical term for "lossy" is "non-surjective": at a given encoding setting, not all inputs can be represented.
The interesting thing is that the blur filter gave zero benefit, but the "median cut" pngquant to palletize the images gave some pretty impressive gains.
Photoshop uses the same tricks for "lossy" gif that this article uses for PNG.
LZW is just a very poor compression. Even best case is taking ridiculous amount of bits (you can only add 1 byte to previously used pattern, so it's sequence of symbols for 1+2+3+5+6+etc. pixels resetting every 4k iterations), so there isn't even room for improvement.
So, GIF is awful. Should be forgotten.
8-bit palette and crappy compression do not matter when you offer exclusive features.
What you are getting is a lossless copy of an image that has been cleverly preprocessed to be easier for the PNG algorithm to compress while not losing noticeable visual quality. The result is good compression and transparency support (which JPEG doesn't have).
backgorund-attachment:fixed is a bit buggy in Android Firefox, but images themselves are fine.
The page should explain this, since it looks a little weird.
https://gist.github.com/ronjouch/6258621
EDIT: screenshot of what it looks like: https://dl.dropboxusercontent.com/u/368761/bugreport/pngquan...
On the flipside, part of why PNG does so well on lossless compression is due to the scanline-oriented predictor selection - that allows it to beat regular GZIP by identifying ways to losslessly compress 2D image patterns that aren't necessarily obvious in the 1D stream of bytes being sent to the compressor.
That's not lossy PNG. The information is lost in the blur (or other pre-process) before PNG gets ahold of it.
From the example you can see it's not a simple blur, it's side-effect of lossy application of PNG filter.
I mean, you are right that it's not a feature of PNG, rather a side effect of some clever preprocessing but that's just semantics.
The information is lost in the blur (or other pre-process) before PNG gets ahold of it.
As I understood it, I think that's opposite of what he's saying. He's saying blur helps restore info.
From the description, I understood the information is lost by deliberately omitting certain pixels that PNG rendering will try to restore from adjacent pixel data, and that he did a diagonal blur to influence the adjacent pixels to contribute better data to the missing ones. Blurring spread info into diagonally adjacent pixels improving results of using them to reconstruct missing ones.
// source is invoking three png utils, so didn't dig into what it's really doing, just saying I think the explanation is that reconstructing pixels saves space and reconstruction is improved by letting diagonal neighbors contain more info on reconstructed pixel through blur.
> PNG has an ability to “guess” pixels based on their top and left neighbors and successful guesses compress to almost nothing. Usually only few pixels match a guess, but latest ImageAlpha's “Blurizer” option manipulates image data to match the guesses, making compression much much more effective.
You'd be surprised.
Maybe a quick JS speed test and if possible switch all your lossy to lossless? Would look weird on load without a splash screen though.
For reference: http://www.reddit.com/r/apng
There is a simple Chrome extension that adds APNG support, but anything that is not installed by default is unlikely to be used by most users. 90% of Chrome users don't even install an ad blocker!
You say that like it's crazy.
I don't install an ad blocker because I don't mind sites earning money for their content.
"Batch processing Available from command line. ImageAlpha is based on pngquant. You'll find compiled pngquant executable in ImageAlpha.app/Contents/Resources directory."
So you should be able to script that.
Also for people on non-Mac systems, it appears this is available for Linux / Windows as well: https://github.com/pornel/pngquant
Edit: Better link to pngquant: http://pngquant.org/