#10024·Pillow

ImageText.wrap() doesn't wrap text by width on height fit with shrink scaling

Author: DezzelshipcCreated Sep 18, 2026Updated Sep 18, 2026

https://github.com/python-pillow/Pillow/blob/ec16a5785b89b277a027e5bc6203d15e6620c7e0/src/PIL/ImageText.py#L221-L223

Code doesn't reach newline join https://github.com/python-pillow/Pillow/blob/ec16a5785b89b277a027e5bc6203d15e6620c7e0/src/PIL/ImageText.py#L269-L270

Example:

python
width, height = 198, 228
text = "Master Librarian"
font = ImageFont.truetype("Courier.ttf", 30)
image_text = ImageText.Text(text, font)
image_text.stroke(width=0.7, fill="#ffffff")
a = image_text.wrap(width, height, scaling=("shrink", 20))
wrap = ImageText._Wrap(image_text, width, height, font)
print(repr(image_text.text), repr(a), repr(wrap.lines))

Outputs 'Master Librarian' None ['Master', 'Librarian']