Code.Report

Insights for productivity and tech related info

Using convert to resize and rotate images

2019-09-28 Code.Reportunix

The convert command can quickly resize an image directly on a linux terminal.

The following command will resize an image based on a percent of 50%:

convert -resize 50% example.jpg example.jpg

To resize an image forcing a width and height:

convert example.jpg -resize 200x100 example.jpg

To resize an image keeping the aspect ratio and a width of 200:

convert example.jpg -resize 200 example.jpg

To resize an image keeping the aspect ratio an a height of 200:

convert example.jpg -resize x200 example.jpg

To rotate an image, just specify the angle needed:

convert example.jpg -rotate 90 example-rotated.jpg

You can convert all the files on the folder

convert -resize 50% *.jpg

Or you can convert all the images on the folder onto a single pdf file

convert *.jpg all-images.pdf

Remember that some linux distributions might not have the convert by default, you can install it with

sudo apt-get install imagemagick