ImageMagic is the tool of choice when you have to manipulate images on the command line.
You can easily install it from a shell with the following command:
sudo apt-get install imagemagick
Change all images in the current folder to a with of 800 pixels with a quality of 80%:
for file in *.jpg; do convert $file -resize 800 -quality 80 $file; done
Convert a *.gif image to a *.jpg image
convert -strip test.gif test.jpg