最近的工作需要用到屏幕截图命令,对于程序员来说还是喜欢用命令行来操作(虽然OSX提供的键盘快捷键可以完成相关截图工作,但是感觉没命令行来得痛快)。在OSX中截图可以用screencapture命令,该命令位于/usr/sbin/screencapture目录。
命令
screencapture
参数相关
-i 自由选择截图区域
screencapture -i /Users/iMac/Desktop/IMG.PNG
-w 自动捕获桌面窗口区域
screencapture -w /Users/iMac/Desktop/IMG.PNG
-c 截图后保存在剪贴板
screencapture -c
当然还有更多命令选择,可以参考screencapture -h
-C capture the cursor as well as the screen. only in non-interactive modes
-d display errors to the user graphically
-m only capture the main monitor, undefined if -i is set
-M screen capture output will go to a new Mail message
-o in window capture mode, do not capture the shadow of the window
-P screen capture output will open in Preview
-s only allow mouse selection mode
-S in window capture mode, capture the screen not the window
-t<format> image format to create, default is png (other options include pdf, jpg, tiff and other formats)
-T<seconds> Take the picture after a delay of <seconds>, default is 5
-W start interaction in window selection mode
-x do not play sounds
-a do not include windows attached to selected windows
-r do not add dpi meta data to image
-l<windowid> capture this windowsid
-R<x,y,w,h> capture screen rect
-B<bundleid> screen capture output will open in app with bundleidBS