What the agent does
Pillow 10 removed FreeTypeFont.getsize, and the two replacements people paste in do not return what it returned. So the agent first reads what the numbers are used for. In 13Bytes/eInkCalendar, a desk calendar drawn on an e-ink panel, requirements.txt lists Pillow with no version and the README's install step is sudo python3 -m pip install -r requirements.txt, so a new install gets the current release. displayHelpers.py calls getsize in three helpers, at lines 33, 39 and 44. One of them, draw_text_centered, is referenced only from a commented-out line. The other two carry the layout: displayRun.py keeps a running current_height and adds get_font_height(font) after each block, six times, and right-aligns the weekday with get_font_width.
That use decides the fix. With the repository's own Roboto-Black.ttf at size 200, the font of the large day number, getsize("A") on Pillow 9.5.0 returns (129, 186) and getbbox("A") returns (0, 43, 129, 186). The old call was the right and bottom edge of the box, measured from the point where drawing starts, including the 43 empty pixels above the glyph. The answer most often copied for this error computes height as bottom minus top, which gives 143. Every row below the date would then sit 43 pixels higher, on top of the number. getlength is close to the old width but returns a float, 127.640625 for the same letter. The agent writes the helpers as font.getbbox(text)[2] and font.getbbox("A")[3] and says why.
It then proves it without the hardware. The panel driver under lib/ imports spidev and RPi.GPIO when it starts, and dataHelper.py fetches a calendar and a contact list over the network, but render_content needs only two ImageDraw canvases, a width and a height. The agent stands in a stub driver with the panel's 800 by 480 size, a settings module, five fixed events and two birthday names, pins the random icon choices, and saves the black and red layers. On Pillow 9.5.0 the original helpers and the getbbox helpers produce images with zero differing pixels in either layer. The bottom-minus-top version differs in 12,869 pixels of the 480 by 800 black layer.
The last comparison is across the upgrade, and it is reported honestly: the fixed code on a current Pillow differs from the 9.5.0 baseline in 26 pixels of the black layer and none of the red. The two builds bundle different FreeType versions, 2.13.0 and 2.14.3, and every measurement that drives the layout is the same in both. The agent also reports one thing it has to work around to render at all. On the sandbox's 64-bit Python, convert_image_to_screen builds an int64 array with np.vectorize, and Image.fromarray refuses it with Cannot handle this data type: (1, 1), <i8 on old and new Pillow alike. An int32 array is accepted. It leaves that function alone and puts the finding in the pull request.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "After a fresh install this project fails with \"AttributeError: 'FreeTypeFont' object has no attribute 'getsize'\" (Pillow 10 removed it). Find every call to getsize on a font and to textsize on an ImageDraw object, and for each one say what the result is used for: a width, a height added to a running layout position, centring, or wrapping. Using the font files in this repository at the sizes the code uses, print getsize, getbbox and getlength for a few strings on Pillow 9.5.0, and state the relationship between them. Replace each call so that the value the code receives is exactly the value getsize returned; do not use bottom minus top for a height unless the surrounding code already compensates for the offset. Then prove the layout is unchanged without the device: stub the hardware driver and any network calls with fixed data, fix any random choices, render the output image on Pillow 9.5.0 with the original code and with your change, and count differing pixels. Render once more with your change on the newest Pillow and report the difference separately, saying whether it is layout or glyph rasterisation. Also render a version that uses bottom minus top, to show reviewers what the common fix would have done. Save the rendered images as artifacts. If something unrelated stops the off-device render, work around it in your test harness only, and report it without changing it. State the oldest Pillow version your replacement works on, checked by running it, and set that bound in the requirements file. Open a pull request with the numbers.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
A pull request that changes three lines of displayHelpers.py and one line of requirements.txt. The description holds the measurement table for each font and size the project uses, the sentence that getsize(text) equals the third and fourth numbers of getbbox(text), and three pixel counts: original against fixed on the old Pillow, fixed on old against fixed on new, and fixed against the bottom-minus-top variant. The rendered layers are attached to the session as artifacts, so a reviewer can open the before and after images instead of trusting the counts.
What a reviewer checks is short. The first count should be zero; if it is not, the replacement changed the layout and the pull request should say where. The second count should be small and explained by the font engine. They read the note about anything the harness worked around, since that is a second bug report they did not ask for, and decide whether it matters on the device. Nothing is flashed to a panel and no calendar account is contacted; the run uses stand-in data throughout.
Run it on every issue labelled pillow
Projects like this hear about the break from users: someone installs on a new device and opens an issue with the traceback. An automation with a github trigger on issues.labeled, filtered to one label, starts a run when a maintainer adds that label, and the issue is placed after the saved prompt as event text. Issues opened by outside users do not fire a trigger on their own; a labelled one does because a collaborator applied the label.
For an application with an error tracker, a handler on your server can forward events whose message contains has no attribute 'getsize' to a webhook trigger's URL, sending the trigger's secret as Authorization: Bearer. Trackers that sign their own deliveries cannot send that header themselves. Set the automation's max runs per hour to a small number, since one device reboot loop can raise the same error many times.
The use case this job follows, with its automation and trigger: Fix a bug from an alert.
Why run it on Rush?
The proof here is an image, and making it needs two Pillow versions side by side, the project's fonts, and a render that does not depend on a panel wired to a Raspberry Pi. A Rush run has its own sandbox for that: it creates one environment per Pillow version, runs the same harness in each, and keeps the commands, the printed measurements and the saved images with the session. A developer fixing this at a desk usually has one environment and the device in another room.
It also guards against the fix that passes review and ships a broken screen. A change from getsize(text)[1] to a bounding-box height looks correct in a diff and raises no error. Only the rendered output shows rows drawn over each other. Because the run renders the common wrong answer as well and counts its pixels, the pull request explains the choice in a way a reviewer can verify in a minute.
Frequently asked questions
What replaces font.getsize in Pillow 10?
font.getbbox(text) returns left, top, right and bottom, and getsize(text) was the right and bottom values. font.getlength(text) gives the advance width as a float. Which one you want depends on what the code did with the old number, which is why the agent reads the call sites first.
Why did my text move after I switched to getbbox?
Most likely the height was computed as bottom minus top. The old height included the space between the drawing origin and the top of the glyphs, so code that stacks lines by adding heights loses that space on every line. In the fixture the difference is 43 pixels for the size 200 font.
Can I pin Pillow below 10 instead?
It works as a stopgap, and Pillow 9.5.0 prints a DeprecationWarning that names getbbox and getlength. It also keeps the device on an old imaging library. The replacement calls exist on 9.5.0 too, so the fix does not force the upgrade; the pull request states the oldest version it was run on.
Does ImageDraw.textsize need the same fix?
Yes. It was removed at the same time, and the replacements are textbbox and textlength on the draw object. The prompt asks for both spellings to be found, and the same rule about offsets applies.
Does the agent need my display hardware?
No. It stubs the driver and the network calls in a test harness and renders to image files. That checks layout and drawing, not the panel, so the first run on the device is still yours to watch.
More Pillow jobs
More jobs like this: Fix a bug from an alert
- Fix "TypeError: gca() got an unexpected keyword argument 'projection'" in Matplotlib 3D Plots (Matplotlib)
- Fix "RuntimeError: generator raised StopIteration" in Python 3.7 and Later (Python)
- Fix `Call to undefined function get_magic_quotes_gpc()` When a PHP App Lands on PHP 8 (PHP)
- Fix "TypeError: glob is not a function" after upgrading the glob package (glob)