HSL conversion tools
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
HSL-1.0.3.tar.gz
(58.8 kB
view details)
Built Distributions
File details
Details for the file HSL-1.0.3.tar.gz
.
File metadata
- Download URL: HSL-1.0.3.tar.gz
- Upload date:
- Size: 58.8 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c259b95d56ff45c58186fc5f52bd596e24e7eff26e33a7988a277ee712f07427 |
|
MD5 | ce811743487f143c4272b8a522d43945 |
|
BLAKE2b-256 | 2100e5424a357552fa64e64ad38f9cc9faf9c83ac232b9aa1811c2e62153a1ec |
File details
Details for the file HSL-1.0.3-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: HSL-1.0.3-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 41.5 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6ae2b8982ce7033362ef2a293b76b08e8ba224484427e80c8ee539929f29481 |
|
MD5 | 9d4deb3d2a81a97d1d17ce0e8860c5e6 |
|
BLAKE2b-256 | c58c1a07318db6cb044766a6d3a42fd1b7e74a82714332a65d5be06875f4959d |
File details
Details for the file HSL-1.0.3-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: HSL-1.0.3-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 41.5 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55d55e015becd21ad26d728f31ba3ed34f6db18b2ae1329b2f7b1360fc11575c |
|
MD5 | 74d331ff9b995a370a6e3e52528137c6 |
|
BLAKE2b-256 | ce52a8013a8440d38b9439d8bc8bb553980801f077e7d1c25c3d5538855f1374 |
File details
Details for the file HSL-1.0.3-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: HSL-1.0.3-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 41.5 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70126504e26b67d413799e95f17f2b929e5be280861eeb2684651780b73b9a1d |
|
MD5 | 51266c0b4d4dd9b954cc4dd6c62b2f90 |
|
BLAKE2b-256 | 7fa687cb93f670f3b50cc8161818b744cf1bb29f30766d4eba1ac8196ba070ba |
File details
Details for the file HSL-1.0.3-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: HSL-1.0.3-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 41.4 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e917c998afbdf96d9a8ed4eecd9aa9c21a37d874e7cc722ae6d497cb6b1f3efd |
|
MD5 | 212e9b10ef64d22ebc8596444d140308 |
|
BLAKE2b-256 | 94305c0150d98f4e5cfa1b99a438cad32c217026326452e27017e974453e385d |
File details
Details for the file HSL-1.0.3-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: HSL-1.0.3-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 41.3 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90f3c3f8c1937e0240e7ecca46cf49973f1fd3f8fcc5cac61c5fba403bd78721 |
|
MD5 | 6b1e8664592434402be6433f978edf97 |
|
BLAKE2b-256 | a311a1bce8d72ed7823cf3aa2feff58f8e12719bbad9b596c802c10417036978 |