/* Program to use ADPro to resize all the pics in a directory and maybe also crop them and reduce the number of colours. They can be saved to another directory. */
trace n
options results
address "ADPro"
getdir '"Select source directory"'
if rc=10 then exit
directory = ADPro_Result
getdir '"Select destination directory"'
if rc=10 then exit
outdirectory = ADPro_Result
address command
"list >ram:filelist "directory" all quick"
call open(input,"ram:filelist","r")
address "ADPro"
lformat "UNIVERSAL"
sformat "IFF"
/* Use the current screen format and number of colours. */
render_type
colours = ADPro_result
screen_type
stype = ADPro_result
/* Here is where you ask the user for figures */
getnumber '"Top crop (pixels)"'
topcrop = ADPro_result
if rc~=0 then topcrop = 0
getnumber '"Left crop (pixels)"'
leftcrop = ADPro_result
if rc~=0 then leftcrop = 0
getnumber '"Right crop (pixels)"'
rightcrop = ADPro_result
if rc~=0 then rightcrop = 0
getnumber '"Bottom crop (pixels)"'
bottomcrop = ADPro_result
if rc~=0 then bottomcrop = 0
getnumber '"Output width (pixels)"' 320 16 1280
if rc~=0 then do
okay1 "User aborted program"
exit
end
width = ADPro_result
getnumber '"Output height (pixels)"' 256 16 1024
if rc~=0 then do
okay1 "User aborted program"
exit
end
height = ADPro_result
do i = 1 to 100 /* safety limit of 100 files */
filename = readln(input)
if filename = "" then break
if word(filename,2) = "files" then iterate /* This line not a file name */
if word(filename,1) = "TOTAL:" then break /* or this one */
if right(directory,1) = ":" then fullname = directory||filename
else fullname = directory||"/"||filename
load fullname
if rc ~=0 then iterate /* if load fails, try the next one */
/* Get size of loaded image, before scaling */
xsize
inputwidth = ADPro_result
ysize
inputheight = ADPro_result
/* Here is where all the image processing is done */