Resizing images via command line


Posted by Diego Assencio on 2013.11.30 under Linux (Shell)

To resize images on Ubuntu/Debian via command line, you can use a package called imagemagick. To install it, open a terminal and run:

sudo apt-get install imagemagick

Now you can resize images using an utility called convert which is installed with imagemagick. Here is an example of how to resize a JPEG file to 640x480 pixels:

convert -resize 640x480 <input-file.jpg> <output-file.jpg>

The command above takes an image called input-file.jpg, resizes it to 640x480 pixels and outputs the result to output-file.jpg.

You can also use a percentage value to resize the image. To reduce the image to 50% of its original size, run:

convert -resize 50% <input-file.jpg> <output-file.jpg>

Comments

Emmanuel on Jan 18, 2014:
This command is a life saver when you need to convert all pictures of a directory as a batch job

Leave a reply

NOTE: A name and a comment (max. 1024 characters) must be provided; all other fields are optional. Equations will be processed if surrounded with dollar signs (as in LaTeX). You can post up to 5 comments per day.