home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Amiga / Internet / Web / thumbnail.lha / thumbnail.rexx < prev   
OS/2 REXX Batch file  |  1998-05-05  |  4KB  |  122 lines

  1. /* Taken from original script by Matthias Finger
  2.    Modified by Sebastien Boisvert for general use */
  3.  
  4. addlib("rexxsupport.library",0,-30,0)
  5.  
  6. BORDER=1                                          /* border width for our table */
  7. GFXCON="work:images/gfxcon/GfxCon_68020 "         /* Path for GfxCON (SPACE reqiered) */
  8. FORMAT="GIF"                                      /* Format for destination pictiure  */
  9. /* FORMAT="JPEG" */
  10. QUALITY=85                                  /* Quality for jpeg destination     */
  11. VERBOSE=0                                   /* Verbose: 1=OFF, 0=ON             */ 
  12. OTHER=""                                    /* Other options for GfxCON         */
  13.  
  14. /* ------- You should know what you do, if you change anything below -------- */
  15. Options results
  16. signal on error           /* Setup a place for errors to go */
  17. signal on BREAK_C
  18.  
  19. if arg()==0 then exit
  20.  
  21. PARSE ARG pattern sizex sizey dest res . /* get pattern of files to scale (not wildcards), X Y sizes, destination directory for thumbnails*/
  22.                                          /* and optional intended X resolution */
  23.  
  24. pattern="."||upper(pattern)           /* put proper extensions on the pattern and format; remove 'E' form 'JPEG' */
  25. form="."||format
  26. form=compress(form,"E")
  27.  
  28. if ~exists(dest) then 
  29.  call  makedir(dest)           /* check if directory exists and create it if not */
  30.  
  31. dest=dest||"/"
  32.  
  33. dir = showdir('','f',',')    /* make comma seperated list of files in directory */
  34.  
  35. say "Checking for new pictures..."
  36.  
  37. do while dir ~=""
  38. parse var dir name "," dir .     /* get next filename from list */
  39. name=upper(name)
  40. parse var name file (pattern) . /* look for the pattern (removing it from final result */
  41. if file == name then iterate    /* is final name same as filename? If so, not a matching file and skip this loop */
  42.  
  43. if exists(dest||"t_"||file||FORM) then iterate    /* skip if thumbnail already exists */
  44.   call pragma("STACK",22000)
  45.   comm = GFXCON||file||pattern
  46.    IF(VERBOSE==1) THEN
  47.      comm = comm||' >NIL:'
  48.   comm = comm||' TO '||dest||'t_'||file||form||' FORMAT 'FORMAT
  49.    IF (UPPER(FORM)=="JPEG") THEN DO
  50.     comm = comm||' QUALITY 'QUALITY||' '
  51.   END
  52.   comm = comm||' '||OTHER||' BOXFIT '||sizex||' '||sizey
  53.   ADDRESS COMMAND comm                                     /* make up command line and execute it */
  54. END
  55.  
  56. /* create thumbnail table */
  57.  
  58. files=0
  59.  
  60. if res="" then res=800  /* resolution; 800 for X default */
  61.  
  62. dir = showdir(dest,"f",",")
  63. do while dir ~=""                      /* get number of files */
  64. parse var dir name "," dir .
  65. files=files+1
  66. end
  67. dir = showdir(dest,"f",",")
  68.  
  69. if files>0 then do
  70. max = res % ((border*2)+sizex+3)    /* get maximum number of thumbnails that fit on one row */
  71.  
  72. if (files//max) ~=0  then  do        /* if all thumbnails don't fit all equally */
  73.   mostremainders=files//max
  74.      do temp=max to 2 by -1                       /* figure out how many across will produce the least */
  75.         if files//temp > mostremainders then do
  76.            mostremainders=files//temp
  77.            max=temp
  78.         end
  79.      end
  80. end
  81.  
  82. rows = files%max                    
  83. if files//max ~=0 then rows=rows+1
  84.  
  85. file="output"
  86. if open(file,"t_index.html","W") then do
  87.  
  88. say "Creating index page..."                      /* Create the index page */
  89.  
  90.   call writeln(file,"<HTML>")                     /* Put the code in */
  91.   call writeln(file,"<BODY>")
  92.   call writeln(file,"<CENTER>")
  93.   call writeln(file,"<TABLE BORDER="||border||">")
  94.  
  95. do rows                                           /* do the tables */
  96. call writeln(file,"<TR>")
  97.   do max
  98.      parse var dir name "," dir .
  99.      if name="" then iterate
  100.      name=upper(name)
  101.      parse var name "T_" name (form) .
  102.      call writeln(file,"   <TD><A HREF="||name||pattern||"><IMG SRC="||dest||"t_"||name||form||" ALT="||name||pattern||" WIDTH="||sizex||" HEIGHT="||sizey||"></A></TD>")
  103.   end
  104.   call writeln(file,"</TR>")
  105.   end
  106.  call writeln(file,"</CENTER>")             /* close off the HTML document */
  107.  call writeln(file,"</TABLE>")
  108.  call writeln(file,"</BODY>")
  109.  call writeln(file,"</HTML>")
  110.  close (file)
  111.  end
  112. else
  113.   say "Can't open ouput file!!!"
  114. end
  115.  
  116. exit
  117.  
  118.  
  119. error:
  120. BREAK_C:
  121.    exit
  122.