Merge pull request #8124 from radarhere/imagedraw_getdraw

This commit is contained in:
Hugo van Kemenade 2024-06-11 06:26:27 -06:00 committed by GitHub
commit 7928bebd65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 16 deletions

View File

@ -1624,3 +1624,8 @@ def test_incorrectly_ordered_coordinates(xy: tuple[int, int, int, int]) -> None:
draw.rectangle(xy) draw.rectangle(xy)
with pytest.raises(ValueError): with pytest.raises(ValueError):
draw.rounded_rectangle(xy) draw.rounded_rectangle(xy)
def test_getdraw():
with pytest.warns(DeprecationWarning):
ImageDraw.getdraw(None, [])

View File

@ -115,6 +115,13 @@ Support for LibTIFF earlier than 4
Support for LibTIFF earlier than version 4 has been deprecated. Support for LibTIFF earlier than version 4 has been deprecated.
Upgrade to a newer version of LibTIFF instead. Upgrade to a newer version of LibTIFF instead.
ImageDraw.getdraw hints parameter
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. deprecated:: 10.4.0
The ``hints`` parameter in :py:meth:`~PIL.ImageDraw.getdraw()` has been deprecated.
Removed features Removed features
---------------- ----------------

View File

@ -34,6 +34,11 @@ Support for LibTIFF earlier than 4
Support for LibTIFF earlier than version 4 has been deprecated. Support for LibTIFF earlier than version 4 has been deprecated.
Upgrade to a newer version of LibTIFF instead. Upgrade to a newer version of LibTIFF instead.
ImageDraw.getdraw hints parameter
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The ``hints`` parameter in :py:meth:`~PIL.ImageDraw.getdraw()` has been deprecated.
API Changes API Changes
=========== ===========

View File

@ -37,6 +37,7 @@ import struct
from typing import TYPE_CHECKING, AnyStr, Sequence, cast from typing import TYPE_CHECKING, AnyStr, Sequence, cast
from . import Image, ImageColor from . import Image, ImageColor
from ._deprecate import deprecate
from ._typing import Coords from ._typing import Coords
""" """
@ -904,26 +905,17 @@ except AttributeError:
def getdraw(im=None, hints=None): def getdraw(im=None, hints=None):
""" """
(Experimental) A more advanced 2D drawing interface for PIL images,
based on the WCK interface.
:param im: The image to draw in. :param im: The image to draw in.
:param hints: An optional list of hints. :param hints: An optional list of hints. Deprecated.
:returns: A (drawing context, drawing resource factory) tuple. :returns: A (drawing context, drawing resource factory) tuple.
""" """
# FIXME: this needs more work! if hints is not None:
# FIXME: come up with a better 'hints' scheme. deprecate("'hints' parameter", 12)
handler = None from . import ImageDraw2
if not hints or "nicest" in hints:
try:
from . import _imagingagg as handler
except ImportError:
pass
if handler is None:
from . import ImageDraw2 as handler
if im: if im:
im = handler.Draw(im) im = ImageDraw2.Draw(im)
return im, handler return im, ImageDraw2
def floodfill( def floodfill(