Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 37 additions & 10 deletions Tests/test_imagecms.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def truncate_tuple(tuple_or_float):
2: (False, False, True),
3: (False, False, True)
})
self.assertEqual(p.color_space, 'RGB')

self.assertIsNone(p.colorant_table)
self.assertIsNone(p.colorant_table_out)
self.assertIsNone(p.colorimetric_intent)
Expand Down Expand Up @@ -361,16 +361,9 @@ def truncate_tuple(tuple_or_float):
(5000.722328847392,))
self.assertEqual(p.model,
'IEC 61966-2-1 Default RGB Colour Space - sRGB')
self.assertEqual(p.pcs, 'XYZ')

self.assertIsNone(p.perceptual_rendering_intent_gamut)
self.assertEqual(p.product_copyright,
'Copyright International Color Consortium, 2009')
self.assertEqual(p.product_desc, 'sRGB IEC61966-2-1 black scaled')
self.assertEqual(p.product_description,
'sRGB IEC61966-2-1 black scaled')
self.assertEqual(p.product_manufacturer, '')
self.assertEqual(
p.product_model, 'IEC 61966-2-1 Default RGB Colour Space - sRGB')

self.assertEqual(
p.profile_description, 'sRGB IEC61966-2-1 black scaled')
self.assertEqual(
Expand All @@ -393,6 +386,40 @@ def truncate_tuple(tuple_or_float):
'Reference Viewing Condition in IEC 61966-2-1')
self.assertEqual(p.xcolor_space, 'RGB ')

def test_deprecations(self):
self.skip_missing()
o = ImageCms.getOpenProfile(SRGB)
p = o.profile

def helper_deprecated(attr, expected):
result = self.assert_warning(DeprecationWarning, getattr, p, attr)
self.assertEqual(result, expected)

# p.color_space
helper_deprecated("color_space", "RGB")

# p.pcs
helper_deprecated("pcs", "XYZ")

# p.product_copyright
helper_deprecated(
"product_copyright", "Copyright International Color Consortium, 2009"
)

# p.product_desc
helper_deprecated("product_desc", "sRGB IEC61966-2-1 black scaled")

# p.product_description
helper_deprecated("product_description", "sRGB IEC61966-2-1 black scaled")

# p.product_manufacturer
helper_deprecated("product_manufacturer", "")

# p.product_model
helper_deprecated(
"product_model", "IEC 61966-2-1 Default RGB Colour Space - sRGB"
)

def test_profile_typesafety(self):
""" Profile init type safety

Expand Down
20 changes: 20 additions & 0 deletions docs/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,26 @@ PILLOW_VERSION constant
``PILLOW_VERSION`` has been deprecated and will be removed in the next
major release. Use ``__version__`` instead.

ImageCms.CmsProfile attributes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. deprecated:: 3.2.0

Some attributes in ``ImageCms.CmsProfile`` are deprecated. From 6.0.0, they issue a
``DeprecationWarning``:

======================== ===============================
Deprecated Use instead
======================== ===============================
``color_space`` Padded ``xcolor_space``
``pcs`` Padded ``connection_space``
``product_copyright`` Unicode ``copyright``
``product_desc`` Unicode ``profile_description``
``product_description`` Unicode ``profile_description``
``product_manufacturer`` Unicode ``manufacturer``
``product_model`` Unicode ``model``
======================== ===============================

Removed features
----------------

Expand Down
10 changes: 5 additions & 5 deletions docs/reference/ImageCms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,21 @@ can be easily displayed in a chromaticity diagram, for example).

.. py:attribute:: manufacturer

The (english) display string for the device manufacturer (see
The (English) display string for the device manufacturer (see
9.2.22 of ICC.1:2010).

:type: :py:class:`unicode` or ``None``

.. py:attribute:: model

The (english) display string for the device model of the device
The (English) display string for the device model of the device
for which this profile is created (see 9.2.23 of ICC.1:2010).

:type: :py:class:`unicode` or ``None``

.. py:attribute:: profile_description

The (english) display string for the profile description (see
The (English) display string for the profile description (see
9.2.41 of ICC.1:2010).

:type: :py:class:`unicode` or ``None``
Expand Down Expand Up @@ -269,14 +269,14 @@ can be easily displayed in a chromaticity diagram, for example).

.. py:attribute:: viewing_condition

The (english) display string for the viewing conditions (see
The (English) display string for the viewing conditions (see
9.2.48 of ICC.1:2010).

:type: :py:class:`unicode` or ``None``

.. py:attribute:: screening_description

The (english) display string for the screening conditions.
The (English) display string for the screening conditions.

This tag was available in ICC 3.2, but it is removed from
version 4.
Expand Down
18 changes: 18 additions & 0 deletions docs/releasenotes/6.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,24 @@ version.

Use ``PIL.__version__`` instead.

ImageCms.CmsProfile attributes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Some attributes in ``ImageCms.CmsProfile`` have been deprecated since Pillow 3.2.0. From
6.0.0, they issue a ``DeprecationWarning``:

======================== ===============================
Deprecated Use instead
======================== ===============================
``color_space`` Padded ``xcolor_space``
``pcs`` Padded ``connection_space``
``product_copyright`` Unicode ``copyright``
``product_desc`` Unicode ``profile_description``
``product_description`` Unicode ``profile_description``
``product_manufacturer`` Unicode ``manufacturer``
``product_model`` Unicode ``model``
======================== ===============================

MIME type improvements
^^^^^^^^^^^^^^^^^^^^^^

Expand Down
18 changes: 9 additions & 9 deletions src/PIL/ImageCms.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,11 +686,11 @@ def getProfileName(profile):
# // name was "%s - %s" (model, manufacturer) || Description ,
# // but if the Model and Manufacturer were the same or the model
# // was long, Just the model, in 1.x
model = profile.profile.product_model
manufacturer = profile.profile.product_manufacturer
model = profile.profile.model
manufacturer = profile.profile.manufacturer

if not (model or manufacturer):
return profile.profile.product_description + "\n"
return (profile.profile.profile_description or "") + "\n"
if not manufacturer or len(model) > 30:
return model + "\n"
return "%s - %s\n" % (model, manufacturer)
Expand Down Expand Up @@ -727,8 +727,8 @@ def getProfileInfo(profile):
# Python, not C. the white point bits weren't working well,
# so skipping.
# info was description \r\n\r\n copyright \r\n\r\n K007 tag \r\n\r\n whitepoint
description = profile.profile.product_description
cpright = profile.profile.product_copyright
description = profile.profile.profile_description
cpright = profile.profile.copyright
arr = []
for elt in (description, cpright):
if elt:
Expand Down Expand Up @@ -762,7 +762,7 @@ def getProfileCopyright(profile):
# add an extra newline to preserve pyCMS compatibility
if not isinstance(profile, ImageCmsProfile):
profile = ImageCmsProfile(profile)
return profile.profile.product_copyright + "\n"
return (profile.profile.copyright or "") + "\n"
except (AttributeError, IOError, TypeError, ValueError) as v:
raise PyCMSError(v)

Expand Down Expand Up @@ -790,7 +790,7 @@ def getProfileManufacturer(profile):
# add an extra newline to preserve pyCMS compatibility
if not isinstance(profile, ImageCmsProfile):
profile = ImageCmsProfile(profile)
return profile.profile.product_manufacturer + "\n"
return (profile.profile.manufacturer or "") + "\n"
except (AttributeError, IOError, TypeError, ValueError) as v:
raise PyCMSError(v)

Expand Down Expand Up @@ -819,7 +819,7 @@ def getProfileModel(profile):
# add an extra newline to preserve pyCMS compatibility
if not isinstance(profile, ImageCmsProfile):
profile = ImageCmsProfile(profile)
return profile.profile.product_model + "\n"
return (profile.profile.model or "") + "\n"
except (AttributeError, IOError, TypeError, ValueError) as v:
raise PyCMSError(v)

Expand Down Expand Up @@ -848,7 +848,7 @@ def getProfileDescription(profile):
# add an extra newline to preserve pyCMS compatibility
if not isinstance(profile, ImageCmsProfile):
profile = ImageCmsProfile(profile)
return profile.profile.product_description + "\n"
return (profile.profile.profile_description or "") + "\n"
except (AttributeError, IOError, TypeError, ValueError) as v:
raise PyCMSError(v)

Expand Down
Loading