home *** CD-ROM | disk | FTP | other *** search
- /*
- * $VER: Snapshot 2.0.0 (19.8.94)
- *
- * Arexx program for the ImageFX image processing system.
- * Written by Thomas Krehbiel (from an idea by Bob Fisher)
- *
- * Take a directory of images, and reduce them to small thumbnail
- * snapshot images, and place them on one or more images which are
- * then saved out somewhere. This script also renders the snapshot
- * pages down to 16 color images for easy viewing. We can also
- * optionally stamp the name of the file at the bottom of each
- * thumbnail.
- *
- * By default we make 640x400 24-bit renderings with a 5x5 grid
- * of thumbnails.
- *
- */
-
- OPTIONS RESULTS
-
- SIGNAL ON BREAK_C
-
- GetMain
- IF rc = 0 THEN DO
- RequestResponse 'The current buffer will be destroyed.'
- IF rc ~= 0 THEN EXIT
- END
-
- KillBuffer Force
-
- /* retreive defaults from any previous useage of this macro */
- defsdir = GETCLIP('IFX_Snapshot_DefSource')
- defspat = GETCLIP('IFX_Snapshot_DefSrcPat')
- defdest = GETCLIP('IFX_Snapshot_DefDest')
- numcols = GETCLIP('IFX_Snapshot_Colors')
- gridsize = GETCLIP('IFX_Snapshot_Grid')
- width = GETCLIP('IFX_Snapshot_Width')
- height = GETCLIP('IFX_Snapshot_Height')
- labelit = GETCLIP('IFX_Snapshot_Labels')
- grey = GETCLIP('IFX_Snapshot_Grey')
- keepext = GETCLIP('IFX_Snapshot_KeepExt')
- saveform = GETCLIP('IFX_Snapshot_SaveForm')
- saveopt = GETCLIP('IFX_Snapshot_SaveOpts')
- spacing = GETCLIP('IFX_Snapshot_Spacing')
- enhance = GETCLIP('IFX_Snapshot_Enhance')
- doback = GETCLIP('IFX_Snapshot_DoBack')
- backdrop = GETCLIP('IFX_Snapshot_Backdrop')
- doshadow = GETCLIP('IFX_Snapshot_DoShadow')
- red = GETCLIP('IFX_Snapshot_Red')
- green = GETCLIP('IFX_Snapshot_Green')
- blue = GETCLIP('IFX_Snapshot_Blue')
-
- /* some defaults - change as desired */
-
- IF defsdir = '' THEN defsdir = "" /* default source dir */
- IF defspat = '' THEN defspat = "#?" /* default source pattern */
- IF defdest = '' THEN defdest = "RAM:.Snap" /* default dest files */
- IF numcols = '' THEN numcols = 8 /* colors in renderings */
- IF gridsize = '' THEN gridsize = 5 /* thumbnail rows/cols */
- IF width = '' THEN width = 640 /* dest width */
- IF height = '' THEN height = 400 /* dest height */
- IF labelit = '' THEN labelit = 1 /* label each thumbnail? */
- IF grey = '' THEN grey = 0 /* convert to greyscale? */
- IF keepext = '' THEN keepext = 1 /* keep file extensions? */
- IF saveform = '' THEN saveform = 'ILBM' /* save format */
- IF spacing = '' THEN spacing = 10 /* spacing between nails */
- IF enhance = '' THEN enhance = 1 /* enhance nails? */
- IF doback = '' THEN doback = 0 /* do backdrop texture? */
- IF backdrop = '' THEN backdrop = 'Textures/Leather' /* backdrop texture */
- IF doshadow = '' THEN doshadow = 1 /* do shadowed nails? */
- IF red = '' THEN red = 128
- IF green = '' THEN green = 100
- IF blue = '' THEN blue = 140
-
- RequestFile '"Source Directory:"' '"'defsdir'"' '" "' '"'defspat'"'
- IF rc ~= 0 THEN EXIT /* cancelled */
- sourcedir = filereq.path
- sourcepat = filereq.pat
-
- /* get a directory and pattern and grid size */
-
- Gadget.1 = 'I/190/19/Rows & Columns:/'gridsize
- Gadget.2 = 'I/190/34/Spacing:/'spacing
-
- Gadget.3 = 'I/190/50/Width (Pixels):/'width
- Gadget.4 = 'I/190/65/Height (Pixels):/'height
- Gadget.5 = 'T/190/80/60/0/Save Format:/'saveform
- Gadget.6 = 'T/190/95/60/0/Save Options:/'saveopt
- Gadget.7 = 'D/162/110/100/Colors:/9/2/4/8/16/32/64/128/254/24-Bit/'numcols
- Gadget.8 = 'T/110/125/140/1/Basename:/'defdest
-
- Gadget.9 = 'X/300/20/Convert To Greyscale?/'grey
- Gadget.10 = 'X/300/34/Label Thumbnails?/'labelit
- Gadget.11 = 'X/300/46/Keep Extensions?/'keepext
- Gadget.12 = 'X/300/60/Enhance Thumbnails?/'enhance
- Gadget.13 = 'X/300/72/Create Shadows?/'doshadow
- Gadget.14 = 'X/300/86/Create Backdrop?/'doback
-
- Gadget.15 = 'T/300/98/180/0/ /'backdrop
-
- Gadget.16 = 'J/300/125/35/R:/'red
- Gadget.17 = 'J/370/125/35/G:/'green
- Gadget.18 = 'J/440/125/35/B:/'blue
-
- ComplexRequest '"Snapshot V2.0 Options:"' 18 Gadget 520 165
- IF rc ~= 0 THEN EXIT
-
- gridsize = result.1
- spacing = result.2
- width = result.3
- height = result.4
- saveform = result.5
- saveopt = result.6
- numcols = result.7
- destbase = result.8
- grey = result.9
- labelit = result.10
- keepext = result.11
- enhance = result.12
- doshadow = result.13
- doback = result.14
- backdrop = result.15
- red = result.16
- green = result.17
- blue = result.18
-
- CALL SETCLIP('IFX_Snapshot_DefSource', sourcedir)
- CALL SETCLIP('IFX_Snapshot_DefSrcPat', sourcepat)
- CALL SETCLIP('IFX_Snapshot_DefDest', destbase)
- CALL SETCLIP('IFX_Snapshot_Colors', numcols)
- CALL SETCLIP('IFX_Snapshot_Grid', gridsize)
- CALL SETCLIP('IFX_Snapshot_Width', width)
- CALL SETCLIP('IFX_Snapshot_Height', height)
- CALL SETCLIP('IFX_Snapshot_Labels', labelit)
- CALL SETCLIP('IFX_Snapshot_Grey', grey)
- CALL SETCLIP('IFX_Snapshot_KeepExt', keepext)
- CALL SETCLIP('IFX_Snapshot_SaveForm', saveform)
- CALL SETCLIP('IFX_Snapshot_SaveOpts', saveopt)
- CALL SETCLIP('IFX_Snapshot_Spacing', spacing)
- CALL SETCLIP('IFX_Snapshot_Enhance', enhance)
- CALL SETCLIP('IFX_Snapshot_DoBack', doback)
- CALL SETCLIP('IFX_Snapshot_Backdrop', backdrop)
- CALL SETCLIP('IFX_Snapshot_DoShadow', doshadow)
- CALL SETCLIP('IFX_Snapshot_Red', red)
- CALL SETCLIP('IFX_Snapshot_Green', green)
- CALL SETCLIP('IFX_Snapshot_Blue', blue)
-
-
- SELECT
- WHEN numcols = 0 THEN numcols = 2
- WHEN numcols = 1 THEN numcols = 4
- WHEN numcols = 2 THEN numcols = 8
- WHEN numcols = 3 THEN numcols = 16
- WHEN numcols = 4 THEN numcols = 32
- WHEN numcols = 5 THEN numcols = 64
- WHEN numcols = 6 THEN numcols = 128
- WHEN numcols = 7 THEN numcols = 256
- WHEN numcols = 8 THEN numcols = 'DEEP'
- OTHERWISE EXIT 0
- END
-
-
- thumbxspace = (width / gridsize)
- thumbyspace = ((height-20) / gridsize)
-
- thumbwidth = thumbxspace - spacing
- thumbheight = thumbyspace - spacing
-
- picnum = 1
-
-
- DO FOREVER
-
- /* build list of files to process */
-
- ECHO 'List >RAM:__Snap_TEMP__ NOHEAD LFORMAT='sourcedir'/%s' sourcedir 'PAT' sourcepat
- ADDRESS COMMAND 'List >RAM:__Snap_TEMP__ NOHEAD LFORMAT='sourcedir'/%s' sourcedir 'PAT' sourcepat
- IF rc ~= 0 THEN DO
- RequestNotify 'Problem scanning the source directory.'
- EXIT
- END
-
- /* sort alphabetically */
- ADDRESS COMMAND 'Sort RAM:__Snap_TEMP__ TO RAM:__Snap_LIST__'
- ADDRESS COMMAND 'Delete RAM:__Snap_TEMP__ QUIET'
-
- /* okay, process the files */
-
- IF ~OPEN(infile, 'RAM:__Snap_LIST__', 'Read') THEN DO
- RequestNotify 'Problem reading sorted file list - no files found?'
- EXIT
- END
-
- IF numcols ~= 'DEEP' THEN DO
- SetRender 'Amiga'
- Render Mode HIRES LACE
- Render Colors numcols
- Render Dither 1 2 0 /* floyd zigzag none */
- END
-
- Requesters Off /* disable error requesters */
- Redraw Off
- Undo Off
-
- Blend 100
- EdgeMode Normal
- Transparency Include 0 Exclude 0
-
- /* force new buffer the first time: */
- x = 999
- y = 999
- pagenum = 0
-
- DO WHILE ~EOF(infile)
-
- x = x + 1
- IF x >= gridsize THEN DO
- x = 0
- y = y + 1
- IF y >= gridsize THEN DO
-
- GetMain
- IF rc = 0 THEN DO
- IF numcols ~= 'DEEP' THEN DO
- Render Go
- SaveRenderedAs saveform destbase||RIGHT('000'||picnum,3) saveopt
- Render Close
- END
- ELSE DO
- SaveBufferAs saveform destbase||RIGHT('000'||picnum,3) saveopt
- END
- END
-
- pagenum = pagenum + 1
- picnum = picnum + 1
-
- IF grey THEN CreateBuffer width height 'GREY' red green blue FORCE
- ELSE CreateBuffer width height red green blue FORCE
-
- IF doback THEN DO
- Hook ApplyTexture backdrop 0 80 Shiny
- END
-
- title = sourcedir||' ('||pagenum||')'
-
- ActiveColor 0 /* usually black */
- Text 'topaz.font' 11 100 BOLD title
- Blend 50
- Point width%2+2 9
- Blend 100
- KillBrush
-
- ActiveColor 1 /* usually white */
- Text 'topaz.font' 11 100 BOLD title
- Point width%2 7
- KillBrush
-
- Redraw
- y = 0
-
- END
- END
-
- nextfile = READLN(infile)
- IF nextfile = "" THEN ITERATE
- Message nextfile
-
- xp = x*thumbxspace
- yp = y*thumbyspace+20
-
- LoadBrush nextfile 1 /* 1 in case we find an anim */
-
- IF rc = 0 THEN DO
-
- GetBrush
- PARSE VAR result name w h d ax ay .
-
- IF grey THEN DO
- IF (d > 1) THEN Color2Grey Luma
- END
-
- IF (ax > 0) THEN h = h * ay % ax
-
- IF (w > h) THEN DO
- nw = thumbwidth
- nh = h * nw % w
- IF (nh > thumbheight) THEN nh = thumbheight
- END
- ELSE DO
- nh = thumbheight
- nw = w * nh % h
- IF (nw > thumbwidth) THEN nw = thumbwidth
- END
-
- IF (w < thumbwidth) & (h < thumbheight) THEN
- Scale nw nh FAST
- ELSE
- Scale nw nh
-
- /* a little enhancement - makes 'em stand out more */
- IF enhance THEN DO
- Contrast 10
- UnsharpMask 8
- END
-
- IF doshadow THEN DO
- DrawMode Darken
- EdgeMode FeatherIn 4
- Point xp+thumbxspace%2+4 yp+thumbyspace%2+4
- DrawMode Normal
- EdgeMode Normal
- END
-
- Point xp+thumbxspace%2 yp+thumbyspace%2
- KillBrush
-
- END
-
- IF labelit THEN DO
-
- /* strip path and optionally the trailing extension */
- n = LASTPOS('/', nextfile) + 1
- label = SUBSTR(nextfile,n)
- IF ~keepext THEN DO
- n = 1
- DO WHILE n > 0
- n = LASTPOS('.', label)
- IF (n > 0) THEN label = LEFT(label,n-1)
- END
- END
-
- ActiveColor 0 /* usually black */
- Text 'topaz.font' 8 100 label
- Blend 50
- Point xp+thumbxspace%2+1 yp+thumbheight-6
- Blend 100
- KillBrush
-
- ActiveColor 1 /* usually white */
- Text 'topaz.font' 8 100 label
- Point xp+thumbxspace%2 yp+thumbheight-7
- KillBrush
-
- END
-
- Redraw xp yp thumbxspace thumbyspace
-
- END
-
- IF (x > 0) | (y > 0) THEN DO
- IF numcols ~= 'DEEP' THEN DO
- Render Go
- SaveRenderedAs saveform destbase||RIGHT('000'||picnum,3) saveopt
- Render Close
- END
- ELSE DO
- SaveBufferAs saveform destbase||RIGHT('000'||picnum,3) saveopt
- END
- END
-
- RequestResponse 'Please insert next volume.'
- IF rc ~= 0 THEN LEAVE
-
- CALL CLOSE(infile)
-
- KillBuffer Force
-
- END
-
- BREAK_C:
-
- CALL CLOSE(infile)
-
- ADDRESS COMMAND 'Delete RAM:__Snap_LIST__ QUIET'
-
- KillBrush
- Undo On
- Redraw On
- Requesters On
-
- EXIT
-
-