11 How to resize images in current folder based on width only

This example looks for all png files in current folder and will make thumbnails (shrink) any image that has a width larger than say 200 pixels. The height of the image is adjusted so that aspect ratio remain the same as originally was.

Edit as needed

#!/bin/bash 
shopt -s nullglob 
FILES=*.png 
for file in $FILES 
do 
     f=${file%.*} 
     echo "file is $file and f is $f" 
     convert "$f.png[200x>]" "$f"_thumb.png 
done
 

This example is as above except that the resizing is limited to enlarging the images to say 200 pixels. Edit as needed

#!/bin/bash 
shopt -s nullglob 
FILES=*.png 
for file in $FILES 
do 
     f=${file%.*} 
     echo "file is $file and f is $f" 
     convert "$f.png[200x<]" "$f"_thumb.png 
done
 

Reference:

  1. http://askubuntu.com/questions/135477/how-can-i-scale-all-images-in-a-folder-to-the-same-width
  2. http://www.cyberciti.biz/faq/bash-loop-over-file/