Detect Main Image Color API

Detect the main color of an image. The API returns a list of colors and their hex codes. The API supports images in the following formats: JPEG, PNG, and GIF.

The detected colors are given in hex code and their specific and main color (color family) names.

GET
https://api.apileague.com/detect-color
Example Request and Response
GET
https://api.apileague.com/{{ examples.getDetectMainImageColor }}
[
    {
        "hex_code": "#b01c20",
        "specific_color": "Firebrick",
        "main_color": "Red"
    },
    {
        "hex_code": "#bfaf9a",
        "specific_color": "Thistle Green",
        "main_color": "Green"
    },
    {
        "hex_code": "#36180d",
        "specific_color": "Brown Pod",
        "main_color": "Brown"
    }
]
cURL
Java
Javascript
Python
Go
C#
 {{ codeCopyText }}
 {{ codeCopyText }}
 {{ codeCopyText }}
 {{ codeCopyText }}
 {{ codeCopyText }}
 {{ codeCopyText }}

Frequently Asked Questions

What image formats are supported?

The API supports common image formats including JPEG, PNG, and GIF.

Does it return the exact color or a general color name?

The API returns both the specific hex code of the detected color and the general "main color" family (e.g., Red, Blue, Green) it belongs to.

Can I use this for sorting images by color?

Yes, by using the "main color" returned by the API, you can easily categorize and sort images based on their dominant color family.

How is the Detect Main Image Color API different from the Search Images API?

The Detect Main Image Color API analyzes an uploaded or linked image to find its dominant color, whereas the Search Images API allows you to find images based on keywords or color filters.

Questions? Need Help? Ask Away