Command Line (cli) Resize Image - Linux

June 14, 2019

Install

sudo apt-get install imagemagick

Resize

convert source.png -resize 600x600 output.png

Replace/overwrite original source

mogrify -resize 600x600 source.png

Resize all PNG files in directory and replace original source

mogrify -resize 600x600 *.png

-resize

Original aspect ratio is always respected.

  • -resize 600x600 - max width and max height is 600. If original image is 1200x600, it shall be resize to 600x300. If original image is 300x150, it shall be upsize to 600x300.
  • -resize 600 - max width and max height is 600
  • -resize 600x300 - max width is 600 and max height is 300. If original image is 600x600, it shall be resize to 300x300.
  • -resize 600x600\> - will prevent upsize. If the original image is 300x300, the original size remain as it is smaller than 600x600.

References:

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.