This simple BASH script will resize all images in the current folder and convert them to jpeg. You choose the resolution and quality.
Save it to ~/bin/resizeimages and make it executable chmod +x ~/bin/resizeimages
Example of usage:
resizeimages 1024×768 65
#!/bin/bash
# Checking for the proper number of command line args.
if [ $# -ne 2 ]
then
echo Wrong number of arguments. `basename $0` takes two arguments.
echo
echo "Usage: `basename $0` {new-resolution} {jpeg-quality}"
echo
echo Example:
echo " This will convert all images in the current directory to jpeg with quality 65 and as close to 1000x667 resolution as possible while maintaining aspect ratio. The resized images are put in the subdirectory 1000x667."
echo " "`basename $0` 1000x667 65
echo
exit
fi
# Check file list of current folder for images and resize
for file in `ls`
do
name=`echo $file | cut -f1 -d.`
type=`file -ib $file`
if [[ $type == *image* ]]
then
if [ ! -d $1 ]; then
mkdir $1
fi
convert -geometry $1 -quality $2 $file $1/${name}_$1.jpg
fi
done
Norsk
English