Resizing images on the command line

The quickest way I know of to resize an image on the command line is this
$ mogrify -resize 50% image.jpg 
This will resize the image named "image.jpg" by 50%, maintaining aspect ratio and saving the resized image to the same file. For this to work you will need to have ImageMagick installed
$ sudo apt install imagemagick 
You will now have some handy commands available such as identify, convert and mogrify. Mogrify is basically the same command as convert, but by default uses the original file as output. So these two commands are identical:
$ convert image.png -resize 10% image.png 
$ mogrify -resize 10% image.png 
You can check the result of the operation using identify like this
$ identify image.jpg  
image.jpg JPEG 4160x2340 4160x2340+0+0 8-bit DirectClass 3.03MB 0.010u 0:00.020 
$ mogrify -resize 50% image.jpg  
$ identify image.jpg            
image.jpg JPEG 2080x1170 2080x1170+0+0 8-bit DirectClass 604KB 0.000u 0:00.000 



related blogs: