Python binding for LittleCMS2 library
Project description
python-lcms2
Python binding for the LittleCMS2 color management library.
Installation
pip install python-lcms2
Pre-built wheels are available on PyPI for Windows (x86-64) and Linux (x86-64) on Python 3.10 and later. For other platforms, see Building from source.
Usage
import lcms2
Profiles
A Profile can be created from a built-in name, a file on disk, or raw bytes in memory:
srgb = lcms2.Profile("sRGB")
prophoto = lcms2.Profile("ProPhoto RGB")
from_file = lcms2.Profile(filename="CMYK.icm")
with open("CMYK.icm", "rb") as f:
from_bytes = lcms2.Profile(buffer=f.read())
Built-in profiles provided by LittleCMS: sRGB, Lab, XYZ.
Additional built-in RGB profiles: Adobe RGB (1998), Apple RGB, Best RGB, Beta RGB, Bruce RGB, CIE RGB, ColorMatch RGB, Don RGB 4, ECI RGB v2, Ekta Space PS5, NTSC RGB, PAL/SECAM RGB, ProPhoto RGB, SMPTE-C RGB, _sRGB, Wide Gamut RGB.
Transforms
A Transform converts pixel data from one profile and format to another:
lab = lcms2.Profile("Lab")
srgb = lcms2.Profile("sRGB")
transform = lcms2.Transform(lab, "Lab_DBL", srgb, "RGB_16")
The constructor signature is:
Transform(src_profile, src_format, dst_profile, dst_format, intent="PERCEPTUAL", flags="NONE")
All supported format strings:
lcms2.DATA_TYPES.keys()
Rendering intents (lcms2.INTENT): PERCEPTUAL, RELATIVE_COLORIMETRIC, SATURATION, ABSOLUTE_COLORIMETRIC.
Flags (lcms2.FLAG) can be combined with commas, spaces, semicolons, or |:
transform = lcms2.Transform(lab, "Lab_DBL", srgb, "RGB_16",
intent="PERCEPTUAL",
flags="GAMUTCHECK,SOFTPROOFING")
Applying a transform
Transform.apply accepts a NumPy array or any array-compatible object and returns a transformed NumPy array:
result = transform.apply([50.0, 0.0, 0.0]) # L*a*b* neutral grey
The input type must match the source format declared at construction time. When passing lists or other convertibles, the data is cast automatically where possible.
Building from source
Clone the repository with its submodules:
git clone --recurse-submodules https://github.com/wzjoriv/python-lcms2.git
cd python-lcms2
Install the build tool if needed:
pip install build --upgrade
Build a wheel:
python -m build --wheel
The wheel is written to dist/. Install it with:
pip install dist/python_lcms2*.whl
Windows path detection (Windows SDK include and library directories) is handled automatically via the registry in setup.py. If the build fails on your Windows installation, the paths may need to be adjusted manually.
For bugs, questions, and feature requests use GitHub Issues.
Acknowledgements
This project is a continuation of work by prior maintainers. The lineage of the repository is: sk1-project → RomanKosobrodov → wzjoriv.
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 Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_lcms2-0.1.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: python_lcms2-0.1.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 176.2 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf65324a412b348e6ad23dde890d744cd0872805ad462188180961eebacda6b4
|
|
| MD5 |
57a0c26a565075e12bc4efd71205e8fe
|
|
| BLAKE2b-256 |
0dd0878f7bbddffa0135c424887fd927b1ab8b7690ec2085aac9f6d4be45c59d
|