Skip to main content

Image color clustering library for extracting N dominant colors from image

Project description


ImageToColors is a Image color clustering library for extracting N dominant colors from image and provide list of extracted colors in HEX format.THe prime purpose of this library is to provide quick colors extraction. It has ExtractColors() function which deals with clustering it also operate image according to their sizes for fast and secure clustering. It also provides HEXtoRGB() conversion function.For Graphical analysis ImageToColors gives you ClusterAnalaysis() using this function one can analyze color values along with each color percentage present in given image


The easiest way to install the library is to execute

pip install ImageToColors

(note that you need network access to do it this way; if you do not have the pip tool installed -- see:

Alternatively, you can download_ the library source archive, unpack it, cd to the unpacked directory and execute the following command

python install

It is also possible to use the library without installing it: as its code is contained in a single file (, you can just copy it into your project.



It takes 2 arguments image and cluster value which is nothing but the integer value for number of colors want to extract.ExtractColors() takes any image having .jpg, .jpeg, .png any one of them extension.It returns a list of hex color code list.

['#46a947', '#ed3723', '#0b66b5', '#af60a8', '#fbbf10']


It takes single HEX colors list argument and convert returns a RGB colors code list

[(70, 169, 71), (237, 55, 35), (11, 102, 181), (175, 96, 168), (251, 191, 16)]


It takes extracted HEX colors list and plot the donut graph showing color code and percentage of colors present in given image.



from ImageToColors.ImageToColors import *

img = "image.jpg" # .png or .jpg
clust = 5 # Cluster value nothing but the how many dominant colors user want to extract

#to print extracted colors list use ExtractColors() function
HEXlist= ExtractColors(img,clust)

# To convert Hex color list to RGB use HEXtoRGB
RGBlist = HEXtoRGB(HEXlist)

#For graphical analysis use ClusterAnalysis()


Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.


Distributed under the MIT License. See LICENSE for more information.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ImageToColors-1.1.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

ImageToColors-1.1-py3-none-any.whl (5.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page