Skip to content

Commit 0b2e2b2

Browse files
committed
document ImageCms.Flags
1 parent 26b2aa5 commit 0b2e2b2

2 files changed

Lines changed: 43 additions & 18 deletions

File tree

docs/reference/ImageCms.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ Constants
2727
:members:
2828
:member-order: bysource
2929
:undoc-members:
30+
.. autoclass:: Flags
31+
:members:
32+
:member-order: bysource
33+
:undoc-members:
3034

3135
Functions
3236
---------

src/PIL/ImageCms.py

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -123,26 +123,43 @@ class Direction(IntEnum):
123123

124124

125125
class Flags(IntFlag):
126-
# These are taken from lcms2.h (including comments)
126+
"""Flags and documentation are taken from ``lcms2.h``."""
127+
127128
NONE = 0
128-
NOCACHE = 0x0040 # Inhibit 1-pixel cache
129-
NOOPTIMIZE = 0x0100 # Inhibit optimizations
130-
NULLTRANSFORM = 0x0200 # Don't transform anyway
131-
GAMUTCHECK = 0x1000 # Out of Gamut alarm
132-
SOFTPROOFING = 0x4000 # Do softproofing
129+
NOCACHE = 0x0040
130+
"""Inhibit 1-pixel cache"""
131+
NOOPTIMIZE = 0x0100
132+
"""Inhibit optimizations"""
133+
NULLTRANSFORM = 0x0200
134+
"""Don't transform anyway"""
135+
GAMUTCHECK = 0x1000
136+
"""Out of Gamut alarm"""
137+
SOFTPROOFING = 0x4000
138+
"""Do softproofing"""
133139
BLACKPOINTCOMPENSATION = 0x2000
134-
NOWHITEONWHITEFIXUP = 0x0004 # Don't fix scum dot
135-
HIGHRESPRECALC = 0x0400 # Use more memory to give better accuracy
136-
LOWRESPRECALC = 0x0800 # Use less memory to minimize resources
140+
NOWHITEONWHITEFIXUP = 0x0004
141+
"""Don't fix scum dot"""
142+
HIGHRESPRECALC = 0x0400
143+
"""Use more memory to give better accuracy"""
144+
LOWRESPRECALC = 0x0800
145+
"""Use less memory to minimize resources"""
137146
# this should be 8BITS_DEVICELINK, but that is not a valid name in Python:
138-
USE_8BITS_DEVICELINK = 0x0008 # Create 8 bits devicelinks
139-
GUESSDEVICECLASS = 0x0020 # Guess device class (for transform2devicelink)
140-
KEEP_SEQUENCE = 0x0080 # Keep profile sequence for devicelink creation
141-
FORCE_CLUT = 0x0002 # Force CLUT optimization
142-
CLUT_POST_LINEARIZATION = 0x0001 # create postlinearization tables if possible
143-
CLUT_PRE_LINEARIZATION = 0x0010 # create prelinearization tables if possible
144-
NONEGATIVES = 0x8000 # Prevent negative numbers in floating point transforms
145-
COPY_ALPHA = 0x04000000 # Alpha channels are copied on cmsDoTransform()
147+
USE_8BITS_DEVICELINK = 0x0008
148+
"""Create 8 bits devicelinks"""
149+
GUESSDEVICECLASS = 0x0020
150+
"""Guess device class (for transform2devicelink)"""
151+
KEEP_SEQUENCE = 0x0080
152+
"""Keep profile sequence for devicelink creation"""
153+
FORCE_CLUT = 0x0002
154+
"""Force CLUT optimization"""
155+
CLUT_POST_LINEARIZATION = 0x0001
156+
"""create postlinearization tables if possible"""
157+
CLUT_PRE_LINEARIZATION = 0x0010
158+
"""create prelinearization tables if possible"""
159+
NONEGATIVES = 0x8000
160+
"""Prevent negative numbers in floating point transforms"""
161+
COPY_ALPHA = 0x04000000
162+
"""Alpha channels are copied on cmsDoTransform()"""
146163
NODEFAULTRESOURCEDEF = 0x01000000
147164

148165
_GRIDPOINTS_1 = 1 << 16
@@ -156,7 +173,11 @@ class Flags(IntFlag):
156173

157174
@staticmethod
158175
def GRIDPOINTS(n: int) -> Flags:
159-
# Fine-tune control over number of gridpoints
176+
"""
177+
Fine-tune control over number of gridpoints
178+
179+
:param n: :py:class:`int` in range ``0 <= n <= 255``
180+
"""
160181
return Flags.NONE | ((n & 0xFF) << 16)
161182

162183

0 commit comments

Comments
 (0)