Ein Skript, um Dateien in Grafikformate umzuwandeln. Zum Beispiel Pdf nach Tiff. Wenn das schon in dieser Form taugt, kann mit Zenity oder dem anderen Ding.., Moment. „Yad“. Damit können grafische Oberflächen gebaut werden. Für die Dose (Windows) muss das als Batch-Datei neu geschrieben werden, Zenity läuft auch damit.
Code: Alles auswählen
#!/bin/dash
#
# prints files to image
#
# defaults
TYPE=tif
DEV=tiff24nc
RES=400x400
PAPER=a4
GS=/usr/bin/gs
USAGE="Syntax:\n\tuser@machine:$0 [file0] <file1> ... <filen>\nWill create 1 file converted to $TYPE for each page in any of the input-files.\
\n\tusr@machine:$0 <output type> [file0] <file1> ... <filen>\nWill instead create files of the specified output type e.g. jpeg, png, pgm"
if [ "$#" -gt 0 ]
then
case "$1" in
tif)
TYPE=tif
DEV=tiffscaled24
shift 1
;;
tiff)
TYPE=tiff
DEV=tiffscaled24
shift 1
;;
jpg)
TYPE=jpg
DEV=jpeg
shift 1
;;
jpeg)
TYPE=jpeg
DEV=jpeg
shift 1
;;
pgm)
TYPE=pgm
DEV=pgm
shift 1
;;
png)
TYPE=png
DEV=png48
shift 1
;;
pcx)
TYPE=pcx
DEV=pcx24b
shift 1
;;
bmp)
TYPE=bmp
DEV=bmp256
shift 1
;;
esac
if [ "$#" -gt 0 ]
then
for inf in "$@"
do
ext=${inf}
DIR=`dirname "$inf"`
if [ "$DIR"=='' ]
then
DIR='.'
fi
OUTPUT="$DIR"/`basename "$inf" ."$ext"`_%04d."$TYPE"
echo "creating files $OUTPUT"
# /usr/bin/gs -SDEVICE="$DEV" -r"$RES" -sPAPERSIZE="$PAPER" -sOutputFile="$OUTPUT" -dNOPAUSE -dBATCH -- "$inf"
"$GS" -SDEVICE="$DEV" -r"$RES" -sPAPERSIZE="$PAPER" -sOutputFile="$OUTPUT" -dNOPAUSE -- "$inf"
done
else
echo -e "ERROR: No files"
echo -e "$USAGE"
fi
else
echo -e "ERROR: No arguments."
echo -e "$USAGE"
fi