Capture iSight Images Using the Command Line
We all know that Photo Booth is great fun and is sure to entertain our friends and family with the goofy effects. But what if you want to take pictures using your iSight from the command line? Unfortunately Apple doesn’t provide this option (at least that we know of), but thanks to a crafty individual named Axel Bauer, we have a command line tool available for the task. Being able to capture images from the command line opens up many interesting possibilities, and we name a few potential uses.
Updated: 1/31/2013 – We are now referring to the ImageSnap tool to take pictures with the iSight or FaceTime camera by way of the Terminal. The old iSightCapture app is no longer supported and it doesn’t work on newer Macs and newer versions of OSX, instead the ImageSnap works. ImageSnap is based on iSightCapture but remains in development and works with OS X 10.8+ Mountain Lion and later.
Capture iSight / FaceTime Camera Images with the Command Line
ImageSnap is a free third party app that is very easy to use. Here is how to download it, install it, and use it:
- Download ImageSnap
- Extract it with tar -xvf imagesnap.tgz
- Copy imagesnap executable into /usr/local/bin/ with ‘sudo cp imagesnap /usr/local/bin/’
- Confirm it is working by running ‘imagesnap’ at the command line
The default file is saved as a JPG named snapshot.jpg in the present working directory. You can specify another file name or path if desired:
To immediately see a picture after it has been taken with imagesnap from the command line:
imagesnap & open snapshot.jpg
That will launch the picture in the default photo editor, whichever is associated with the JPG file format. By default that is usually Preview in Mac OS X unless the file and app association has been changed within the Finder. Open functions as a command line interface to opening files, documents, and directories into the Finder and OS X GUI.
Do note the older article about iSightCapture remains below for archival purposes, and for those with older Macs where ImageSnap may not work. For all newer Macs, use ImageSnap instead if you wish to capture camera images with iSight (or FaceTime) images using the command line.
Installation of iSightCapture is very simple, place the isightcapture tool in /usr/sbin (or elsewhere if you’d prefer) and you’ll be able to run the command line tool, with the following options:
-d : enable debugging messages. Off by default
-n : capture nth-frame
-w : output file pixel width. Defaults to 640 pixels.
-h : output file pixel height. Defaults to 480 pixels.
-t : output format – one of jpg, png, tiff or bmp. Defaults to JPEG.
Using the tool is easy, and here are a few examples (from the readme.rtf):
$ ./isightcapture image.jpg
will output a 640×480 image in JPEG format
$ ./isightcapture -w 320 -h 240 -t png image.png
will output a scaled 320×240 image in PNG format
Other than the obvious usages, there are a some creative ideas floating around for use with this utility, our favorite being Dylan O’Donnell’s script that takes a picture on system wake and uploads it to a website, creating a nice photo collage. The results are quite interesting, check out his site for the script and a demonstration of the effect. Of course, you could also ssh/telnet into a Mac running this tool and take pictures of the user without them knowing, or even create a security system of sorts by writing a simple script that automates picture taking. The possibilities are numerous…