How to Resize Images Like a Pro Using Terminal Commands

As a web developer and photographer, I often look for the most efficient methods to manage images. Terminal commands make life easy for me, especially when I need to manage files in bulk. This is a guide on how to use terminal (on a Mac) to resize and manage your images.

Getting Started With Terminal

The fist step to managing your images like a pro with terminal is to get started using terminal. If you are well versed with working with a command line interface before then you should be right at home. Otherwise, here is a quick rundown on how to use Terminal.

Opening Terminal

Opening the terminal app will open a nifty little command line interface. It is important to note that your commands will run in whichever folder terminal is open to. By default, your user’s home folder will be open by default upon launch. This means that you will need to change to the directory that your images in before you can start to manage them.

There are a few ways that you can do this. The first is to use a command. Changing directory can be done by using the CD command. Here is an example that will open your Pictures directory:

cd Pictures

An often easier way to open folders in terminal is to enable the option to open a folder in terminal when right clicking on the folder. To enable this, open your settings and navigate to Keyboard > Shortcuts and click on Services in the left sidebar. Then locate New Terminal at Folder and New Terminal Tab at Folder and make sure they are checked.

Now, you can right click on a folder when viewing it in finder and you should be able to see New Terminal at Folder and New Terminal Tab at Folder as options. Clicking either of those will launch Terminal directly into that folder.

Resize Images Using Terminal

Now that you are able to open Terminal to a folder that contains your pictures, you are ready to actually manage your images. I recommend testing these commands in a folder that contains images that are backed up.

Open a Folder and Locate Your Image

Launch Terminal into a folder with some images that you would like to manage. Then type the command ls and hit enter. This should display a list of all of the files in that folder.


You can expand on the ls command to list the sizes of files like this:

ls -lh

Resize Your Image With a Terminal Command

Now that you have located your image in Terminal, you are ready to resize it. You can check the dimensions of your image using this command:

file file.png

You can get more information about your file using this command:

sips -g all file.png 

The following command will resize file.png so that it is 300 pixels at its longest side. This means that it will be 300 pixels wide if it is oriented to landscape and will be 300 pixels wide if it is portrait orientation.

sips -Z 300 file.png

To resize all images in a folder at the same time use this command:

sips -Z 300 *.png

Sips and terminal are capable of a lot more than this. Here is a resource to learn more about what the sips command can do for you and your images.