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?
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.
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