PHPackages                             hracik/php-recognize-average-color-from-image - 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. hracik/php-recognize-average-color-from-image

ActiveLibrary

hracik/php-recognize-average-color-from-image
=============================================

Recognize average color from image.

0.0.4(6y ago)0150[1 PRs](https://github.com/hracik/php-recognize-average-color-from-image/pulls)MITPHPCI passing

Since Jun 14Pushed 3w agoCompare

[ Source](https://github.com/hracik/php-recognize-average-color-from-image)[ Packagist](https://packagist.org/packages/hracik/php-recognize-average-color-from-image)[ RSS](/packages/hracik-php-recognize-average-color-from-image/feed)WikiDiscussions master Synced today

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

Recognize color from image
==========================

[](#recognize-color-from-image)

Recognize average color from image - can be external image URL or local file.

Getting Started
---------------

[](#getting-started)

These instructions will get you a copy of the project up and running

### Installing

[](#installing)

Install with Composer

```
composer require hracik/php-recognize-average-color-from-image

```

### Usage

[](#usage)

If you want to alter average color, e.g. to use the color on web dark/light designs, you can provide custom saturation and lightness within options.

```
use Hracik\RecognizeAverageColorFromImage;

//can be path to local image or URL
$path = 'https://raw.githubusercontent.com/hracik/php-recognize-average-color-from-image/master/example/example2.jpg;
//possible return options are: RETURN_STRING_HEX, RETURN_STRING_RGB, RETURN_ARRAY_RGB, RETURN_ARRAY_RGB_NORMALIZED, RETURN_ARRAY_HSL
$return = RecognizeAverageColorFromImage::RETURN_STRING_HEX;
//only accepted keys are saturation and lightness
$options = ['saturation' => 0.6, 'lightness' => 0.3];
$color = RecognizeAverageColorFromImage::getAverageColor($path, $return);
echo $color;
```

Output [\#707A1E](https://www.google.com/search?q=%23707A1E). Same image without options return color [\#838B45](https://www.google.com/search?q=%23838B45).

Or just get counted average without options attribute.

```
use Hracik\RecognizeAverageColorFromImage;

$path = 'https://raw.githubusercontent.com/hracik/php-recognize-average-color-from-image/master/example/example3.jpg;
$color = RecognizeAverageColorFromImage::getAverageColor($path, RecognizeAverageColorFromImage::RETURN_STRING_HEX);
echo $color;
```

Output [\#658FAD](https://www.google.com/search?q=%23658FAD).

Running the tests
-----------------

[](#running-the-tests)

Run

```
./vendor/bin/phpunit --bootstrap vendor/autoload.php tests

```

For Windows platforms

```
./vendor/bin/phpunit.bat --bootstrap vendor/autoload.php tests

```

Built With
----------

[](#built-with)

- [PHPUnit](https://phpunit.de/) - The PHP Testing Framework
- [PHP: ImageMagick - Manual ](https://www.php.net/manual/en/book.imagick.php)

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

[](#contributing)

Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.

Versioning
----------

[](#versioning)

We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/hracik/php-recognize-average-color-from-image/tags).

Authors
-------

[](#authors)

- **Andrej Lahucky** - *Initial work* - [Hracik](https://github.com/hracik)

See also the list of [contributors](https://github.com/hracik/php-recognize-average-color-from-image/graphs/contributors) who participated in this project.

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.

Acknowledgments
---------------

[](#acknowledgments)

- PurpleBooth

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance62

Regular maintenance activity

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity53

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

Every ~0 days

Total

4

Last Release

2519d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/acfc4c5459b67a7fa200816b6d3b938cf2efbd3ba942f66b5b1f665275301334?d=identicon)[hracik029](/maintainers/hracik029)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hracik-php-recognize-average-color-from-image/health.svg)

```
[![Health](https://phpackages.com/badges/hracik-php-recognize-average-color-from-image/health.svg)](https://phpackages.com/packages/hracik-php-recognize-average-color-from-image)
```

PHPackages © 2026

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