5 ms·
Sips: Scriptable Image Processing System
- daneel_w 4y agoI've made use of sips(1) for years to un/bundle application icons for build processes and other things. Great tool, more or less unknown like so many other hidden userland gems in macOS.
- torstenvl 4y agoSame. I use sips as part of my build process. The package target depends on the binary target and the icns target, which depends on the iconset target, which uses sips.
- RodgerTheGreat 4y agoI've always used "iconutil" to do the same.
- giantrobot 4y agoI've found sips very helpful dealing with JPEG 2000 images in places where ImageMagick would not render them correctly. Another very helpful Mac utility is textutil which will convert text documents between different formats. It uses the same underlying frameworks as TextEdit so it's not a replacement for {Microsoft,Libre}Office but it can spit out an OpenOffice document from an RTF or Word document in a pinch.
- Terretta 4y ago> convert text documents between different formats see also pandoc, though obv not a built-in
- giantrobot 4y agoPandoc is far and away more powerful than textutil hands down. If you've got pandoc available you likely don't need textutil. However, as you point out, pandoc isn't built in. Like sips it's nice to know it's available on a default macOS install.
- arrakeen 4y agoat first i thought this was some sort of wrapper around vips[1] which is extremely powerful, but whose CLI leaves a lot to be desired. even so, i make use of it quite a bit. here's how i'd convert the webps to png: parallel vips copy {} {.}.png ::: *.webp [1] https://www.libvips.org/API/current/using-cli.html https://www.libvips.org/API/current/using-cli.html
- Uehreka 4y agoHow does this deal with throttling those operations? Like, if I’m converting 100 or 1000 PNGs to Webp, I probably only want 12-ish operations going on at a time so my CPU isn’t context-switching like crazy and the PNGs don’t all load into RAM at once.
- anamexis 4y agoThey're using GNU parallel, which will default to the number of CPU threads available, but which can be tweaked to your liking. https://www.gnu.org/software/parallel/sphinx.html https://www.gnu.org/software/parallel/sphinx.html
- giantrobot 4y agoWhile I love GNU Parallel there's also the venerable (and installed by default) xargs.
- lelandfe 4y agoUndermentioned macOS feature: right click an image in Finder, Quick Actions > Convert Image. Lets you change formats, resize, and strip metadata from images, and supports bulk operations too.
- deleted 4y ago[deleted]
- gouggoug 4y agoIs there a place listing all these little known but useful macOS utilities?
- joshspankit 4y ago`man -k .`
- KingLancelot 4y agoWe need lossless content first and foremost, after that we can worry about yet another image compression pipeline.
- foverzar 4y agoI've always used ImageMagick for this kind of stuff.
- m000 4y agoThe problem with ImageMagick is that its scripting language sucks. I had tried using it a couple of times but it's too obscure and sparsely documented to get it to work for you. In the end I gave up because I realized that the result would be unmaintainable, so I'm better off with bash scripts. Sips got it right with providing a Javascript API instead of inventing another obscure DSL.
- bobajeff 4y agoWhat about making a bash script with ImageMagick commands? I didn't even know it had a scripting language.
- speed_spread 4y agoIf you need scripting just use IM as a lib from Python.
- buildbot 4y agoTangential, but one of the things I love about MacOS is stuff like this. It's hard to discover, but very cool when you do. Like the say command, which is still updated to work with the very latest AI voices.
- billfruit 4y agoBut is it very different from ImageMagik in terms of functionality?
- buildbot 4y agoNot that I know of, but one has to install that.
- giantrobot 4y agoImageMagick is vastly more powerful than sips. There's little reason not to use it when it's available. However if you're writing a script for macOS and sips suits your needs it's really nice to have. See also the avconvert tool, it's not as capable as ffmpeg but it'll ingest and convert any format/codec supported by AVFoundation and comes with the system.
- jbverschoor 4y agoSips is way faster and produces better results in tens of quality (color management). It’s a tricky thing to do right with magick
- woolion 4y agoCould you expand? I've used ImageMagick to do some fairly advanced color management, and I really don't see how that can be true. You have basic keyword arguments for common use-cases, and you can get down to matrix operations on the color space to have absolute control. The only thing that I missed was that if you wanted to 'pipe' matrix transforms one into the other, you couldn't do it in different steps because of the precision loss (that is due to image encoding, not IM), so the best way to do that was to multiply the matrices to always do it on one step.
- yogthos 4y agoYou can also do this with node npm install nbb canvas create a draw.cljs file with the code below (ns draw.core (:require ["fs" :as fs] ["canvas" :refer (createCanvas)])) (def width 400) (def height 400) (def canvas (createCanvas width height)) (def ctx (.getContext canvas "2d")) (set! (.-fillStyle ctx) "#764abc") (.fillRect ctx 0 0 width height) (set! (.-fillStyle ctx) "#fff") (set! (.-textAlign ctx) "center") (set! (.-font ctx) "bold 50pt 'PT Sans'") (.fillText ctx "Hello World" (/ width 2) (/ height 2)) (set! (.-strokeStyle ctx) "#fff") (.beginPath ctx) (.arc ctx 75 75 50 0 (* 2 js/Math.PI) true) (.moveTo ctx 110, 75) (.arc ctx 75 75 35 0 js/Math.PI false) (.moveTo ctx 65 65) (.arc ctx 60 65 5 0 (* 2 js/Math.PI) true) (.moveTo ctx 95 65) (.arc ctx 90 65 5 0 (* 2 js/Math.PI) true) (.closePath ctx) (.stroke ctx) (.writeFileSync fs "./hello.png" (.toBuffer canvas "image/png")) and run to make a PNG npx nbb draw.cljs as a bonus you can start nREPL and connect your editor to it for interactive development nbb nrepl-server :port 1337
- wokwokwok 4y agoUm. You can, but I'm not sure why you would, or how it's relevant? sips is installed by default, that's the only reason you'd use it over any number of other drawing tools. Using node and clojure seems like it's more effort, more obscure and less functionality than any number of other things. If you're going to install something, install imagemagick. If you're looking for something else kind of like sips, try hand coding an svg like: <svg xmlns="http://www.w3.org/2000/svg" width="500" height="500" viewBox="0 0 500 500"> <rect x="3" y="3" width="200" height="200"></rect> </svg> Then run the thumbnail generator on it: qlmanage -t -s 500 -o . junk.svg Using clojure (nbb) for this seems... like a solution looking for a problem to solve.
- yogthos 4y agoUm. This would not seem to be relevant only if you didn't bother reading the article in the submission. Once you do, you'll notice the following example there: 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: const canvas = new Canvas(150, 150) canvas.beginPath() canvas.arc(75, 75, 50, 0, Math.PI * 2, true) canvas.moveTo(110, 75) canvas.arc(75, 75, 35, 0, Math.PI, false) canvas.moveTo(65, 65) canvas.arc(60, 65, 5, 0, Math.PI * 2, true) canvas.moveTo(95, 65) canvas.arc(90, 65, 5, 0, Math.PI * 2, true) canvas.stroke() const output = new Output(canvas, sips.outputPath) output.addToQueue() Then run: sips -j smile.js -o smile.png This produces an alpha-transparent PNG of a smiling face. The obvious advantage of using node over sips is that it works on every platform. You'll also have to elaborate on what this additional effort you speak of is. If you have node installed, as practically everyone does nowadays, then the presumed effort is in having to run npm install? Also, you obviously don't have to use Clojure, I chose it because that's the language I already use and like. You could just make a regular Js file as well. Hope that helped clarify things for you.