colourtools
colourtools is a lightweight Python library for intuitive conversion and manipulation of colours across multiple formats.
Features
- Convert between CMYK, RGB, and HEX colour spaces
- Support for both integer and floating-point representations
- Simple, readable API for common colour transformations
- Utility functions for encoding and decoding colour values
- Designed for clarity, reliability, and easy integration into your projects
Example Usage
from colourtools import cmyk_to_rgb, rgb_to_cmyk, hex_to_rgb, rgb_to_hex
rgb = cmyk_to_rgb((0, 100, 100, 0)) # (255, 0, 0)
cmyk = rgb_to_cmyk((255, 0, 0)) # (0, 100, 100, 0)
rgb = hex_to_rgb("#FF0000") # (255, 0, 0)
hex_ = rgb_to_hex((255, 0, 0)) # '#ff0000'
Full API
| Function | Input | Output |
|---|---|---|
cmyk_to_rgb(cmyk) |
CMYK (0–100) | RGB (0–255) |
cmyk_to_float_rgb(cmyk) |
CMYK (0–100) | float RGB (0.0–1.0) |
cmyk_to_hex(cmyk) |
CMYK (0–100) | hex string |
rgb_to_cmyk(rgb, decimal_places=0) |
RGB (0–255) | CMYK (0–100) |
rgb_to_float_rgb(rgb) |
RGB (0–255) | float RGB (0.0–1.0) |
rgb_to_hex(rgb) |
RGB (0–255) | hex string |
rgb_to_rgbk(rgb, k=1.0) |
RGB (0–255) | (R, G, B, K) |
hex_to_rgb(hex_color) |
hex string | RGB (0–255) |
hex_to_float_rgb(hex_color) |
hex string | float RGB (0.0–1.0) |
hex_to_cmyk(hex_color, decimal_places=0) |
hex string | CMYK (0–100) |
float_rgbk(rgbk) |
(R, G, B int, K float) | float (R, G, B, K) |
CMYK values are always in the range 0–100 (not 0–1). Hex strings are accepted with or without a leading #.
Installation
pip install colourtools
License
MIT License
colourtools makes colour conversion in Python simple, consistent, and accessible for everyone—no matter how you spell it.
Release files for colourtools 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| colourtools-0.1.4.tar.gz | 3.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| colourtools-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.0 kB
Release files / colourtools-0.1.4.tar.gz
| Download URL | colourtools-0.1.4.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c7d6d70d6c88f2b3cfa4b1ed0cdef4f64a268d17a1b4ee44b92bc9f6abee8722
|
|
BLAKE2b-256 checksum How to use checksums |
a956854548ff88054d71b36bb4575e244dfa0612e9585b54d0c41acbe9928238
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.14.5 Darwin/25.4.0
|
Release files / colourtools-0.1.4-py3-none-any.whl
| Download URL | colourtools-0.1.4-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
497a65cfeec58849c8a923ebc3f0ee914aa29f4c3a2e37e2b1b3543a86d4970c
|
|
BLAKE2b-256 checksum How to use checksums |
b76eda6699eb44bac5d0a69a645cb51495934255ba4a17eb984ee481bf0cf7e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.14.5 Darwin/25.4.0
|