# Color Palette Extractor: web pages and images to hex palettes (`examsens.ai/color-palette-extractor`) Actor

Renders each web page in a headless browser, or reads each image, and returns its dominant colors with hex, RGB and share, plus the CSS color variables the page defines.

- **URL**: https://apify.com/examsens.ai/color-palette-extractor.md
- **Developed by:** [Ed Rayyis](https://apify.com/examsens.ai) (community)
- **Categories:** For creators, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $36.00 / 1,000 url analyzeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Color Palette Extractor: web pages and images to hex palettes

Give it web pages, image links, or both in one list. It returns the dominant colors of each one with the hex code, the RGB values and the share of the visible pixels each color covers, largest first.

Web pages are rendered in headless Chrome, so the palette is what a visitor sees, including colors set by JavaScript, background images and photos. For each page you also get the CSS custom properties (variables such as `--brand-primary`) whose value is a color, with the resolved hex, and the page's `theme-color` meta tag.

Images are read directly: JPEG, PNG, GIF, WebP, AVIF, BMP, TIFF and SVG. Transparent pixels are left out, so a logo on a transparent background gives the logo's colors only. SVG files are drawn at up to 1,200 pixels on a side and read the same way.

Close shades are merged into one color, so the palette shows distinct colors and not several versions of near black.

### Input

- Web pages or image URLs (required). The actor reads the type from the server's answer.
- Colors per palette (default 8, 2 to 32)
- Whole page (default off: the first screen only)
- Browser width and height for web pages (default 1280 by 800)
- CSS color variables (default on)
- Timeout per URL (default 45 seconds)

### Output

Dataset: one item per URL with `url`, `ok`, `source` (`page`, `image` or `svg`), `finalUrl`, `status`, `contentType`, `width` and `height` (of the image, or of the captured page area), `format` for images, `title` for pages, and `colors`: a list of `hex`, `rgb` and `share` (0 to 1). `hexList` repeats the hex codes as a plain list.

For web pages: `themeColor`, `cssColorVariables` (each with `name`, `value` as written, `declaredOn` (the selector), `hex`, `rgb` and `alpha`), `cssColorVariableCount`, and `unreadableStylesheets` (style sheets from another site that the browser does not let a page script read).

A URL that cannot be read gets `ok: false` and an `error`, such as `HTTP 404` or an unknown host, and the rest of the run carries on. Export as JSON, CSV or Excel, or read it over the API.

### Pricing

Pay per event: one event per URL analyzed. A URL that fails is not charged. The run stops when it reaches the maximum charge you set.

### Scope and conduct

Only the URLs you supply are opened, one at a time, each in a fresh browser with no cookies carried over. The actor does not log in anywhere, click anything, or collect personal data. Analyze pages and images you are allowed to use.

### Support

Questions and problems: the Issues tab on this page. Replies are written by an AI assistant on behalf of the developer and reviewed by the developer.

# Actor input Schema

## `urls` (type: `array`):

Web pages to render, or direct links to images (JPEG, PNG, GIF, WebP, AVIF, BMP, TIFF or SVG). The type is read from the server's answer, so you can mix both in one run.

## `colorCount` (type: `integer`):

How many dominant colors to return for each page or image.

## `fullPage` (type: `boolean`):

Read colors from the whole scrollable page. When off, only the first screen is read.

## `viewportWidth` (type: `integer`):

Browser window width in pixels.

## `viewportHeight` (type: `integer`):

Browser window height in pixels.

## `includeCssVariables` (type: `boolean`):

List the CSS custom properties on the page whose value is a color, with the resolved hex.

## `timeoutSecs` (type: `integer`):

Give up on a page or image after this many seconds.

## Actor input object example

```json
{
  "urls": [
    {
      "url": "https://apify.com"
    }
  ],
  "colorCount": 8,
  "fullPage": false,
  "viewportWidth": 1280,
  "viewportHeight": 800,
  "includeCssVariables": true,
  "timeoutSecs": 45
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        {
            "url": "https://apify.com"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("examsens.ai/color-palette-extractor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "urls": [{ "url": "https://apify.com" }] }

# Run the Actor and wait for it to finish
run = client.actor("examsens.ai/color-palette-extractor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    {
      "url": "https://apify.com"
    }
  ]
}' |
apify call examsens.ai/color-palette-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,examsens.ai/color-palette-extractor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/gI1abY5N9GQe3kruK/builds/LspcUWsSp6WDVRVUn/openapi.json
