Image resize tool with “auto-center” feature

image editing

Does anybody know of a tool that can resize an image and automatically center it on it's new dimension?

Example, I have a 200×300 image, I wanted to resize it to 300×300 putting whitespace of 50px on both the right and left sides.

I'm using FastStone Photo Resizer, it works as I wanted including resizing multiple folders at once but it doesn't have that "auto-center" capability.

Best Answer

  • You can do that (and much more) with ImageMagick. With ImageMagick installed, type this on your command line / shell (replace arguments to your need):

     convert input.jpg -resize 80x80 -size 80x80 \
        xc:blue +swap -gravity center -composite output.jpg

    This resizes the image to fit within a "canvas" of 80x80 pixels, centers the image and fills the background blue (blue was only chosen as an example).

    ImageMagick is available for several (most?) OSes.

    Folder processing

    If you're working in Unix-like environment (Linux, BSD etc - even Mac), you can execute the aforementioned command through find, which enables you to process folders etc:

    find /path/to/my/folder -iname "*.jpg" -exec \
        convert {} -resize 80x80 -size 80x80 \
        xc:blue +swap -gravity center -composite {}_resized.jpg \;
  • Related Question