Android Screenshot Script

If you make apps and work in a consultancy you’ll probably be used to taking a screenshot on-device with the power and volume keys pressed, then emailing them to yourself, downloading, and scaling them down to a smaller size before sending them on.

This little script does it all for you (if you’re on OSX, remove the sips line for Linux):


timestamp=$(date +%s)
echo $filepath
adb shell screencap -p $filepath
adb pull $filepath
adb shell rm $filepath
sips --resampleWidth 270 $timestamp.png

Just put the script somewhere suitable, edit the permissions to make it executable (chmod u+x, attach your device via USB, make sure it’s debuggable, then run the script. The Android SDK comes with adb (android debug bridge) which allows you to take and grab the screenshot, then Apple’s own sips (scriptable image processing system full guide here) takes the image file and scales it down to 270 pixels wide (while maintaining the image ratio).