Skip to content

Commit f8ec9f7

Browse files
authored
Merge pull request #7931 from Yay295/imagingcms_modes
Remove unused CMS properties and fix documentation
2 parents ff64ade + 7eee479 commit f8ec9f7

File tree

3 files changed

+15
-39
lines changed

3 files changed

+15
-39
lines changed

src/PIL/ImageCms.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -704,12 +704,12 @@ def applyTransform(
704704
"""
705705
(pyCMS) Applies a transform to a given image.
706706
707-
If ``im.mode != transform.inMode``, a :exc:`PyCMSError` is raised.
707+
If ``im.mode != transform.input_mode``, a :exc:`PyCMSError` is raised.
708708
709-
If ``inPlace`` is ``True`` and ``transform.inMode != transform.outMode``, a
709+
If ``inPlace`` is ``True`` and ``transform.input_mode != transform.output_mode``, a
710710
:exc:`PyCMSError` is raised.
711711
712-
If ``im.mode``, ``transform.inMode`` or ``transform.outMode`` is not
712+
If ``im.mode``, ``transform.input_mode`` or ``transform.output_mode`` is not
713713
supported by pyCMSdll or the profiles you used for the transform, a
714714
:exc:`PyCMSError` is raised.
715715
@@ -723,13 +723,13 @@ def applyTransform(
723723
724724
If you want to modify im in-place instead of receiving a new image as
725725
the return value, set ``inPlace`` to ``True``. This can only be done if
726-
``transform.inMode`` and ``transform.outMode`` are the same, because we can't
727-
change the mode in-place (the buffer sizes for some modes are
726+
``transform.input_mode`` and ``transform.output_mode`` are the same, because we
727+
can't change the mode in-place (the buffer sizes for some modes are
728728
different). The default behavior is to return a new :py:class:`~PIL.Image.Image`
729-
object of the same dimensions in mode ``transform.outMode``.
729+
object of the same dimensions in mode ``transform.output_mode``.
730730
731-
:param im: An :py:class:`~PIL.Image.Image` object, and im.mode must be the same
732-
as the ``inMode`` supported by the transform.
731+
:param im: An :py:class:`~PIL.Image.Image` object, and ``im.mode`` must be the same
732+
as the ``input_mode`` supported by the transform.
733733
:param transform: A valid CmsTransform class object
734734
:param inPlace: Bool. If ``True``, ``im`` is modified in place and ``None`` is
735735
returned, if ``False``, a new :py:class:`~PIL.Image.Image` object with the

src/PIL/_imagingcms.pyi

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,6 @@ class CmsProfile:
108108
def is_intent_supported(self, intent: int, direction: int, /) -> int: ...
109109

110110
class CmsTransform:
111-
@property
112-
def inputMode(self) -> str: ...
113-
@property
114-
def outputMode(self) -> str: ...
115111
def apply(self, id_in: int, id_out: int) -> int: ...
116112

117113
def profile_open(profile: str, /) -> CmsProfile: ...

src/_imagingcms.c

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -181,17 +181,15 @@ cms_profile_dealloc(CmsProfileObject *self) {
181181
/* a transform represents the mapping between two profiles */
182182

183183
typedef struct {
184-
PyObject_HEAD char mode_in[8];
185-
char mode_out[8];
186-
cmsHTRANSFORM transform;
184+
PyObject_HEAD cmsHTRANSFORM transform;
187185
} CmsTransformObject;
188186

189187
static PyTypeObject CmsTransform_Type;
190188

191189
#define CmsTransform_Check(op) (Py_TYPE(op) == &CmsTransform_Type)
192190

193191
static PyObject *
194-
cms_transform_new(cmsHTRANSFORM transform, char *mode_in, char *mode_out) {
192+
cms_transform_new(cmsHTRANSFORM transform) {
195193
CmsTransformObject *self;
196194

197195
self = PyObject_New(CmsTransformObject, &CmsTransform_Type);
@@ -201,9 +199,6 @@ cms_transform_new(cmsHTRANSFORM transform, char *mode_in, char *mode_out) {
201199

202200
self->transform = transform;
203201

204-
strncpy(self->mode_in, mode_in, 8);
205-
strncpy(self->mode_out, mode_out, 8);
206-
207202
return (PyObject *)self;
208203
}
209204

@@ -395,7 +390,7 @@ _buildTransform(
395390

396391
Py_END_ALLOW_THREADS
397392

398-
if (!hTransform) {
393+
if (!hTransform) {
399394
PyErr_SetString(PyExc_ValueError, "cannot build transform");
400395
}
401396

@@ -429,7 +424,7 @@ _buildProofTransform(
429424

430425
Py_END_ALLOW_THREADS
431426

432-
if (!hTransform) {
427+
if (!hTransform) {
433428
PyErr_SetString(PyExc_ValueError, "cannot build proof transform");
434429
}
435430

@@ -476,7 +471,7 @@ buildTransform(PyObject *self, PyObject *args) {
476471
return NULL;
477472
}
478473

479-
return cms_transform_new(transform, sInMode, sOutMode);
474+
return cms_transform_new(transform);
480475
}
481476

482477
static PyObject *
@@ -523,7 +518,7 @@ buildProofTransform(PyObject *self, PyObject *args) {
523518
return NULL;
524519
}
525520

526-
return cms_transform_new(transform, sInMode, sOutMode);
521+
return cms_transform_new(transform);
527522
}
528523

529524
static PyObject *
@@ -1456,21 +1451,6 @@ static struct PyMethodDef cms_transform_methods[] = {
14561451
{"apply", (PyCFunction)cms_transform_apply, 1}, {NULL, NULL} /* sentinel */
14571452
};
14581453

1459-
static PyObject *
1460-
cms_transform_getattr_inputMode(CmsTransformObject *self, void *closure) {
1461-
return PyUnicode_FromString(self->mode_in);
1462-
}
1463-
1464-
static PyObject *
1465-
cms_transform_getattr_outputMode(CmsTransformObject *self, void *closure) {
1466-
return PyUnicode_FromString(self->mode_out);
1467-
}
1468-
1469-
static struct PyGetSetDef cms_transform_getsetters[] = {
1470-
{"inputMode", (getter)cms_transform_getattr_inputMode},
1471-
{"outputMode", (getter)cms_transform_getattr_outputMode},
1472-
{NULL}};
1473-
14741454
static PyTypeObject CmsTransform_Type = {
14751455
PyVarObject_HEAD_INIT(NULL, 0) "PIL.ImageCms.core.CmsTransform", /*tp_name*/
14761456
sizeof(CmsTransformObject), /*tp_basicsize*/
@@ -1501,7 +1481,7 @@ static PyTypeObject CmsTransform_Type = {
15011481
0, /*tp_iternext*/
15021482
cms_transform_methods, /*tp_methods*/
15031483
0, /*tp_members*/
1504-
cms_transform_getsetters, /*tp_getset*/
1484+
0, /*tp_getset*/
15051485
};
15061486

15071487
static int

0 commit comments

Comments
 (0)