vim: Update to latest patch level
[termux-packages] / packages / termux-api / termux-camera-photo
1 #!/bin/sh
2 set -e -u
3
4 SCRIPTNAME=termux-camera-photo
5 show_usage () {
6 echo "Usage: termux-camera-photo [-c camera-id] output-file"
7 echo "Take a photo and save it to a file in JPEG format."
8 echo " -c camera-id ID of the camera to use (see termux-camera-info), default: 0"
9 exit 0
10 }
11
12
13 PARAMS=""
14 while getopts :hc: option
15 do
16 case "$option" in
17 h) show_usage;;
18 c) PARAMS="--es camera $OPTARG";;
19 ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
20 esac
21 done
22 shift $(($OPTIND-1))
23
24 if [ $# = 0 ]; then echo "$SCRIPTNAME: missing file argument"; exit 1; fi
25 if [ $# != 1 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
26
27 touch $1
28 PARAMS="$PARAMS --es file `realpath $1`"
29
30 @TERMUX_API@ CameraPhoto $PARAMS