PHPackages                             ozdemirburak/iris - 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. ozdemirburak/iris

ActiveLibrary

ozdemirburak/iris
=================

PHP library for color manipulation and conversion.

4.1.1(4mo ago)1201.7M—3.5%2115MITPHPPHP ^8.1CI passing

Since May 30Pushed 3mo ago5 watchersCompare

[ Source](https://github.com/ozdemirburak/iris)[ Packagist](https://packagist.org/packages/ozdemirburak/iris)[ Docs](https://colorconverter.dev)[ RSS](/packages/ozdemirburak-iris/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (22)Used By (15)

Iris - PHP Color Library
========================

[](#iris---php-color-library)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fd610ac6123372f95e0146d376de08d50db82270008427dd2966584df59ce134/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f7a64656d6972627572616b2f697269732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ozdemirburak/iris)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/cff84b0b9e7c2fe151e2b5add36e9cf8ae1290e57c3ae0adcf3d56428af39019/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f7a64656d6972627572616b2f697269732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ozdemirburak/iris)

PHP library for color manipulation and conversion. Requires PHP 8.1+ and supports Hex, Hexa, RGB, RGBA, HSL, HSLA, HSV, CMYK, and OKLCH color formats.

Install
-------

[](#install)

```
$ composer require ozdemirburak/iris
```

Usage
-----

[](#usage)

### Hex

[](#hex)

```
use OzdemirBurak\Iris\Color\Hex;

$hex = new Hex('#ff00ff'); // same as new Hex('fuchsia');
echo $hex->red(); // ff
echo $hex->green(); // 00
echo $hex->blue(); // ff
echo $hex->values(); // ['ff', '00', 'ff']
$hexa = $hex->toHexa(); // \OzdemirBurak\Iris\Color\Hexa('ff00ffff')
$hsl = $hex->toHsl(); // \OzdemirBurak\Iris\Color\Hsl('300,100,50')
$hsla = $hex->toHsla(); // \OzdemirBurak\Iris\Color\Hsla('300,100,50,1.0')
$hsv = $hex->toHsv(); // \OzdemirBurak\Iris\Color\Hsv('300,100,100')
$rgb = $hex->toRgb(); // \OzdemirBurak\Iris\Color\Rgb('255,0,255')
$rgba = $hex->toRgba(); // \OzdemirBurak\Iris\Color\Rgba('255,0,255,1.0')
$oklch = $hex->toOklch(); // \OzdemirBurak\Iris\Color\Oklch('70.17,0.3225,328.36')
echo $hex; // #ff00ff
```

### Hexa (hex with alpha value)

[](#hexa-hex-with-alpha-value)

```
use OzdemirBurak\Iris\Color\Hexa;

$hexa = new Hexa('#ff00ff4c');
echo $hexa->red(); // ff
echo $hexa->green(); // 00
echo $hexa->blue(); // ff
echo $hexa->alpha(); // 0.3 - as a float for compatibility with the other conversions
echo $hexa->values(); // ['ff', '00', 'ff', 0.3]
$hsl = $hexa->toHsl(); // \OzdemirBurak\Iris\Color\Hsl('300,100,50')
$hsla = $hexa->toHsla(); // \OzdemirBurak\Iris\Color\Hsla('300,100,50,0.3')
$hsv = $hexa->toHsv(); // \OzdemirBurak\Iris\Color\Hsv('300,100,100')
$rgb = $hexa->toRgb(); // \OzdemirBurak\Iris\Color\Rgb('255,0,255')
$rgba = $hexa->toRgba(); // \OzdemirBurak\Iris\Color\Rgba('255,0,255,0.3')
echo $hexa; // #ff00ff4c
```

### HSL

[](#hsl)

```
use OzdemirBurak\Iris\Color\Hsl;

$hsl = new Hsl('hsl(300,100%,50%)'); // same as new Hsl('fuchsia');
echo $hsl->hue(); // 300
echo $hsl->saturation(); // 100
echo $hsl->lightness(); // 50
$values = $hsl->values(); // [300, '100%', '50%']
$normalizedValues = $hsl->valuesInUnitInterval(); // [300/360, 100/100, 50/100]
$hex = $hsl->toHex(); // \OzdemirBurak\Iris\Color\Hex('ff00ff')
$hexa = $hsl->toHexa(); // \OzdemirBurak\Iris\Color\Hexa('ff00ffff')
$hsv = $hsl->toHsv(); // \OzdemirBurak\Iris\Color\Hsv('300,100,100')
$rgb = $hsl->toRgb(); // \OzdemirBurak\Iris\Color\Rgb('255,0,255')
$rgba = $hsl->toRgba(); // \OzdemirBurak\Iris\Color\Rgba('255,0,255,1.0')
echo $hsl; // hsl(300,100%,50%)
```

### HSLA

[](#hsla)

```
use OzdemirBurak\Iris\Color\Hsla;

$hsla = new Hsla('hsla(150,100%,50%,0.3)');
echo $hsla->hue(); // 150
echo $hsla->saturation(); // 100
echo $hsla->lightness(); // 50
echo $hsla->alpha(); // 0.3
$values = $hsla->values(); // [150, '100%', '50%', 0.3]
$hex = $hsla->toHex(); // \OzdemirBurak\Iris\Color\Hex('b2ffd8')
$rgba = $hsla->toRgba(); // \OzdemirBurak\Iris\Color\Rgba('0,255,128,0.3')
$hexa = $hsla->toHexa(); // \OzdemirBurak\Iris\Color\Hexa('00ff804d')
echo $hsla; // hsla(150,100%,50%,0.3)
```

### HSV

[](#hsv)

```
use OzdemirBurak\Iris\Color\Hsv;

$hsv = new Hsv('hsv(300,100%,100%)'); // same as new Hsv('fuchsia');
echo $hsv->hue(); // 300
echo $hsv->saturation(); // 100
echo $hsv->value(); // 100
$values = $hsv->values(); // [300, '100%', '100%']
$normalizedValues = $hsv->valuesInUnitInterval(); // [300/360, 100/100, 100/100]
$hex = $hsv->toHex(); // \OzdemirBurak\Iris\Color\Hex('ff00ff')
$hexa = $hsv->toHexa(); // \OzdemirBurak\Iris\Color\Hexa('ff00ffff')
$hsl = $hsv->toHsl(); // \OzdemirBurak\Iris\Color\Hsl('300,100,50')
$hsla = $hsv->toHsla(); // \OzdemirBurak\Iris\Color\Hsla('300,100,50,1.0')
$hsv = $hsv->toHsv(); // \OzdemirBurak\Iris\Color\Hsv('300,100,100')
$rgb = $hsv->toRgb(); // \OzdemirBurak\Iris\Color\Rgb('255,0,255')
$rgba = $hsv->toRgba(); // \OzdemirBurak\Iris\Color\Rgba('255,0,255,1.0')
echo $hsv; // hsv(300,100%,100%)
```

### RGB

[](#rgb)

```
use OzdemirBurak\Iris\Color\Rgb;

$rgb = new Rgb('rgb(255, 0, 255)'); // same as new Rgb('fuchsia');

echo $rgb->red(); // 255
echo $rgb->green(); // 0
echo $rgb->blue(); // 255
$values = $rgb->values(); // [255, 0, 255]
$hex = $rgb->toHex(); // \OzdemirBurak\Iris\Color\Hex('ff00ff')
$hexa = $rgb->toHexa(); // \OzdemirBurak\Iris\Color\Hexa('ff00ffff')
$hsl = $rgb->toHsl(); // \OzdemirBurak\Iris\Color\Hsl('300,100,50')
$hsla = $rgb->toHsla(); // \OzdemirBurak\Iris\Color\Hsla('300,100,50,1.0')
$hsv = $rgb->toHsv(); // \OzdemirBurak\Iris\Color\Hsv('300,100,100')
$rgb = $rgb->toRgb(); // \OzdemirBurak\Iris\Color\Rgb('255,0,255')
$rgba = $rgb->toRgba(); // \OzdemirBurak\Iris\Color\Rgba('255,0,255,1.0')
echo $rgb; // rgb(255,0,255)
```

### RGBA

[](#rgba)

```
use OzdemirBurak\Iris\Color\Rgba;

$rgba = new Rgba('rgba(93,111,222,0.33)');

echo $rgba->red(); // 93
echo $rgba->green(); // 111
echo $rgba->blue(); // 222
echo $rgba->alpha(); // 0.33
$hex = $rgba->background((new Hex('ccc'))->toRgb())->toHex(); // \OzdemirBurak\Iris\Color\Hex('a7add1')
$hexa = $rgba->toHexa(); // \OzdemirBurak\Iris\Color\Hexa('5d6fde54') - preserves original RGB
echo $rgba; // rgba(93,111,222,0.33)
```

### CMYK

[](#cmyk)

```
use OzdemirBurak\Iris\Color\Cmyk;

$cmyk = new Cmyk('cmyk(0,100,0,0)');

echo $cmyk->cyan(); // 0
echo $cmyk->magenta(); // 100
echo $cmyk->yellow(); // 0
echo $cmyk->black(); // 0

$values = $cmyk->values(); // [0, 100, 0, 0]
$hex = $cmyk->toHex(); // OzdemirBurak\Iris\Color\Hex('ff00ff')
$hexa = $cmyk->toHexa(); // OzdemirBurak\Iris\Color\Hexa('ff00ffff')
$hsl = $cmyk->toHsl(); // OzdemirBurak\Iris\Color\Hsl('300,100,50')
$hsla = $cmyk->toHsla(); // OzdemirBurak\Iris\Color\Hsla('300,100,50,1.0')
$hsv = $cmyk->toHsv(); // OzdemirBurak\Iris\Color\Hsv('300,100,100')
$rgb = $cmyk->toRgb(); // OzdemirBurak\Iris\Color\Rgb('255,0,255')
$rgba = $cmyk->toRgba(); // OzdemirBurak\Iris\Color\Rgba('255,0,255,1.0')

echo $cmyk; // cmyk(0,100,0,0)
```

### OKLCH

[](#oklch)

```
use OzdemirBurak\Iris\Color\Oklch;
use OzdemirBurak\Iris\Color\Hex;

// Comma-separated syntax
$oklch = new Oklch('oklch(70%, 0.15, 150)');

// Space-separated syntax (CSS Color Level 4)
$oklch = new Oklch('oklch(40.1% 0.123 21.57)');
$oklch = new Oklch('oklch(59.69% 0.156 49.77)');

echo $oklch->lightness(); // 59.69
echo $oklch->chroma(); // 0.156
echo $oklch->hue(); // 49.77

$values = $oklch->values(); // [59.69, 0.156, 49.77]
$hex = $oklch->toHex(); // OzdemirBurak\Iris\Color\Hex
$rgb = $oklch->toRgb(); // OzdemirBurak\Iris\Color\Rgb
$hsl = $oklch->toHsl(); // OzdemirBurak\Iris\Color\Hsl

echo $oklch; // oklch(59.69% 0.156 49.77)

// Convert from other formats to OKLCH
$hex = new Hex('#ff0000');
$oklch = $hex->toOklch();
echo $oklch; // oklch(62.8% 0.2577 29.23)
```

**Note:** The following are not supported:

- Alpha values (e.g., `oklch(59.69% 0.156 49.77 / .5)`) - alpha is ignored
- Relative color syntax with `from` keyword (e.g., `oklch(from green l c h)`)

### Via Factory

[](#via-factory)

If you do not know what the color string will be (for example, you're getting it from a group of rows from a database), then you can try using Factory to instantiate an appropriate color class:

```
use OzdemirBurak\Iris\Color\Factory;

$color = Factory::init('rgba(93,111,222,0.33)');
echo $color->red(); // 93
echo $color->green(); // 111
echo $color->blue(); // 222
echo $color->alpha(); // 0.33
```

### Color Cloning

[](#color-cloning)

You can clone a color object to make a copy and modify it as needed.

```
use OzdemirBurak\Iris\Color\Hex;

$original = new Hex('#b2b2b2');
$cloned = $original->clone()->toHexa()->alpha(0.5); // OzdemirBurak\Iris\Color\Hexa('#b2b2b280')
```

### Color Manipulation

[](#color-manipulation)

#### Saturation

[](#saturation)

Saturate or desaturate by a percent.

```
echo (new Hsl('90,80%,50%'))->saturate(20)->toHex(); // #80ff00
echo (new Hsl('90, 80%, 50%'))->desaturate(20)->toRgb(); // rgb(128,204,51)
echo (new Hex('#80cc33'))->grayscale(); // #808080, same as desaturate 100
```

#### Lightness

[](#lightness)

Lighten, darken or brighten by a percent.

```
$hex = new Hex('#333');
echo $hex->lighten(20); // #666666
echo $hex->darken(20); // #000000
echo $hex->brighten(20); // #666666
```

#### Spin

[](#spin)

Spin by an angle \[-360, 360\]

```
$hex = (new Hsl('10,90%,50'))->spin(30)->toHex();
echo $hex; // #f2a60d
```

#### Mix

[](#mix)

Mix by a percent.

```
$hex = new Hex('#000');
echo $hex->mix(new Hex('#fff'), 50); // #808080
```

#### Tint

[](#tint)

Mix color with white by a percent.

```
$hex = new Hex('#000');
echo $hex->tint(50); // #808080
```

#### Shade

[](#shade)

Mix color with black by a percent.

```
$hex = new Hex('#FFF');
echo $hex->shade(50); // #808080
```

#### Fade

[](#fade)

Set the absolute opacity of a color by a percent.

```
$hsl = new Hsl('90,90,50');
echo $hsl->fade(10); // hsla(90,90%,50%,0.1)

$rgb = new Rgb('128,242,13');
echo $rgb->fade(10); // rgba(128,242,13,0.1)
```

#### FadeIn

[](#fadein)

Increase the opacity of a color by a percent.

```
$hsla = new Hsla('90,90,50,0.3');
echo $hsla->fadeIn(10); // hsla(90,90%,50%,0.4)

$rgba = new Rgba('128,242,13,0.3');
echo $rgba->fadeIn(10); // rgba(128,242,13,0.4)
```

#### FadeOut

[](#fadeout)

Decrease the opacity of a color by a percent.

```
$hsla = new Hsla('90,90,50,0.3');
echo $hsla->fadeOut(10); // hsla(90,90%,50%,0.2)

$rgba = new Rgba('128,242,13,0.3');
echo $rgba->fadeOut(10); // rgba(128,242,13,0.2)
```

#### Is light or dark

[](#is-light-or-dark)

Determine if color is dark or light color.

```
$hex = new Hex('#000');
echo $hex->isLight(); // false
echo $hex->isDark(); // true
```

#### Gradient

[](#gradient)

Generate an array of colors (gradient) between two or more colors.

```
use OzdemirBurak\Iris\Color\Hex;
use OzdemirBurak\Iris\Color\Rgb;

// Two-color gradient: 5 steps from red to blue
$gradient = (new Hex('#ff0000'))->gradient(new Hex('#0000ff'), 5);
// ['#ff0000', '#bf0040', '#800080', '#4000bf', '#0000ff']

// Multi-color gradient with pivot: red → yellow → green in 7 steps
$gradient = (new Hex('#ff0000'))->gradient([new Hex('#ffff00'), new Hex('#00ff00')], 7);
// ['#ff0000', '#ff5500', '#ffaa00', '#ffff00', '#aaff00', '#55ff00', '#00ff00']

// Works with any color type - output matches the starting color type
$gradient = (new Rgb('255,0,0'))->gradient(new Rgb('0,0,255'), 3);
// [rgb(255,0,0), rgb(128,0,128), rgb(0,0,255)]
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Burak Özdemir](https://github.com/ozdemirburak)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

67

—

FairBetter than 100% of packages

Maintenance80

Actively maintained with recent releases

Popularity57

Moderate usage in the ecosystem

Community34

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 58.4% 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 ~165 days

Recently: every ~262 days

Total

20

Last Release

132d ago

Major Versions

1.2.1 → 2.0.02019-10-12

2.4.0 → 3.0.02022-02-08

2.5.0 → 3.1.02023-02-08

3.1.1 → 4.0.02025-12-02

PHP version history (7 changes)1.0.0PHP ~5.5|~7.0

1.1.1PHP ~5.6|~7.0

2.0.0PHP ~7.1

2.1.0PHP ~7.2

2.3.0PHP ^7.3|^8.0

3.0.0PHP ^8.0

4.0.0PHP ^8.1

### Community

Maintainers

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

---

Top Contributors

[![ozdemirburak](https://avatars.githubusercontent.com/u/5355510?v=4)](https://github.com/ozdemirburak "ozdemirburak (52 commits)")[![kudashevs](https://avatars.githubusercontent.com/u/15892462?v=4)](https://github.com/kudashevs "kudashevs (7 commits)")[![jaulz](https://avatars.githubusercontent.com/u/5358638?v=4)](https://github.com/jaulz "jaulz (6 commits)")[![NikarashiHatsu](https://avatars.githubusercontent.com/u/43662951?v=4)](https://github.com/NikarashiHatsu "NikarashiHatsu (5 commits)")[![amnuts](https://avatars.githubusercontent.com/u/684421?v=4)](https://github.com/amnuts "amnuts (4 commits)")[![f3ath](https://avatars.githubusercontent.com/u/831399?v=4)](https://github.com/f3ath "f3ath (3 commits)")[![Vincentv92](https://avatars.githubusercontent.com/u/2413796?v=4)](https://github.com/Vincentv92 "Vincentv92 (2 commits)")[![DevDavido](https://avatars.githubusercontent.com/u/997605?v=4)](https://github.com/DevDavido "DevDavido (2 commits)")[![martinsustek](https://avatars.githubusercontent.com/u/3765387?v=4)](https://github.com/martinsustek "martinsustek (1 commits)")[![maximzasorin](https://avatars.githubusercontent.com/u/13367689?v=4)](https://github.com/maximzasorin "maximzasorin (1 commits)")[![khamer](https://avatars.githubusercontent.com/u/1452?v=4)](https://github.com/khamer "khamer (1 commits)")[![olivernybroe](https://avatars.githubusercontent.com/u/5870441?v=4)](https://github.com/olivernybroe "olivernybroe (1 commits)")[![Jako](https://avatars.githubusercontent.com/u/148371?v=4)](https://github.com/Jako "Jako (1 commits)")[![pricop](https://avatars.githubusercontent.com/u/920945?v=4)](https://github.com/pricop "pricop (1 commits)")[![SanderMuller](https://avatars.githubusercontent.com/u/9074391?v=4)](https://github.com/SanderMuller "SanderMuller (1 commits)")[![dtSniper](https://avatars.githubusercontent.com/u/42205971?v=4)](https://github.com/dtSniper "dtSniper (1 commits)")

---

Tags

cmykcolor-conversioncolor-manipulationcolorshexhslhslahsvoklchrgbrgbamanipulationconversioncolorrgbhextransformationcmykhslrgbahslahsvhexaoklch

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ozdemirburak-iris/health.svg)

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

###  Alternatives

[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)
