Merge pull request #7931 from Yay295/imagingcms_modes

Remove unused CMS properties and fix documentation
This commit is contained in:
Hugo van Kemenade 2024-04-06 09:28:45 +03:00 committed by GitHub
commit f8ec9f7974
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 39 deletions

View File

@ -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

View File

@ -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: ...

View File

@ -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