DEV Community


Posted on

Detect any color with Python

You can detect any color with Python. That can be a color of any object defined as string, like:

fish ='fish')

What it's doing behind the scenes is use Google Image API.


You can install the module WhatColorIsX with pip.

$ pip install WhatColorIsX

You may find you need to pip install Pillow as a dependency first, although it will be attempted automatically.

Import to your project

For almost all cases, call the new() factory function, then get the colour value from the color() method:

import WhatColorIsX

brick ='brick')
brick_color = brick.color()
fish ='fish')
fish_color_bright = fish.color(bright_hue=True)

If you already have PIL images that you want to process, you can use the same syntax:

from WhatColorIsX import whatcoloris_image
from PIL import Image

img ='images/cat.jpg')
cat =
cat_color = cat.color()

Top comments (0)