TaillookTech

モバイルアプリ開発を追っています

ImageSnapを使ってbash上で写真を撮る

はじめに

bashコマンドで写真とか撮れないかなーって探してたらあったので使ってみた.

ImageSnapとは

ImageSnapはWebカメラから画像をキャプチャできるコマンドラインツール.

詳細

github.com

使ってみる

環境

インストール

brewでインストールできる.
brew install imagesnap

ヘルプ

とりあえずimagesnap -h

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

写真を撮る

imagesnap -q -w 1 snapshot.pngで写真が撮れる.
オプションはqとwを使っている.
qはリザルトとかの出力をなくす.wは写真を撮る時間をコマンド実行時から遅らせる.
今回は1秒遅らせた.(このオプションを付けないと画像が真っ暗になった.レンズのライトが着くタイミングとかなのかな…?)

何秒かごとに写真を撮る.

tオプションを付けることで何秒かごとに写真を撮ることができる.
imagesnap -t 1.00で1秒ごとに写真を撮ることができる.

結果

open snapshot.pngで写真を開く.
f:id:taillook:20170306232438p:plain
こんな感じの写真が撮れた.

感想

後ろに居る人にバレずに写真を撮りたい時とかに使えそう.