Richard Suchenwirth 2003-02-25 - Photo images can be resized by adding the -zoom or -subsample switches when copying an image. Here is a wrapper that takes only a factor and selects the appropriate switch. The image is scaled in place, the temporary image t is freed when no more needed.
proc scaleImage {im factor} { if {$factor < 1} { set factor [expr round(1./$factor)] set mode -subsample } else {set mode -zoom} set t [image create photo] $t copy $im $im blank $im copy $t $mode $factor -shrink image delete $t }
Usage example: adding the following lines gives iFile: a little file system browser scaling capacities on the image shown on the "File" page:
.m add casc -label Image -menu [menu .m.image -tearoff 0] .m.image add comm -label "Zoom x 3" -command {scaleImage $g(i) 3} .m.image add comm -label "Zoom x 2" -command {scaleImage $g(i) 2} .m.image add comm -label "Zoom x 0.5" -command {scaleImage $g(i) 0.5} .m.image add comm -label "Zoom x 0.33" -command {scaleImage $g(i) 0.33}
For robustness, one might disable this menu when no image is displayed.