diff --git a/src/PIL/ImageCms.py b/src/PIL/ImageCms.py index 3a45572a1..4af1b79e2 100644 --- a/src/PIL/ImageCms.py +++ b/src/PIL/ImageCms.py @@ -704,12 +704,12 @@ def applyTransform( """ (pyCMS) Applies a transform to a given image. - If ``im.mode != transform.inMode``, a :exc:`PyCMSError` is raised. + If ``im.mode != transform.input_mode``, a :exc:`PyCMSError` is raised. - If ``inPlace`` is ``True`` and ``transform.inMode != transform.outMode``, a + If ``inPlace`` is ``True`` and ``transform.input_mode != transform.output_mode``, a :exc:`PyCMSError` is raised. - If ``im.mode``, ``transform.inMode`` or ``transform.outMode`` is not + If ``im.mode``, ``transform.input_mode`` or ``transform.output_mode`` is not supported by pyCMSdll or the profiles you used for the transform, a :exc:`PyCMSError` is raised. @@ -723,13 +723,13 @@ def applyTransform( If you want to modify im in-place instead of receiving a new image as the return value, set ``inPlace`` to ``True``. This can only be done if - ``transform.inMode`` and ``transform.outMode`` are the same, because we can't - change the mode in-place (the buffer sizes for some modes are + ``transform.input_mode`` and ``transform.output_mode`` are the same, because we + can't change the mode in-place (the buffer sizes for some modes are different). The default behavior is to return a new :py:class:`~PIL.Image.Image` - object of the same dimensions in mode ``transform.outMode``. + object of the same dimensions in mode ``transform.output_mode``. - :param im: An :py:class:`~PIL.Image.Image` object, and im.mode must be the same - as the ``inMode`` supported by the transform. + :param im: An :py:class:`~PIL.Image.Image` object, and ``im.mode`` must be the same + as the ``input_mode`` supported by the transform. :param transform: A valid CmsTransform class object :param inPlace: Bool. If ``True``, ``im`` is modified in place and ``None`` is returned, if ``False``, a new :py:class:`~PIL.Image.Image` object with the diff --git a/src/PIL/_imagingcms.pyi b/src/PIL/_imagingcms.pyi index 036521b0e..f704047be 100644 --- a/src/PIL/_imagingcms.pyi +++ b/src/PIL/_imagingcms.pyi @@ -108,10 +108,6 @@ class CmsProfile: def is_intent_supported(self, intent: int, direction: int, /) -> int: ... class CmsTransform: - @property - def inputMode(self) -> str: ... - @property - def outputMode(self) -> str: ... def apply(self, id_in: int, id_out: int) -> int: ... def profile_open(profile: str, /) -> CmsProfile: ... diff --git a/src/_imagingcms.c b/src/_imagingcms.c index 84b8a7e71..f18d55a57 100644 --- a/src/_imagingcms.c +++ b/src/_imagingcms.c @@ -181,9 +181,7 @@ cms_profile_dealloc(CmsProfileObject *self) { /* a transform represents the mapping between two profiles */ typedef struct { - PyObject_HEAD char mode_in[8]; - char mode_out[8]; - cmsHTRANSFORM transform; + PyObject_HEAD cmsHTRANSFORM transform; } CmsTransformObject; static PyTypeObject CmsTransform_Type; @@ -191,7 +189,7 @@ static PyTypeObject CmsTransform_Type; #define CmsTransform_Check(op) (Py_TYPE(op) == &CmsTransform_Type) static PyObject * -cms_transform_new(cmsHTRANSFORM transform, char *mode_in, char *mode_out) { +cms_transform_new(cmsHTRANSFORM transform) { CmsTransformObject *self; self = PyObject_New(CmsTransformObject, &CmsTransform_Type); @@ -201,9 +199,6 @@ cms_transform_new(cmsHTRANSFORM transform, char *mode_in, char *mode_out) { self->transform = transform; - strncpy(self->mode_in, mode_in, 8); - strncpy(self->mode_out, mode_out, 8); - return (PyObject *)self; } @@ -395,7 +390,7 @@ _buildTransform( Py_END_ALLOW_THREADS - if (!hTransform) { + if (!hTransform) { PyErr_SetString(PyExc_ValueError, "cannot build transform"); } @@ -429,7 +424,7 @@ _buildProofTransform( Py_END_ALLOW_THREADS - if (!hTransform) { + if (!hTransform) { PyErr_SetString(PyExc_ValueError, "cannot build proof transform"); } @@ -476,7 +471,7 @@ buildTransform(PyObject *self, PyObject *args) { return NULL; } - return cms_transform_new(transform, sInMode, sOutMode); + return cms_transform_new(transform); } static PyObject * @@ -523,7 +518,7 @@ buildProofTransform(PyObject *self, PyObject *args) { return NULL; } - return cms_transform_new(transform, sInMode, sOutMode); + return cms_transform_new(transform); } static PyObject * @@ -1456,21 +1451,6 @@ static struct PyMethodDef cms_transform_methods[] = { {"apply", (PyCFunction)cms_transform_apply, 1}, {NULL, NULL} /* sentinel */ }; -static PyObject * -cms_transform_getattr_inputMode(CmsTransformObject *self, void *closure) { - return PyUnicode_FromString(self->mode_in); -} - -static PyObject * -cms_transform_getattr_outputMode(CmsTransformObject *self, void *closure) { - return PyUnicode_FromString(self->mode_out); -} - -static struct PyGetSetDef cms_transform_getsetters[] = { - {"inputMode", (getter)cms_transform_getattr_inputMode}, - {"outputMode", (getter)cms_transform_getattr_outputMode}, - {NULL}}; - static PyTypeObject CmsTransform_Type = { PyVarObject_HEAD_INIT(NULL, 0) "PIL.ImageCms.core.CmsTransform", /*tp_name*/ sizeof(CmsTransformObject), /*tp_basicsize*/ @@ -1501,7 +1481,7 @@ static PyTypeObject CmsTransform_Type = { 0, /*tp_iternext*/ cms_transform_methods, /*tp_methods*/ 0, /*tp_members*/ - cms_transform_getsetters, /*tp_getset*/ + 0, /*tp_getset*/ }; static int