Resize all images in current directory using bash and graphicsmagick

von tobonaut

Today again one command which I have to look for at google almost every time I need it because I can’t remember the complete and correct syntax of the bash for-loop and graphics magick image resize:

for file in $(ls *.jpg); do; mv $file tmp; gm convert -resize 800x600 tmp $file; rm tmp; done;

This is a single line version of the following lines and takes every image that matches the *.jpg statement and resizes it to max. 800×600 pixels:

for file in $(ls *.jpg)
  mv $file tmp
  gm convert -resize 800x600 tmp $file
  rm tmp