-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
MemoryError with large georef image #7534
Comments
Would you be able to provide the full traceback of the error? |
I ran import tkinter
from PIL import Image, ImageTk
im = Image.new("RGB", (29898, 18312))
root = tkinter.Tk()
ImageTk.PhotoImage(im) and hit Pillow/src/libImaging/Storage.c Lines 456 to 459 in 25cc5af
This check was added in #1781. Because this is part of our C code, and not an arbitrary limit set in Python, there isn't a simple workaround for this, no. |
Hi @radarhere, thank you so much for the analysis and tests you did. |
Is that all you wanted, or is there something further to be done here? |
Unfortunately, if, as understood, there is no solution to the problem, I believe that nothing else can be done. I'll try to see if I can solve it in another way, using smaller images that are correctly processed (size limit about 1GB max.) Thank you so much for your help and support, and for the time you have dedicated to the problem. |
Pillow does support larger images, but the Lines 164 to 182 in 902055f
|
So perhaps a workaround is to simply crop out sections of the image, convert them into multiple PhotoImages, and place them onto the canvas one at a time. |
This is super old code -- and it looks like the general idea is that the pointer to the block of memory is passed directly into tk (here: Line 71 in 902055f
The only possibility I can see here is if you're actually using a 32 bit build of python. I don't recall if we can actually allocate bigger chunks than 2 gig in the 64 bit builds, but I do think that we avoid doing so in general. This is kind of a special case though, since as noted this is the only place where we explicitly require a single block. That being said, I don't know how TK would react to passing in such a large image. |
Is there anything further to be done here? |
No, thank you very much. bye...CIAO |
What did you do?
Hi everyone.
I have a large georef image (file .tif 1.6 GB 29898x18312 px. - 72 dpi - 24 bit) and I should be able to create an ImageTk.PhotoImage object for use in a canvas (tk.Canvas) without resizing it
What did you expect to happen?
the object to be used
What actually happened?
the following exception is raised
<class 'MemoryError'>
(<class 'MemoryError'>, MemoryError(), <traceback object at 0x00000233632B8D00>)
What are your OS, Python and Pillow versions?
Is there a work-around for solve the error?
What is the maximum usable size?
Thank you for your attention and for the information you provide me.
The text was updated successfully, but these errors were encountered: