Generate un file di nome: riduci e dopo avergli dato i permessi salvate in /usr/bin/
Code: Select all
#! /bin/bash
# Nome File: riduci
echo; echo
echo $0
echo "######################################################################"
echo "# Ver. 1.0 - 11/08/2011 - (C)-MIB-PIANETALINUX - by Roberto Zaffuto #"
echo "# Riduce dimensioni foto e converte in altri formati #"
echo "######################################################################"
echo -n "Premi il tasto [ENTER]..."; read
echo -n "Estenzione files foto: [jpg]-->"; read EST
if [ ! $EST ]; then
EST="jpg"
fi
echo
echo "Formato di riduzione o ringrandimento:"
echo "0 = (Libero)"
echo "1 = 640x480"
echo "2 = 720x480"
echo "3 = 1200x800"
echo; echo -n " [2]-->"; read formato
f="n"
if [ $formato == "0" ]; then
echo; echo "Dimensioni Formato:"
echo -n " Larghezza: --->"; read l
echo -n " Altezza: --->"; read a
dim=$l"x"$a
else
if [ ! $formato ]; then
format0="2"
fi
if [ $formato == "1" ]; then
dim="640x480"
fi
if [ $formato == "2" ]; then
dim="720x480"
fi
if [ $formato == "3" ]; then
dim="1200x800"
fi
fi
echo -n " Forzatura (s/n)? [n]--->"; read f
if [ ! $f ]; then
f="n"
fi
echo; echo -n "Vuoi la conversione automatica in jpeg, gif, png, bmp (s/n)? [n]-->"; read conv
if [ ! $conv ]; then
conv="n"
else
conv="s"
fi
d="r${dim}"
if [ ! -d $d ]; then
if [ $conv == "s" ]; then
mkdir ${d} ${d}/jpeg ${d}/gif ${d}/png ${d}/bmp
else
mkdir ${d}
fi
fi
if [ ! -d originale ]; then
mkdir originale
fi
echo
echo "Formato: "$dim" Forzatura = "$f
if [ $f == "s" ]; then
f="!"
else
f=""
fi
for SRC in $(ls *.${EST})
do echo $SRC" -->"$dim
BASENAME="`basename $SRC .$EST`"
cp ${SRC} originale/${SRC}
mogrify -geometry ${dim}${f} ${SRC}
if [ $conv == "s" ]; then
echo " Genero: ${d}/jpeg/${BASENAME}.jpg"
convert ${SRC} ${d}/jpeg/${BASENAME}.jpg
echo " Genero: ${d}/gif/${BASENAME}.gif"
convert ${SRC} ${d}/gif/${BASENAME}.gif
echo " Genero: ${d}/png/${BASENAME}.png"
convert ${SRC} ${d}/png/${BASENAME}.png
echo " Genero: ${d}/bmp/${BASENAME}.bmp"
convert ${SRC} ${d}/bmp/${BASENAME}.bmp
fi
cp -f ${SRC} r""${dim}/${SRC}
rm ${SRC}
done
echo; echo "Done."; read