convert directory images to a new width
#!/bin/bash
#
# Parameters:
# <ARG> Width of the new images.
#
# Description:
# Resize all the images in the current directory to a new
# directory called <ARG>, using as new width the value of <ARG>.
#
# Usage:
# convert-img WIDTH
if [ -d $1 ];then
echo -e "Correct usage:\n convert-img WIDTH";
else
if [[ $1 =~ ^[0-9]+$ ]];then
echo "Using width: $1";
mkdir -p $1;
for i in $(/bin/ls -1 | egrep -i "jpg|png|jpeg");do
echo "Converting $i"
convert -geometry $1 $i $1/$i;
done
else
echo "Argument must be a number"
fi
fi
Written by Cristián Maureira
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#