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: screencapture -R takes the same screenshot area every time

Screenshot
~/tips/tip-screenshot-screencapture-region

screencapture -R 0,0,1280,720 ~/Desktop/step-1.png

Grab an exact rectangle of the screen with identical size each run.

For a before and after comparison, or a set of pictures in a guide, dragging a selection by hand never gives you quite the same frame twice. You can give the coordinates instead.

screencapture -R 0,0,1280,720 ~/Desktop/step-1.png

The four numbers are x, y, width and height: where the top left corner of the rectangle starts, then how big it is. Run it again with a new file name and you get the identical area.

Add -x if the camera sound bothers you, and a small loop gives you a series:

for i in 1 2 3; do
  screencapture -x -R 0,0,1280,720 ~/Desktop/frame-$i.png
  sleep 5
done

I’d put the window I’m documenting in the corner first and then adjust the numbers until the frame fits. It takes a couple of tries and then it is repeatable.

The numbers are screen points, so on a Retina display the saved image usually has more pixels than the width you typed. The coordinates point at the screen and not at a window: move the window and you capture whatever is there now. macOS may also ask you to allow screen recording for your terminal app before other windows show up in the result.

Further reading: Take screenshots or screen recordings on Mac

More Screenshot tips Tap the preview > Full Page > Done > Save PDF to Files Shift-Command-5 > Options > Show Floating Thumbnail screencapture -T 5 ~/Desktop/menu.png All Screenshot tips (4) All topics

Link