Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch process images using OS X SIPS (scriptable image processing system) to downsize images only?

I'd like to batch process several folders of 1000's of images to downsize any images with a long side greater than 1440 pixels down to 1440 while ignoring any files that are already smaller than that.

I was looking at sips and can't tell if it skips upsizing by default or if there is a way to filter it using getProperty perhaps? (I'm not the best at deciphering CLI options from man pages).

I was thinking maybe I could use a find or sips query first and then pipe it into another sips to resize, I'm not sure exactly how though and don't think find can search by image size.

(also open to something other than sips to handle this, just seemed the quickest way)

like image 819
jb510 Avatar asked Nov 16 '25 02:11

jb510


1 Answers

Using spotlight to filter results to to images larger than a particular size works perfectly:

mdfind -0 -onlyin . "kMDItemPixelHeight > 1440 || kMDItemPixelWidth > 1440" | xargs -0 sips -Z 1440

This find images recursively from the current directory with width OR height greater than 1440 pixels and resizes them down to 1440. Files under 1440 get left alone.

like image 54
jb510 Avatar answered Nov 17 '25 21:11

jb510



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!