Newsletter
TechAnV Blog
Get updates on security engineering, Rust, eBPF, and DevSecOps. No spam, unsubscribe anytime.
Check your inbox and click the confirmation link to complete your subscription.
sips: Scriptable image processing system#
I wanted to convert some .webp images to .png on my Mac. I asked ChatGPT:
On MacOS use CLI to convert webp images to PNG
And it told me about sips:
1sips -s format png image.webp --out image.pngOr to run it against all PNGs in a folder:
1for file in *.webp; do sips -s format png "$file" --out "${file%.*}.png"; doneI had never heard of sips before - but apparently it’s been a default command on macOS for a very long time.
It stands for “scriptable image processing system”. man sips starts like this:
1NAME2 sips – scriptable image processing system.3
4SYNOPSIS5 sips [image-functions] imagefile ...6 sips [profile-functions] profile ...7
8DESCRIPTION9 This tool is used to query or modify raster image files and ColorSync ICC10 profiles. Its functionality can also be used through the "Image Events"11 AppleScript suite. It also supports executing JavaScript to either12 modify or generate images.It can run JavaScript!
I asked ChatGPT for an example, but it halucinated something that didn’t actually work.
After some searching I found manicmaniac/sips-js-api which is the only place online I could see that documented how to use the sips --js option. Here’s their example - save this in smile.js:
1const canvas = new Canvas(150, 150)2canvas.beginPath()3canvas.arc(75, 75, 50, 0, Math.PI * 2, true)4canvas.moveTo(110, 75)5canvas.arc(75, 75, 35, 0, Math.PI, false)6canvas.moveTo(65, 65)7canvas.arc(60, 65, 5, 0, Math.PI * 2, true)8canvas.moveTo(95, 65)9canvas.arc(90, 65, 5, 0, Math.PI * 2, true)10canvas.stroke()11const output = new Output(canvas, sips.outputPath)12output.addToQueue()Then run:
1sips -j smile.js -o smile.pngThis produces an alpha-transparent PNG of a smiling face.

The only other relevant documentation I could find was this section of the man sips page:
1JavaScript2 HTML Canvas objects can be created and used to create a 2D drawing context. The commands for drawing into the context are well documented elsewhere. This3 section will describe the sips global object and other interesting classes.4
5 Global variable (sips) properties6 images7 Valid images passed as arguments converted into an array of Image objects8 arguments9 Arguments passed into the program as an array of strings10 size Recommended size for output. Setting the crop or resample flags will set this value.11 longestEdge12 If specified, the value of the -Z/--resampleHeightWidthMax option. [default: 0]13 outputPath14 Output directory [default: current directory]15
16 Image Object17 name Name of image18 size Size of image (pixels)19 properties20 Image properties21 getProperty(name)22 Return the image property for name, if any.23 sizeToFitLongestEdge(length)24 Return the size that will contain the image with the longest edge set to length. Maintains aspect ratio.25
26 Output Object27 new Output(context, name[, type])28 Output the context to disk with name and optional type (extension or UTI).29 addToQueue()30 Adds the output to the queue to be written to disk.31
32 Functions33 print(str)34 Output to standard output. Equivalent to console.log(str).