0

i have written a script in python using monkeyrunner:

image=device.takeSnapshot()
image.writeToFile('filename.jpg','jpg')

but i have got a null image like this:

-rw-rw-r-- owner group 0 Apr 14 21:56 filename.jpg

when i write

image.writeToFile('filename.png','png')

it worked well.I don't know why.

manlio
  • 18,345
  • 14
  • 76
  • 126
Arthur
  • 11
  • 2

1 Answers1

0

Fortunately, adbclient the communication method used by AndroidViewClient/culebra to interact with Android devices and emulators, supports saving images as JPEG.

The basic script to do it would be really simple

#! /usr/bin/env python
# -*- coding: utf-8 -*-

from com.dtmilano.android.adb.adbclient import AdbClient

AdbClient('.*').takeSnapshot().save('/tmp/image.jpg', 'JPEG')

If you are interested in knowing more about adbclient, why it can save images as JPEG or the driving forces behind it creation, there is an article that could help you understand, adbclient: under the hood of AndroidViewClient/culebra.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134