PHPackages                             devloopsnet/color-extractor - 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. devloopsnet/color-extractor

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

devloopsnet/color-extractor
===========================

Extract colors from an image as a human would do.

v0.4.0(3y ago)15MITPHPPHP ^8.0

Since Aug 18Pushed 3y agoCompare

[ Source](https://github.com/devloopsnet/color-extractor)[ Packagist](https://packagist.org/packages/devloopsnet/color-extractor)[ Docs](https://github.com/thephpleague/color-extractor)[ RSS](/packages/devloopsnet-color-extractor/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

ColorExtractor
==============

[](#colorextractor)

[![Build Status](https://camo.githubusercontent.com/911bfddbdddf7d74cbfe49ba6ea0d588f224975cc0351ad25bbbb2db8ad1e10e/68747470733a2f2f7472617669732d63692e6f72672f6465766c6f6f70736e65742f636f6c6f722d657874726163746f722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/thephpleague/color-extractor)[![Total Downloads](https://camo.githubusercontent.com/baed15394d56a170ecf1e8da608c492d6ca0a19d450dfd1ed50408dfcef88542/68747470733a2f2f706f7365722e707567782e6f72672f6465766c6f6f70736e65742f636f6c6f722d657874726163746f722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/devloopsnet/color-extractor)[![Latest Stable Version](https://camo.githubusercontent.com/fc325238cb72b5dfa61acb453c710a8bff3d3d218cc60ea9e19a7831b1a974ab/68747470733a2f2f706f7365722e707567782e6f72672f6465766c6f6f70736e65742f636f6c6f722d657874726163746f722f762f737461626c652e706e67)](https://packagist.org/packages/devloopsnet/color-extractor)

Extract colors from an image like a human would do.

Install
-------

[](#install)

Via Composer

```
$ composer require devloopsnet/color-extractor:0.4.*
```

Usage
-----

[](#usage)

```
require 'vendor/autoload.php';

use League\ColorExtractor\Color;
use League\ColorExtractor\ColorExtractor;
use League\ColorExtractor\Palette;

$palette = Palette::fromFilename('./some/image.png');

// $palette is an iterator on colors sorted by pixel count
foreach($palette as $color => $count) {
    // colors are represented by integers
    echo Color::fromIntToHex($color), ': ', $count, "\n";
}

// it offers some helpers too
$topFive = $palette->getMostUsedColors(5);

$colorCount = count($palette);

$blackCount = $palette->getColorCount(Color::fromHexToInt('#000000'));

// an extractor is built from a palette
$extractor = new ColorExtractor($palette);

// it defines an extract method which return the most “representative” colors
$colors = $extractor->extract(5);
```

Handling transparency
---------------------

[](#handling-transparency)

By default **any pixel with alpha value greater than zero will be discarded**. This is because transparent colors are not perceived as is. For example fully transparent black would be seen white on a white background. So if you want to take transparency into account when building a palette you have to specify this background color. You can do this with the second argument of `Palette` constructors. Its default value is `null`, meaning a color won't be added to the palette if its alpha component exists and is greater than zero.

You can set it as an integer representing the color, then transparent colors will be blended before addition to the palette.

```
// we set a white background so fully transparent colors will be added as white in the palette
// pure red #FF0000 at 50% opacity will be stored as #FF8080 as it would be perceived
$palette = Palette::fromFilename('./some/image.png', Color::fromHexToInt('#FFFFFF'));
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/devloopsnet/color-extractor/blob/master/CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Mathieu Lechat](https://github.com/MatTheCat)
- [Abdullah Al-Faqeir](https://github.com/abdullahfaqeir)
- [All Contributors](https://github.com/devloopsnet/color-extractor/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/devloopsnet/color-extractor/blob/master/LICENSE) for more information.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.6% 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

1369d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1428547?v=4)[Abdullah Al-Faqeir](/maintainers/AbdullahFaqeir)[@AbdullahFaqeir](https://github.com/AbdullahFaqeir)

---

Top Contributors

[![MatTheCat](https://avatars.githubusercontent.com/u/1898254?v=4)](https://github.com/MatTheCat "MatTheCat (46 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (3 commits)")[![AbdullahFaqeir](https://avatars.githubusercontent.com/u/1428547?v=4)](https://github.com/AbdullahFaqeir "AbdullahFaqeir (2 commits)")[![curtisgibby](https://avatars.githubusercontent.com/u/1086964?v=4)](https://github.com/curtisgibby "curtisgibby (1 commits)")[![philsturgeon](https://avatars.githubusercontent.com/u/67381?v=4)](https://github.com/philsturgeon "philsturgeon (1 commits)")[![thinksaydo](https://avatars.githubusercontent.com/u/519600?v=4)](https://github.com/thinksaydo "thinksaydo (1 commits)")[![toin0u](https://avatars.githubusercontent.com/u/672421?v=4)](https://github.com/toin0u "toin0u (1 commits)")

---

Tags

imagecolorextracthumanpalette

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/devloopsnet-color-extractor/health.svg)

```
[![Health](https://phpackages.com/badges/devloopsnet-color-extractor/health.svg)](https://phpackages.com/packages/devloopsnet-color-extractor)
```

###  Alternatives

[league/color-extractor

Extract colors from an image as a human would do.

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

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

6353.8M37](/packages/ksubileau-color-thief-php)[brianmcdo/image-palette

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

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

Prominent image colour extraction for PHP

2952.9k](/packages/marijnvdwerf-material-palette)[talesoft/phim

An image and color manipulation and processing library for PHP

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

Change the colors of an image without lose alpha channnel

273.7k](/packages/gabrieldarezzo-colorizzar)

PHPackages © 2026

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