/* trace r (leave this line in) */ options results signal on break_c if ~show('l',"rexxsupport.library") then check = addlib('rexxsupport.library',0,-30,0) if ~show('l',"rexxmathlib.library") then check = addlib('rexxmathlib.library',0,-30,0) if ~show('l',"rexxarplib.library") then check = addlib('rexxarplib.library',0,-30,0) ext = '.JPEG' dstdir = '' srcdir = '' hires = 1 lace = 2 compression = "75" parse arg cmdline srcdir = word(cmdline,1) dstdir = subword(cmdline,2) call check_src() parse value statef(dstdir) with type . if type = 'DIR' then do if (right(dstdir,1) ~== ':') & (right(dstdir,1) ~== '/') then dstdir = dstdir||'/' end else do end call load_adpro() call setupadp() do n = 1 to filecount call process_file(srcdir||file.n) if rc > 0 then iterate end address 'ADPro' adpro_exit exit 0 check_src: call getlist() if (right(srcdir,1) ~== ':') & (right(srcdir,1) ~== '/') then srcdir = srcdir||'/' return 0 getlist: parse value statef(srcdir) with type . if type = 'DIR' then do thefiles = showdir(srcdir,'f') filecount = words(thefiles) do i = 1 to filecount file.i = word(thefiles,i) end end else do call usage() exit 5 end return 0 load_adpro: address command 'run nil: adpro:adpro BEHIND' address command 'sys:rexxc/waitforport ADPro' if RC = 5 then do exit 20 end return 0 setupadp: address 'ADPro' orientation portrait lformat 'UNIVERSAL' address 'ADPro' screen_type lace address 'ADPro' dither 0 address 'ADPro' sformat "JPEG" return 0 process_file: parse arg gotit scaled = 0 pos = index(gotit,'.') if pos = 0 then sfile = file.n else sfile = substr(file.n,1,lastpos('.',file.n)-1) address 'ADPro' load gotit if rc ~= 0 then do call adp_error('loading file '||gotit) return 5 end operator 'DEFINE_PXL_ASPECT' asp = adpro_result parse var asp a b c d W H . savetext = 'Saving '||sfile||ext||' to '||dstdir address 'ADPro' save dstdir||sfile||ext "RAW" compression return 0 scaleit: Y = 400 X = trunc(W/2*Y/H*1.2) scaled = 1 scale_text = "Scaling "upper(sfile)" from "W"x"H" to" X"x"Y return 0 break_c: if show(ports,"ADPro") then address 'ADPro' adpro_exit exit 2 adp_error: parse arg what error_text = "ERROR: "||what||" "||upper(sfile) say error_text return 0