by symisc_devel on 9/29/21, 4:29 PM with 121 comments
by ohazi on 9/29/21, 5:14 PM
In fact, even in the 80's, dithered images were often larger than their un-dithered counterpart, sometimes by a lot. But it was worth the trade-off when the alternative was an image with so much banding that it could be confused for a European flag.
Unless you're trying to display your image on a retro console (or have aesthetic reasons for wanting to achieve that effect), you should not use dithering. Essentially all modern devices have a sufficiently enormous color palette, and modern compression algorithms use other techniques to achieve their efficiency.
In fact, modern compression will do a much better job giving you a smaller file size if you don't use dithering.
Edit:
Don't get me wrong, dithering is a super interesting topic, and designing a good dither can be surprisingly hard, it's just not going to help you if your goal is to shrink the images on your website the way the article claims.
If you haven't seen the trailer for "Return of the Obra Dinn" you owe it to yourself to take a look:
Super cool aesthetic, and writing that shader must have been all sorts of difficult/fun. But you don't do this sort of thing for compression efficiency.
by pseudosavant on 9/29/21, 5:18 PM
Dithered 8-bit/256-color images will look 'better' than non-dithered 8-bit/265-color images, but it will almost always be worse that a 24-bit JPEG (no alpha) or 32-bit webP (includes alpha) and have a much larger file size.
I did some quick tests with https://squoosh.app. The 8-bit dithered PNG is >4x the size of the JPEG. It also shows some terrible banding on any kind of gradient in the image. The PNG is 5x larger than a better looking webP version of the same image.
I tested a lot of images (photos, drawings, digital artwork, etc) and some of the images were 10x larger as dithered PNGs vs webP/JPEG. Only one was smaller as a dithered PNG.
by kangalioo on 9/29/21, 4:57 PM
If you just want small images, a lossily compressed image will probably look better than a lossless dithered image
by diogoterremoto on 9/29/21, 5:03 PM
Modern compression algorithms with native lazy loading will probably offer the best of both worlds.
by icyfox on 9/29/21, 4:58 PM
by jameshart on 9/29/21, 5:03 PM
If you are coming up with a look for a site, dithering all the hero images, or running them through a cell-animation filter, or mosaicing them, or halftoning them, all are stylistic choices that might help your design stand out, and help reduce file size.
But… no, you probably shouldn’t just diffusion dither everything down to black and white.
by dmitrybrant on 9/30/21, 2:35 AM
First of all, no discussion of minimizing PNG sizes is complete without `pngcrush` which applies all kinds of optimizations to the PNG file (losslessly). In fact pngcrush reduces the author's 48kb dithered file down to 28kb.
And secondly, modern compression formats like webp and avif will blow PNG out of the water when compressing any kind of photographic image. Heck, just turn down your JPG quality, and your image will be much smaller, and still perfectly recognizable.
Know when to use the right tool for the job:
PNG -> diagrams, charts, anything with perfectly uniform areas of color and sharp transitions.
JPG/AVIF -> photos, anything with smooth variations in color.
by w0mbat on 9/29/21, 5:04 PM
by armada651 on 9/29/21, 5:36 PM
by mark-r on 9/29/21, 6:25 PM
Dithering isn't usually worth the reduction in quality. And ironically it can make things worse if you're not careful - dithering the image and saving it as JPEG actually INCREASED the size to 39K!
by kixiQu on 9/29/21, 5:17 PM
and on the command line, good ol' imagemagick comes through with something like
convert picture_with_cool_colors_you_like.png -colors 10 -unique-colors sourcecolormap.png
convert source.jpg -resize 500x500\> -ordered-dither o4x4 -remap sourcecolormap.png output.png
mutatis mutandis. :)
by tblt on 9/29/21, 6:33 PM
Given all the trade, commerce, learning, community, education, entertainment, and countless other benefits and multipliers the internet brings, I can't help but feel it's a fantastic return on its energy investment.
by defanor on 9/29/21, 5:03 PM
by WoodenChair on 9/30/21, 2:49 AM
Here's the app: https://oaksnow.com/retrodither/
And here's my blog post talking about how I wrote it: https://www.observationalhazard.com/2021/09/building-retro-d...
by dahart on 9/30/21, 4:53 AM
Dithering is still commonplace, but mostly invisible, for high-end color. Photoshop quietly dithers by default when converting from 16 bits per channel to 8 bits, for example. This is important when sending 8 bits/channel images out for large-format printing because the invisible differences on screen can become clearly visible on paper - the monitor’s gamut and the printer’s gamut are surprisingly dissimilar. Dither is needed to keep smooth gradients from banding badly, and it sucks when you’re spending $100 per print or more to have nasty bands or even compression artifacts appear.
by Brajeshwar on 9/29/21, 4:56 PM
by mikl on 9/29/21, 5:56 PM
If you really want to save bandwidth, you’d be better off looking at better formats like AVIF, and WebP.
Those will shave off a lot of extra bits, especially AVIF, although that is not universally supported yet.
Combine that with making a the images a little smaller would save you a lot of bandwidth, without making your pictures look like they are 20 years old.
by tyingq on 9/29/21, 5:22 PM
Also, better to compile from source. There are os packages, but they tend to be older versions of pngquant that have various issues.
by WithinReason on 9/29/21, 5:49 PM
by naikrovek on 9/30/21, 12:55 AM
this is an often-missed detail, unfortunately.
by the_gipsy on 9/29/21, 4:57 PM
by munificent on 9/29/21, 6:28 PM
This means that the main meaningful way users will see the image is resized as a thumbnail, so before you start dithering, you should really test to see how the resized dithered image looks. Odds are good it will not look good.
by pablodavila on 9/29/21, 5:17 PM
by dreamcompiler on 9/30/21, 5:01 AM
1-bit DACs in CD players are the same idea: Trading higher sampling frequency for lower sample resolution to convey the same information.
Bresenham's algorithm is yet another expression of the same idea but there the samples in question represent the slopes of straight lines represented by pixels.
by discreditable on 9/29/21, 5:07 PM
by edflsafoiewq on 9/29/21, 6:13 PM
For example, my-dog-dithered.png which uses only black and white is stored as 4x8 bpp instead of 1bpp. Running it through optipng halves the size.
by Gormisdomai on 9/29/21, 5:04 PM
by Sohcahtoa82 on 9/29/21, 5:44 PM
And probably 3 MB of JavaScript...
by Panino on 9/29/21, 5:17 PM
If you don't, but you want your webpages to load fast, look into WebP and AVIF images. Load them opportunistically using the html5 PICTURE tag - no JS required and no worry about old browsers not supporting new formats. Even plain lossless encoding of legacy formats goes a long way. Test your own site for ideas:
by system2 on 9/29/21, 5:16 PM
LOL What. Make it 10mb.
by bigattichouse on 9/29/21, 5:08 PM
by dirtyid on 9/29/21, 7:38 PM
This is a fun stat, I wonder how much physical infrastructure is actually behind serving all the images vs videos / adtech.
by zokier on 9/29/21, 9:05 PM
I think we can pretty conclusively say that dithered PNG does not make sense from bandwidth point of view.
by MrYellowP on 9/29/21, 8:26 PM
This GDC presentation, featuring Mark Ferrari, shows how it's done: https://www.youtube.com/watch?v=ri4_3P2Oh14
by robbrown451 on 9/29/21, 5:36 PM
by petermcneeley on 9/29/21, 5:44 PM
by supermatt on 9/30/21, 6:51 AM
by noja on 9/29/21, 4:58 PM
by neivin on 9/29/21, 5:49 PM
This is literally moving backwards.
by jjcm on 9/29/21, 5:55 PM
Here's his dog picture encoded to webp using default settings (11KB): https://image.non.io/dog.webp
This is smaller than all but his two color and his four color examples, at a tremendously higher fidelity. Just for comparison:
webp vs original @ 11KB: 2.1% difference from source image.
gameboy vs original @ 8KB: 18.2% difference from source image.
4 color vs original @ 9KB: 15.2% difference from source image.
Even if you compress the webp down to 8KB, you only encounter a 3.3% difference from the original.
TL;DR - use modern image formats. Don't use dithering for compression.
by literallyaduck on 9/29/21, 5:38 PM
by jebronie on 9/29/21, 6:38 PM
by skyde on 9/29/21, 8:07 PM