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

ImageTk.getimage is broken #2372

Closed
wiredfool opened this issue Jan 24, 2017 · 1 comment · Fixed by #3814
Closed

ImageTk.getimage is broken #2372

wiredfool opened this issue Jan 24, 2017 · 1 comment · Fixed by #3814

Comments

@wiredfool
Copy link
Member

wiredfool commented Jan 24, 2017

What did you do?

Looked at the api, tried ImageTk.getimage

What did you expect to happen?

An Image.

What actually happened?

I got a TkError. Digging through the code, get image calls tkImaging.c:PyImagingPhotoGet:

static int
PyImagingPhotoGet(ClientData clientdata, Tcl_Interp* interp,
               int argc, char **argv)
{
    Tk_PhotoHandle photo;
    Tk_PhotoImageBlock block;

    if (argc != 2) {
        Tcl_AppendResult(interp, "usage: ", argv[0],
                         " srcPhoto", (char *) NULL);
        return TCL_ERROR;
    }

    /* get Tcl PhotoImage handle */
    photo = Tk_FindPhoto(interp, argv[1]);
    if (photo == NULL) {
        Tcl_AppendResult(
            interp, "source photo must exist", (char *) NULL
            );
        return TCL_ERROR;
    }

    Tk_PhotoGetImage(photo, &block);

    printf("pixelPtr = %p\n", block.pixelPtr);
    printf("width = %d\n", block.width);
    printf("height = %d\n", block.height);
    printf("pitch = %d\n", block.pitch);
    printf("pixelSize = %d\n", block.pixelSize);
    printf("offset = %d %d %d %d\n", block.offset[0], block.offset[1],
           block.offset[2], block.offset[3]);

    Tcl_AppendResult(
        interp, "this function is not yet supported", (char *) NULL
        );

    return TCL_ERROR;
}

Note that every code path ends in an error.

What versions of Pillow and Python are you using?

master. But it really doesn't matter, since most of this code hasn't been touched since the PIL import. Except for the Tk reorg. Which didn't actually check that this code could run.

This code is enough to see the error, added in viewer.py. Other repros are left as an exercise to the reader.

self.image = ImageTk.PhotoImage(im)
ImageTk.getimage(self.image)
@radarhere
Copy link
Member

I've created PR #3814 to resolve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants