Re: Dithering: an idea whose time has finally come?

Published by Beto Dealmeida on

Dithering and tinting images

mntn.xyz talks about dithering:

It seems that dithering is undergoing a renaissance on Gemini. Not only does it introduce a pleasant retro aesthetic, but for images with smaller dimensions, dithering with a reduced palette can both save bandwidth and make content more accessible to old devices.

I decided to give it a try, with a couple twists.

Sunrise in the Estero Americano, Bodega Bay, CA

Python dithering

I'm using Python to dither the images:

from PIL import Image

input_ = Image.open('image.jpg')
output = input_.quantize(
    colors=8,
    dither=Image.FLOYDSTEINBERG,
    kmeans=1,
)

CSS blending

On my blog I'm blending the dithered images using CSS, depending on the choice of a light or dark theme:

@media (prefers-color-scheme: dark) {
  img {
    mix-blend-mode: screen;
  }
}

@media (prefers-color-scheme: light) {
  img {
    mix-blend-mode: multiply;
  }
}

Enclosures

Tags

Categories