Get image mode PIL Python

Chidwack picture Chidwack · Nov 20, 2015 · Viewed 18.2k times · Source

I am trying to blend two images together but I keep getting an error that one of the images in in the wrong mode. I tried to convert this image but every mode I have tried just makes the entire image white. Is there a way in Python with the PIL module to find out what the current image mode is?

Image.blend(img ,im ,0.05)

Error message: ValueError: image has wrong mode

Answer

Peter Wood picture Peter Wood · Nov 20, 2015

See the Image Attributes in the documentation:

im.modestring

Image mode. This is a string specifying the pixel format used by the image. Typical values are '1', 'L', 'RGB', or 'CMYK.' See Concepts for a full list.

The Image.convert method creates, from an existing image, a new Image with a given mode.