pythonimagepython-imaging-libraryblending

Get image mode PIL Python


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


Solution

  • See the Image Attributes in the documentation:

    Image.mode: str

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

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