_           _                 
 | |_ ___  __| |____  ___ _   _ 
 | __/ _ \/ _` |_  / / _ \ | | |
 | ||  __/ (_| |/ / |  __/ |_| |
  \__\___|\__,_/___(_)___|\__,_|

Resize a jpeg image to a maximum height or width with Imagemagick

To resize one jpeg image to a maximum height and width (300px in this example), preserving its aspect ratio:

convert photo.jpg -resize 300x300\> photo.jpg

To do the same to a set of files in the current directory:

for f in * ; do echo $f ; convert $f -resize 300x300\> ../output_images/$f ; done