python-lcms2 0.0.20__cp313-cp313-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- __init__.py +0 -0
- _lcms2.pyd +0 -0
- lcms2/__init__.py +124 -0
- lcms2/_lcms2.c +89 -0
- lcms2/_lcms2.pyd +0 -0
- lcms2/implementation.py +221 -0
- pylcms2/__init__.py +124 -0
- pylcms2/_lcms2.c +84 -0
- pylcms2/implementation.py +221 -0
- python_lcms2-0.0.20.dist-info/METADATA +130 -0
- python_lcms2-0.0.20.dist-info/RECORD +14 -0
- python_lcms2-0.0.20.dist-info/WHEEL +5 -0
- python_lcms2-0.0.20.dist-info/licenses/LICENSE +674 -0
- python_lcms2-0.0.20.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import _lcms2
|
|
2
|
+
import numpy as np
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class CMSError(Exception):
|
|
7
|
+
def __init__(self, message="LibCMS2 error"):
|
|
8
|
+
super().__init__(message)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def create_profile(profile, white_point=None, degrees=2, temperature=None):
|
|
12
|
+
if profile in ("sRGB", "Lab", "XYZ"):
|
|
13
|
+
coordinates = None
|
|
14
|
+
if profile == "Lab":
|
|
15
|
+
if isinstance(white_point, str):
|
|
16
|
+
coordinates = np.array(WHITE_POINTS[degrees][white_point]["xyY"])
|
|
17
|
+
else:
|
|
18
|
+
if isinstance(temperature, (int, float)):
|
|
19
|
+
wp_list = _lcms2.white_point_from_temperature(temperature)
|
|
20
|
+
coordinates = np.array(wp_list)
|
|
21
|
+
else:
|
|
22
|
+
if white_point is not None:
|
|
23
|
+
coordinates = np.array(white_point)
|
|
24
|
+
if coordinates.size != 3:
|
|
25
|
+
raise CMSError(
|
|
26
|
+
"white_point should be an array-like object of size 3 containing xyY coordinates of the white point")
|
|
27
|
+
p = _lcms2.create_profile(profile, coordinates)
|
|
28
|
+
return p
|
|
29
|
+
|
|
30
|
+
if profile in RGB_COLORSPACES.keys():
|
|
31
|
+
space = RGB_COLORSPACES[profile]
|
|
32
|
+
profile_white_point = space["white point"]
|
|
33
|
+
if profile_white_point not in WHITE_POINTS[degrees].keys():
|
|
34
|
+
raise CMSError(f"Unknown white point `{profile_white_point}`")
|
|
35
|
+
wp = np.array(WHITE_POINTS[degrees][profile_white_point]["xyY"])
|
|
36
|
+
red = np.array(space["red"])
|
|
37
|
+
green = np.array(space["green"])
|
|
38
|
+
blue = np.array(space["blue"])
|
|
39
|
+
tc = space["tone curve"]
|
|
40
|
+
curve_type = int(tc["type"])
|
|
41
|
+
parameters = np.array(tc["parameters"])
|
|
42
|
+
p = _lcms2.create_rgb_profile(wp, red, green, blue, curve_type, parameters)
|
|
43
|
+
return p
|
|
44
|
+
|
|
45
|
+
raise CMSError(
|
|
46
|
+
f"Invalid profile '{profile}'. It must be one of built in profiles ('sRGB', 'Lab' or 'XYZ') or supported RGB profiles.")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def open_profile(filename):
|
|
50
|
+
if not isinstance(filename, str):
|
|
51
|
+
raise CMSError("filename must be a string containing a path to a profile")
|
|
52
|
+
if not os.path.isfile(filename):
|
|
53
|
+
raise CMSError(f"Unable to find '{filename}'.")
|
|
54
|
+
|
|
55
|
+
p = _lcms2.open_profile(filename)
|
|
56
|
+
return p
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def profile_from_memory(buffer):
|
|
60
|
+
if not isinstance(buffer, bytes):
|
|
61
|
+
raise CMSError("filename must be a bytes object")
|
|
62
|
+
|
|
63
|
+
p = _lcms2.profile_from_memory(buffer)
|
|
64
|
+
return p
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
"""
|
|
68
|
+
White points of standard illuminants for 2 degrees and 10 degrees field of view
|
|
69
|
+
xyY are the coordinates of the white point,
|
|
70
|
+
CCT is correlated color temperature in Kelvins
|
|
71
|
+
"""
|
|
72
|
+
WHITE_POINTS = {2: {'A': {'xyY': [0.44758, 0.40745, 1.0], 'CCT': 2856.0, 'description': 'incandescent / tungsten'},
|
|
73
|
+
'B': {'xyY': [0.34842, 0.35161, 1.0], 'CCT': 4874.0,
|
|
74
|
+
'description': 'obsolete, direct sunlight at noon'},
|
|
75
|
+
'C': {'xyY': [0.31006, 0.31616, 1.0], 'CCT': 6774.0,
|
|
76
|
+
'description': 'obsolete, average / North sky daylight NTSC 1953, PAL-M'},
|
|
77
|
+
'D50': {'xyY': [0.34567, 0.3585, 1.0], 'CCT': 5003.0,
|
|
78
|
+
'description': 'horizon light, ICC profile PCS'},
|
|
79
|
+
'D55': {'xyY': [0.33242, 0.34743, 1.0], 'CCT': 5503.0,
|
|
80
|
+
'description': 'mid-morning / mid-afternoon daylight'},
|
|
81
|
+
'D65': {'xyY': [0.31272, 0.32903, 1.0], 'CCT': 6504.0,
|
|
82
|
+
'description': 'noon daylight: television, sRGB color space'},
|
|
83
|
+
'D75': {'xyY': [0.29902, 0.31485, 1.0], 'CCT': 7504.0, 'description': 'North sky daylight'},
|
|
84
|
+
'D93': {'xyY': [0.28315, 0.29711, 1.0], 'CCT': 9305.0,
|
|
85
|
+
'description': 'high-efficiency blue phosphor monitors, BT.2035, NTSC-J'},
|
|
86
|
+
'E': {'xyY': [0.33333, 0.33333, 1.0], 'CCT': 5454.0, 'description': 'equal energy'},
|
|
87
|
+
'F1': {'xyY': [0.3131, 0.33727, 1.0], 'CCT': 6430.0, 'description': 'daylight fluorescent'},
|
|
88
|
+
'F2': {'xyY': [0.37208, 0.37529, 1.0], 'CCT': 4230.0, 'description': 'cool white fluorescent'},
|
|
89
|
+
'F3': {'xyY': [0.4091, 0.3943, 1.0], 'CCT': 3450.0, 'description': 'white fluorescent'},
|
|
90
|
+
'F4': {'xyY': [0.44018, 0.40329, 1.0], 'CCT': 2940.0, 'description': 'warm white fluorescent'},
|
|
91
|
+
'F5': {'xyY': [0.31379, 0.34531, 1.0], 'CCT': 6350.0, 'description': 'daylight fluorescent'},
|
|
92
|
+
'F6': {'xyY': [0.3779, 0.38835, 1.0], 'CCT': 4150.0, 'description': 'light white fluorescent'},
|
|
93
|
+
'F7': {'xyY': [0.31292, 0.32933, 1.0], 'CCT': 6500.0,
|
|
94
|
+
'description': 'D65 simulator, daylight simulator'},
|
|
95
|
+
'F8': {'xyY': [0.34588, 0.35875, 1.0], 'CCT': 5000.0,
|
|
96
|
+
'description': 'D50 simulator, Sylvania F40 Design 50'},
|
|
97
|
+
'F9': {'xyY': [0.37417, 0.37281, 1.0], 'CCT': 4150.0,
|
|
98
|
+
'description': 'cool white deluxe fluorescent'},
|
|
99
|
+
'F10': {'xyY': [0.34609, 0.35986, 1.0], 'CCT': 5000.0, 'description': 'Philips TL85, Ultralume 50'},
|
|
100
|
+
'F11': {'xyY': [0.38052, 0.37713, 1.0], 'CCT': 4000.0, 'description': 'Philips TL84, Ultralume 40'},
|
|
101
|
+
'F12': {'xyY': [0.43695, 0.40441, 1.0], 'CCT': 3000.0, 'description': 'Philips TL83, Ultralume 30'},
|
|
102
|
+
'FL3.1': {'xyY': [0.4407, 0.4033, 1.0], 'CCT': 2932.0, 'description': 'standard halophosphate'},
|
|
103
|
+
'FL3.2': {'xyY': [0.3808, 0.3734, 1.0], 'CCT': 3965.0, 'description': 'standard halophosphate'},
|
|
104
|
+
'FL3.3': {'xyY': [0.3153, 0.3439, 1.0], 'CCT': 6280.0, 'description': 'standard halophosphate'},
|
|
105
|
+
'FL3.4': {'xyY': [0.4429, 0.4043, 1.0], 'CCT': 2904.0, 'description': 'DeLuxe type'},
|
|
106
|
+
'FL3.5': {'xyY': [0.3749, 0.3672, 1.0], 'CCT': 4086.0, 'description': 'DeLuxe type'},
|
|
107
|
+
'FL3.6': {'xyY': [0.3488, 0.36, 1.0], 'CCT': 4894.0, 'description': 'DeLuxe type'},
|
|
108
|
+
'FL3.7': {'xyY': [0.4384, 0.4045, 1.0], 'CCT': 2979.0, 'description': 'Three-band'},
|
|
109
|
+
'FL3.8': {'xyY': [0.382, 0.3832, 1.0], 'CCT': 4006.0, 'description': 'Three-band'},
|
|
110
|
+
'FL3.9': {'xyY': [0.3499, 0.3591, 1.0], 'CCT': 4853.0, 'description': 'Three-band'},
|
|
111
|
+
'FL3.10': {'xyY': [0.3455, 0.356, 1.0], 'CCT': 5000.0, 'description': 'Three-band'},
|
|
112
|
+
'FL3.11': {'xyY': [0.3245, 0.3434, 1.0], 'CCT': 5854.0, 'description': 'Three-band'},
|
|
113
|
+
'FL3.12': {'xyY': [0.4377, 0.4037, 1.0], 'CCT': 2984.0, 'description': 'Multi-band'},
|
|
114
|
+
'FL3.13': {'xyY': [0.383, 0.3724, 1.0], 'CCT': 3896.0, 'description': 'Multi-band'},
|
|
115
|
+
'FL3.14': {'xyY': [0.3447, 0.3609, 1.0], 'CCT': 5045.0, 'description': 'Multi-band'},
|
|
116
|
+
'FL3.15': {'xyY': [0.3127, 0.3288, 1.0], 'CCT': 6509.0, 'description': 'D65 Simulator'},
|
|
117
|
+
'HP1': {'xyY': [0.533, 0.415, 1.0], 'CCT': 1959.0,
|
|
118
|
+
'description': 'Standard high pressure sodium lamp'},
|
|
119
|
+
'HP2': {'xyY': [0.4778, 0.4158, 1.0], 'CCT': 2506.0,
|
|
120
|
+
'description': 'Color-enhanced high-pressure sodium lamp'},
|
|
121
|
+
'HP3': {'xyY': [0.4302, 0.4075, 1.0], 'CCT': 3144.0,
|
|
122
|
+
'description': 'High pressure metal halide lamp'},
|
|
123
|
+
'HP4': {'xyY': [0.3812, 0.3797, 1.0], 'CCT': 4002.0,
|
|
124
|
+
'description': 'High pressure metal halide lamp'},
|
|
125
|
+
'HP5': {'xyY': [0.3776, 0.3713, 1.0], 'CCT': 4039.0,
|
|
126
|
+
'description': 'High pressure metal halide lamp'},
|
|
127
|
+
'LED-B1': {'xyY': [0.456, 0.4078, 1.0], 'CCT': 2733.0, 'description': 'phosphor-converted blue'},
|
|
128
|
+
'LED-B2': {'xyY': [0.4357, 0.4012, 1.0], 'CCT': 2998.0, 'description': 'phosphor-converted blue'},
|
|
129
|
+
'LED-B3': {'xyY': [0.3756, 0.3723, 1.0], 'CCT': 4103.0, 'description': 'phosphor-converted blue'},
|
|
130
|
+
'LED-B4': {'xyY': [0.3422, 0.3502, 1.0], 'CCT': 5109.0, 'description': 'phosphor-converted blue'},
|
|
131
|
+
'LED-B5': {'xyY': [0.3118, 0.3236, 1.0], 'CCT': 6598.0, 'description': 'phosphor-converted blue'},
|
|
132
|
+
'LED-BH1': {'xyY': [0.4474, 0.4066, 1.0], 'CCT': 2851.0,
|
|
133
|
+
'description': 'mixing of phosphor-converted blue LED and red LED (blue-hybrid)'},
|
|
134
|
+
'LED-RGB1': {'xyY': [0.4557, 0.4211, 1.0], 'CCT': 2840.0,
|
|
135
|
+
'description': 'mixing of red, green, and blue LEDs'},
|
|
136
|
+
'LED-V1': {'xyY': [0.4548, 0.4044, 1.0], 'CCT': 2724.0, 'description': 'phosphor-converted violet'},
|
|
137
|
+
'LED-V2': {'xyY': [0.3781, 0.3775, 1.0], 'CCT': 4070.0, 'description': 'phosphor-converted violet'},
|
|
138
|
+
'ID50': {'xyY': [0.3432, 0.3602, 1.0], 'CCT': 5098.0, 'description': 'natural indoor daylight'},
|
|
139
|
+
'ID65': {'xyY': [0.3107, 0.3307, 1.0], 'CCT': 6603.0, 'description': 'natural indoor daylight'}},
|
|
140
|
+
10: {'A': {'xyY': [0.45117, 0.40594, 1.0], 'CCT': 2856.0, 'description': 'incandescent / tungsten'},
|
|
141
|
+
'B': {'xyY': [0.3498, 0.3527, 1.0], 'CCT': 4874.0,
|
|
142
|
+
'description': 'obsolete, direct sunlight at noon'},
|
|
143
|
+
'C': {'xyY': [0.31039, 0.31905, 1.0], 'CCT': 6774.0,
|
|
144
|
+
'description': 'obsolete, average / North sky daylight NTSC 1953, PAL-M'},
|
|
145
|
+
'D50': {'xyY': [0.34773, 0.35952, 1.0], 'CCT': 5003.0,
|
|
146
|
+
'description': 'horizon light, ICC profile PCS'},
|
|
147
|
+
'D55': {'xyY': [0.33411, 0.34877, 1.0], 'CCT': 5503.0,
|
|
148
|
+
'description': 'mid-morning / mid-afternoon daylight'},
|
|
149
|
+
'D65': {'xyY': [0.31382, 0.331, 1.0], 'CCT': 6504.0,
|
|
150
|
+
'description': 'noon daylight: television, sRGB color space'},
|
|
151
|
+
'D75': {'xyY': [0.29968, 0.3174, 1.0], 'CCT': 7504.0, 'description': 'North sky daylight'},
|
|
152
|
+
'D93': {'xyY': [0.28327, 0.30043, 1.0], 'CCT': 9305.0,
|
|
153
|
+
'description': 'high-efficiency blue phosphor monitors, BT.2035, NTSC-J'},
|
|
154
|
+
'E': {'xyY': [0.33333, 0.33333, 1.0], 'CCT': 5454.0, 'description': 'equal energy'},
|
|
155
|
+
'F1': {'xyY': [0.31811, 0.33559, 1.0], 'CCT': 6430.0, 'description': 'daylight fluorescent'},
|
|
156
|
+
'F2': {'xyY': [0.37925, 0.36733, 1.0], 'CCT': 4230.0, 'description': 'cool white fluorescent'},
|
|
157
|
+
'F3': {'xyY': [0.41761, 0.38324, 1.0], 'CCT': 3450.0, 'description': 'white fluorescent'},
|
|
158
|
+
'F4': {'xyY': [0.4492, 0.39074, 1.0], 'CCT': 2940.0, 'description': 'warm white fluorescent'},
|
|
159
|
+
'F5': {'xyY': [0.31975, 0.34246, 1.0], 'CCT': 6350.0, 'description': 'daylight fluorescent'},
|
|
160
|
+
'F6': {'xyY': [0.3866, 0.37847, 1.0], 'CCT': 4150.0, 'description': 'light white fluorescent'},
|
|
161
|
+
'F7': {'xyY': [0.31569, 0.3296, 1.0], 'CCT': 6500.0,
|
|
162
|
+
'description': 'D65 simulator, daylight simulator'},
|
|
163
|
+
'F8': {'xyY': [0.34902, 0.35939, 1.0], 'CCT': 5000.0,
|
|
164
|
+
'description': 'D50 simulator, Sylvania F40 Design 50'},
|
|
165
|
+
'F9': {'xyY': [0.37829, 0.37045, 1.0], 'CCT': 4150.0,
|
|
166
|
+
'description': 'cool white deluxe fluorescent'},
|
|
167
|
+
'F10': {'xyY': [0.3509, 0.35444, 1.0], 'CCT': 5000.0, 'description': 'Philips TL85, Ultralume 50'},
|
|
168
|
+
'F11': {'xyY': [0.38541, 0.37123, 1.0], 'CCT': 4000.0,
|
|
169
|
+
'description': 'Philips TL84, Ultralume 40'},
|
|
170
|
+
'F12': {'xyY': [0.44256, 0.39717, 1.0], 'CCT': 3000.0,
|
|
171
|
+
'description': 'Philips TL83, Ultralume 30'}}}
|
|
172
|
+
|
|
173
|
+
RGB_COLORSPACES = {'Adobe RGB (1998)': {'tone curve': {'type': 1, 'parameters': [2.2]}, 'white point': 'D65',
|
|
174
|
+
'red': [0.64, 0.33, 0.297361], 'green': [0.21, 0.71, 0.627355],
|
|
175
|
+
'blue': [0.15, 0.06, 0.075285]},
|
|
176
|
+
'Apple RGB': {'tone curve': {'type': 1, 'parameters': [1.8]}, 'white point': 'D65',
|
|
177
|
+
'red': [0.625, 0.34, 0.244634], 'green': [0.28, 0.595, 0.672034],
|
|
178
|
+
'blue': [0.155, 0.07, 0.083332]},
|
|
179
|
+
'Best RGB': {'tone curve': {'type': 1, 'parameters': [2.2]}, 'white point': 'D50',
|
|
180
|
+
'red': [0.7347, 0.2653, 0.228457], 'green': [0.215, 0.775, 0.737352],
|
|
181
|
+
'blue': [0.13, 0.035, 0.034191]},
|
|
182
|
+
'Beta RGB': {'tone curve': {'type': 1, 'parameters': [2.2]}, 'white point': 'D50',
|
|
183
|
+
'red': [0.6888, 0.3112, 0.303273], 'green': [0.1986, 0.7551, 0.663786],
|
|
184
|
+
'blue': [0.1265, 0.0352, 0.032941]},
|
|
185
|
+
'Bruce RGB': {'tone curve': {'type': 1, 'parameters': [2.2]}, 'white point': 'D65',
|
|
186
|
+
'red': [0.64, 0.33, 0.240995], 'green': [0.28, 0.65, 0.683554],
|
|
187
|
+
'blue': [0.15, 0.06, 0.075452]},
|
|
188
|
+
'CIE RGB': {'tone curve': {'type': 1, 'parameters': [2.2]}, 'white point': 'E',
|
|
189
|
+
'red': [0.735, 0.265, 0.176204], 'green': [0.274, 0.717, 0.812985],
|
|
190
|
+
'blue': [0.167, 0.009, 0.010811]},
|
|
191
|
+
'ColorMatch RGB': {'tone curve': {'type': 1, 'parameters': [1.8]}, 'white point': 'D50',
|
|
192
|
+
'red': [0.63, 0.34, 0.274884], 'green': [0.295, 0.605, 0.658132],
|
|
193
|
+
'blue': [0.15, 0.075, 0.066985]},
|
|
194
|
+
'Don RGB 4': {'tone curve': {'type': 1, 'parameters': [2.2]}, 'white point': 'D50',
|
|
195
|
+
'red': [0.696, 0.3, 0.27835], 'green': [0.215, 0.765, 0.68797],
|
|
196
|
+
'blue': [0.13, 0.035, 0.03368]},
|
|
197
|
+
'ECI RGB v2': {
|
|
198
|
+
'tone curve': {'type': 4, 'parameters': [3.000000, 0.862076, 0.137924, 0.110703, 0.080002]},
|
|
199
|
+
'white point': 'D50', 'red': [0.67, 0.33, 0.32025],
|
|
200
|
+
'green': [0.21, 0.71, 0.602071], 'blue': [0.14, 0.08, 0.077679]},
|
|
201
|
+
'Ekta Space PS5': {'tone curve': {'type': 1, 'parameters': [2.2]}, 'white point': 'D50',
|
|
202
|
+
'red': [0.695, 0.305, 0.260629], 'green': [0.26, 0.7, 0.734946],
|
|
203
|
+
'blue': [0.11, 0.005, 0.004425]},
|
|
204
|
+
'NTSC RGB': {'tone curve': {'type': 1, 'parameters': [2.2]}, 'white point': 'C',
|
|
205
|
+
'red': [0.67, 0.33, 0.298839], 'green': [0.21, 0.71, 0.586811],
|
|
206
|
+
'blue': [0.14, 0.08, 0.11435]},
|
|
207
|
+
'PAL/SECAM RGB': {'tone curve': {'type': 1, 'parameters': [2.2]}, 'white point': 'D65',
|
|
208
|
+
'red': [0.64, 0.33, 0.222021], 'green': [0.29, 0.6, 0.706645],
|
|
209
|
+
'blue': [0.15, 0.06, 0.071334]},
|
|
210
|
+
'ProPhoto RGB': {'tone curve': {'type': 1, 'parameters': [1.8]}, 'white point': 'D50',
|
|
211
|
+
'red': [0.7347, 0.2653, 0.28804], 'green': [0.1596, 0.8404, 0.711874],
|
|
212
|
+
'blue': [0.0366, 0.0001, 8.6e-05]},
|
|
213
|
+
'SMPTE-C RGB': {'tone curve': {'type': 1, 'parameters': [2.2]}, 'white point': 'D65',
|
|
214
|
+
'red': [0.63, 0.34, 0.212395], 'green': [0.31, 0.595, 0.701049],
|
|
215
|
+
'blue': [0.155, 0.07, 0.086556]},
|
|
216
|
+
'_sRGB': {'tone curve': {'type': 4, 'parameters': [2.399994, 0.947861, 0.052139, 0.077393, 0.040451]},
|
|
217
|
+
'white point': 'D65', 'red': [0.64, 0.33, 0.212656],
|
|
218
|
+
'green': [0.3, 0.6, 0.715158], 'blue': [0.15, 0.06, 0.072186]},
|
|
219
|
+
'Wide Gamut RGB': {'tone curve': {'type': 1, 'parameters': [2.2]}, 'white point': 'D50',
|
|
220
|
+
'red': [0.735, 0.265, 0.258187], 'green': [0.115, 0.826, 0.724938],
|
|
221
|
+
'blue': [0.157, 0.018, 0.016875]}}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-lcms2
|
|
3
|
+
Version: 0.0.20
|
|
4
|
+
Summary: Python binding for LittleCMS2 library
|
|
5
|
+
Author-email: Josue N Rivera <josue.n.rivera@outlook.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/wzjoriv/python-lcms2
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/wzjoriv/python-lcms2/issues
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: C
|
|
10
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Topic :: Multimedia :: Graphics :: Graphics Conversion
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: numpy>=1.22
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# python-lcms2
|
|
22
|
+
|
|
23
|
+
Simplified Python binding of [LittleCMS2](https://github.com/mm2/Little-CMS) library.
|
|
24
|
+
|
|
25
|
+
# Installation
|
|
26
|
+
|
|
27
|
+
Wheel files for 64-bit Windows and Python 3.10+ are available from PyPI. Use `pip` to install the package:
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
pip install python-lcms2
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The package can be uninstalled using the corresponding command:
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
python -m pip uninstall -y python-lcms2
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
# Getting started
|
|
40
|
+
|
|
41
|
+
Little CMS functionality is implemented by two classes: `Profile` and `Transform`.
|
|
42
|
+
|
|
43
|
+
## Profiles
|
|
44
|
+
|
|
45
|
+
A `Profile` object can be created using one of the built-in profiles, by reading a profile file (using the `filename` argument) or from data stored in memory as Python `bytes` object (`buffer` argument).
|
|
46
|
+
|
|
47
|
+
Built-in profiles include `sRGB`, `Lab` and `XYZ` provided by the Little CMS library and additional RGB profiles:
|
|
48
|
+
`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`, and `Wide Gamut RGB`.
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
import lcms2
|
|
52
|
+
|
|
53
|
+
x = lcms2.Profile("sRGB")
|
|
54
|
+
p = lcms2.Profile("ProPhoto RGB")
|
|
55
|
+
y = lcms2.Profile(filename="CMYK.icm")
|
|
56
|
+
|
|
57
|
+
with open("CMYK.icm", "rb") as f:
|
|
58
|
+
z = lcms2.Profile(buffer=f.read)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Transforms
|
|
62
|
+
|
|
63
|
+
Transforms between profiles are implemented by the respective class. To create an instance of `Transform` call its constructor and provide six arguments: (1) source profile, (2) source data type string, (3) destination profile, (4) destination data type string, (5) rendering intent string (optional, defaults to "PERCEPTUAL"), and (6) flags (optional, the default value is "NONE").
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
lab_profile = lcms2.create_profile("Lab")
|
|
67
|
+
rgb_profile = lcms2.create_profile("sRGB")
|
|
68
|
+
transform = lcms2.Transform(lab_profile, "Lab_DBL",
|
|
69
|
+
rgb_profile, "RGB_16",
|
|
70
|
+
"PERCEPTUAL",
|
|
71
|
+
"NONE")
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Supported format strings can be listed as follows:
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
lcms2.DATA_TYPES.keys()
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Rendering intents could be one of the following: 'PERCEPTUAL', 'RELATIVE_COLORIMETRIC', 'SATURATION', and 'ABSOLUTE_COLORIMETRIC' (see `lcms2.INTENT` dictionary).
|
|
81
|
+
|
|
82
|
+
Likewise, supported transform flags are available as keys of the `lcms2.FLAG` dictionary. Several flags can be combined by including them in the `flags` argument string separating them by commas, semicolons, spaces or the pipe symbol `|`, for example
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
flags = "GAMUTCHECK,SOFTPROOFING,PRESERVEBLACK"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The transform is calculated using the `Transform.apply` method, for example:
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
neutral_grey = transform.apply([50.0, 0.0, 0.0])
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The method takes a Numpy array (or an object convertible to NumPy array) and returns a transformed array of appropriate shape. The data type of the input array must correspond to the input data type specified during transform creation. When lists and other array-compatible objects are used the data types will be converted, when possible. For instance in the example above the input data could be provided as `[50, 0, 0]` (list containing integers):
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
neutral_grey = transform.apply([50, 0, 0])
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Building form source
|
|
101
|
+
|
|
102
|
+
To build `python-lcms2` for your own platform, clone the repository with its submodules:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
git clone --recurse-submodules git@github.com:wzjoriv/python-lcms2.git
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Check that the `build` package is installed:
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
python -m pip install build --upgrade
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
navigate to the root directory of the repository (the one containing the `pyproject.toml` file) and run:
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
python -m build --wheel
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
If everything goes smoothly you will have a wheel file for you platform generated in the `dist` directory. It can be installed by pip as follows:
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
python -m pip install --upgrade dist/python_lcms2*.whl
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Building the package on Windows might involve minor modifications to include and library paths. An attempt was made to automate the process (see `setup.py`) though there is no guarantee that the code works on your version of Windows.
|
|
127
|
+
|
|
128
|
+
# Issues, bugs and feedback
|
|
129
|
+
|
|
130
|
+
You are likely to hit a few bugs and issues while using `python-lcms2`. Please report them through [GitHub Issues]("https://github.com/wzjoriv/python-lcms2/issues").
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
_lcms2.pyd,sha256=pMdysuPNLX1XXY26BswfWTjOYsMrfphHMI3lkOgxzTU,348160
|
|
3
|
+
lcms2/__init__.py,sha256=KqAV_dAz77Em7CZWPx4JopgAgmtbhV_iOrU9Lu38i7E,5185
|
|
4
|
+
lcms2/_lcms2.c,sha256=aJOw7L4ABx-kA9iXveBEOXxeF4zNYUDQfyC83M7LsEc,2275
|
|
5
|
+
lcms2/_lcms2.pyd,sha256=rzKvDqeoXSJotixYcJeXV_PDg58HtWwHdLFBxXXXnMk,348160
|
|
6
|
+
lcms2/implementation.py,sha256=HUhgvSPRy8Ng6zszNsDeiOGapQ4lmHWAs134HbknrB4,16834
|
|
7
|
+
pylcms2/__init__.py,sha256=jx6uNK_seOgZ-RI6Sp5C5OX2-nxaqYWK_GKBr7Jb70M,5178
|
|
8
|
+
pylcms2/_lcms2.c,sha256=0np16jszZmhOL59X-qeb0Y6S93eZ2jGVWj22IRfzU1M,2160
|
|
9
|
+
pylcms2/implementation.py,sha256=dlZIHrEIZEq5fwXfVyp9fNMRSetRU8p0cBB3xH_q-Cs,16827
|
|
10
|
+
python_lcms2-0.0.20.dist-info/licenses/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
|
|
11
|
+
python_lcms2-0.0.20.dist-info/METADATA,sha256=l8HmAcEJHyke4OiQMLvrvz1tg1Wm_gl7HI2Nz1NAfNk,5164
|
|
12
|
+
python_lcms2-0.0.20.dist-info/WHEEL,sha256=x5Wpw_tLx5PQKiWdxpqvs0e7Sg-SO0mTWdEADYDGPGA,101
|
|
13
|
+
python_lcms2-0.0.20.dist-info/top_level.txt,sha256=QjTMasy-VPB6SBo17SY2e-bNQAWKCqrqYmWJIuLpd_U,6
|
|
14
|
+
python_lcms2-0.0.20.dist-info/RECORD,,
|