SIPS image resize for batch size and namming

1.8k views Asked by At

I would like a quick/simple way to use SIPS to resize images to the sizes I want.

Currently- I have to do each file one-by-one, including runnings the sips command, then renaming the file and copying it to another directory.

Ideally- I could automate this to work like the following.

In terminal:

sips -Z 500 *.png

rename the FILENAME_500x.png

sips -Z 1000 *.png

rename the FILENAME_1000x.png

sips -Z 1500 *.png

rename the FILENAME_1000x.png

1

There are 1 answers

0
Hamid Rouhani On

Define this function in your shell:

function resize() {for f in *.png; do sips -Z "$1" "$f"; mv "$f" "${f/.png/_$1x.png}"; done }

Then change current directory to where you want to resize images:

cd YourFolderContainsPNGFiles

Finally invoke resize function like this:

resize 500

For different pixelsWH change the argument:

resize 1500

The function resizes all *.png files in the current folder with the given argument and then appends _pixelWH to the file name.