Command Line (cli) Resize Image - Linux

Jun 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:

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.