hist: batch convert images
Posted by gregster on 01 Sep 2010 in Activity log
Wrote a little script to batch convert the Siberian images and create thumbs. Needs imagemagick installed, though.
#!/bin/bash
directory="thumbs"
dimensions="220x220"
# check if directory exists
if [ -d $directory ]; then
# check for files inside existing directory
if [ $(ls -1A $directory | wc -l) -ne 0 ]; then
echo "Directory $directory exists, but is not empty."
echo "Please clear out the $directory directory"
echo "and start this script again."
echo "We don't want to overwrite something important."
exit 1
fi
else
echo "Can't find a $directory directory. Creating one."
mkdir $directory
fi
for f in *.jpg;
do
echo "Processing $f"
convert -resize $dimensions \
$f $directory/$f
done