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

Map buffer into (0, 0) image #7359

Merged
merged 1 commit into from
Sep 4, 2023
Merged

Conversation

radarhere
Copy link
Member

In frombuffer, Pillow maps the buffer onto a (1, 1) image.

Pillow/src/PIL/Image.py

Lines 3003 to 3004 in 2460621

im = new(mode, (1, 1))
im = im._new(core.map_buffer(data, size, decoder_name, 0, args))

As a small change for the sake of performance, this PR changes it to be a (0, 0) image instead.

@@ -3000,7 +3000,7 @@ def frombuffer(mode, size, data, decoder_name="raw", *args):
if args == ():
args = mode, 0, 1
if args[0] in _MAPMODES:
im = new(mode, (1, 1))
im = new(mode, (0, 0))
Copy link
Member

Choose a reason for hiding this comment

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

For the record. This call gives 1.37 µs instead of 1.47 µs, which probably unmeasurable for whole frombuffer function.

@radarhere radarhere merged commit 2f9ef61 into python-pillow:main Sep 4, 2023
53 checks passed
@radarhere radarhere deleted the frombuffer branch September 4, 2023 09:44
This pull request was closed.
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.

2 participants