mhucka
mhucka

Reputation: 2399

Python Pillow: how to produce 3-channel image from 1-channel image?

A Python package that I'm trying to use only works with 3-channel images. If I have a grayscale PNG image, Pillow's Image.open() naturally reads it as a single-layer image. How can I use Pillow to transform the 1-channel image into a 3-channel RGB image?

Upvotes: 5

Views: 3704

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207883

The simplest method to convert a single-channel greyscale image into a 3-channel RGB image with PIL is probably like this:

RGB = Image.open('image.png').convert('RGB')

Further discussion and explanation is available here.

Upvotes: 6

Related Questions