home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / Batch / Convolve.ieb < prev    next >
Encoding:
Text File  |  1997-02-02  |  2.9 KB  |  114 lines

  1. /*
  2. ** $VER: Convolve.ieb 1.1, IE Arexx script
  3. ** Image Engineer Batch Processing script
  4. ** Copyright © by Patrik M Nydensten 
  5. ** 24/1 1997 Stockholm/Sweden
  6. **
  7. ** Convolve image.
  8. */
  9.  
  10. options results
  11. signal on error
  12.  
  13. parse arg input command
  14. input = upper(strip(input))
  15. address 'IMAGEENGINEER'
  16.  
  17. select  /* Required batch script commands */
  18.   when input = 'INFO' then    return get_info()
  19.   when input = 'CONFIG' then  return get_config(command)
  20.   when input = 'PROCESS' then return process_image(command)
  21.   otherwise do
  22.     'REQUEST' '"Failure in call to batch script!"' '" Quit "'
  23.     return '<ERROR>'
  24.   end
  25. end
  26.  
  27. exit 0
  28.  
  29. /* Required "Get_info" procedure  ------------------------------------ */
  30. /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files       */
  31.  
  32. get_info:
  33.   back = 'OK'
  34. return back
  35.  
  36. /* Required "Get_config" procedure  ---------------------------------- */
  37.  
  38. get_config:
  39.   parse arg '"'command'"'
  40.  
  41.   'IE_TO_FRONT'
  42.  
  43.   /* Unchanged config, only picked for first image */
  44.  
  45.   if command = '' then do  
  46.     'GET_FILE' '"Select a convolve matrix."' '" OK "' '"IE:Convolves/"'
  47.     if (RC=5) then return '<ERROR>'
  48.     Matrix = strip(Result,B,'"')
  49.   end
  50.   else do
  51.     'REQUEST' '"You can only select a convolve'd2c(10)||'matrix for the first image."' '" OK "'
  52.     Matrix = 'none'
  53.   end
  54.  
  55.   back = '#'Matrix
  56. return back
  57.  
  58. /* Required "Process_image" procedure  ------------------------------- */
  59.  
  60. process_image:
  61.   parse arg '"'src_image'"' '"'dst_image'"' '"'options'"'
  62.   parse var options '#'Matrix
  63.  
  64.   'OPEN' '"'src_image'"' '24'
  65.   if (RC ~= 0) then do
  66.     'IE_TO_FRONT'
  67.     'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "'
  68.     return '<ERROR>'
  69.   end
  70.   else LoadImage = result
  71.  
  72.   if ~exists(Matrix) then do
  73.     'IE_TO_FRONT'
  74.     'REQUEST' '"Failed to load convolve matrix:' d2c(10)||matrix'"' '" OK "'
  75.     return '<ERROR>'
  76.   end
  77.  
  78.   'CONVOLVE' LoadImage '"'Matrix'"'
  79.   OutputImage = result
  80.   'CLOSE' LoadImage
  81.   
  82.   if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1')
  83.   'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"'
  84.   if (RC ~= 0) then do
  85.     'IE_TO_FRONT'
  86.     'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "'
  87.     return '<ERROR>'
  88.   end
  89.   'CLOSE' OutputImage
  90.  
  91.   back = 'OK'
  92. return back
  93.  
  94. /* Internal procedures  ---------------------------------------------- */
  95.  
  96. /*******************************************************************/
  97. /* This is where control goes when an error code is returned by IE */
  98. /* It puts up a message saying what happened and on which line     */
  99. /*******************************************************************/
  100.  
  101. error:
  102. if RC=5 then do
  103.     IE_TO_FRONT
  104.     LAST_ERROR
  105.     'REQUEST "'||RESULT||'"'
  106. end
  107. else do
  108.     IE_TO_FRONT
  109.     LAST_ERROR
  110.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  111. end
  112.  
  113. return '<ERROR>'
  114.