Linux Image Resizing Commands (on Ubuntu)

Install GraphicsMagick package and run the “convert” command.

sudo apt-get install graphicsmagick

Install jpegoptim and use the “jpegoptim” command.

sudo apt-get install jpegoptim

Resize all images in a folder into another folder

Use the following command to resize one image (keeping the aspect ratio)

convert name.jpg -resize 1200x10^ resized-folder/name.jpg

To run this for all files in a folder and put the resized images into the “resized” folder…

mkdir resized-folder; for i in *.jpg; do convert $i -resize 1200x10^ resized-folder/$i; done

Convert png to jpg

convert file.png file.jpg

Optimize a jpg file in place (overwrite the file with the optimized version)

jpegoptim file.jpg