head 1.7; access; symbols; locks alexis:1.7; strict; comment @# @; 1.7 date 98.01.28.14.58.03; author alexis; state Exp; branches; next 1.6; 1.6 date 97.10.05.13.58.57; author alexis; state Exp; branches; next 1.5; 1.5 date 96.10.28.12.41.59; author alexis; state Exp; branches; next 1.4; 1.4 date 96.10.28.11.30.34; author alexis; state Exp; branches; next 1.3; 1.3 date 96.10.04.20.27.37; author alexis; state Exp; branches; next 1.2; 1.2 date 95.10.16.20.59.36; author alexis; state Exp; branches; next 1.1; 1.1 date 95.10.16.20.50.56; author alexis; state Exp; branches; next ; desc @M A K E T H U M B N A I L S @ 1.7 log @millions of differences! principally these involve using the new messaging functions, sorting out a few minor bugs which stopped it working totally. @ text @#!SCRIPTSHELLCMD_MARKER ############################################################################## # # # CONFIGURABLE THINGS ... # # # ############################################################################## # First off, is the shell after the '#!' at the top of the file valid? It # must be the full pathname of a shell that understands shell functions. # The suggested order of preference is full/path/of/ksh, full/path/of/bash. # If you want to use some non-standard initial verbosity, then set it # here, otherwise a sensible default is set elsewhere. # VERBOSE_LEVEL=3 # provide extra information # VERBOSE_LEVEL=0 # provide no messages at all # VERBOSE_LEVEL=1000 # provide all debug DFLT_THN_MODE=1024x768_5x6 DFLT_THP_COL_BG=black DFLT_THT_COL_BG=white DFLT_THP_QLT_PC=80 DFLT_FIL_MODE=normal DFLT_VERBOSE_LEVEL=2 TMPDIR=/var/tmp ############################################################################## # # # THE AUTHOR MAY CHANGE THINGS BELOW HERE, BUT THE CONFIGUROR SHOULD NOT! # # # ############################################################################## PROGNAME=`basename $0` # $Id: shell-script,v 1.1 1997/10/26 22:44:12 alexis Exp $ VERSION="PATCHLEVEL_MARKER" OUTNAME="index" MTNTMPDIR=$TMPDIR/$PROGNAME.$$ ############################################################################## # # # MAIN FUNCTION # # # # This function processes options and then performs whatever this script is # # supposed to do. It is called from the very end of the script. # # # ############################################################################## main() { THN_MODE=$DFLT_THN_MODE FIL_MODE=$DFLT_FIL_MODE THP_COL_BG=$DFLT_THP_COL_BG THT_COL_BG=$DFLT_THT_COL_BG THP_QLT_PC=$DFLT_THP_QLT_PC VERBOSE_LEVEL=$DFLT_VERBOSE_LEVEL # Process options - author to add extra options! while [ "X$1" != X ]; do case "$1" in -V) if expr "$VERSION" : 'P.*R$' > /dev/null; then warning "this is a development version; use 'ident' for version information" exit 1 else echo "$PROGNAME version $VERSION" exit 0 fi ;; -d) [ "X$2" = X ] && usage VERBOSE_LEVEL=$2 shift ;; -v) VERBOSE_LEVEL=3 ;; -r) FIL_MODE=recurse ;; -m) [ "X$2" != X ] || usage THN_MODE=$2 shift ;; -*) usage ;; *) break ;; esac shift done [ $FIL_MODE = normal -a "X$1" = X ] && usage set_mode_vars $THN_MODE rm -fr $MTNTMPDIR trap "echo 'cleaning up, please wait ...'; rm -fr $MTNTMPDIR; exit 1" 1 2 15 mkdir $MTNTMPDIR ########################################################################### # # Create blank title and picture of maximum sizes # ########################################################################### info "creating blank thumbnail ..." pbmmake -$THP_COL_BG $THP_WDT_PXL $THP_HGT_PXL > $MTNTMPDIR/blank-pic.pbm info "creating blank title ..." pbmmake -$THT_COL_BG $THP_WDT_PXL $THT_HGT_PXL > $MTNTMPDIR/blank-tit.pbm case $FIL_MODE in normal) process $OUTNAME "$*" ;; recurse) OLD_PWD=`pwd` find ${*:-.} -type f | grep -v '.xvpics' | sed 's/^\(.*\)\/[^\/][^\/]*$/\1/' | sort -u | while read DIR; do info "recursing into $DIR ..." cd $DIR if [ -f index0.jpg ]; then info "index0.jpg exists" else process $OUTNAME * fi cd $OLD_PWD done ;; esac } set_mode_vars() { case $THN_MODE in 1024x768_5x6) IDP_HGT_THN=5 IDP_WDT_THN=6 THP_WDT_PXL=170 THP_HGT_PXL=123 THT_HGT_PXL=29 IDT_HGT_PXL=29 IDT_WDT_PXL=984 ;; *) error "invalid or unsupported mode" ;; esac } ############################################################################## # # # USAGE FUNCTION # # # # This function just displays a message indicating the correct usage # # syntax. It is called from whereever a usage syntax error is detected - # # mainly from the option and required argument processing code. # # # ############################################################################## usage() { { echo "Usage: $PROGNAME [ -d | -v ] [ -r ] [ -m x_x ] { | } ..." echo " $PROGNAME -V" } >&2 exit 2 } ############################################################################## # # # STATUS MESSAGE FUNCTIONS # # # # These functions display standard messages on the screen. These include # # error messages, warnings, informational messages and debug messages. # # # ############################################################################## internal() { echo "$PROGNAME: INTERNAL \ ERROR: $*" >&2 exit 2 } VERBOSE_LEVEL=${VERBOSE_LEVEL:-2} error() { FATAL=false while :; do case "$1" in -f) FATAL=true ;; -*) internal "invalid option to error() '$1'" ;; *) break ;; esac shift done if [ $VERBOSE_LEVEL -ge 1 ]; then if [ $FATAL = true ]; then echo "$PROGNAME: FATAL \ ERROR: $*" >&2 else echo "$PROGNAME: \ ERROR: $*" >&2 fi fi [ $FATAL = true ] && exit 1 return 1 } VERBOSE_LEVEL=${VERBOSE_LEVEL:-2} warning() { [ $VERBOSE_LEVEL -ge 2 ] && { echo "$PROGNAME: \ WARNING: $*" >&2; } return 0 } VERBOSE_LEVEL=${VERBOSE_LEVEL:-2} debug() { [ $VERBOSE_LEVEL -ge $1 ] && { shift; echo "$PROGNAME: \ DEBUG: $*" >&2; } return 0 } VERBOSE_LEVEL=${VERBOSE_LEVEL:-2} info() { [ $VERBOSE_LEVEL -lt 3 ] && return while :; do case "$1" in -*) internal "invalid option to info() '$1'" ;; *) break ;; esac shift done echo "$PROGNAME: \ INFO: $*" >&2 return 0 } # The method to suppress the newline displayed by the 'echo' command # varies from system to system. This function abstracts this variation. # Note that even if you don't use this command directly yourself, it *is* # called by other functions in this script. ############################################################################## # # # SUPPORT FUNCTIONS # # # ############################################################################## # This function should be called for each major command this script calls. # It tests that the command exists and is in a standard place. It should be # called *after* option processing. A simple example of how to use it is: # REMSH_CMD=`locatecmd remsh rsh ssh` || error -f "can't locate remote shell" # Note that 'whichcmd' is required by 'locatecmd'. locatecmd() { for POSSCMD in $*; do [ X`whichcmd $POSSCMD` != X ] && { echo $POSSCMD; return 0; } done return 1 } whichcmd() { for DIR in `echo $PATH | sed 's/:/ /g'`; do [ -x $DIR/$1 ] && { echo $DIR/$1; return 0; } done return 1 } process() { debug 4 "process: TOF" L_OUTNAME=$1 shift PROCFILES="$*" for FILE in $PROCFILES; do debug 4 "process: loop $FILE" FILEBASE=`basename $FILE` ####################################################################### # # Convert each picture to PNM format # ####################################################################### info "$FILE: converting image to PNM format ..." case $FILE in *.[jJ][Pp][Gg]|*.[Jj][Pp][Ee][Gg]) djpeg < $FILE ;; *.[Gg][Ii][Ff]) giftopnm < $FILE ;; *) error "$FILE: unknown file extension" ;; ####################################################################### # # Scale each picture to maximum allowable size without distorting # ####################################################################### esac | { info "$FILE: \ creating ${THP_WDT_PXL}x$THP_HGT_PXL thumbnail ..." pnmscale -xysize $THP_WDT_PXL $THP_HGT_PXL > $MTNTMPDIR/$FILEBASE-sclpic.pnm } ####################################################################### # # Put each picture in the middle of a maximum sized blank thumbnail # ####################################################################### info "$FILE: calculating required thumbnail offsets ..." set X `pnmfile $MTNTMPDIR/$FILEBASE-sclpic.pnm` X=$5; Y=$7 info "$FILE: centering thumbnail ..." pnmpaste $MTNTMPDIR/$FILEBASE-sclpic.pnm `expr \( $THP_WDT_PXL - $X \) / 2` `expr \( $THP_HGT_PXL - $Y \) / 2` $MTNTMPDIR/blank-pic.pbm > $MTNTMPDIR/$FILEBASE-pddpic.pnm ####################################################################### # # For each picture generate a title # ####################################################################### info "$FILE: generating title ..." pbmtext `echo $FILE | cut -c1-20` > $MTNTMPDIR/$FILEBASE-tit.pbm ####################################################################### # # Put each picture's title in middle of a maximum sized blank title # ####################################################################### info "$FILE: calculating title padding offsets ..." set X `pnmfile $MTNTMPDIR/$FILEBASE-tit.pbm` X=$5; Y=$7 info "$FILE: centering title ..." pnmpaste $MTNTMPDIR/$FILEBASE-tit.pbm `expr \( $THP_WDT_PXL - $X \) / 2` `expr \( $THT_HGT_PXL - $Y \) / 2` $MTNTMPDIR/blank-tit.pbm > $MTNTMPDIR/$FILEBASE-pddtit.pnm done IDXS=0 COLS=0 ROWS=0 ROWPICFILES= ROWTITFILES= IDXFILES= ########################################################################### # # Now combine all the correctly sized titles and thumbnails # ########################################################################### for FILE in $PROCFILES; do info "next: $FILE" FILEBASE=`basename $FILE` ROWPICFILES="$ROWPICFILES $MTNTMPDIR/$FILEBASE-pddpic.pnm" ROWTITFILES="$ROWTITFILES $MTNTMPDIR/$FILEBASE-pddtit.pnm" COLS=`expr $COLS + 1` ####################################################################### # # If we have six then combine the titles and thumbnails into a row # ####################################################################### if [ `expr $COLS / $IDP_WDT_THN` = 1 ]; then info "complete row: $ROWPICFILES - creating row $MTNTMPDIR/rowpic-$ROWS.pnm" pnmcat -lr -$THP_COL_BG $ROWPICFILES > $MTNTMPDIR/rowpic-$ROWS.pnm ROWPICFILES= pnmcat -lr -$THT_COL_BG $ROWTITFILES > $MTNTMPDIR/rowtit-$ROWS.pnm ROWTITFILES= IDXFILES="$IDXFILES $MTNTMPDIR/rowpic-$ROWS.pnm $MTNTMPDIR/rowtit-$ROWS.pnm" ROWS=`expr $ROWS + 1` COLS=0 fi ####################################################################### # # If we have five rows then combine them into an index # ####################################################################### if [ `expr $ROWS / $IDP_HGT_THN` = 1 ]; then info "complete index: $IDXFILES - creating index $MTNTMPDIR/$L_OUTNAME$IDXS.pnm" pnmcat -tb $IDXFILES | cjpeg -Q $THP_QLT_PC > $L_OUTNAME$IDXS.jpg IDXFILES= IDXS=`expr $IDXS + 1` ROWS=0 fi done ########################################################################### # # Now combine all outstanding pics that weren't enough to make a row # and pad to the end of the row with blanks # ########################################################################### if [ $COLS != 0 ]; then info "incomplete row - padding with blanks ($COLS/$IDP_WDT_THN)" while [ `expr $COLS / $IDP_WDT_THN` = 0 ]; do info "next: blank" ROWPICFILES="$ROWPICFILES $MTNTMPDIR/blank-pic.pbm" ROWTITFILES="$ROWTITFILES $MTNTMPDIR/blank-tit.pbm" COLS=`expr $COLS + 1` done info "padded row: $ROWPICFILES - creating row $MTNTMPDIR/rowpic-$ROWS.pnm" pnmcat -lr -$THP_COL_BG $ROWPICFILES > $MTNTMPDIR/rowpic-$ROWS.pnm ROWPICFILES= pnmcat -lr -$THT_COL_BG $ROWTITFILES > $MTNTMPDIR/rowtit-$ROWS.pnm ROWTITFILES= IDXFILES="$IDXFILES $MTNTMPDIR/rowpic-$ROWS.pnm $MTNTMPDIR/rowtit-$ROWS.pnm" ROWS=`expr $ROWS + 1` COLS=0 fi ########################################################################### # # Now combine all outstanding rows that weren't enough to make an index # ########################################################################### if [ $ROWS != 0 ]; then info "incomplete index (not padding): $IDXFILES - creating index $MTNTMPDIR/$L_OUTNAME$IDXS.pnm" pnmcat -tb $IDXFILES | cjpeg -Q $THP_QLT_PC > $L_OUTNAME$IDXS.jpg IDXFILES= IDXS=`expr $IDXS + 1` ROWS=0 fi rm -fr $MTNTMPDIR } ############################################################################## # # # ENTRY POINT # # # ############################################################################## # All files created should be readable by all. You might want to change this # to 'umask 077' to exclude all access for group and others. umask 022 # Call the main function, passing it the same arguments that this script # itself recieved. main "$@@" # If main() returned an exit code then now pass that back to the thing that # called this script. Note that that is what would happen anyway but this # just makes that a little more explicit. exit $? @ 1.6 log @addition of a few options - so rpi functionality now internal change of variable names not known to work @ text @d1 17 a17 3 #!/bin/sh PROGNAME=`basename $0` VERSION=`echo '$Id: mtn,v 1.5 1996/10/28 12:41:59 alexis Exp $' | cut -d' ' -f3` d24 12 a35 1 DFLT_DEBUG_LEVEL=2 a36 1 TMPDIR=/tmp/$PROGNAME.$$ d38 78 d131 10 d144 1 a144 1 echo "Usage: $PROGNAME [ -r ] [ -m x_x ] { | } ..." d150 10 a159 1 debug() d161 3 a163 1 [ $DEBUG_LEVEL -ge $1 ] && { shift; echo "$PROGNAME: DEBUG $@@"; } d166 1 d169 23 a191 2 [ $DEBUG_LEVEL -ge 1 ] && { echo "$PROGNAME: ERROR $@@" >&2; } exit 1 d194 1 d197 3 a199 1 [ $DEBUG_LEVEL -ge 2 ] && { echo "$PROGNAME: WARNING $@@" >&2; } d202 2 a203 1 info() d205 3 a207 1 [ $DEBUG_LEVEL -ge 3 ] && { echo "$PROGNAME: INFO $@@"; } d210 2 a211 1 main() d213 1 d215 1 a215 8 THN_MODE=$DFLT_THN_MODE FIL_MODE=$DFLT_FIL_MODE THP_COL_BG=$DFLT_THP_COL_BG THT_COL_BG=$DFLT_THT_COL_BG THP_QLT_PC=$DFLT_THP_QLT_PC DEBUG_LEVEL=$DFLT_DEBUG_LEVEL while [ "X$1" != X ]; do d217 1 a217 11 -V) echo "$PROGNAME version $VERSION" exit ;; -v) DEBUG_LEVEL=3 ;; -r) FIL_MODE=recurse ;; -d) [ "X$2" != X ] || usage DEBUG_LEVEL=$2 shift ;; -m) [ "X$2" != X ] || usage THN_MODE=$2 shift ;; -*) usage ;; a221 1 [ "X$1" != X ] || usage d223 4 a226 1 set_mode_vars $THN_MODE d228 16 a243 3 rm -fr $TMPDIR trap "echo 'cleaning up, please wait ...'; rm -fr $TMPDIR; exit 1" 1 2 15 mkdir $TMPDIR d245 7 a251 5 ########################################################################### # # Create blank title and picture of maximum sizes # ########################################################################### d253 6 a258 14 info "making blank picture ..." pbmmake -$THP_COL_BG $THP_WDT_PXL $THP_HGT_PXL > $TMPDIR/blank-pic.pbm info "making blank title ..." pbmmake -$THT_COL_BG $THP_WDT_PXL $THT_HGT_PXL > $TMPDIR/blank-tit.pbm case $FIL_MODE in normal) process $OUTNAME "$*" ;; recurse) find ${*:-.} -type f | grep -v '.xvpics' | sed 's/^\(.*\)\/[^\/][^\/]*$/\1/' | sort -u | while read DIR; do cd $DIR info "$DIR ..." [ -f index0.jpg ] && { info "index0.jpg exists"; continue; } process $OUTNAME "$*" done ;; esac d263 2 d270 1 d279 1 d281 6 a286 5 *.jpg) info "$FILE: decoding and scaling ..." djpeg < $FILE ;; *.gif) info "$FILE: decoding and scaling ..." giftopnm < $FILE ;; *) error "Unknown file extension" ;; d294 5 a298 1 esac | pnmscale -xysize $THP_WDT_PXL $THP_HGT_PXL > $TMPDIR/$FILEBASE-sclpic.pnm d306 2 a307 2 info "$FILE: calculating padding offsets for picture ..." set X `pnmfile $TMPDIR/$FILEBASE-sclpic.pnm` d309 2 a310 2 info "$FILE: padding picture ${X}x${Y} to ${THP_WDT_PXL}x${THP_HGT_PXL} ..." pnmpaste $TMPDIR/$FILEBASE-sclpic.pnm `expr \( $THP_WDT_PXL - $X \) / 2` `expr \( $THP_HGT_PXL - $Y \) / 2` $TMPDIR/blank-pic.pbm > $TMPDIR/$FILEBASE-pddpic.pnm d319 1 a319 1 pbmtext `echo $FILE | cut -c1-20` > $TMPDIR/$FILEBASE-tit.pbm d327 2 a328 2 info "$FILE: calculating padding offsets for title ..." set X `pnmfile $TMPDIR/$FILEBASE-tit.pbm` d330 2 a331 2 info "$FILE: padding title ..." pnmpaste $TMPDIR/$FILEBASE-tit.pbm `expr \( $THP_WDT_PXL - $X \) / 2` `expr \( $THT_HGT_PXL - $Y \) / 2` $TMPDIR/blank-tit.pbm > $TMPDIR/$FILEBASE-pddtit.pnm d350 2 a351 2 ROWPICFILES="$ROWPICFILES $TMPDIR/$FILEBASE-pddpic.pnm" ROWTITFILES="$ROWTITFILES $TMPDIR/$FILEBASE-pddtit.pnm" d361 2 a362 2 info "complete row: $ROWPICFILES - creating row $TMPDIR/rowpic-$ROWS.pnm" pnmcat -lr -$THP_COL_BG $ROWPICFILES > $TMPDIR/rowpic-$ROWS.pnm d364 1 a364 1 pnmcat -lr -$THT_COL_BG $ROWTITFILES > $TMPDIR/rowtit-$ROWS.pnm d366 1 a366 1 IDXFILES="$IDXFILES $TMPDIR/rowpic-$ROWS.pnm $TMPDIR/rowtit-$ROWS.pnm" d378 1 a378 1 info "complete index: $IDXFILES - creating index $TMPDIR/$L_OUTNAME$IDXS.pnm" d397 2 a398 2 ROWPICFILES="$ROWPICFILES $TMPDIR/blank-pic.pbm" ROWTITFILES="$ROWTITFILES $TMPDIR/blank-tit.pbm" d402 2 a403 2 info "padded row: $ROWPICFILES - creating row $TMPDIR/rowpic-$ROWS.pnm" pnmcat -lr -$THP_COL_BG $ROWPICFILES > $TMPDIR/rowpic-$ROWS.pnm d405 1 a405 1 pnmcat -lr -$THT_COL_BG $ROWTITFILES > $TMPDIR/rowtit-$ROWS.pnm d407 1 a407 1 IDXFILES="$IDXFILES $TMPDIR/rowpic-$ROWS.pnm $TMPDIR/rowtit-$ROWS.pnm" d419 1 a419 1 info "incomplete index (not padding): $IDXFILES - creating index $TMPDIR/$L_OUTNAME$IDXS.pnm" d426 1 a426 1 rm -fr $TMPDIR d429 11 d441 4 @ 1.5 log @A lot of changes; driven by changes to the pbm package. But also a lot of cosmetic ones. Oh, and the index title has been ditched because there wasn't room for it. @ text @d3 1 a3 1 VERSION=`echo '$Id: mtn,v 1.3 1996/10/04 20:27:37 alexis Exp $' | cut -d' ' -f3` d5 6 a10 10 PICWIDTH=170 PICHEIGHT=123 TITHEIGHT=29 IDXWIDTH=6 IDXTITWIDTH=984 IDXTITHEIGHT=29 IDXHEIGHT=5 PICBGCOL=black TITBGCOL=white QUALITY=80 d13 15 a27 1 PATH=$PATH:/big/pbm/bin d31 4 a34 2 echo "Usage: $PROGNAME file ..." >&2 echo " $PROGNAME -V" >&2 d38 5 d45 1 a45 1 echo "$PROGNAME: ERROR $@@" 1>&2 d49 6 a54 1 verbose() d56 1 a56 1 echo "$PROGNAME: INFO $@@" 1>&2 a60 1 trap "echo 'Aborting ...'; rm -fr $TMPDIR; exit 1" 1 2 15 d62 7 a68 1 OUTNAME="index" d73 8 d88 2 d91 1 d100 15 a114 4 verbose "making blank picture ..." pbmmake -$PICBGCOL $PICWIDTH $PICHEIGHT > $TMPDIR/blank-pic.pbm verbose "making blank title ..." pbmmake -$TITBGCOL $PICWIDTH $TITHEIGHT > $TMPDIR/blank-tit.pbm d116 4 d121 1 d132 1 a132 1 *.jpg) verbose "$FILE: decoding and scaling ..." d134 1 a134 1 *.gif) verbose "$FILE: decoding and scaling ..." d144 1 a144 1 esac | pnmscale -xysize $PICWIDTH $PICHEIGHT > $TMPDIR/$FILEBASE-sclpic.pnm d152 1 a152 1 verbose "$FILE: calculating padding offsets for picture ..." d155 2 a156 2 verbose "$FILE: padding picture ${X}x${Y} to ${PICWIDTH}x${PICHEIGHT} ..." pnmpaste $TMPDIR/$FILEBASE-sclpic.pnm `expr \( $PICWIDTH - $X \) / 2` `expr \( $PICHEIGHT - $Y \) / 2` $TMPDIR/blank-pic.pbm > $TMPDIR/$FILEBASE-pddpic.pnm d164 2 a165 2 verbose "$FILE: generating title ..." pbmtext $FILE > $TMPDIR/$FILEBASE-tit.pbm d173 1 a173 1 verbose "$FILE: calculating padding offsets for title ..." d176 2 a177 2 verbose "$FILE: padding title ..." pnmpaste $TMPDIR/$FILEBASE-tit.pbm `expr \( $PICWIDTH - $X \) / 2` `expr \( $TITHEIGHT - $Y \) / 2` $TMPDIR/blank-tit.pbm > $TMPDIR/$FILEBASE-pddtit.pnm d194 1 a194 1 verbose "next: $FILE" d206 3 a208 3 if [ `expr $COLS / $IDXWIDTH` = 1 ]; then verbose "complete row: $ROWPICFILES - creating row $TMPDIR/rowpic-$ROWS.pnm" pnmcat -lr -$PICBGCOL $ROWPICFILES > $TMPDIR/rowpic-$ROWS.pnm d210 1 a210 1 pnmcat -lr -$TITBGCOL $ROWTITFILES > $TMPDIR/rowtit-$ROWS.pnm d223 3 a225 3 if [ `expr $ROWS / $IDXHEIGHT` = 1 ]; then verbose "complete index: $IDXFILES - creating index $TMPDIR/$OUTNAME$IDXS.pnm" pnmcat -tb $IDXFILES | cjpeg -Q $QUALITY > $OUTNAME$IDXS.jpg d240 3 a242 3 verbose "incomplete row - padding with blanks ($COLS/$IDXWIDTH)" while [ `expr $COLS / $IDXWIDTH` = 0 ]; do verbose "next: blank" d248 2 a249 2 verbose "padded row: $ROWPICFILES - creating row $TMPDIR/rowpic-$ROWS.pnm" pnmcat -lr -$PICBGCOL $ROWPICFILES > $TMPDIR/rowpic-$ROWS.pnm d251 1 a251 1 pnmcat -lr -$TITBGCOL $ROWTITFILES > $TMPDIR/rowtit-$ROWS.pnm d265 2 a266 2 verbose "incomplete index (not padding): $IDXFILES - creating index $TMPDIR/$OUTNAME$IDXS.pnm" pnmcat -tb $IDXFILES | cjpeg -Q $QUALITY > $OUTNAME$IDXS.jpg @ 1.4 log @works, but fractionally to big for the page because the title bars are slightly taller than they were before (25-->29 pixels) due to changes in pbmtext program. Solution will be to ditch the main title. @ text @d3 1 a3 1 VERSION='$Id: mtn,v 1.3 1996/10/04 20:27:37 alexis Exp $' a6 1 #TITHEIGHT=25 a9 1 #IDXTITHEIGHT=25 a17 1 VERSION=`echo $VERSION | cut -d' ' -f3` d21 2 a22 1 echo "Usage: $PROGNAME [ -t title ] file ..." >&2 d39 2 a40 1 TITLE="Untitled" a43 4 -t) [ "X$2" != X ] || usage TITLE="$2" shift ;; -*) usage ;; d46 1 a52 4 # In the event of a disaster, here's what to do trap "echo 'Aborting ...'; rm -fr $TMPDIR; exit 1" 1 2 15 # Create some temporary space d56 6 a61 1 # Create some blank images over which to lay pictures and titles later a63 1 pnmfile $TMPDIR/blank-pic.pbm a65 1 pnmfile $TMPDIR/blank-tit.pbm a66 3 pbmmake -$TITBGCOL $IDXTITWIDTH $IDXTITHEIGHT > $TMPDIR/blank-idxtit.pbm # Process all specified files d69 7 a76 2 # First turn them into PBM files from their native format FILEBASE=`basename $FILE` d84 6 a89 1 # Then scale to the required size keeping the aspect ratio a90 1 pnmfile $TMPDIR/$FILEBASE-sclpic.pnm d92 6 a97 1 # Now pad the image out, so when they are joined in a row they are all the same width a102 1 pnmfile $TMPDIR/$FILEBASE-pddpic.pnm d104 6 a109 1 # Generate a title string a111 1 pnmfile $TMPDIR/$FILEBASE-tit.pbm d113 6 a118 1 # Now pad the title out, so when they are joined in a row they are all the same width a123 1 pnmfile $TMPDIR/$FILEBASE-pddtit.pnm a125 1 # Now we combine them into rows and the rows into complete pictures d133 6 a139 1 a141 1 # Note another image and title d146 6 a151 1 # If we have a rows worth then output the row and reset d163 6 a168 1 # if we have enough rows to make a complete picture then output it now and reset a169 12 # Generate a title string verbose "complete index: generating index title ..." pbmtext "Date: `date`, Title: $TITLE" > $TMPDIR/idxtit-$IDXS.pbm # Now pad the title out, so when they are joined in a row they are all verbose "calculating padding offsets for index title ..." set X `pnmfile $TMPDIR/idxtit-$IDXS.pbm` X=$5; Y=$7 verbose "$FILE: padding title ..." pnmpaste $TMPDIR/idxtit-$IDXS.pbm `expr \( $IDXTITWIDTH - $X \) / 2` `expr \( $IDXTITHEIGHT - $Y \) / 2` $TMPDIR/blank-idxtit.pbm > $TMPDIR/idxtit$IDXS-pddtit.pnm d171 1 a171 1 pnmcat -tb $TMPDIR/idxtit$IDXS-pddtit.pnm $IDXFILES | cjpeg -Q $QUALITY > $OUTNAME$IDXS.jpg d178 7 a184 1 # This bit deals with imcomplete rows a187 1 # Add blank titles and pictures to the end of the row d204 6 a209 1 # And this deals with incomplete indexes a210 15 # Note though that we don't fill up the screen vertically with # blank rows. # Generate a title string verbose "incomplete index: generating index title ..." pbmtext "Date: `date`, Title: $TITLE" > $TMPDIR/idxtit-$IDXS.pbm # Now pad the title out, so when they are joined in a row they are verbose "calculating padding offsets for index title ..." set X `pnmfile $TMPDIR/idxtit-$IDXS.pbm` X=$5; Y=$7 verbose "$FILE: padding title ..." pnmpaste $TMPDIR/idxtit-$IDXS.pbm `expr \( $IDXTITWIDTH - $X \) / 2` `expr \( $IDXTITHEIGHT - $Y \) / 2` $TMPDIR/blank-idxtit.pbm > $TMPDIR/idxtit$IDXS-pddtit.pnm d212 1 a212 1 pnmcat -tb $TMPDIR/idxtit$IDXS-pddtit.pnm $IDXFILES | cjpeg -Q $QUALITY > $OUTNAME$IDXS.jpg a217 1 # clean up a220 1 # And this calls the whole thing @ 1.3 log @changed path @ text @d3 1 a3 1 VERSION='$Id: mtn,v 1.2 1995/10/16 20:59:36 alexis Exp alexis $' d7 2 a8 1 TITHEIGHT=25 d11 2 a12 1 IDXTITHEIGHT=25 d65 1 d67 2 d70 1 d89 1 d95 1 a95 1 verbose "$FILE: padding picture ..." d97 1 d102 1 d110 1 @ 1.2 log @Removal of -o (output filename) option. Addition of version control id and -V option. Changing all occurences of "STEM" to "OUTFILE" - unnecessarily had two different variables to do the same thing. Removed hyphens from indexed created. @ text @d3 1 a3 1 VERSION='$Id$' d17 1 a17 1 PATH=$PATH:/apps/pbm/bin @ 1.1 log @Initial revision @ text @d3 1 d18 1 a18 1 STEM=index d22 1 a22 1 echo "Usage: $PROGNAME [ -t title ] [ -o outputfile ] file ..." 1>&2 a42 3 -o) [ "X$2" != X ] || usage OUTNAME="$2" shift ;; d47 2 d146 2 a147 2 verbose "complete index: $IDXFILES - creating index $TMPDIR/$STEM-$IDXS.pnm" pnmcat -tb $TMPDIR/idxtit$IDXS-pddtit.pnm $IDXFILES | cjpeg -Q $QUALITY > $STEM-$IDXS.jpg d192 1 a192 1 verbose "incomplete index (not padding): $IDXFILES - creating index $TMPDIR/$STEM-$IDXS.pnm" @