-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove deprecations for Pillow 10.0.0 #7059
Conversation
Will remove the other deprecations here too. |
Question about
Should we also do this? - def show_file(self, path=None, **options):
+ def show_file(self, path, **options):
"""
Display given file.
"""
- if path is None:
- msg = "Missing required argument: 'path'"
- raise TypeError(msg)
os.system(self.get_command(path, **options)) # nosec
return 1 |
Question about
# _E(scale, offset) represents the affine transformation scale * x + offset.
# The "data" field is named for compatibility with the old implementation,
# and should be renamed once coerce_e is removed. What should it be renamed to? |
Yes, sounds like good to me. The default value of |
From my reading of the comment, the user's plan was for it to be renamed "offset" |
My reading of the comment is the following change: -# _E(scale, offset) represents the affine transformation scale * x + offset.
-# The "data" field is named for compatibility with the old implementation,
-# and should be renamed once coerce_e is removed.
class _E:
- def __init__(self, scale, data):
+ def __init__(self, scale, offset):
self.scale = scale
- self.data = data
+ self.offset = offset (which I think is the same as @radarhere's comment, but I didn't understand it until I posted this comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made a few suggestions for textsize
tests: hugovk#100
@@ -665,7 +474,6 @@ def getmask2( | |||
self, | |||
text, | |||
mode="", | |||
fill=_UNSPECIFIED, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #6195 (comment) there was a suggestion to make this function, and possibly others, use keyword-only arguments. I see that I was planning to deprecate positional arguments for other text-related functions, but it seems I didn't get to it in time for removal in Pillow 10.
One option would be to remove support for positional arguments here by replacing fill
with *
, and to deprecate positional arguments in related functions, so that they will be consistent in Pillow 11.
Removing positional argument support here would simplify updating the API while preserving backwards compatibility, and allow the documentation to be in a logical or alphabetical order rather than version-added order.
However, this does not have to be decided in this PR. Perhaps it might be better to discuss in a separate issue/PR - perhaps I could make a separate deprecation PR once this is merged to discuss.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, let's discuss this in another issue or PR.
src/PIL/ImageDraw.py
Outdated
)[1] | ||
+ spacing | ||
) | ||
return self.textbbox((0, 0), "A", font, stroke_width=stroke_width)[3] + spacing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is slightly different when stroke_width != 0
. The deprecated function FreeTypeFont.getsize
seems to have an additional issue that I had not noticed before: it was adding the stroke width to the "height" twice even though it was returning the bottom coordinate instead of the actual height.
This has the effect of changing multiline spacing due to the change (see the changed image for an example). There are three options on how to proceed, and it is not clear to me whether any one of them is better than the others:
- Do not consider stroke width for line spacing (i.e. remove the parameter). I believe this would be the best visually, I would not expect a varying stroking width to affect the text layout.
- Consider 2x stroke width for line spacing (i.e. add stroke width to the returned value). This would preserve exact backwards compatibility. It would extend the line spacing by the size of stroke both on the top and bottom side.
- Consider 1x stroke width for line spacing (i.e. the current proposed change). This is the simplest option, and avoids mixing ImageDraw and ImageFont behaviour.
An alternative suggestion could be to move line spacing calculations to the font class, which can have other (including non backwards compatible) benefits, but I'm not sure what that API would look like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we drop these ImageFont
removals from this PR and we can consider all this separately?
The other changes here fix a failure with the new 3.12.0a7 (#7072 (comment)), so it'd be good to get that merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, whatever you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, made a copy of this branch and pushed to https://github.com/hugovk/Pillow/tree/rm-qt5a, then dropped the last two commits here (ac23f4f, 7712062), then rebased on main (to cleanup the fixups) and force-pushed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nulano Please could you make a followup for ImageFont
? Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've created PR #7080 to help this along - feel free to suggest changes.
…NTAINER, deprecated in 8.2.0
Remove deprecations for Pillow 10.0.0
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
I've created PR #7080 as the followup PR. |
Remove deprecations scheduled for removal in Pillow 10.0.0:
Tk/Tcl <= 8.4 support was deprecated in 8.2.0
Deprecate Tk/Tcl 8.4, to be removed in Pillow 10 (2023-07-01) #5216
im.category
and relatedImage.NORMAL
,Image.SEQUENCE
andImage.CONTAINER
attributes, deprecated in 8.2.0Deprecated categories #5351
JpegImagePlugin.convert_dict_qtables
, deprecated in 8.3.0De-zigzag JPEG's DQT when loading; deprecate convert_dict_qtables #4989
ImagePalette
size
parameter, deprecated in 8.4.0Deprecate ImagePalette size parameter #5641
ImageShow.Viewer.show_file()
file
argument, deprecated in 9.1.0Deprecated show_file "file" argument in favour of "path" #5959
Constants deprecated in 9.1.0
Added enums, deprecate constants #5954
FitsStubImagePlugin
, deprecated in 9.1.0Added FITS reading, deprecate FitsStubImagePlugin #6056
FreeTypeFont.getmask2()
fill
parameter, deprecated in 9.2.0Deprecate FreeTypeFont.getmask2 fill parameter #6220
PhotoImage.paste()
box
parameter, deprecated in 9.2.0Deprecated PhotoImage.paste() box parameter #6178
Qt5 support, deprecated in Pillow 9.2.0
Deprecate support for Qt 5 (PyQt5 and PySide2) #6237
Image.coerce_e
, deprecated in 9.2.0Support more affine expression forms in im.point(), deprecate Image.coerce_e #6254
TODO in followup:
Font size and offset methods
Deprecate ImageFont.getsize and related functions #6381
Release notes