3

Is it possible to take a screenshot of my Android device using PHP?

I suppose that I need to take a screenshot using adb (exec an adb command) and then display the result in my PHP code?

Have someone tried something similar?

Any suggestions?

hakre
  • 193,403
  • 52
  • 435
  • 836
glarkou
  • 7,023
  • 12
  • 68
  • 118

2 Answers2

0

Yes, it is possible when the device is connected to the system running PHP and the user running PHP has access rights to USB.

You need the following software for my quick & dirty solution: BASH (or similar), ffmpeg, adb and PHP with shell_exec.

screenshot.sh

adb pull /dev/graphics/fb0 && \
ffmpeg -vframes 1 -f rawvideo -pix_fmt rgb32 -s 480x854 -i fb0 screenshot.png

It is important to adjust the screen resolution (480x854).

Test

php -r 'echo shell_exec("sh ./screenshot.sh");'

Thanks to http://forum.xda-developers.com/showthread.php?t=1405275

Rayne
  • 2,620
  • 20
  • 28
-1

The only way you can do that is running PHP code in your Android device and running an external program, thats because PHP can't see/"touch" the client side when you are browsing a website.

Babblo
  • 794
  • 5
  • 17