A simple script which will recognize all image types in the PWD and reduce them by 50% and copy them to the resized
folder under PWD. Good for bulk resizing of images.
#!/bin/bash
files=($(file -i * | awk -F ':' 'BEGIN {ORS=""} /^.*:[ \t]*image\/[a-z]*; charset=binary/ {for(i=1;i<NF-1;i++) {print $i":"} {print $(NF-1)"\n"} }' | sed 's/ /:spacecharacter:/g' | tr '\n' ' '))
echo ${files[@]}
mkdir -p resized
for file in ${files[@]}
do
file=$(echo $file | sed 's/:spacecharacter:/ /')
convert -resize 50% "$file" resized/"$file"
#You can use mogrify instead of resize if you want to edit the images in place.
#mogrify -resize 50% "$file"
done
Copy the script to ~/bin
directory and make it executable chmod +x resize_images
. Change into the directory containing the images and execute the script.