How do I get a list of all the Indexed Color mode PNGs that are present in a given folder that contains a lot of other files (which are all images, but they all have different Color Modes) using Python?
Previously tried code:
from PIL import Image
import os
path = 'logos/'
for x in os.listdir (path):
if x.endswith(".png"):
img = Image.open(path + x)
cmode = str(img)
P = 'mode=P' in cmode
if P == True:
print (x + " " + str(img))
Using this code, I got a list of images, some of which are Indexed Color mode, and the rest are RGB color mode (checking them through Photoshop) https://www.dropbox.com/s/vlvywqhcfrkk8kq/3978.png?dl=0 This is a link to an image that shows up as P through the script, but it is an RGB image in Photoshop. https://www.dropbox.com/s/x3qiuuhs3gv9bp9/6507.png?dl=0 This is a truly Indexed Color image, like the ones that I need to find.