Screen capture as a full-resolution jpeg image

Screen capture using the standard key press Command-Shift-3 by default saves the captured screen image in png format. The default format may be changed to jpeg using the well-described Terminal commands:

defaults write com.apple.screencapture type jpg
killall SystemUIServer

## Note: change jpg to png to restore default behavior

A potential drawback to this approach is that the resolution of the captured jpeg screen images cannot be modified and is somewhat less than the very high resolution needed to approximate the quality of full resolution png image capture. The following shell script, which may be saved as a Services Automator action and bound to a keyboard shortcut, allows one to control the resolution of the captured jpeg image:

## Create a unique file name using the current date
fileName="Screen Shot $(date '+%Y-%m-%d at %-l.%M.%S %p')"
## Capture the screen initially as a full-resolution png image in the temporary folder
screencapture -S -t png "/private/tmp/$fileName.png"
## Convert the png image to a very-high-resolution jpeg image using the shell program "sips", and save it to the desktop in the form: "Screen Shot YYYY-MM-DD at HH.MM.SS AM (or PM).jpg"
sips -s format jpeg -s formatOptions best "/private/tmp/$fileName.png" --out "/Users/[username]/Desktop/$fileName.jpg"
## Delete the png image in the temporary folder
rm "/private/tmp/$fileName.png" || :

Usage notes:

  1. Replace “[username]” with your username
  2. Change “screencapture -S” to “screencapture -i” to mimic the standard key press Command-Shift-4, i.e., interactive partial screen capture, rather than whole screen capture
  3. Change “formatOptions best” to “formatOptions [one of the values listed below]” to modify the jpeg resolution to the desired value:

best

  • Very high resolution
  • Image quality is virtually indistiguishable from the full-resolution png image but generally a little smaller in size than the png image
  • This is the setting in the script above

high

  • High resolution
  • Image quality is slightly-to-mildly inferior to the full-resolution png image but significantly smaller in size
  • This is essentially the setting after changing standard screen capture to jpeg format with the previously listed Terminal commands: defaults write com.apple.screencapture type jpg; killall SystemUIServer;

normal

  • Medium resolution
  • Even smaller file size but with mild loss of image quality

low

  • Low resolution
  • Much smaller file size but with moderate loss of image quality

To make the shell script particularly useful, save it as a Services Automator action and bind it to a keyboard shortcut as follows.

  1. Launch the Automator application
  2. Choose “Service” as the document type
  3. Select (i.e., drag and drop) the “Run Shell Script” service
  4. Under “Service receives”, select “no input” in “any application”
  5. Be sure Shell is set to “/bin/bash”
  6. Copy the above script (from “## Create a unique file name using the current date” to “rm “/private/tmp/$fileName.png” || :”) into the content area of the “Run Shell Script” service
  7. Press File > Save, and give the service a name such as “Jpeg Whole Screen Capture” or “Jpeg Interactive Screen Capture” depending on whether “screencapture -S” or “screencapture -i”, respectively, is used in the script
  8. Quit Automator
  9. Open System Preferences > Keyboard > Shortcuts
  10. Select “Services” in the left column, scroll down to the services you just created, and add the desired keyboard shortcuts.

I assigned Command-Option-Shift-3 to “Jpeg Whole Screen Capture” and Command-Option-Shift-4 to “Jpeg Interactive Screen Capture” to create full-resolution jpeg screen captures analogous to the standard key presses Command-Shift-3 and Command-Shift-4 for png screen captures.

A final note: The various features of interactive screen capture, such as pressing the spacebar for window capture, will continue to work as expected for jpeg screen captures using this technique.

Edit note: A couple of minor typos were corrected within a few minutes after submitting the post.