home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / prog / arexx / scripti.lha / 3-DEE / Scripti / General / Scale.rexx < prev   
Encoding:
OS/2 REXX Batch file  |  1993-05-19  |  3.9 KB  |  175 lines

  1. /*
  2. -----------------------------------------------------------------------------
  3. This AREXX-Script will scale any image to any size, specified by the user
  4.      in the arguments.
  5. The size argument allows percents!
  6.  
  7. Host address: ADPro (Art Department Professional   ®ASDG)
  8. Written by Jan Van Overbeke, 3-DEE, ©1993.
  9. Read the AREXX-Scripti doc, for info about operation and rights!
  10. -----------------------------------------------------------------------------
  11. */
  12.  
  13. arg filename SpecX SpecY
  14. if ~exists(filename)|filename='' then do
  15.     say 'Unable to find the image !!'
  16.     say 'See Ya...'
  17.     say ''
  18.     exit
  19.     end
  20.  
  21. address 'ADPro'
  22. options results
  23. say 'Scale: Written by JAN VAN OVERBEKE, 3-DEE, ©1993'
  24. say 'Image: 'filename
  25. say 'SAVE: IFF Original Colors.'
  26. say ''
  27.  
  28. LFORMAT "UNIVERSAL"
  29. if RC ~=0 then do
  30.     say 'Unable to select the UNIVERSAL loader.'
  31.     say 'See Ya...'
  32.     say ''
  33.     exit
  34.     end
  35.  
  36. say 'Loading.........'
  37. LOAD filename
  38. if RC ~=0 then do
  39.     say 'Had some problems while loading.'
  40.     say 'See Ya...'
  41.     say ''
  42.     exit
  43.     end
  44.  
  45. /* ---- Let's see if it is 24Bit ---- */
  46. /* ---------------------------------- */
  47. IMAGE
  48. help=ADPRO_RESULT
  49. dontrender='ok'
  50. if pos('RENDERED',help)>0|pos('BITPLANE',help)>0 then dontrender='nok'
  51.  
  52. say 'Converting......'
  53. XSIZE
  54. w=ADPRO_RESULT
  55. YSIZE
  56. h=ADPRO_RESULT
  57. say 'Scaling from: 'w'x'h'.......'
  58.  
  59. /* ---- This is were we are going to scale..... ---- */
  60. /* ------------------------------------------------- */
  61. done='no'
  62. /* ---- Just halve it ---- */
  63. /* ----------------------- */
  64. if SpecX='50%' & SpecY='50%' then do
  65.     operator Halve
  66.     done='yes'
  67.     end
  68.  
  69. /* ---- Just testing if we could do ABS_SCALE ---- */
  70. /* ----------------------------------------------- */
  71. if datatype(SpecX)='NUM' & datatype(SpecY)='NUM' & done='no' then do
  72.     call Sizenmr SpecX SpecY
  73.     done='yes'
  74.     end
  75.  
  76. /* ---- Just testing if we could do PCT_SCALE ---- */
  77. /* ----------------------------------------------- */
  78. if datatype(SpecX)='CHAR' & datatype(SpecY)='CHAR' & done='no' then do
  79.     call Percent delstr(SpecX,length(SpecX)) delstr(SpecY,length(SpecY))
  80.     done='yes'
  81.     end
  82.  
  83. /* ---- Mixed use of ABS_SCALE and PCT_SCALE ---- */
  84. /* ---------------------------------------------- */
  85. if datatype(SpecX)='NUM' & done='no' then do
  86.     call Sizenmr SpecX h
  87.     call percent 100 specY
  88.     done='yes'
  89.     end
  90. if datatype(SpecX)='CHAR' & done='no' then do
  91.     call Percent delstr(SpecX,length(SpecX)) 100
  92.     XSIZE
  93.     w=ADPRO_RESULT
  94.     call Sizenmr w SpecY
  95.     done='yes'
  96.     end
  97.  
  98. XSIZE
  99. w=ADPRO_RESULT
  100. YSIZE
  101. h=ADPRO_RESULT
  102. say 'Scaled to: 'w'x'h'........'
  103.  
  104. SFORMAT "IFF"
  105. if RC ~=0 then do
  106.     say 'Unable to select the IFF Saver.'
  107.     say 'See Ya...'
  108.     say ''
  109.     exit
  110.     end
  111.  
  112. /* ----      If the loaded image was not 24Bit,        ---- */
  113. /* ---- we'll have to adjust he palette to the colors, ---- */
  114. /* ----         and then render a new image            ---- */
  115. /* -------------------------------------------------------- */
  116. if dontrender='nok' then do
  117.     palette=0
  118.     render_type
  119.     colors=ADPRO_RESULT
  120.     if colors='HAM' then palette=16
  121.     if colors='HAM8' then palette=64
  122.     if palette=0 then palette=colors
  123.     ptotal palette
  124.     pused palette
  125.     EXECUTE
  126.     if RC~=0 then do
  127.         say 'Execute failed.'
  128.         say 'See Ya.......'
  129.         say ''
  130.         exit
  131.         end
  132.     savemode='IMAGE'
  133.     say 'Saving IMAGE 'colors'......'
  134.     end
  135.     else do
  136.         savemode='RAW'
  137.         say 'Saving RAW......'
  138.          end
  139.  
  140. filename=filename'.new'
  141. SAVE filename savemode
  142. if RC~=0 then do
  143.     say 'Problems while saving: NOT SAVED.'
  144.     say 'See Ya...'
  145.     end
  146. say ''
  147. exit
  148.  
  149.  
  150. /* ---- This is a little procedure for ABS_SCALE ---- */
  151. /* -------------------------------------------------- */
  152. SizeNmr:
  153.     parse arg SizeX SizeY
  154.     ABS_SCALE SizeX SizeY
  155.     if RC~=0 then do
  156.         say 'SCALE failed!'
  157.         say 'See Ya.....'
  158.         say ''
  159.         exit
  160.         end
  161.     return SizeX SizeY
  162.  
  163. /* ---- This is a little procedure for PCT_SCALE ---- */
  164. /* -------------------------------------------------- */
  165. Percent:
  166.     parse arg PercX PercY
  167.     PCT_SCALE PercX PercY
  168.     if RC~=0 then do
  169.         say 'SCALE failed!'
  170.         say 'See Ya.....'
  171.         say ''
  172.         exit
  173.         end
  174.     return PercX PercY
  175.