PHPackages                             ghero/laravel-dominant-color - 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. ghero/laravel-dominant-color

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

ghero/laravel-dominant-color
============================

A package that generates a base64 encoded GIF with the dominant color of the given image (for lazy loading use)

v1.0(9y ago)269MITPHPPHP &gt;=5.4.0

Since Dec 12Pushed 9y ago1 watchersCompare

[ Source](https://github.com/Davide-Gheri/laravel-dominant-color)[ Packagist](https://packagist.org/packages/ghero/laravel-dominant-color)[ RSS](/packages/ghero-laravel-dominant-color/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

laravel-dominant-color
======================

[](#laravel-dominant-color)

A package that generates a base64 encoded GIF with the dominant color of the given image (for lazy loading use)

Requires the php Imagik library to work!
----------------------------------------

[](#requires-the-php-imagik-library-to-work)

Installation
------------

[](#installation)

Require the package via composer

```
composer require ghero/laravel-dominant-color

```

Include the service provider within your providers in `config/app.php`.

```
'providers' => [
    ...
    Ghero\DominantColor\DominantColorServiceProvider::class,
    ...
];
```

Next, add the class alias to the aliases array of `config/app.php`.

```
'aliases' => [
    ...
    'DominantColor' => Ghero\DominantColor\Facades\DominantColor::class,
    ...
];
```

Usage
-----

[](#usage)

Simply call `DominantColor::create($file);` passing a valid url to an Image or an Imagick instance

this will generate a string with the base 64 encoded 1x1 GIF (ex. `data:image/gif;base64,R0lGODlhAQABAIABAI2JggAAACwAAAAAAQABAAACAkQBADs=`) The GIF is only 1 color, the dominant color of the image

You can then easily set this string as src attribute specifing the desired width and height:

```

```

### Other available methods

[](#other-available-methods)

#### Get the color

[](#get-the-color)

You can also get just the hex code of the dominant color using `$color = DominantColor::setColor($file)->getColor();`The default output will be a plain hex code without the starting "#". You can customize the output passing an optional parameter to the `getColor` method: Available outputs:

- "hex": outputs complete hex code (ex. `#FFFFFF`)
- "rgb": outputs Rgb format string (ex. `255,255,255`)
- "array": outputs Rgb format as an array (ex. `['r' => 255, 'g' =>  255, 'b' => 255]`)

#### Get the GIF

[](#get-the-gif)

To get the base 64 encoded GIF from an hex code, just use `$gif = DominantColor::setGif($color)->getGif()`.

Todo
----

[](#todo)

- Add GD and Gmagick support

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

3483d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c95484d9394d371bd0ae389b39b90cd3741efc211468b9680d9220bd47c1fa47?d=identicon)[Davide-Gheri](/maintainers/Davide-Gheri)

---

Top Contributors

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

---

Tags

laravel 5lazy loaddominant-color

### Embed Badge

![Health badge](/badges/ghero-laravel-dominant-color/health.svg)

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

###  Alternatives

[goat1000/svggraph

Generates SVG graphs

133890.0k3](/packages/goat1000-svggraph)[gravatarphp/gravatar

Gravatar URL builder which is most commonly called as a Gravatar library

12644.1k2](/packages/gravatarphp-gravatar)

PHPackages © 2026

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