Recently in these days, I have started using Linux in my computer because of some professional reason. As I do blogging from my computer, I felt the necessity to resize image from my Linux work terminal as I need to edit one image because of the purpose of blogging. So, at first I tried installing different software which are like MS Paint in Windows operating system. I tried editing image with those software but I was not really satisfied with the efficiency of those software. So, I was desperately looking for an alternative option. I think I have found one easy alternative option to edit and resize image in Linux and the most interesting thing is I can do it from terminal. I am going to explain below how one can resize and edit image using the Linux terminal.
Resize and Edit Image Easily from Terminal:
To resize and edit image from terminal in Linux, you need to install one software and you can do it from your terminal. Just copy and paste the below command in your terminal window and you will be all set to edit image. The package that we are going to install is ImageMagick.
sudo apt-get install imagemagick
After typing this code, the terminal will ask for your sudo password and just type you computer password.
Convert and Resize Your Image As You Like:
Now installing the ImageMagick, you are all set and you will be able to resize and edit your image from your Linux terminal. Just follow the below instructions to do that:
1. Convert one image from png to JPG:
Normally, png is a high quality image and while uploading one image or using it for some small purpose, we prefer to choose the JPG format of the image. So, if we have one PNG image, then we can convert it to JPG from terminal. Use the code to do so and replace the example.jpg or example.png with your image name.
convert example.png example.jpg
2. Resize the image:
If you want to resize one image, just do it using the below command:
convert example.png -resize 200×100! example.png
So, in the output, you will get one image with 200 pixel width and 100 pixel height. But if you want to keep the image close to 200×100 pixel and want to maintain the aspect ratio, then just use the below command which does not have the ! sign.
convert example.png -resize 200×100! example.png
If you only want to specify the height or only want to specify the width of the image then you can also do it by using the below commands:
For width: convert example.png -resize 200 example.png
For Height: convert example.png -resize ×100! example.png
3. Rotate Image:
If you want to rotate image by 90 degree and want to save it with the same name then just use the below command:
convert example.jpg -rotate 90 example.jpg
There are also other commands but these are the most useful commands and you can use those for editing the image from your Linux terminal. If you want to learn about more command, you can just ask me in the comment and I will be happy to answer those.