How to resize images from command line

Posted on November 24, 2020

First install imagemagick, it includes you the convert command, that will process the images. For Ubuntu:

sudo apt-get install imagemagick

Convert an image with examples:

convert image.jpg  image.png
convert image.png -quality 95 image.jpg
convert image.jpg -resize 400x400 image.png
convert image.jpg -rotate 90 image.png

Resize all images in a folder (to save with the same name remove the sm- preffix):

for file in *.jpg; do convert $file -resize 640x640 sm-$file; done

Source:

https://www.howtogeek.com/109369/how-to-quickly-resize-convert-modify-images-from-the-linux-terminal/