Ubuntu: I would like to batch re-size images in a terminal



Question:

I've got like 500 images to resize, I'm not going to do that in gimp...a terminal solution would suit me best. On ubuntu 14.04.

I've read this question on stackoverflow (first posted the question there but someone started naging that stackoverflow is not the best place to ask this question) about batch resizeing using Imagemagic and I guess that is partly what I'm after (I don't care about the recursive part). I need to resize all images so that the longest side of the image will be a set number of pixels. There are images where the longest side will be the width of the image and some where that is the height.

I guess something in the order of:

find "*.jpg" | xargs convert -resize ...  

Any help would be appreciated


Solution:1

If you don't need recursion, you can use Imagemagick's batch tool, mogrify. This takes most of the same arguments. To scale the longest size down to 300px, we can offer -resize "300x300>". For safety's sake I've also got this saving the new images into a subdirectory rather than overwriting.

# assuming you're in the directory of images  mkdir resized  mogrify -resize "300x300>" -path resized *.jpg  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »