Skip to content

MemoryError: Integer overflow in ysize #3963

@elhuhdron

Description

@elhuhdron

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, tested using PIL version 6.1.0 and numpy version 1.16.4. I believe this version already incorporates fix #3791 (?)

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions