in reply to Re^13: Tk:Photo -data with binary data?
in thread Tk:Photo -data with binary data?

returning to your 1/2 year ago attempt on pure tcl/tk attempt - "Image format png is not supported" - you just need

package require Img

#!/usr/bin/wish package require Img set fdata [read [open "/test/colorcube.png"]] label .l1 -image [image create photo -format png -data $fdata] pack .l1

Results is a popup labelled "Error in startup script" containing the text

couldn't recognise image data while executing "image create photo -format png -data $fdata" invoked from within "labal,l1 -image [image create photo -format png -data $fdata]" (file c:\Tcl\test\test.tcl" line 4)

Which looks extremely similar to the problem I was having in OP of this thread. Namely, that it doesn't seem to be possible to pass image data in binary form using the -data option. Even when using Tcl directly.

It seems unlikely that if I ever get Tcl::Tk to install, that it would allow me to do this either.

All of which makes this whole Tcl/Tk subthread, and the time expended downloading and installing Tcl, a complete waste of time! Thanks.

And if that sounds ungrateful, it probably is. You see, I asked my question in the OP because I was trying to solve a particular problem. That problem remains unsolved.

I understand that as the author of Tcl/Tk, you are keen to promote it, but offering me a 'solution' that can never solve my problem is just a ****** *** ***** waste of my ****** time.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^15: Tk:Photo -data with binary data?
by vkon (Curate) on Jun 08, 2007 at 07:12 UTC
    I am not author of Tcl/Tk.

    I am user of Tcl/Tk, who happen to use it indirectly (from Perl)

    I am maintainer of Tcl::Tk, but I am not author of Tcl::Tk either.

      I am user of Tcl/Tk, who happen to use it indirectly (from Perl). I am maintainer of Tcl::Tk,

      Then you presumably have enough understanding of how these components fit together and work, and have an existing installation that would have allowed you to write and test that this actually worked:

      #!/usr/bin/wish package require Img set fdata [read [open "/test/colorcube.png"]] label .l1 -image [image create photo -format png -data $fdata] pack .l1

      Before suggesting Tcl::Tk as a solution?


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        this do what you want:
        use Tcl::Tk; my $int = new Tcl::Tk; $int->packageRequire('img::png'); open my $fh, "valid-xhtml10.png"; binmode $fh; $int->mainwindow->Label(-image => $int->imageCreate('photo', -data=>join'', <$fh>, ))->pack; $int->MainLoop;
        your Tcl/Tk code probably misses 'binmode'
        yet img::png...

        as for related mailing list, you'll more chance on help on it because it is more on-topic.

        PM is good resource but your question will not always find a person who could answer.