Skip to content

Fixed bug in decoding large images#3791

Merged
hugovk merged 1 commit intopython-pillow:masterfrom
radarhere:int
May 4, 2019
Merged

Fixed bug in decoding large images#3791
hugovk merged 1 commit intopython-pillow:masterfrom
radarhere:int

Conversation

@radarhere
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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