-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Refactor broken unsafe SetImagePillow() #1818
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
Refactor broken unsafe SetImagePillow() #1818
Conversation
|
Which version of pillow should I be installing? <12 or is 12 and above fine with this PR? |
|
<12 is compatible prior to this PR. After this, all versions should be |
|
Hi! I am facing this issue and am curious about when you think the PR could be merged? |
|
Also awaiting this PR merge. Recently built a new RGB matrix system using the latest Raspberry Pi OS and found out a part of one of my projects no longer works due to PIL 12.0. This fix will also benefit the people that use the Adafruit guide for implementing this library with Python as PIL is now at 12 and the older commits that their build script pulls will no longer work moving forward. |
|
Just to put things in context, I didn't write this driver, and I do not use its python interface, at all. I wanted @hzeller to have a chance to look at this PR, but my understanding is that he doesn't really have time to work on this code, so I'm going to trust your work and merge this. |
|
Everyone affected, please confirm head now fixes your issues with this. |
@marcmerlin I just built it and can confirm this merge fixes the issue and it works on my end (to the extent that my project uses these bindings) |
|
Perfect, thank you both |
|
Thanks for merging @marcmerlin ! |
|
@ty-porter since no one with commit access is actually using the python bindings, would you be interested in being the python binding maintainer for this project? We can also go in the commit logs and see how else submitted the original bindings and recent fixes. |
|
@marcmerlin Sure, I'm happy to help out. |
|
Thanks. Let's start with |
Supersedes #1817 and resolves #1769
Previous PR was broken ->
image.im.getim()should have beenimage.getim()Second, using PyCapsules means we need precise byte offsets into the image structs (in this case
ImagingMemoryInstancethey contain in order to access the image frame.get_unsafe_ptrs()did this for us previously.https://github.com/python-pillow/Pillow/blob/e36e67081ae9d4162f5254ce6f3c1478fc342d9c/src/libImaging/Imaging.h#L80
Unfortunately it's not trivial, the first attribute
modespecifically is not stable and is changing fromchar[]tostruct*to enum value between Pillow 11 / 12, so the offsets are not stable.Cython also cannot compile the header we need natively:
Instead, this PR creates a simple C shim that hides
ImagingMemoryInstanceand provides portable access to theimage32field needed for fastSetImage()Retested this change on a fresh install of Pi OS Bookworm, I think the fact the previous PR worked was a competing installation.