exemple que processa les imatges del directori actual (només les modificades els últims 5 dies) i les redimensiona a 125×125 píxels (posant-les al directori ../125)…
for fitxer in `find ./ -mmin -7200 -printf "%f\n"`
do
if [[ $(file --mime-type -b "$fitxer") == image/j* ]]
then
DIMS=`identify "${fitxer}" | awk '{print $3}'`
WIDTH=`identify -format '%w' $fitxer`
HEIGHT=`identify -format '%h' $fitxer`
if [ "$WIDTH" -gt "$HEIGHT" ]
then
#es horitzontal
convert $fitxer -gravity center -extent ${WIDTH}x${WIDTH} tmp_${fitxer}
fi
if [ "$HEIGHT" -gt "$WIDTH" ]
then
#es vertical
convert $fitxer -gravity center -extent ${HEIGHT}x${HEIGHT} tmp_${fitxer}
fi
if [ "$HEIGHT" == "$WIDTH" ]
then
cp $fitxer tmp_${fitxer}
fi
WIDTH=`identify -format '%w' tmp_${fitxer}`
if [ "$WIDTH" -gt "125" ]
then
convert tmp_${fitxer} -resize 125x125 ../125/${fitxer}
fi
\rm tmp_${fitxer}
fi
done