/* * $VER: Snapshot 1.04.00 (24.9.92) * * 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 16-color renderings with a 5x5 grid * of thumbnails. * */ OPTIONS RESULTS SIGNAL ON BREAK_C /* 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') /* 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 = 16 /* 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? */ /* get a directory and pattern and grid size */ RequestFile '"Source Directory:"' defsdir DIRONLY IF rc ~= 0 THEN EXIT /* cancelled */ sourcedir = result RequestString '"File Pattern:"' defspat IF rc ~= 0 THEN EXIT /* cancelled */ sourcepat = result Gadget.1 = 'I/190/18/Rows & Columns:/'gridsize Gadget.2 = 'I/190/35/Output Width (Pixels):/'width Gadget.3 = 'I/190/50/Output Height (Pixels):/'height Gadget.4 = 'I/190/67/Output Colors:/'numcols Gadget.5 = 'X/30/85/Label Thumbnails?/'labelit Gadget.6 = 'X/30/97/Keep Extensions In Labels?/'keepext Gadget.7 = 'X/30/109/Convert To Greyscale?/'grey ComplexRequest '"Thumbnail Snapshot Options:"' 7 Gadget 280 142 IF rc ~= 0 THEN EXIT gridsize = result.1 width = result.2 height = result.3 numcols = result.4 labelit = result.5 keepext = result.6 grey = result.7 /* separate path into dir and file components */ n = LASTPOS('/', defdest) l = n - 1 IF n = 0 THEN DO n = LASTPOS(':', defdest) l = n END IF n ~= 0 THEN DO defdest.file = SUBSTR(defdest, n+1) defdest.dir = LEFT(defdest, l) END ELSE DO defdest.file = path defdest.dir = '' END RequestFile '"Output Snapshot Basename:"' defdest.dir defdest.file IF rc ~= 0 THEN EXIT /* cancelled */ destbase = result /* 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 */ pagenum = 1 x = 0 y = 0 thumbwidth = width / gridsize thumbheight = height / gridsize IF ~OPEN(infile, 'RAM:__Snap_LIST__', 'Read') THEN DO RequestNotify 'Problem reading sorted file list - no files found?' EXIT END SetRender 'Amiga' Render Mode HIRES LACE Render Colors numcols Render Dither 1 2 0 /* floyd zigzag none */ IF grey THEN CreateBuffer width height 'GREY' FORCE ELSE CreateBuffer width height FORCE Requesters Off /* disable error requesters */ Redraw Off Undo Off Blend 100 EdgeMode Normal Transparency Include 0 Exclude 0 DO WHILE ~EOF(infile) nextfile = READLN(infile) IF nextfile = "" THEN ITERATE Message nextfile LoadBrush nextfile 1 /* 1 in case we find an anim */ IF rc ~= 0 THEN ITERATE 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-2 nh = h * nw % w IF (nh > thumbheight-2) THEN nh = thumbheight-2 END ELSE DO nh = thumbheight-2 nw = w * nh % h IF (nw > thumbwidth-2) THEN nw = thumbwidth-2 END IF (w < thumbwidth-2) & (h < thumbheight-2) THEN Scale nw nh FAST ELSE Scale nw nh /* a little enhancement - makes 'em stand out more */ Contrast 10 Sharpen 40 Point x*thumbwidth+thumbwidth%2 y*thumbheight+thumbheight%2 KillBrush IF labelit THEN DO /* strip path and optionally the trailing extension */ n = LASTPOS('/', nextfile) + 1 label = SUBSTR(nextfile,n) IF ~keepext THEN DO n = LASTPOS('.', label) IF (n > 0) THEN label = LEFT(label,n-1) END ActiveColor 0 /* usually black */ Text 'topaz.font' 8 100 label Point x*thumbwidth+thumbwidth%2+1 y*thumbheight+thumbheight-6 KillBrush ActiveColor 1 /* usually white */ Text 'topaz.font' 8 100 label Point x*thumbwidth+thumbwidth%2 y*thumbheight+thumbheight-7 KillBrush END Redraw x*thumbwidth y*thumbheight thumbwidth thumbheight x = x + 1 IF x >= gridsize THEN DO x = 0 y = y + 1 IF y >= gridsize THEN DO Render Go SaveRenderedAs 'ILBM' destbase||RIGHT('000'||pagenum,3) Render Close pagenum = pagenum + 1 IF grey THEN CreateBuffer width height 'GREY' FORCE ELSE CreateBuffer width height FORCE Redraw y = 0 END END END IF (x > 0) | (y > 0) THEN DO Render Go SaveRenderedAs 'ILBM' destbase||RIGHT('000'||pagenum,3) Render Close END BREAK_C: CALL CLOSE(infile) ADDRESS COMMAND 'Delete RAM:__Snap_LIST__ QUIET' KillBrush Undo On Redraw On Requesters On 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) EXIT