#! /bin/bash # Copyright (C) 1998 Stephane Levant # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; see the file COPYING. If not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. prog=`basename $0` usage() { cat <&2 Usage: $prog [-Pimprimante] [-f fichier] image_1 image_2 ... image_n Creer un fichier bd.ps à partir des images. 2 pages par feuille sont affichées. Le fichier obtenu est fait pour être imprimé sur une imprimante recto/verso (à l'ENSERB: lp -Pduccio bd.ps). Ce script utilise mpage. Options : -Pimprimante : Ne crée pas de fichier et imprime directement -f fichier: Utilise fichier au lieu de bd.ps EOF # ' exit 1 } erreur() { echo "$prog: $@" >&2 exit 1 } fic=bd.ps continue=oui while [ $continue = oui ]; do case "$1" in -h*|--h*) usage ;; -f) [ $# = 1 ] && erreur "L'option -f requiert un argument" fic=$2; shift 2 ;; -P*) fic=""; imprimante="$1" ; shift ;; -*) erreur "Option inconnue : $1" ;; *) continue=non ;; esac done [ $# = 0 ] && usage echo '######## $prog v1.0 #########' echo '######## Fabrication des PNM ... #######' n=0 for i in "$@"; do echo "$i" n=$((n+1)) [ -f "$i" ] || erreur "$i : fichier introuvable" [ -r "$i" ] || erreur "$i : Impossible de lire le fichier" if [ "${i##*.}" = jpg -o "${i##*.}" = JPG ]; then djpeg -grayscale -outfile bd$(printf "%.3i" $n).pnm "$i" else cjpeg -grayscale "$i" | djpeg -grayscale -outfile bd$(printf "%.3i" $n).pnm fi done while ((n%4!=0)); do n=$((n+1)) cp ~levant/public_html/pict/blanc.pnm bd$(printf "%.3i" $n).pnm done echo '####### Retournement des PNM ... #######' RETOURNE() { echo $1 ; pnmrotate 90 $1 | pnmrotate 90 > .tmp ; mv .tmp $1 ;} k=1 while ((k bd${2}.ps ; } k=1 while ((k<=n/4)); do PNMTOPS $(printf "%.3i" $((k*2-1))) $(printf "%.3i" $(((k-1)*4+2))) PNMTOPS $(printf "%.3i" $((k*2))) $(printf "%.3i" $(((k-1)*4+4))) PNMTOPS $(printf "%.3i" $((n-k*2+1))) $(printf "%.3i" $(((k-1)*4+3))) PNMTOPS $(printf "%.3i" $((n-k*2+2))) $(printf "%.3i" $(((k-1)*4+1))) k=$((k+1)) done 2>/dev/null echo '####### Création de la bd #########' if [ "$fic" ]; then mpage -2 -o -c -M-20 *.ps > $fic else mpage $imprimante -2 -o -c -M-20 *.ps fi rm bd???.ps *.pnm echo '####### done ########' # # Execute bd dans plein de rep ... (! : *.jpg) # bd-all() { # for dir in "$@"; do # if [ ! -f "$dir/bd.ps" ] ; then # echo "------------------ $dir -----------------------" # cd "$dir" # bd *.jpg # cd .. # fi # done # }