How to take a photo on MacBook using Terminal Command?

Take Photo using Mac Terminal Command

If you have a use-case where in you want to capture an image (photo) using the Macbook webcam using a Terminal Command, well you can do so easily by using a tool called imagesnap

You can install the imagesnap package using brew,

% brew install imagesnap

Usage Example:

Once installed, open the Mac Terminal App and simply type imagesnap on the shell prompt when ready to capture an image,

% imagesnap
Capturing image from device "FaceTime HD Camera"...snapshot.jpg

For the first use you will be asked - "" would like to access the camera. say OK would like to access the camera - message

The image you captured will be saved as snapshot.jpg to the current location you are in (pwd)

To save the image with a custom image name, pass in an argument with the file-name.jpg

% imagesnap mike-2023-01-23.jpg

If you have multiple camera devices attached to your device, make use of the -l option to list them,

% imagesnap -l
Video Devices:
=> FaceTime HD Camera (Built-in)
=> USB 3.0 Camera
=> bitCam

You can set the custom camera to click a photo using the -d option followed by the device name,

% imagesnap -d bitCam 

Check out the help to know more,

% imagesnap -h
USAGE: imagesnap [options] [filename]
Version: 0.2.15
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.
JPEG is the only supported output type.
  -h          This help message
  -v          Verbose mode
  -l          List available video devices
  -t x.xx     Take a picture every x.xx seconds
  -n num      Limit to <num> snapshots in -t timelapse mode
  -q          Quiet mode. Do not output any text
  -w x.xx     Warmup. Delay snapshot x.xx seconds after turning on the camera (default 3sec)
  -d device   Use named video device

Github Page:

You can easily use this package in a Python Script to fit in a use-case such as

  • Take class attendance using photo capture and face recognition.
  • Take a photo after submitting an application form.
  • Take photo before a git commit

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail:

Copyright ยฉ Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap