Skip to main content

colourtools is a lightweight Python library for intuitive conversion and manipulation of colours across multiple formats

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

colourtools-0.1.4.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

colourtools-0.1.4-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file colourtools-0.1.4.tar.gz.

File metadata

  • Download URL: colourtools-0.1.4.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.14.5 Darwin/25.4.0

File hashes

Hashes for colourtools-0.1.4.tar.gz
Algorithm Hash digest
SHA256 c7d6d70d6c88f2b3cfa4b1ed0cdef4f64a268d17a1b4ee44b92bc9f6abee8722
MD5 40939bc84e2b02c99ee569af4982df42
BLAKE2b-256 a956854548ff88054d71b36bb4575e244dfa0612e9585b54d0c41acbe9928238

See more details on using hashes here.

File details

Details for the file colourtools-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: colourtools-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.14.5 Darwin/25.4.0

File hashes

Hashes for colourtools-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 497a65cfeec58849c8a923ebc3f0ee914aa29f4c3a2e37e2b1b3543a86d4970c
MD5 9a2f06ffffd1ad005dd142d1eda19de6
BLAKE2b-256 b76eda6699eb44bac5d0a69a645cb51495934255ba4a17eb984ee481bf0cf7e7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page