In this tutorial you will learn how to convert images on Linux from one format to another, let’s say you have an “.jpeg” image, and want to convert it to “.png” format. To do that we’ll need to use the convert command.
The convert Command allows you to do much more than just converting, it also allows you to resize images in terms of the image size and in scale.
The following command will convert the format of the image1 from .jpeg to png.
convert image1.jpeg image1.png
The following command will convert jpeg to 3 different type of image formats, to gif,bmp and tif.
convert image1.jpeg image1.gif convert image1.jpeg image1.bmp convert image1.jpeg image1.tif
To resize an image, you need to call convert and specify width and height you want.Let’s say you want to give an width of 800px and height of 900px to the image. To do that, you need run the following command.
convert imageiwanttoresize.png -resize 800x900 resizedimage.png
The command to do this is the same, but in this case you have to specify only the height of image not width. To do that run the following command.
convert imageiwanttoresize.png -resize x900 resizedimage.png
Simply specify only the width, so in this case you can do this by running the following command below.
convert imageiwanttoresize.png -resize 900 resizedimage.png
Changing the quality of the image, means making the image smaller in terms of the physical size of the image.
The following command below will change the quality to 90
convert image1.png -quality 80 image1.png
Changing the quality of the image, it’s not the only way to reduce the physical size of the image, by changing the aspect ratio and the file format can reduce the size as well.
To get the full list of the commands, check the manual by running the following command.
man convert
In this tutorial you learned how to manipulate images on Linux by using the convert command.