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

Fixed bug in decoding large images #3791

Merged
merged 1 commit into from May 4, 2019
Merged

Conversation

radarhere
Copy link
Member

Resolves #1475

@radarhere radarhere changed the title Changed raw decode buffer size to unsigned int Fixed bug in decoding large raw images Apr 13, 2019
@hugovk
Copy link
Member

hugovk commented Apr 15, 2019

#1475 (comment) suggests changing all ints to py_ssize_t.

What are the pros and cons of using unsigned int over py_ssize_t?

@radarhere
Copy link
Member Author

It didn't occur to me that py_ssize_t was also applicable here, thanks for spotting. I've changed the commit to use that.

I've also changed the other decoders as well, to fix a compilation warning.

@radarhere radarhere changed the title Fixed bug in decoding large raw images Fixed bug in decoding large images Apr 15, 2019
@radarhere radarhere added the Bug Any unexpected behavior, until confirmed feature. label Apr 22, 2019
@hugovk hugovk merged commit ab9a25d into python-pillow:master May 4, 2019
@radarhere radarhere deleted the int branch May 4, 2019 13:16
@elhuhdron
Copy link

elhuhdron commented Jul 11, 2019

Many PIL operations are working for me for image manipulations of images over 32 bit in size, which is fantastic. However, I still have a problem with fromarray even after this fix (tested using PIL version 6.1.0 and numpy version 1.16.4):

The test case is relatively simple:

from PIL import Image
import numpy as np

# this works
a = np.zeros((46340, 46340), dtype=np.uint8)
b = Image.fromarray(a)
del a,b

# this works
b = Image.new('L', (46341, 46341))
del b

# this does not work, fails with:
# MemoryError: Integer overflow in ysize
a = np.zeros((46341, 46341), dtype=np.uint8)
b = Image.fromarray(a)

This is likely because 46341*46341 > 2^31-1
Is this easily fixable?

@radarhere
Copy link
Member Author

@elhuhdron could you open a new issue with your problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Any unexpected behavior, until confirmed feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OverflowError in PIL.Image.fromarray
3 participants