8
Feb

Resizing Photos in Linux or Mac OSX

Forget pulling up Photoshop, GIMP, or any other GUI program for a simple CLI job. With utilities like ‘mogrify‘ for Linux and ‘sips‘ for Mac OSX, it’s incredibly quick and easy to batch resize images through the command line. For example, if I wanted to resize all images within a particular folder to a width of 800px without losing aspect ratio, I would use the following commands:

Under Linux:

mogrify -resize 800 *.jpg

Under Mac OSX:

sips --resampleWidth 800 *.jpg

There are many more options for these programs, so play around and be sure to read the man pages.

Another usage example that I heard about today was to use the commands above in a script that will automatically create a thumbnail, small, medium, and large image sizes from a supplied image and then copy them off to the appropriate folder.  This is useful in building a website that has a lot of different image sizes required for the same image.

Additional Resources:
http://www.smokinglinux.com/tutorials/howto-batch-image-resize-on-linux
http://www.ibm.com/developerworks/linux/library/l-graf/

Feel free to donate if this post prevented any headaches! Another way to show your appreciation is to take a gander at these relative ads that you may be interested in:


There's 1 Comment So Far

  • Geek4Hire
    March 1st, 2013 at 4:38 am

    Love it! Using the command line is such a lost art these days. Love that this is built right in and just works. Well worth the 5 minutes it took to learn. Thank you!

Share your thoughts, leave a comment!