PHPackages                             diggipacks-co/laravel-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. diggipacks-co/laravel-color-extractor

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

diggipacks-co/laravel-color-extractor
=====================================

Extract colors from an image as a human would do.

18.5k1PHP

Since Oct 31Pushed 4y agoCompare

[ Source](https://github.com/DiggipacksCo/laravel-color-extractor)[ Packagist](https://packagist.org/packages/diggipacks-co/laravel-color-extractor)[ RSS](/packages/diggipacks-co-laravel-color-extractor/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

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

[](#colorextractor)

[![Build Status](https://camo.githubusercontent.com/52b8657bd8f366af07ef9a6f03c9498b884e30e079ad899aa135958085c87b98/68747470733a2f2f7472617669732d63692e6f72672f7468657068706c65616775652f636f6c6f722d657874726163746f722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/thephpleague/color-extractor)[![Total Downloads](https://camo.githubusercontent.com/b182f8dd9fb4d17f5eab0b50e52e8ff401dfe1d029ef3f09652f6651f6648a3f/68747470733a2f2f706f7365722e707567782e6f72672f6c65616775652f636f6c6f722d657874726163746f722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/league/color-extractor)[![Latest Stable Version](https://camo.githubusercontent.com/b390f5e95fd901e324dfcb1a40b48f15a394be142875d7108087190be793c74b/68747470733a2f2f706f7365722e707567782e6f72672f6c65616775652f636f6c6f722d657874726163746f722f762f737461626c652e706e67)](https://packagist.org/packages/league/color-extractor)

Extract colors from an image like a human would do.

Install
-------

[](#install)

Via Composer

```
composer require diggipacks-co/laravel-color-extractor
```

Usage
-----

[](#usage)

```
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);

// get hex color from $colors
foreach($colors as $color) {
    echo dechex($color);
}
```

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/thephpleague/color-extractor/blob/master/CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Mathieu Lechat](https://github.com/MatTheCat)
- [All Contributors](https://github.com/thephpleague/color-extractor/contributors)

License
-------

[](#license)

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

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity28

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/5b34d64120e99961f7dfae89a8bdee85fba49ab9c48f414be75367cca35b20d6?d=identicon)[diggipacks](/maintainers/diggipacks)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/diggipacks-co-laravel-color-extractor/health.svg)

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

###  Alternatives

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[char0n/ffmpeg-php

PHP wrapper for FFmpeg application

495225.1k1](/packages/char0n-ffmpeg-php)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

63991.3k4](/packages/netresearch-rte-ckeditor-image)

PHPackages © 2026

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