#!/usr/sbin/imgtcl

# Scale an ImageVision image file.

# check arguments
if {$argc != 3} {
    puts "Usage: imgscale <zoom factor> <input-file> <output-file>"
    exit 1
}

# open the input image

ilFileImgOpen infile [lindex $argv 1]

set zoomfactor [lindex $argv 0]

# create a zoomed version of the image use bi-linear resampling

set img $infile
if {[infile getColorModel] == "iflRGBPalette"} {
    ilRGBImg rgb infile
    set img $rgb
}

ilRotZoomImg zoom $img 0 $zoomfactor $zoomfactor ilBiCubic

# save it in the ouput file

ilFileImgCreate outfile [lindex $argv 2] zoom
ilSetDither ilFSDither
outfile copy zoom
outfile delete
