Capture an image of the whole, or part of the screen.

       screencapture [options] [file]
   -a   Do not capture attached windows.

   -b   Capture Touch Bar, only works in non-interactive modes.
   -B bundleid  Open in the app matching bundleid.

   -c   Force screen capture to go to the clipboard.
   -C   Capture the cursor as well as the screen.  Only allowed in 
        non-interactive modes.

   -d   Display errors to the user graphically.
   -D display Screen capture or record from the display specified.
              1 is main, 2 secondary, etc

   -g   Capture audio during a video recording using default input.
   -G id  Capture audio during a video recording using audio source specified by id.

   -i   Capture screen interactively, by selection or window.
          The control key = copy screen to the clipboard.
          The space key will toggle between mouse selection and window selection modes.
          The escape key will cancel the screen shot.
   -I   Open the taken picture in Messages.

   -J style  Set the starting style of interfactive capture "selection","window","video".

   -k   Show clicks in video recordings.

   -l windowid  Capture the window with windowid.

   -m   Only capture the main monitor, undefined if -i is set.
   -M   Open the taken picture in a new Mail message.

   -o   In window capture mode, do not capture the shadow of the window.

   -p   Screen capture will use the default settings for capture.
        The files argument will be ignored.
   -P   Open the taken picture in a Preview window or QuickTime Player if video..

   -r   Do not add screen dpi meta data to captured file.
   -R rectangle  Capture rectangle using format x,y,width,height.

   -s   Only allow mouse selection mode.
   -S   In window capture mode, capture the screen instead of the window.

   -t format   Image format to create, default is png (other options
               include pdf, jpg, tiff and others).

   -T seconds  Take the picture after a delay of seconds, default=5
               Handy for arranging windows/menus before taking the screenshot.

   -u   Present UI after screencapture is complete. Files passed to commandline will be ignored.
   -U   Show interactive toolbar in interactive mode.
   -v          Capture video recording of the screen.
   -V seconds  Capture video recording of the screen for the specified seconds.

   -w   Only allow window selection mode.
   -W   Start interaction in window selection mode.
   -x   Do not play sounds.

   -l windowid  Capture a specific windowsid.

   -R x,y,w,h   Capture a screen rectangle, top,left,width,height.

  file   Where to save the screen capture, 1 file per screen.

  -help  Display brief syntax summary.

Drop Shadow

To turn off the default window drop shadows, this will make your screenshot files smaller.

defaults write disable-shadow -bool true
killall SystemUIServer

Save Screenshots to a given Location

By default screen shots are saved to the desktop, but this can be changed with a default

Set save location to ~/Desktop:
defaults write location ~/Desktop && \ killall SystemUIServer

Set the file format for saved screenshots

By default screneshots are saved as .png files, supported formats are: .bmp, .gif, .jpg, .jpeg, .pdf, .tiff

Set file format to .png:
defaults write type -string "png"

Remote captures:

To capture screen content while logged in via ssh, you must launch screencapture in the same mach bootstrap hierarchy as loginwindow:

PID=pid of loginwindow
sudo launchctl bsexec $PID screencapture [options]


Wait 10 seconds, then take a screen capture of the entire screen including the cursor:

$ screencapture -T 10 -C ~/screencap1.png

To take a screenshot of one window, excluding the surrounding drop shadow, point and click with the mouse to take the screenshot:

$ screencapture -o -W ~/screencap2.png

Take a screen shot of the DVD player (where the normal keyboard shortcuts won’t work)

$ screencapture -i ~/Desktop/dvd.png

The mouse will turn into crosshairs, hit the space bar for camera mode, now click the window the DVD is playing in.
A file called "dvd.png" will appear on your desktop.

“The photograph itself doesn’t interest me. I want only to capture a minute part of reality” ~ Henri Cartier-Bresson

Related macOS commands

sips - Scriptable image processing system.
macOS Keyboard shortcuts
VLC will also allow screenshots of DVDs.

Copyright © 1999-2024
Some rights reserved