Capture Images from the Command Line
Latest Info on github.com/rharder/imagesnap
ImageSnap is a Public Domain command-line tool that lets you capture still images from an iSight or other video source.
The rest of this page is left here for historical purposes.
Installation
Copy the imagesnap file to someplace on your path like /usr/local/bin, or leave it in a "current directory," and call it with ./imagesnap instead.
Enjoy!
Usage
To capture an image simply run the program from the command line.
$ imagesnap Capturing image from device "iSight"..................snapshot.jpg
To specify a filename, make that your last argument:
$ imagesnap icu.jpg Capturing image from device "iSight"..................icu.jpg
If you have multiple video devices attached to your computer, use the -l ("el") flag to list them:
$ imagesnap -l Video Devices: iSight DV
To select a specific video device use the -d device flag:
$ imagesnap -d DV Capturing image from device "DV"..................snapshot.jpg
To output a jpeg representation to standard out (stdout), use a dash for the filename:
$ ssh johndoe@somewhere.com /usr/local/bin/imagesnap - > snapshot.jpg $ open snapshot.jpg
Thanks to Bas Zoetekouw for adding timelapse capability. Freebie: if you want to convert the fielnames, which have dates embedded in them, to a simple serial number for use with QuickTimer Player 7, try this:
for f in *.jpg; do mv $f ${f:0:14}.jpg; done
All commands:
USAGE: imagesnap [options] [filename] Version: 0.2.5 Captures an image from a video device and saves it in a file. If no device is specified, the system default will be used. If no filename is specfied, snapshot.jpg will be used. Supported image types: JPEG, TIFF, PNG, GIF, BMP -h This help message -v Verbose mode -l List available video devices -t x.xx Take a picture every x.xx seconds -q Quiet mode. Do not output any text -w x.xx Warmup. Delay snapshot x.xx seconds after turning on camera -d device Use named video device
Clever Scripts
MacOSXHints.com has had a number of useful hints over time on what to do with command line capturing from an iSight camera (using the original isightcapture tool). The ideas apply the same to ImageSnap. Here are some of the hints out there:
- An advanced script/web solution to track stolen Macs
- Take iSight snapshots during invalid login attempts
- Some perl scripts to help track stolen computers
- Capture laptop screenshots to remote devices
- Snap and upload iSight pictures on wake from sleep
You could also make a sneaky Automator workflow that takes a picture discreetly, if you don't want to use the Apple "Take Video Snapshot" action which presents a preview window. Use the Run Shell Script action, and echo the filename to the next component:
Image Formats
The following image formats are supported and are determined by the filename extension:
- JPEG (*.jpg, *.jpeg)
- TIFF (*.tif, *.tiff)
- PNG (*.png)
- GIF (*.gif)
- BMP (*.bmp)
Changes
- v0.2.5 - Added option to delay the first snapshot for some time. Added a time-lapse feature (thanks, Bas Zoetekouw).
- v0.2.4 - Found bug that caused crash on Mac OS X 10.5 (but not 10.6).
- v0.2.3 - Fixed bug that caused crash on Mac OS X 10.5 (but not 10.6).
- v0.2.3 - Fixed bug that caused all images to be saved as TIFF. Not sure when this bug was introduced.
- v0.2.2 - Added ability to output jpeg to standard out. Made executable lowercase imagesnap.
- v0.2.1 - Changed name to ImageSnap from ImageCapture to avoid confusion with Apple's Image Capture application.
- v0.2 - Multiple file formats (not just TIFF). Faster response.
- v0.1 - This is the initial release.
A Note About Public Domain
I have released this software into the Public Domain. That means you can do whatever you want with it. Really. You don't have to match it up with any other open source license—just use it. You can rename the files, do whatever you want. If your lawyers say you have to have a license, contact me, and I'll make a special release to you under whatever reasonable license you desire: MIT, BSD, GPL, whatever.
blog comments powered by Disqus