dotmatrix icon indicating copy to clipboard operation
dotmatrix copied to clipboard

Feature Request: Dithered Images

Open timfi opened this issue 3 years ago • 0 comments

Description

An amazing feature would be the ability to render a given image onto a dotmatrix. And to make things prettier some sort of dithering, be it Floyd-Steinberg or Atkinson or something else entirely, would also be nice.

Code

import dotmatrix as dm

m = dm.Matrix(256, 256)

m.blit(
    "path/to/my/image",
    area=((63, 63), (191, 191)),  # The area to blit the image to.
    dither=dm.dither.Floyd        # The dithering algorithm to use.
)

print(m.render())

or

import dotmatrix as dm
from PIL import Image


m = dm.Matrix(256, 256)
img = Image.open("path/to/my/image")

m.blit(
    img,
    area=((63, 63), (191, 191)),  # The area to blit the image to.
    dither=dm.dither.Floyd        # The dithering algorithm to use.
)

print(m.render())

Output

No response

Anything else?

Example: DotArt by Garrett Albright

The latter example usage would require pillow as dependency. Thus it might be sensible to block this feature behind an "import guard" and add pillow as an extra-install-option, àla dotmatrix[images].

timfi avatar Aug 16 '21 20:08 timfi