
Thumbnail 1.9 by Sébastien Boisvert
===================================

Purpose
-------

This Arexx program will create thumbnails, and an HTML document table using the 
thumbnails as the images, with its links pointing to the original full image.

Requirements
------------

You'll need ARexx, and the GfxCon program from Aminet (gfx/conv/gfxcon.lha)
The program also requires RexxArp library (util/rexx/ral3p3.lha) and RexxDosSupport
library (util/rexx/rexxdossupport.lha)

Installation
------------

Install the required libraries in your LIBS: path. GfxCon can be put anywhere, and
Thumbnail.rexx should preferably be in the REXX: path.

Usage
-----

runs from the Shell, with the following AmigaDOS style arguments (defaults values
listed are the original defaults):

rx thumbnail SIZEX/N SIZEY/N DEST/K PERPAGE/N RES/N PATTERN/K PICPAGE/S

SIZEX         are the sizes for the thumbnail. GfxCon proportionally scales the 
SIZEY         thumbnails to fit in these resolutions. Default: 100

DEST          is the directory in which the thumbnails will be placed 
              (no '/') Default: thumb

PERPAGE       this will indicate how many thumbnails to create per page. It will
              create as many pages as needed to index all images. Defaults to 0,
              which means to create 1 table with all images

RES           is the intended X resolution for the page ('800' for 800x600, 
              '1024' for 1024x768, etc...) Default: 800

PATTERN       standard AmigaDOS pattern used to match files. Default: ~#?.(htm#?|info)

PICPAGE       if specified will create an HTML page for each picture (see below)

The program also has some setting which you may change; they are all in the 
first few lines of the code:

The pattern to match/exclude; can be any standard AmigaDOS pattern
The path and name of the program 'GfxCon' (you'll probably need to change this)
The format for the thumbnails (gif or jpeg - must be lower case!)
The border width for the table
The quality for JPEG output if applicable
The verbose switch to see GfxCon's output while processing images
The base reference tag to include in the index/picture page(s)
A header and footer string to be inserted in the index/picture page(s) (normal HTML)
And last, the defaults for the different arguments.

Operation
---------

You must run the program while currently in the directory where the pictures to be 
thumbnailed are.

Once given its arguments, the program will proceed to scan all files in the current 
directory. It will also create the thumbnail directory if it doesn't exist.

When a file is found, it proceeds to make a thumbnail, name it to "t_<name>" plus 
the proper extension, and save it to the thumbnail directory. It will then repeat 
for all other matching files.

Once all the files are done, it will create the table for the HTML page putting the
files in alphabetical order. It will first calculate how many thumbnails will fit 
in the given  page resolution with the given thumbnail resolution. It will then 
verify and adjust as necessary this number to create a table with as few blanks as 
possible in the last row.

The program will  also put the thumbnail size attributes in the table to avoid
'stretching' of the thumbnail to fill the entire cell. Please note that since the
maximum width of the table is calculated using the given SIZEX argument, it may 
happen that the final width of the table be much smaller than the maximum width of 
the window if most thumbnail are thinner than high. This may result in space on the 
page in which more thumbnails could've fit. In these cases, try specifiying a higher 
resolution to fill the gaps.

If PICPAGE is specified, each picture will get its own page called '<picture name>.html' that
contains an image tag to show the picture (the code will also contain the proper WIDTH and
HEIGHT tags) centered on the screen, and a 'Previous' and 'Next' link (where appropriate)
that allows the user to step through each picture in sequence rather than having to refer
back to the index each time. It will also have link(s) to the index page(s).

Once done, each table is saved as stand-alone HTML page with the name 't_index<#>.html'
in the current directory, which can be directly pasted into an existing document. When
creating multiple pages, each page will contain an index to the all other pages. If PICPAGE
is specified, the picture link will refer to the picture's page, rather than the picture
itself.

Adding pictures or changing resolution later on
-----------------------------------------------

If you wish to add pictures, or remake the table for a different resolution, simply 
run the script again using the same arguments as the last run, where appropriate,
and the program will make thumbnails for new files, and skip those that already
have thumbnails. It will then create new table page(s).

If you wish to change the resolution of the thumbnails, you'll have to erase the 
thumbnail directory and have them all redone again.

Notes
-----

-The program assumes all filenames contain only one extension (ie. filename.jpg,
 not filename.1.jpg)

-The directory of files to be scanned should only contain graphic files. Other file
 types should be excluded using the PATTERN variable. Foreign files may cause GfxCon
 to crash. YOU HAVE BEEN WARNED!

-If a foreign file is encountered, and you have the verbose option on, don't concern 
 yourself with possible error messages from GfxCon; the file will be skipped

-If for any reason GfxCon can't load a picture to create a thumbnail, you will see
 a warning when it happens. The table will still have a cell for the picture, there
 just won't be a thumbnail for it.
 
-If you move the location of the index file, you should add the "<BASE HREF>" 
 attribute in the file in order to have the files properly referenced.

 
History
-------
1.0  Initial release

1.1  Added thumbnail size attributes in index page

1.2  Fixed bug for quality selection for JPG thumbnails
     Eliminated pattern requirement - now scans all files in directory
     All references in index files keep the same case as the original files (for those 
     wonderful UN*X servers :)

1.3  Better file pattern matching using RexxArp library

1.4  Fixed bug with upper case extension in index file
     Added some error checking if GfxCon couldn't process a file
     Now using RexxArp for all directory functions - old way
     resulted in the wrong name being associated with a file
     Now also properly handles filenames containing spaces
     
  Thanks go to Colin Thompson for beta testing the last two revisions
  
1.5  Added AmigaDOS style argument parsing

1.6  Program now creates the table with files in alphabetical order  

1.71 Small bug fix in usage information
     Changed email and fixed file reference for required libraries
     No longer need a space at the end of the GFXCON variable
     Added PATTERN as optional argument for pattern matching
     Usage section now displays the program's current defaults (not the original ones)
     Will now exit properly if no files are available for processing
     Put base reference tag line as user settable variable

1.8  Bug fix in sorting routine (would cause duplicates and omissions in tables)
     Fixed BASE HREF tag for compatibility; now blank, user option
     Added Header and Footer variables to allow automatic insertion of code in page(s)
     
1.9  Added PICPAGE option to create individual picture pages that can be browsed in sequence
     Improved the program's grammar :)
     
If you notice any bugs, have any suggestions or have any modification you'd like to send,
my email address is sboisvert@softhome.net

Sébastien Boisvert
