Version 8 of GIF

Updated 2002-05-09 19:36:39

Graphic Interchange format, a compact and popular way of storing images. LZW-encoded. Tk's photo type of image allows both reading and writing GIF files.

How to make a single-pixel GIF file: (but see also ".gif color dot" for a pure-Tcl version)

 % set im [image create photo -height 1 -width 1] 
 image4
 % $im put red
 % $im write im.gif -format gif
 % hexdump im.gif
 47 49 46 38 37 61 01 00 01 00 91 00 00 FF 00 00 # 0000 GIF87a..........
 FF FF FF FF FF FF FF FF FF 2C 00 00 00 00 01 00 # 0010 .........,......
 01 00 00 02 02 44 01 00 3B                      # 0020 .....D..;

Loading that file indeed shows a single red pixel. (A "hexdump" command is described at Dump a file in hex and ASCII.)


See also


.gif is controversial in that there's an "intellectual property" dispute about its use. One of us will explain this at some point.

DKF - Technically, the IP dispute is over the LZW compression scheme (patented by Unisys) and not the GIF format itself (invented by AOL). I do not recall when the LZW patent expires (I don't know when the patent was granted, or how long patents last for) but for your legal protection, the Tcl GIF writing code doesn't use LZW compression, but rather a run-length encoding scheme that (apparently) works because there's only one sane way to write a GIF decompressor. I'm no expert on that though.