3

Is there any smart way to convert 24-bit RGB .png image to static 8 or 16 colors images?

I've tried convert function from Pillow.

img = image.convert(mode='P', palette=adaptive, colors=16)

It works really nice. Unfortunately colors are different for each picture, so I can't make use of it.

nowakasd
  • 54
  • 7
  • Have a look here... https://stackoverflow.com/a/61969447/2836621 – Mark Setchell May 27 '20 at 16:52
  • Magick didn't work. Like Pillow it takes 8 best matching colors and recreate image with them. I would like to have picture made of 3-bit or 16 color palette. – nowakasd May 27 '20 at 17:34
  • Do you mean you have 16 specific colours in mind? Maybe you could show input and expected output images? – Mark Setchell May 27 '20 at 18:01
  • I mean 3-bit RGB or some kind of predefinied 16 color palette. Even something returning color names would be useful if I'm able to limit it to use 16 colors – nowakasd May 27 '20 at 18:38
  • I made this using W3C Standard 16 Colors and this code https://stackoverflow.com/a/59549285/10802550 . I'm converting my image to 16 colors using PIL then using that function to get color names from static dictionary. Thanks for your help mate – nowakasd May 27 '20 at 18:54

0 Answers0