Imagemagick - Resize images to 25px height and aspect ratio

test picture test · Apr 13, 2013 · Viewed 23.1k times · Source

OK, so I have a folder of like 16 images all between the dimensions of 205x150 to 103x148. I want to size them down to the pixel height and width of 25px and stack them horizontally on a transparent background... is that possible?

I should probably be using ImageMagick for this...

Answer

janos picture janos · Apr 13, 2013

You can do all that with ImageMagick.

You're question is not very specific, so here's a quick cheat sheet of command examples that may help you:

# resize image to width 25, keeping aspect ratio
convert -geometry 25x src/image1.png out/image1.png

# resize image to height 25, keeping aspect ratio
convert -geometry x25 src/image1.png out/image1.png

# concatenate images horizontally
convert +append src/image1.png src/image2.png out/image12horiz.png

# concatenate images vertically
convert -append src/image1.png src/image2.png out/image12vert.png

In addition, the montage command is probably perfect to create the final image you are looking for (on a transparent bg with some padding, etc), but I don't remember the syntax.

Another useful command is identify, to find the dimensions of images (along with other details).

After you install ImageMagick, you can see the list of commands in man ImageMagick, and get further details on each command in the man pages. There are an awful lot of functions, but it should not be too difficult to figure out the rest on Google. (I do that all the time.)