PHPackages                             fonil/coloreeze - 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. fonil/coloreeze

ActiveLibrary

fonil/coloreeze
===============

Color handling and manipulation library with support for Laravel integration

v1.0.4(3mo ago)218.7k↓25.9%UnlicensePHPPHP ^8.5CI passing

Since Jul 21Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/AlcidesRC/coloreeze)[ Packagist](https://packagist.org/packages/fonil/coloreeze)[ Fund](http://www.paypal.me/AlcidesRC)[ GitHub Sponsors](https://github.com/AlcidesRC)[ RSS](/packages/fonil-coloreeze/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (7)Versions (6)Used By (0)

[![Integration Tests](https://github.com/AlcidesRC/coloreeze/actions/workflows/ci.yml/badge.svg)](https://github.com/AlcidesRC/coloreeze/actions/workflows/ci.yml)

coloreeze
=========

[](#coloreeze)

> A PHP library to deal with color conversions

\[TOC\]

Summary
-------

[](#summary)

Coloreeze is a PHP library to deal with color conversions.

Currently it supports the following color spaces:

- Hexadecimal
- Integer
- RGB(a)
- HSB/HSV
- HSL
- CMYK
- CIELab
- XYZ

Features
--------

[](#features)

Additionally this library contains some useful methods to:

- Generate a greyscale version from a color
- Generate a darker version from a color
- Generate a lighter version from a color
- to create gradients and measure the distance CIE76 between colors.

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

[](#installation)

You can install the package via composer:

```
$ composer require alcidesrc/coloreeze
```

Usage
-----

[](#usage)

`Coloreeze` package contains independent color classes, all of them implementing a `Color` interface:

- ColorCIELab
- ColorCMYK
- ColorFactory
- ColorHSB
- ColorHSL
- ColorHex
- ColorInt
- ColorRGBA
- ColorXYZ

### Color Factory

[](#color-factory)

#### ColorFactory::fromString(string $input): Color

[](#colorfactoryfromstringstring-input-color)

The `ColorFactory` class allows you to create a color instance from any valid input string.

If the input string is not a valid color representation it throws an `InvalidInput` exception.

```
ColorFactory::fromString('rgb(0,100,200)'); // Returns a `ColorRGBA` instance
ColorFactory::fromString('#336699'); // Returns a `ColorHex` instance
ColorFactory::fromString('unknown(1,2,3)'); // Throws an `InvalidInput` exception
```

### Color Interface

[](#color-interface)

#### \_\_toString(): string

[](#__tostring-string)

Cast the color value to a string:

```
echo ColorRGBA::fromString('rgba(0,100,200,1.0)');
echo ColorHex::fromString('#336699');

'rgba(0,100,200,1.0)'
'#336699'
```

#### fromString(string $input): Color

[](#fromstringstring-input-color)

Parses an input string and returns accordingly the related `Color` implementation:

```
$hex = ColorHex::fromString('#336699');
$rgba = ColorRGBA::fromString('rgba(0,100,200,1.0)');
...
```

It throws an `InvalidInput` exception in case of the string is not well formed or unsupported color.

#### getValue(): mixed

[](#getvalue-mixed)

Returns the `Color` value. On single-value colors, this method returns a primitive value (int or string) but on composite ones it returns an array with color's components:

```
$int = ColorInt::fromString('int(100)');
var_dump($int->getValue());

int(100)
```

```
$rgba = ColorRGBA::fromString('rgba(0, 100, 200)');
var_dump($int->getValue());

array(3) {
  [0]=>
  int(0)
  [1]=>
  int(100)
  [2]=>
  int(200)
}
```

```
$hex = ColorHex::fromString('#336699');
var_dump($int->getValue());

string(7) "#336699"
```

#### toCIELab(): ColorCIELab

[](#tocielab-colorcielab)

Converts a color to a **CIELab**:

```
$lab = ColorHex::fromString('#336699')->toCIELab();
```

#### toCMYK(): ColorCMYK

[](#tocmyk-colorcmyk)

Converts a color to a **CMYK**:

```
$cmyk = ColorHex::fromString('#336699')->toCMYK();
```

#### toHex(): ColorHex

[](#tohex-colorhex)

Converts a color to a **Hex**:

```
$hex = ColorRGBA::fromString('rgba(100,200,200,1.0)')->toHex();
```

#### toHSB(): ColorHSB

[](#tohsb-colorhsb)

Converts a color to a **HSB/HSV**:

```
$hsb = ColorHex::fromString('#336699')->toHSB();
```

#### toHSL(): ColorHSL

[](#tohsl-colorhsl)

Converts a color to a **HSL**:

```
$hsl = ColorHex::fromString('#336699')->toHSL();
```

#### toInt(): ColorInt

[](#toint-colorint)

Converts a color to an **Int**:

```
$int = ColorHex::fromString('#336699')->toInt();
```

#### toRGBA(): ColorRGBA

[](#torgba-colorrgba)

```
$rgba = ColorInt::fromString('int(255)')->toRGBA();
```

#### toXYZ(): ColorXYZ

[](#toxyz-colorxyz)

```
$rgba = ColorCMYK::fromString('cmyk(0,0,0,0)')->toXYZ();
```

#### toComplementary(): Color

[](#tocomplementary-color)

```
$complementary = ColorRGBA::fromString('hsl(182,25,50)')->toComplementary();
```

#### toGreyscale(): Color

[](#togreyscale-color)

```
$greyscale = ColorInt::fromString('int(4278255615)')->toGreyscale();
```

#### adjustBrightness(int $steps): Color

[](#adjustbrightnessint-steps-color)

```
$dark = ColorInt::fromString('int(4278255615)')->adjustBrightness(-10);
$light = ColorInt::fromString('int(4278255615)')->adjustBrightness(10);
```

#### distanceCIE76(Color $color): float

[](#distancecie76color-color-float)

```
$distance = ColorInt::fromString('int(4278255615)')->distanceCIE76(ColorInt::fromString('int(0)'));
```

Testing
-------

[](#testing)

You can run the test suite via composer:

```
$ composer tests
```

> This Composer script runs the [PHPUnit](https://phpunit.de/) command with [PCOV](https://github.com/krakjoe/pcov) support in order to generate a Code Coverage report.

### Unit Tests

[](#unit-tests)

This library provides a [PHPUnit](https://phpunit.de/) testsuite with **1434 unit tests** and **2670 assertions**:

```
Time: 00:00.426, Memory: 24.00 MB

OK (1434 tests, 2670 assertions)
```

### Code Coverage

[](#code-coverage)

Here is the Code Coverage report summary:

```
Code Coverage Report:
  2022-07-22 06:32:15

 Summary:
  Classes: 100.00% (11/11)
  Methods: 100.00% (135/135)
  Lines:   100.00% (475/475)
```

> Full report will be generated in **./reports/coverage** folder.

QA
--

[](#qa)

### Static Analyzer

[](#static-analyzer)

You can check this library with [PHPStan](https://phpstan.org/):

```
$ composer phpstan
```

This command generates the following report:

```
> vendor/bin/phpstan analyse --level 9 --memory-limit 1G --ansi ./src ./tests
 29/29 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 [OK] No errors
```

### PHP Parallel Lint

[](#php-parallel-lint)

You can check this library with [PHP Parallel Lint](https://github.com/php-parallel-lint/PHP-Parallel-Lint):

```
$ composer linter
```

This command generates the following report:

```
PHP 8.1.8 | 10 parallel jobs
.............................                                29/29 (100 %)
Checked 29 files in 0.1 seconds
No syntax error found
```

PHP Insights
------------

[](#php-insights)

You can check this library with [PHP Insights](https://phpinsights.com/):

```
$ composer phpinsights
```

This command generates the following summary:

```
> ./vendor/bin/phpinsights --fix

 16/16 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ✨ Analysis Completed !

[2022-07-22 08:20:20] `/code`

                99.0%                  89.5%                  94.1%                  100 %
                Code                 Complexity            Architecture              Style

Score scale: ◼ 1-49 ◼ 50-79 ◼ 80-100

[CODE] 99 pts within 494 lines

Comments ....................................................... 5.1 %
Classes ....................................................... 85.6 %
Functions ...................................................... 0.0 %
Globally ....................................................... 9.3 %

[COMPLEXITY] 89.5 pts with average of 1.32 cyclomatic complexity

[ARCHITECTURE] 94.1 pts within 13 files

Classes ....................................................... 84.6 %
Interfaces ..................................................... 7.7 %
Globally ....................................................... 7.7 %
Traits ......................................................... 0.0 %

[MISC] 100 pts on coding style and 0 security issues encountered
```

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review our security policy on how to report security vulnerabilities:

> **PLEASE DON'T DISCLOSE SECURITY-RELATED ISSUES PUBLICLY**

### Supported Versions

[](#supported-versions)

Only the latest major version receives security fixes.

### Reporting a Vulnerability

[](#reporting-a-vulnerability)

If you discover a security vulnerability within this project, please [open an issue here](https://github.com/alcidesrc/coloreeze/issues). All security vulnerabilities will be promptly addressed.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/alcidesrc/coloreeze/blob/main/LICENSE) for more information.

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance79

Regular maintenance activity

Popularity29

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity69

Established project with proven stability

 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 ~321 days

Total

5

Last Release

111d ago

PHP version history (3 changes)v1.0.0PHP ^8.0

v1.0.3PHP ^8.3

v1.0.4PHP ^8.5

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

cielabciexyzcmykcolorcolorsconversionconvertgreyscalehexhsbhslphprgbaconversioncolorhexcmykhslrgbahsvxyzcielabhsbcolor spaces

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/fonil-coloreeze/health.svg)

```
[![Health](https://phpackages.com/badges/fonil-coloreeze/health.svg)](https://phpackages.com/packages/fonil-coloreeze)
```

###  Alternatives

[ozdemirburak/iris

PHP library for color manipulation and conversion.

1201.7M16](/packages/ozdemirburak-iris)[ssnepenthe/color-utils

A PHP library for performing SASS-like color manipulations.

631.1M10](/packages/ssnepenthe-color-utils)[tecnickcom/tc-lib-color

PHP library to manipulate various color representations

247.2M9](/packages/tecnickcom-tc-lib-color)[spatie/color

A little library to handle color conversions

38118.9M28](/packages/spatie-color)[talesoft/phim

An image and color manipulation and processing library for PHP

2958.2k](/packages/talesoft-phim)[fjw/color-compare

A library for converting colors (Hex, RGB, HSL, CIELAB (LAB), DIN-99) and calculating color distances based on DIN-99.

1310.0k](/packages/fjw-color-compare)

PHPackages © 2026

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