Dithering was never a compression technique, it's a filtering technique for reducing banding on devices/displays/images that have a small color palette.<p>In fact, even in the 80's, dithered images were often <i>larger</i> 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.<p>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.<p>In fact, modern compression will do a much better job giving you a smaller file size if you <i>don't</i> use dithering.<p>Edit:<p>Don't get me wrong, dithering is a <i>super</i> 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.<p>If you haven't seen the trailer for "Return of the Obra Dinn" you owe it to yourself to take a look:<p><a href="https://youtu.be/ILolesm8kFY" rel="nofollow">https://youtu.be/ILolesm8kFY</a><p>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.
This is generally some pretty terrible advice. Really, don't follow it. At least not without testing its impact.<p>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) <i>and</i> have a much larger file size.<p>I did some quick tests with <a href="https://squoosh.app" rel="nofollow">https://squoosh.app</a>. 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.<p>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.
Seems more like an article on dithering generally rather than how to optimize your website<p>If you just want small images, a lossily compressed image will probably look better than a lossless dithered image
I like the dither aesthetic and underlying message, but it's possible to compress the first image of the dog (123 kB) to 64 kB with MozJPEG and still maintain the same quality.<p>Modern compression algorithms with native lazy loading will probably offer the best of both worlds.
Images serve to make a website beautiful. Dithered images are not - in my mind - beautiful. There are other ways to optimize a website speed and bandwidth. Let's serve devices the image resolution that they can handle and not an XL image just because we can. Let's minimize JS cruft, minimize excessive renders. Sacrificing image quality would be near the bottom of my list.
I think there’s an interesting idea in here - not necessarily that ‘everyone should use dithering’, but more that <i>if</i> you are using an image and <i>if</i> that image is being used in a way that would not be harmed by stylizing the image in some way, that <i>one</i> of the things you can consider when thinking about how to stylize it might be the compressibility of the stylized image.<p>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, <i>and</i> help reduce file size.<p>But… no, you probably shouldn’t just diffusion dither everything down to black and white.
By all means use dithered images on your website for stylistic reasons, but do not use them simply because dithering produces a slightly smaller PNG file.<p>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.<p>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.<p>Know when to use the right tool for the job:<p>PNG -> diagrams, charts, anything with perfectly uniform areas of color and sharp transitions.<p>JPG/AVIF -> photos, anything with smooth variations in color.
As others have pointed out lossy compression will give a way better result. I feel like the author simply misses the aesthetic of the 90s internet and is trying to find any reason for it to make a return.
False dichotomy. Dithering is hardly the only or even best way to reduce image sizes. Just opening his 200x200 original in my favorite editor and resaving as JPEG with my usual parameter choices reduced it from 30K to 11K with no noticeable reduction in quality. I could have tuned the parameters for even more savings.<p>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!
I'm a big fan of this piece! For those looking to play around further, there's<p><a href="https://ditherit.com/" rel="nofollow">https://ditherit.com/</a><p>and on the command line, good ol' imagemagick comes through with something like<p>convert picture_with_cool_colors_you_like.png -colors 10 -unique-colors sourcecolormap.png<p>convert source.jpg -resize 500x500\> -ordered-dither o4x4 -remap sourcecolormap.png output.png<p>mutatis mutandis. :)
> The internet is responsible for 3.7% of global carbon emissions<p>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.
Apparently the author's point is that image compression is useful, but dithering and then using lossless compression instead of using lossy ones sounds like rather poorly reinventing lossy compressions.
Related—I wrote a novelty dithering Mac app and released it this week. It dithers photos and converts them to MacPaint format for display on old black and white Macs. As another commenter pointed out, dithering was less about compression and more about just making things look okay on the limited displays of the time. The original Macintosh had only black and white pixels (no grayscale).<p>Here's the app:
<a href="https://oaksnow.com/retrodither/" rel="nofollow">https://oaksnow.com/retrodither/</a><p>And here's my blog post talking about how I wrote it:
<a href="https://www.observationalhazard.com/2021/09/building-retro-dither-dithering.html" rel="nofollow">https://www.observationalhazard.com/2021/09/building-retro-d...</a>
> Dithering is a retro way of reducing the colors in an image for use on old hardware or in print. Why dither in 2020?<p>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.
Isn't this the technique used in Black-n-White Newspapers. I used to help compose Newspaper layouts in the early 90s, and dithering of images were done for similar reasoning -- printing flat colors are bad, so dither them.
This reads more as an argument against dithering. Sure, it saves bandwidth, but all the images in the post look awful. If I saw pictures like these on a professional website, I’d assume the people behind it were incompetent.<p>If you really want to save bandwidth, you’d be better off looking at better formats like AVIF, and WebP.<p>Those will shave off a lot of extra bits, especially AVIF, although that is not universally supported yet.<p>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.
Not as drastic as the dithering in the linked post, but if you work with png files, pngquant is worth a look. It's lossy, but the image quality is still quite good.<p><a href="https://pngquant.org/" rel="nofollow">https://pngquant.org/</a><p>Also, better to compile from source. There are os packages, but they tend to be older versions of pngquant that have various issues.
the tool loses a lot of points because it doesn't appear to do the necessary gamma correction before dithering. the dithered images, at least the color ones, probably all, are lighter than the source images.<p>this is an often-missed detail, unfortunately.
The reason so many blogs have "stock images of people in suits doing business" is because when the article is submitted to a social media app, the app scrapes the blog looking for an image to use as a thumbnail for the link. Pages with no image, get a default thumbnail and users don't click it. The <i>entire reason</i> so many pages on the web have some generic image from unsplash is because of these thumbnails.<p>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.
In case anyone is curious about dithering in the context of audio, here[0] is an excellent video on that.<p>[0] <a href="https://www.youtube.com/watch?v=2iDrbgfPjPY" rel="nofollow">https://www.youtube.com/watch?v=2iDrbgfPjPY</a>
For those familiar with Sigma-Delta modulation, that's essentially what Floyd-Steinberg dithering is but in two dimensions: It preserves and diffuses sanpling error. (Sigma-Delta just does a better job than F-S of quantifying where the noise moves so you can filter it in the analog domain.)<p>1-bit DACs in CD players are the same idea: Trading higher sampling <i>frequency</i> for lower sample <i>resolution</i> to convey the same information.<p>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.
With ImageMagick, you can use -colors to reduce the number of colors in the image. You don't even have to go down to 256 colors. This will usually make photos larger in size, but drawings/graphics can be smaller.
The images in the article are not optimized, so the comparisons are not meaningful.<p>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.
If we grant that the right kind of blog could make the aesthetics of this work I still think users with cheaper internet might like to be able to click to load the original full-res versions of the images.
I like dithered images and appreciate the author's post.<p>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:<p><a href="https://webspeedtest.cloudinary.com" rel="nofollow">https://webspeedtest.cloudinary.com</a>
If you take the "4x4 ordered dithering" image, and copy it, use a "mean curvature blur" filter (I used gimp - similarly for gaussian with low enough width) and overlay it on the dither at 50% opacity, the image actually looks pretty good. This could probably be done in CSS/JS on a client machine. a 14k image comes across passably, even on my desktop.
>Climate Change. Big images waste electricity and emit carbon. The internet is responsible for 3.7% of global carbon emissions4. A number that keeps growing as we send more and more data.<p>This is a fun stat, I wonder how much physical infrastructure is actually behind serving all the images vs videos / adtech.
Just threw together quick comparison between AVIF and the dithered image: <a href="https://ibb.co/hKnwF1Z" rel="nofollow">https://ibb.co/hKnwF1Z</a> (scaled up 4x)<p>I think we can pretty conclusively say that dithered PNG does not make sense from bandwidth point of view.
I like the idea a lot, but the execution on his website is horrendous.<p>This GDC presentation, featuring Mark Ferrari, shows how it's done: <a href="https://www.youtube.com/watch?v=ri4_3P2Oh14" rel="nofollow">https://www.youtube.com/watch?v=ri4_3P2Oh14</a>
The example images look awful. If the site really has images of "people in suits doing business," why would you want them to be so ugly? I'm not a fan of such images, but if you are going to have them, they should at least look pleasant. These look awful.
Dithered images cause significant problems with many lower end LCD displays. When I scroll any image on my laptop or my phone they change brightness while in motion.
This is terrible advice. Dithering should not be used for compression. Real world example:<p>Here's his dog picture encoded to webp using default settings (11KB): <a href="https://image.non.io/dog.webp" rel="nofollow">https://image.non.io/dog.webp</a><p>This is smaller than all but his two color and his four color examples, at a tremendously higher fidelity. Just for comparison:<p>webp vs original @ 11KB: 2.1% difference from source image.<p>gameboy vs original @ 8KB: 18.2% difference from source image.<p>4 color vs original @ 9KB: 15.2% difference from source image.<p>Even if you compress the webp down to 8KB, you only encounter a 3.3% difference from the original.<p>TL;DR - use modern image formats. Don't use dithering for compression.
Maybe put dithering images outside the paywall and full pictures within and in your ad block placeholder a message that says pro users get the real images.
the example in the page is kind of stupid.
he could have kept using Jpeg but with increased compression ratio to achieve same file size and the visual quality would still be better than dithered PNG.