Нечто подобное может сделать:
#!/bin/bash
VICTIM="$1"
if [ -z "$VICTIM" ]; then
echo >&2 "Syntax: $0 <imagefile>"
exit 1
fi
if [ ! -f "$VICTIM" ]; then
echo >&2 "$VICTIM is not a regular file"
exit 1
fi
VICTIM=$(readlink -f "$VICTIM")
DSTDIR=$(dirname "$VICTIM")
WORKDIR=$(mktemp -d /tmp/.workXXXXXX)
if [ "$?" != "0" ]; then
echo >&2 "Aiie, failed to create temporary directory"
exit 1
fi
export WORKDIR
trap "rm -rf $WORKDIR" exit INT QUIT TERM
(
cd $WORKDIR
convert -unsharp 5 "$VICTIM" step1.ppm && \
convert -opaque white -fill white -fuzz 10% step1.ppm step2.tif && \
convert -fuzz 1.5% -fill "#816c51" -opaque "#5a4a3b" step2.tif step3.tif && \
convert -fuzz 12% -fill "black" -opaque "#1c110f" step3.tif step4.tif
)
if [ "$?" != "0" ]; then
echo >&2 "Aiie, image processing failed"
exit 1
fi
convert $WORKDIR/step4.tif $DSTDIR/CLEANED-$VICTIM
RC=$?
if [ "$RC" != "0" ]; then
echo >&2 "Aiie, final conversion failed"
fi
exit $RC
Назовите этот скрипт "convert_one.sh" и вызовите с помощью:
for i in *.jpg; do sh convert_one.sh $i;done