Skip to main content

HSL project

Why installing HSL :

This library offers fast conversion tools such as (HSL to RGB ) and (RGB to HSL) 
ported into cython for better performances 

Project description :

Conversions between color systems (cython library)
This module defines bidirectional conversions of color values between colors
expressed in the RGB (Red Green Blue) color space used in computer monitors and three
HLS (Hue Lightness Saturation).

Installation

pip install HSL

How to?

from HSL.hsl import rgb_to_hsl, hsl_to_rgb

if __name__ == '__main__':
    ONE_255 = 1.0 / 255.0
    r, g, b = 25, 60, 128
    print("\nOriginal RGB values (R:%s, G:%s, B:%s)\n" % (r, g, b))
    
    h, s, l = rgb_to_hsl(r * ONE_255, g * ONE_255, b * ONE_255)
    
    print("HSL values (H:%s, S:%s, L:%s)" % (h * 360.0, s * 100.0, l * 100.0))
    
    r, g, b = hsl_to_rgb(h, s, l)
    
    print("Retrieved RGB values (R:%s, G:%s, B:%s)\n" % (r * 255.0, g * 255.0, b * 255.0))

Building cython code

If you need to compile the Cython code after changing the files hsl.pyx or hsl.pxd or
the external C code please proceed as follow:

1) open a terminal window
2) Go in the main project directory where (hsl.pyx & hsl.pxd files are located)
3) run : python setup_hsl.py build_ext --inplace

If you have to compile the code with a specific python version, make sure
to reference the right python version in (c:\python setup_hsl.py build_ext --inplace)

If the compilation fail, refers to the requirement section and make sure cython
and a C-compiler are correctly install on your system.
- A compiler such visual studio, MSVC, CGYWIN setup correctly on your system.
  - a C compiler for windows (Visual Studio, MinGW etc) install on your system
  and linked to your windows environment.
  Note that some adjustment might be needed once a compiler is install on your system,
  refer to external documentation or tutorial in order to setup this process.
  e.g https://devblogs.microsoft.com/python/unable-to-find-vcvarsall-bat/

Credit

Yoann Berenguer

Dependencies :

python >= 3.0
cython >= 0.28

License :

MIT License

Copyright (c) 2019 Yoann Berenguer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Timing :

python
Test with 1000000 iterations

This library
rgb_to_hsl per call 2.061723e-07 overall time 0.206172 seconds
hsl_to_rgb per call 1.181744e-07 overall time 0.118174 seconds

Colorsys library
colorsys.rgb_to_hls per call 1.054554e-06 overall  time 1.054554 seconds
colorsys.hls_to_rgb per call 8.701219e-07 overall  time 0.870121 seconds

Metadata

Release files for HSL 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for HSL 1.0.3
File Size Uploaded
HSL-1.0.3.tar.gz 58.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for HSL 1.0.3
File
HSL-1.0.3-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
HSL-1.0.3-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
HSL-1.0.3-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
HSL-1.0.3-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
HSL-1.0.3-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details

Total release size: 265.9 kB

Release files / HSL-1.0.3.tar.gz

Download URL HSL-1.0.3.tar.gz
Size 58.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c259b95d56ff45c58186fc5f52bd596e24e7eff26e33a7988a277ee712f07427
BLAKE2b-256 checksum
How to use checksums
2100e5424a357552fa64e64ad38f9cc9faf9c83ac232b9aa1811c2e62153a1ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

Release files / HSL-1.0.3-cp310-cp310-win_amd64.whl

Download URL HSL-1.0.3-cp310-cp310-win_amd64.whl
Size 41.5 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
a6ae2b8982ce7033362ef2a293b76b08e8ba224484427e80c8ee539929f29481
BLAKE2b-256 checksum
How to use checksums
c58c1a07318db6cb044766a6d3a42fd1b7e74a82714332a65d5be06875f4959d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

Release files / HSL-1.0.3-cp39-cp39-win_amd64.whl

Download URL HSL-1.0.3-cp39-cp39-win_amd64.whl
Size 41.5 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
55d55e015becd21ad26d728f31ba3ed34f6db18b2ae1329b2f7b1360fc11575c
BLAKE2b-256 checksum
How to use checksums
ce52a8013a8440d38b9439d8bc8bb553980801f077e7d1c25c3d5538855f1374
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

Release files / HSL-1.0.3-cp38-cp38-win_amd64.whl

Download URL HSL-1.0.3-cp38-cp38-win_amd64.whl
Size 41.5 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
70126504e26b67d413799e95f17f2b929e5be280861eeb2684651780b73b9a1d
BLAKE2b-256 checksum
How to use checksums
7fa687cb93f670f3b50cc8161818b744cf1bb29f30766d4eba1ac8196ba070ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

Release files / HSL-1.0.3-cp37-cp37m-win_amd64.whl

Download URL HSL-1.0.3-cp37-cp37m-win_amd64.whl
Size 41.4 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
e917c998afbdf96d9a8ed4eecd9aa9c21a37d874e7cc722ae6d497cb6b1f3efd
BLAKE2b-256 checksum
How to use checksums
94305c0150d98f4e5cfa1b99a438cad32c217026326452e27017e974453e385d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

Release files / HSL-1.0.3-cp36-cp36m-win_amd64.whl

Download URL HSL-1.0.3-cp36-cp36m-win_amd64.whl
Size 41.3 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
90f3c3f8c1937e0240e7ecca46cf49973f1fd3f8fcc5cac61c5fba403bd78721
BLAKE2b-256 checksum
How to use checksums
a311a1bce8d72ed7823cf3aa2feff58f8e12719bbad9b596c802c10417036978
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.6

Release history Release notifications | RSS feed

This release

1.0.3 This release

6 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page