PHPackages                             carloscabo/husl - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. carloscabo/husl

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

carloscabo/husl
===============

HSLuv / RGB / hex color conversion library

2.0.0(9y ago)16281MITPHP

Since Oct 10Pushed 1y agoCompare

[ Source](https://github.com/husl-colors/husl-php)[ Packagist](https://packagist.org/packages/carloscabo/husl)[ Docs](https://github.com/hsluv/hsluv-php)[ RSS](/packages/carloscabo-husl/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (6)Used By (0)

HSLuv-php
=========

[](#hsluv-php)

[![Build Status](https://github.com/hsluv/hsluv-php/actions/workflows/test.yml/badge.svg)](https://github.com/hsluv/hsluv-php/actions/workflows/test.yml)

Port to PHP (5.6+) from Python / JS of [HSLuv](http://www.hsluv.org/) (revision 4).

To run the tests:

```
composer install
./vendor/bin/phpunit

```

Usage
=====

[](#usage)

```
composer require "hsluv/hsluv"

```

From RGB / hex to HSLuv
=======================

[](#from-rgb--hex-to-hsluv)

```
// From hex upper / lowercase
$out = HSLuv::fromHex( '#fabada' );
$out = HSLuv::fromHex( '#FABADA' );

// From RGB (float) in 0.0 - 1.0 range
$out = HSLuv::fromRgb( 0.9803921568627451, 0.7294117647058823, 0.8549019607843137 );
$out = HSLuv::fromRgb( array( 0.9803921568627451, 0.7294117647058823, 0.8549019607843137 ) );

// From RGB (int) in 0 - 255 range
$out = HSLuv::fromRgbInt( 250, 186, 218 );
$out = HSLuv::fromRgbInt( 250.0, 186.0, 218.0 );
$out = HSLuv::fromRgbInt( array( 250, 186, 218 ) );
$out = HSLuv::fromRgbInt( array( 250.0, 186.0, 218.0 ) );
```

Returns HSLuv an array of **float** values ( H, S, L ).

From HSLuv to RGB / hex
=======================

[](#from-hsluv-to-rgb--hex)

Parameters are float H, S, L componets or an array.

```
// Rgb: returns array of (float) in 0.0 - 1.0 range
$out = HSLuv::toRgb( $h, $s, $l )
$out = HSLuv::toRgb( array( $h, $s, $l ) )

// Rgb: returns array if (int) in 0 - 255 range
$out = HSLuv::toRgbInt( $h, $s, $l )
$out = HSLuv::toRgbInt( array( $h, $s, $l ) )

// Hex: returns lowercase string including "#"
$out = HSLuv::toHex( $h, $s, $l )
$out = HSLuv::toRgb( array( $h, $s, $l ) )
```

Authors
=======

[](#authors)

- Port by Carlos Cabo ([carloscabo](https://github.com/carloscabo))
- Support with tests and packaging ([tasugo](https://github.com/tasugo))
- Original HSLuv author: Alexei Boronine ([boronine](http://github.com/boronine))

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 51% 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 ~44 days

Total

4

Last Release

3364d ago

Major Versions

1.0.2 → 2.0.02017-02-21

### Community

Maintainers

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

---

Top Contributors

[![carloscabo](https://avatars.githubusercontent.com/u/3063164?v=4)](https://github.com/carloscabo "carloscabo (26 commits)")[![tasugo](https://avatars.githubusercontent.com/u/3673895?v=4)](https://github.com/tasugo "tasugo (17 commits)")[![boronine](https://avatars.githubusercontent.com/u/93469?v=4)](https://github.com/boronine "boronine (8 commits)")

---

Tags

colorHSLuv

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/carloscabo-husl/health.svg)

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

###  Alternatives

[spatie/color

A little library to handle color conversions

38018.9M28](/packages/spatie-color)[mexitek/phpcolors

A series of methods that let you manipulate colors. Just incase you ever need different shades of one color on the fly.

5003.6M18](/packages/mexitek-phpcolors)[mistic100/randomcolor

Generate attractive random colors

2431.4M6](/packages/mistic100-randomcolor)[kartik-v/yii2-widget-colorinput

An enhanced Yii 2 widget encapsulating the HTML 5 color input (sub repo split from yii2-widgets)

324.8M10](/packages/kartik-v-yii2-widget-colorinput)[ssnepenthe/color-utils

A PHP library for performing SASS-like color manipulations.

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

PHP library to manipulate various color representations

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

PHPackages © 2026

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