Chirag Maheshwari
Chirag Maheshwari

Reputation: 1

2 Color PNG Images

PNG images can be RGB, which is 3 colors. Or they can be greyscale, which is 1 color.

Intuitively, it seems like there should be PNG images that are made out of two colors, and there is some way to convert from RGB to this two-color scale. Is there something well-known like this? And if so, how do you convert the images from RGB to this two-color scale.

Upvotes: 0

Views: 166

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207455

I think you are probably referring to palette images which I described here and Wikipedia describes here.

You didn't describe your environment where you want to convert between RGB and palette, so I'll show you with ImageMagick in Terminal on Linux, macOS and Windows:

magick InputRGBImage.png PNG8:PaletteOutputImage.png

Or, going the other way:

magick PaletteInputImage.png PNG24:OutputRGBimage.png

If you use PIL/Pillow, it is:

paletteImage = RGBImage.convert('P')

and

RGBImage = paletteImage.convert('RGB')

Upvotes: 1

Related Questions