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.

19.2k1PHP

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 1w 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

24

—

LowBetter than 30% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity29

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

[goat1000/svggraph

Generates SVG graphs

135931.0k3](/packages/goat1000-svggraph)[stefangabos/zebra_image

A single-file, lightweight PHP library designed for efficient image manipulation featuring methods for modifying images and applying filters

138121.6k7](/packages/stefangabos-zebra-image)[treinetic/imageartist

ImageArtist is a php gd Wrapper which makes Image manipulation insanely easy, we introduce ImageArtist as Photoshop for php

8783.2k](/packages/treinetic-imageartist)[johncarter/filament-focal-point-picker

An image focal point picker for Filament Admin.

4431.7k1](/packages/johncarter-filament-focal-point-picker)[yk/laravel-ocr

A wrapper for gocr.

1356.6k](/packages/yk-laravel-ocr)

PHPackages © 2026

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