Live data from Hacker News

Websites should not use dithered images

simplethread.com

11–20 of 133 posts

Re: Websites should not use dithered images

#12
The idea that dithering should be used to reduce your image size is a misunderstanding of image compression.

Dithering is a technique which allows you to represent a color image with a very limited palette, in particular a two bit palette. The result is not much like a normal photo, but much better than nothing if you have a machine that can only output a few colors. (You could think of that as a sort of compression where the goal is not to reduce file size, but to reduce the number of colors needed to comprehend the image.)

JPG, WebP etc. are compression techniques designed to reduce the size of a full color images, especially photos. Because they’re specifically designed for photos, they don’t work as well on things that aren’t “photo like.”

Dithered images are very much not like real photos, so it’s not surprising that compression techniques designed for photos don’t work well on dithered images.

(I’m not an expert on image compression, but as an example, I believe JPEG and similar algorithms expect to find large blocks of basically the same color in photos - such as a blue sky - and save space by simplifying that to a few big regions of all one color. The “speckled” appearance caused by dithering actively defeats that particular optimization.)

Re: Websites should not use dithered images

#13

TLDR: There are much better compression algorithms than dithering

Dithering isn't a compression algorithm[1]. It's an algorithm that adds noise to effectively increase bitdepth when downsampling.

In the case of images, it makes color-reduced versions not look terrible.

Adding noise is almost always a bad thing for compression. The undithered images would compress much better.

[1]: https://en.wikipedia.org/wiki/Dither

Re: Websites should not use dithered images

#14
Isn’t the whole point to switch to a palleted image when you dither? If you are leaving it truecolor it just makes the image worse for no benefit as the article noted. Switching to a palleted PNG however can save a lot of bits in certain circumstances.

That said just pulling out a good lossy encoder makes a lot more sense most of the time. It is easier and it will look better. Dithering is lossy anyway.

Re: Websites should not use dithered images

#15

The idea that dithering should be used to reduce your image size is a misunderstanding of image compression. Dithering is a technique which allows you to represent a color image with a very limited palette, in particular a two bit palette. The result is not much like a normal photo, but much better than nothing if you have a machine that can only output a few colors. (You could think of that as a sort of compression…

you might get better results with a run-length encoding on a dithered image. I’m not aware of any modern image formats that use RLE though.

Re: Websites should not use dithered images

#16
post #8

Don't forget dithering your spacer.gif files! very important!

This is what I think of when the dithering articles show up. Way back in the day, dithering and reducing the color palette made a difference, when you were talking images loading over a 28.8k modem. For many widgets, you could shave kilobytes off, when kilobytes really, really meant something.

Re: Websites should not use dithered images

#17
post #6
post #3

Curious if this is a commentary a propos a popular low-tech website we see around HN. I appreciate the dithering pattern, though I recognize it is not as efficient as, say, a compressed jpeg or a palette limited GIF.

Shouldn't dithered images also benefit from the limited palette?

I grabbed one of the dithered images off the article and saved it as an rgb png and as an indexed png with 255 colors.

rgb: 75kb

indexed: 35kb

So indexing does look like it could save a lot. I do wonder if it can still beat out say jpeg or webp though.

Re: Websites should not use dithered images

#18
Lesson learned: test your optimizations.

I will admit I'm surprised by the results. I assume there's not really a rendering perf hit from WebP vs jpg?

Also, the preposition that lowering the file-size, and therefore transfer time, is the most important factor in environmental impact is, I think, a little under-supported.

That being said, the original Low Tech Magazine article's perf claim is back up from the data, but they also use very low resolution images.

I'd be curious if dithering could be optimized to a particular algorithm. For example, jpeg's quantization is based on the assumption that images are mostly made of low frequency data and higher frequency can be removed without changing the quality of the over all image too much. With dithering, this is almost the exact opposite and all low frequency information is replaced with high frequency information, meaning it won't be nearly as effective.

Re: Websites should not use dithered images

#19
post #5

I would also be concerned with how these things scale in terms of the display. For instance somebody might have a HiDPI or Retina screen or they might be zoomed in or out on a particular web page. Or for that matter maybe you want to scale the size of the image so it fills the screen horizontally or vertically. The scaling algorithm might maintain the the dither or it might smooth and blend it. Maybe it looks OK in t…

Not to mention the fact that dithering will look different depending on the display’s gamma calibration...

One thing I like about my Gameboy 3DS is that the display is consistent and artists can tune art up for it.

For some game series (say Hyperdimension Neptunia) fan art captures the essence of art in the game but for the big Nintendo games on the 3DS (say Fire Emblem Fates) fan art doesn't look like the game art at all because the game art is calibrated to the characteristics of the display in every way.

Re: Websites should not use dithered images

#20
post #8

Don't forget dithering your spacer.gif files! very important!

This is what I think of when the dithering articles show up. Way back in the day, dithering and reducing the color palette made a difference, when you were talking images loading over a 28.8k modem. For many widgets, you could shave kilobytes off, when kilobytes really, really meant something.

well tbh they still do today. Every byte you can take off (very easily at that ...) makes websites: . faster to the user, which does contribute to a general reduced level of stress :-) . use less energy: less bandwidth/less CPU (cisco, nginx, your disk/memory cache.... you name it). Less $$ on your bandwidth/cpu bill @[insert cloud provider here] and less BW/CPU used up on your user's mobile metered connection (because nowadays it's mobile, dontcha know) So even though if many instances over-optimisation is definitely overkill ...in nearly all cases a sane amount of optimisation is good.

my 2p

Post reply on HN