set cvs [canvas .c -width 1000 -height 500]
grid $cvs -row 1 -column 1

button .b -text Quit -command exit
grid .b -row 2 -column 1

set im1 [image create photo -file mandala.gif]
$cvs create image 0 0 -image $im1 -anchor nw

set im2 [image create photo -height [image height $im1] \
    -width [image width $im1]]

$cvs create image [image width $im1] 0 -image $im2 -anchor nw

for {set x 0} {$x < [image width $im1]} {incr x } {
  for {set y 0} {$y < [image height $im1]} {incr y } {
    lassign [$im1 get $x $y] red green blue
    set new [format "#%02x%02x%02x" $red $green $blue]
    $im2 put $new -to $x $y
  }
}
