Re: tcl code to read an image and write tcl code?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: tcl code to read an image and write tcl code?

From: Bryan Oakley <oakley@bardo.clearlight.com>
Date: Tue Feb 28 2006 - 04:28:27 CET

Eric Taylor wrote:
> Does anyone know where I can find a tcl proc
> that would take an image, say a gif, and output
> pure tcl code that I could paste into a program?
>
> I saw something about a unix program that did
> something with mimes but I'm on windows.
>
>

Something like this ought to be pretty close (untested, but I think it's
pretty close). It requires the base64 package from tcllib:

   package require base64
   proc main {} {
     global argv

     set file [lindex $argv 0]
     set fd [open $file r]
     set rawdata [read $fd]
     close $fd

     set b64data [base64::encode $rawdata]
     puts "image create photo -data {\n$b64data\n}"
   }
   main
Received on Sun Apr 30 02:17:24 2006