PHPackages                             skyree/php-colorpicker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. skyree/php-colorpicker

ActiveLibrary[Image &amp; Media](/categories/media)

skyree/php-colorpicker
======================

Pick a palette of dominant colors within an image

v1.0.0(7y ago)04MITPHPPHP &gt;=7.1

Since Apr 19Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Skyree/php-colorpicker)[ Packagist](https://packagist.org/packages/skyree/php-colorpicker)[ Docs](https://github.com/Skyree/php-colorpicker)[ RSS](/packages/skyree-php-colorpicker/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

php-colorpicker
===============

[](#php-colorpicker)

*Pick a palette of dominant colors from an image*

### Requirements

[](#requirements)

- php 7.1
- ext-imagick

### Installation

[](#installation)

Clone or download the repository and simply run `composer install`

### Demo

[](#demo)

In order to use the demo, run the following command

```
cd demo
php -S localhost:8000
```

And open the url `localhost:8000` in your browser

### Getting started

[](#getting-started)

Use the `Lol\ColorPicker\ColorPicker` class in your file

Example of usage:

```
$imageUrl = 'http://some.website/some/image.ext';
$colorPicker = new ColorPicker();
$palette = $colorPicker->pick($imageUrl, ColorPicker::KMEANS, 7, 150);
foreach ($palette as $cluster) {
    echo sprintf("#%02x%02x%02x", ...$cluster['color']) . PHP_EOL; // will print up to 5 hex codes
}
```

### Options

[](#options)

ColorPicker::pick($imageUrl, $algorithm, $paletteSize, $resize);

- `$imageUrl` is the url of the image you want to pick colors from
- `$algorithm` is the algorithm to use among `ColorPicker::KMEANS`, `ColorPicker::WEIGHTED_KMEANS`, `ColorPicker::LOCAL_MAXIMA`
- `$paletteSize` is the maximum quantity of dominant colors you want to pick
- `$resize` is the width to which the image should be resized, it can be left empty
- `$quantization` is an array providing the colorspace and number of colors for the quantization, formatted as follow:

```
$quantization = [
    'colorNumber' => 64,
    'colorSpace' => 1 // RGB space
];
```

### Algorithms

[](#algorithms)

- `ColorPicker::KMEANS` uses a standard unsupervised Kmeans or Kmeans++ algorithm to calculate k clusters, some clusters can end up empty
- `ColorPicker::WEIGHTED_KMEANS` implementation of Kmeans from an histogram, calculating the clusters centroids according to coordinate and weight
- `ColorPicker::LOCAL_MAXIMA` keeps the maximum values among their 27 neighboring cells in a 3d space of quantized rgb values. Incompatible with quantization argument !
- `ColorPicker::QUANTIZATION` just quantize the colors and return the highest clusters

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2623d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1636904?v=4)[Loïc Boulakras](/maintainers/Skyree)[@Skyree](https://github.com/Skyree)

---

Top Contributors

[![Skyree](https://avatars.githubusercontent.com/u/1636904?v=4)](https://github.com/Skyree "Skyree (2 commits)")

---

Tags

imagecolorrgbcolorpickerpalettedominantpickcolorpicking

### Embed Badge

![Health badge](/badges/skyree-php-colorpicker/health.svg)

```
[![Health](https://phpackages.com/badges/skyree-php-colorpicker/health.svg)](https://phpackages.com/packages/skyree-php-colorpicker)
```

###  Alternatives

[league/color-extractor

Extract colors from an image as a human would do.

1.3k4.9M19](/packages/league-color-extractor)[ksubileau/color-thief-php

Grabs the dominant color or a representative color palette from an image.

6354.0M43](/packages/ksubileau-color-thief-php)[brianmcdo/image-palette

Extracts colors from an image and generates a color palette against a whitelist of colors.

179217.1k2](/packages/brianmcdo-image-palette)[marijnvdwerf/material-palette

Prominent image colour extraction for PHP

2953.7k](/packages/marijnvdwerf-material-palette)[gabrieldarezzo/colorizzar

Change the colors of an image without lose alpha channnel

273.9k](/packages/gabrieldarezzo-colorizzar)[talesoft/phim

An image and color manipulation and processing library for PHP

2958.8k1](/packages/talesoft-phim)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
