Skip to content

Conversation

@wiredfool
Copy link
Member

Fixes #2973.

Changes proposed in this pull request:

  • Allow buffers to be read/write for at least the array interface, and possibly some mmapd files in the future. This opens up bidirectional communication with numpy arrays through shared memory.

I believe that the reason that it wasn't read/write was probably historical and tied to the old buffer interface, as mmap and the new style buffer interface don't play nicely on 2.7. As I'm not sure of the reason that it's this way, I'm a little cautious of opening this up without reasonably serious checking.

(also, tests, docs, etc)

@vodp
Copy link

vodp commented Nov 8, 2019

When this pull request will be merged? My graphics program is heavily affected by memcpy and this feature is the issue killer.

I've tried your folk however the problem seems not sovled yet,
sudo pip3 install "git+https://github.com/wiredfool/Pillow.git@buffer-updates"

        drawable = canvas.get_drawable()
        im = Image.frombuffer('RGB', drawable.shape[:2][::-1], np.frombuffer(drawable), 'raw', 'RGB', 0, 1)

Any drawing on im is not updated to drawable. Any idea? Or because mode 'RGB' is not supported by Image.frombuffer, see https://pillow.readthedocs.io/en/3.1.x/reference/Image.html#PIL.Image.fromstring ?

@radarhere
Copy link
Member

Looking at the code here, #8330 has added a slight variation on this.

@radarhere radarhere closed this Jun 12, 2025
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.

frombuffer constructed images are disconnected from the original data

4 participants