Sreevathsabr
Sreevathsabr

Reputation: 689

Identifying the Pixel format(Like RGB, CMYK, LAB..etc ) of image in python

I have a set of images, I need to identify the image format.

When I try to do with the number of channels, there are multiple image format with the same number of channels (For Ex: CMYK and YGBR have the same number of channels )

So this methodology didn't work for me.

Please help me, is there any methodology do differentiate the Image pixel format.

Upvotes: 2

Views: 645

Answers (1)

Arkadiy
Arkadiy

Reputation: 56

To determine the color scheme of image, use the following:

from PIL import Image
img = Image.open(PATH_TO_IMAGE)
img.mode

the field "mode" contains the data you need

It is written in more detail here: https://pillow.readthedocs.io/en/5.1.x/handbook/concepts.html

Upvotes: 3

Related Questions