Everyone who creates content has faced this issue once in a while if not every time they get down to writing/creating. People who are trying to insert galleries on their website face it issue as well.
Every piece of content asks for an image if not a number of them. And more often than not you have images on hand that have different orientations and dimensions:-
- Portrait of dimensions such as 100 x 275
- Landscape of dimension such as 600 x 100
On top of that, the dimensions vary widely. So in a typical situation, you would need to display two such images on a canvas of say 150 x 150 pixels. Lots of solutions that are (easily) available help you to
- Resize — to 150 x 150 dimensions in which case because the aspect ratio is different, the image would be stretched; or
- Crop — something similar to above, just that in this case instead of stretching, the image would be clipped. IrfanView (I am sure other tools would have similar features, I just tend to prefer IrfanView for its simplicity) has a nice capability where you could simply auto-crop an image on that dimension while pivoting on any of the 9 different positions (such as Center, Middle Top) on the image.
The above two work, to an extent, when used together.
What I would really want is that a tool
- Create a canvas of 150 x 150.
- Align the center of the image with that of the canvas.
- Resize the image while keeping its original aspect ratio intact and making sure its longest dimension is below 150.
- And most importantly, run the above steps for a batch.
ImageMagick does this and does with lesser effort compared to even the biggest commercial behemoth out there. And it is “free”.
Just make sure you have it in the Path variable while installing.
Go to directory where your images are stored and run the following command on your command line (let me know in the comments if you are not really comfortable with the command line).
magick convert -resize 250x250^ -gravity center -extent 250x250 *.png
The best part is that the conversion is really fast.