Version 1 of Runnable Images

Updated 2008-07-15 12:17:03 by Stu

Runnable Images are images appended to a little bit of Tcl image viewing code that display the images when executed.

#! /bin/sh
# \
exec tclsh8.5 "$0" ${1+"$@"}
set f [open $argv0]
fconfigure $f -eofchar \x1a
read $f
seek $f 1 current
fconfigure $f -translation binary
set d [read $f]
close $f
package require Tk
image create photo i1 -data $d
pack [label .l -image i1]
# EOF
^Z

There must be a Control-Z (0x1a) at the end of the file. Then, (assuming it's saved as 'i.tcl') in a shell: $ cat i.tcl myimage.gif > viewmyimage.tcl $ chmod u+x viewmyimage.tcl $ ./viewmyimage.tcl or tclsh viewmyimage.tcl

This could be used for a single-file slideshow, for example.


Images Tk Embedding