Tkinter with PIL crashing on large images - help

Joel Gould joelg at
Mon Mar 12 13:42:37 CET 2001

Is this expected behavior?  If I load a 3.3 megapixel JPG file into a
PIL (Python Image Library) PhotoImage object and then draw that on a
Tkinter.Canvas object, Python crashes with an access violation (under
WIndows 98).

I have attached the code that fails. You can ge a suitable image from
this link:

I have tried this using the latest py20 distribution (Python 2.0, PIL
1.1.1, etc.) from Secret Labs.  I also tried it using the PythonWorks
Testdrive 1.1 (which uses Python 1.5.2) also from Secret Labs.

I am using Windows 98 SE on a Pentium III with 256MB of RAM.

Can anyone tell me why this is failing?

P.S.  I know the image is very big and I can make it smaller before
displaying it.  I just do not think it should GPF in this case.

Joel Gould
joelg at

----- snip ----

import Tkinter
import Image
import ImageTk

class MainDialog:
    def __init__(self, parent):
        self.canvas = Tkinter.Canvas(parent,width=700,height=500)
        self.image ="001229_1106_charlotteAmalie3.jpg")
        self.tkim = ImageTk.PhotoImage(self.image)
        self.item = self.canvas.create_image(

if __name__ == '__main__':
    root = Tkinter.Tk()
    dialog = MainDialog(root)

More information about the Python-list mailing list