Skip to content

Instantly share code, notes, and snippets.

@petitviolet
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petitviolet/04654990fa54c0c5b130 to your computer and use it in GitHub Desktop.
Save petitviolet/04654990fa54c0c5b130 to your computer and use it in GitHub Desktop.
adb経由でscreenshotを撮る
#!/bin/sh
DATE_TIME=`date +"%Y%m%d-%H%M%S"`
FILE_NAME=${DATE_TIME}.png
TARGET_PATH="./"
SIZE="x480"
USAGE="
Usage: "`basename $0`" -t [target_path] -s [size]\n
options\n
-t: local file path for screen shot\n
-s: compress rate, using convert"
while getopts ht:s: option
do
case $option in
h)
echo $USAGE
exit 0;;
t)
TARGET_PATH=$OPTARG;;
s)
SIZE=$OPTARG;;
\?)
echo $USAGE
exit 1;;
esac
done
adb shell screencap -p /sdcard/$FILE_NAME
adb pull /sdcard/$FILE_NAME
adb shell rm /sdcard/$FILE_NAME
convert -resize $SIZE $FILE_NAME $FILE_NAME
mv ./$FILE_NAME $TARGET_PATH
echo screenshot saved to $TARGET_PATH/$FILE_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment