Größenreduzierung von Bildern (rekursiv)
Die Bibliotek "imagemagick" ist Vorraussetzung. Script funktioniert nur für *.jpg und/oder *.png.
#!/bin/bash
echo $0 $1 $2 $3 $4
NUMCORES=8
SIZE="1024x768"
if [ -z "$1" ] || [ -z "$2" ]
then
echo "Benutzung: $0 <size> <numcores>"
echo "<size> = 1024x768\n<numcores> = Anzahl der Prozessorkerne"
echo "Starting with default options: size=$SIZE; numcores=$NUMCORES"
# SIZE=$1
# if [ -n "$2" ]
# then
# NUMCORES=$2
# fi
fi
if [ -n "$1" ]
then
SIZE=$1
fi
if [ -n "$2" ]
then
NUMCORES=$2
fi
mkdir -p ./small_$SIZE/
j=0
count=1
for i in `find . \( -iname '*.jpg' -or -iname '*.png' \) -printf "%h/%f "`
do
testvar=`echo $i | grep "small_"`
if [ -n "$testvar" ]
then
echo "skipping $i"
continue
fi
mkdir -p ./small_$SIZE/$i
rm -r ./small_$SIZE/$i
echo "$count-$j: $i -> ./small_$SIZE/$i"
( taskset -c $j convert $i -resize $SIZE ./small_$SIZE/$i ) &
let j=j+1
if [ $j -eq $NUMCORES ]
then
let j=0
wait
fi
let count=count+1
done
wait

Kommentare