In this post, I will talk about how to intelligently resize images along one dimension without distorting objects in it. Here I will talk about a free command line tool which takes an image from you and then resizes it intelligently along just one dimension. It uses intelligent algorithms to identify important objects in an image to resize it.
It resizes the image in such a way that the important objects in the image don’t get distorted. Without locking the aspect ratio, it lets you resize images to custom size and without disturbing the living or non-living objects in it. To resize an image, you just have to execute a single command to get the final resized image.
There are a lot of image resizer software available, even the ones which let you resize images from context menu. But none of them can resize an image intelligently as Caire can. It uses an energy map to detect edges in the image for different objects and then resizes it according to the dimensions that you have given.
Another advantage of Caire is its intelligent face recognition technique. Without using heavy libraries like OpenCV, it can easily detect faces in an image and doesn’t let them shrink or distort during the resizing process.
However, there is one disadvantage as well. While resizing images, it might eliminate some elements from the image that it deems to be non-important. So, resizing along one dimension is actually accompanied by intelligent cropping in this software.
How to Resize Image Along One Dimension, without Distorting the Image
To perfectly resize an image, the resizing should be done while maintaining the aspect ratio. So, when one dimension is resized, the second dimension should also resize in the same proportion. In case we try to resize one dimension only, then the image would get distorted.
This is where Caire comes in. But Caire here uses another approach to resize an image by analyzing the input image first. It creates an energy map using the image and then try to find the least important pixels. An energy map is nothing but a grayscale equivalent of the input image.
After creating an energy map, it looks for the pixel values for the brighter and darker regions. By studying the pixel values, it identifies the least important part by checking the low energy values. After detecting least important parts, it draws seams on the image by the means of dynamic programming from top to bottom and left to right.
It assigns different energy values to the different seams and creates an energy matrix. After that, it uses the energy matrix to find out the low-cost seam and then remove it from the image as well. And this process is repeated until the image gets resized to the specified dimensions.
You can see the above image to understand how this tool works to create energy apps for identifying the least important objects in input image.
How to Intelligently Resize Images along one Dimension without distorting Objects
Step 1: Simply grab the GitHub repository of Caire either by cloning or downloading it. Next, get the Windows executable of Caire from here. After that, paste the executable of Caire in the repository that you have already downloaded.
Step 2: Now, paste the images in the folder where then EXE file of Caire is. Next, open a command prompt there. If you don’t know how to open command prompt in any folder, see this post.
Step 3: Now, simply begin with the resizing process. Just run the following command in the specified syntax.
caire -in "InputImage" -out "OutputImage" -width="NewWidth" -height="NewHeight" -debug=false
After running the above command, it will resize your image and will place it in the same directory. And while it is resizing your image, you have to be a little patient. The process is slower and completely depends on the size and colored pixels in the input image.
That is how this command line tool, Caire works to intelligently resize images. This is an open source and a cross-platform tool as well. And you can use it in the same way anytime no matter what platform you are on.
Closing words
Honestly speaking, I have never used an image resizer tool like Caire. I am really amazed by its functionality especially when it comes to resize images when there is a person in it. It identifies objects and living creatures in the images pretty well and resize the images accordingly. I really enjoyed resizing images through this tool and I hope you will find it amazing too. You can tell me in the comments what you think about it.