In this article, we would cover how we can resize an image in Ubuntu. There are many offline and online applications through which we can easily resize images. In Ubuntu we can use command-line utility
convert to resize the image. But, to have that command-line utility we need to install a package – imagemagick.
So, we cover the installation part first and thereafter explore various convert options which help us manage images effectively.
Note: Following operations would require you to have superuser privileges. In case you don’t have one then, contact your System Administrator for assistance.
Resize an image in Ubuntu
Since the package – imagemagick is already available through standard Ubuntu repository. Therefore, we need to update the repository to ensure we get to have the latest version of package. Hence, open a terminal and issue the following –
sudo apt update
Next, to install imagemagick –
sudo apt install imagemagick
We have convert command-line utility available now.
Not only resize but convert also helps us achieve various other outcomes like crop, flip, join etc. But, we stick with resize option here.
It is one of the tools made available through imagemagick package. Following syntax we use to resize images with convert –
convert -resize [widthxheight] <input_image> <output_image>
For instance, if we want test.png to have a size of 1366×768 then use the following code –
convert -resize 1366x768 test.png resize-test.png
But, you would have noticed that it keeps the image aspect ratio and adjust accordingly. But, what if we want to have our way and push it to stick with the image dimension size we have provided. This can be done through –
convert -resize 1366x768! test.png resize-test.png
! we have provided after the dimension size.
Not just the dimensions, we can also reduce image size percentage wise –
convert -resize [percentage] <input_image> <output_image>
convert -resize 10% test.png resize-test.png
It reduces the image size to 10%.
In conclusion, we have covered how to resize an image in Ubuntu through convert command-line utility here.