in reply to Re: Tk not recognising GD image
in thread [Solved] Tk not recognising GD image

Your solution works perfectly. Thank you. Reading "The string can contain base64 encoded data or binary data", I could not see what was wrong with my binary data. But I have more interesting things to investigate, now you have helped me.

Regards,

John Davies

Replies are listed 'Best First'.
Re^3: Tk not recognising GD image
by syphilis (Archbishop) on May 08, 2022 at 01:17 UTC
    But I have more interesting things to investigate

    The error arises in pTk/mTk/generic/tkImgPhoto.c:
    if (formatPtr == NULL) { ... code that might avoid the error by break()ing from the enclosing for() loop } if (formatPtr == NULL) { if ((formatObj != NULL) && !matched) { Tcl_AppendResult(interp, "image format \"", formatString, "\" is not supported", (char *) NULL); } else { Tcl_AppendResult(interp, "couldn't recognize image data", (char *) NULL); } return TCL_ERROR; }
    So ... there are cases where (formatPtr == NULL) is not necessarily an error.
    Perhaps yours should be one such case, but it's currently being undetected ? (I've no idea.)

    Anyway .... just a starting point for you once the "more interesting things" have been investigated ;-)

    Cheers,
    Rob
      Hello,

      a doubt still remains: I confirm this behaviour (and it sounds strange):

      > This code works when used on a file smaller than the screen. On a larger file, it fails ..

      Why it works for smaller files and need to be encoded for larger ones?

      L*

      There are no rules, there are no thumbs..
      Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
        $imtk = $mw->Photo(-data => $imgd->jpeg(), -format => 'jpeg'); } else { $imtk = $mw->Photo(-file => $file, -format => 'jpeg');

        The command is different, using the file directly via the file option rather than data. Larger files have to be resized to fit. I was thinking of using a temporary file as a workaround.

        Regards,

        John Davies