Skip to content
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

Round box position to integer when pasting embedded color #6517

Merged

Conversation

radarhere
Copy link
Member

Resolves #6515

If align="center" is used for multiline_text,

Pillow/src/PIL/ImageDraw.py

Lines 562 to 570 in 4c59f77

elif align == "center":
left += width_difference / 2.0
elif align == "right":
left += width_difference
else:
raise ValueError('align must be "left", "center" or "right"')
self.text(
(left, top),

then coord can be a float for the embedded_color paste. But when pasting one image onto another, the co-ordinates must be integers, and so an error will be raised, as in the issue.
self.im.paste(color, coord + coord2, mask)

This PR rounds the co-ordinates to integers in that case.

@nulano
Copy link
Contributor

nulano commented Aug 24, 2022

I've created radarhere#18 with a few suggestions.

nulano
nulano approved these changes Aug 25, 2022
Copy link
Contributor

@nulano nulano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alternative image is for Centos 7, for some reason the Codecov processing failed for that one coverage report:
image

@hugovk hugovk merged commit eb59cb6 into python-pillow:main Oct 11, 2022
58 of 60 checks passed
@radarhere radarhere deleted the multiline_centered_embedded_color branch October 11, 2022 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't use "align=center" together with "embedded_color=True"
3 participants