brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: sips -Z shrinks photos from the terminal

Terminal
~/tips/tip-macos-sips-resize

sips -Z 1600 photo.jpg --out photo-small.jpg

Shrinks images to a maximum size from the terminal without opening an editor.

You do not need an image editor to make a photo smaller. macOS ships with one that only has a command line.

sips is the scriptable image processing system. The -Z flag resamples an image so that neither its height nor its width is greater than the size you give, and the aspect ratio stays.

sips -Z 1600 photo.jpg --out photo-small.jpg

Loop over a folder for a whole batch:

mkdir small
for f in *.jpg; do sips -Z 1600 "$f" --out small/"$f"; done

You can also convert formats with -s format. The man page lists jpeg, tiff, png, gif and a few more.

sips -s format png photo.jpg --out photo.png

The caveat: I always pass --out. The man page does not describe what happens to the original without it, and I would rather not find out on photos I cannot take again. Try it on a copy first.

If you handle many photos, this is also a decent way to prepare them for a web page, where a huge original only slows everything down. Keep the originals somewhere safe, write the small versions to a new folder, and you can redo the whole thing later with another size.

Further reading: sips.1 man page, On this site: docker image prune -a –filter until= only removes old images, On this site: screencapture -o -w grabs a window without the drop shadow

More Terminal tips ioreg -rn AppleSmartBattery | grep CycleCount Terminal can save your windows and tabs as a window group Export a Terminal profile to a .terminal file and import it on another Mac mc hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029}]}' All Terminal tips (116) All topics

Link