1

I'm using https://github.com/appknox/pyaxmlparser to parse apk.

There is an property to get icon data :

apk.icon_data

When i print the output i have a string like this :

\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\xc0\x00\x00\x00\xc0\x08\x06\x00\x00\x00R\xd

(It's too long )

What is this ?

How can i use this string to get a real image file ? Or even convert it to Base64 format

2
  • 5
    it seems to be the bytes that compose a PNG file - try writing them to a file with .png extension then open it with your image viewer
    – nosklo
    Commented Sep 7, 2018 at 7:11
  • Thanks. i'm going to check this @nosklo
    – A Pishma
    Commented Sep 7, 2018 at 7:32

1 Answer 1

0

apk.icon_data returns the value in byte-array(unicode UTF-16). In Python, Pillow supports byte-array to image conversion. You can checkout this issue for details -

import sys
from pyaxmlparser import APK
from PIL import Image
from io import BytesIO

apk = APK ('apk/file/path.apk')

LEFT_THUMB = apk.icon_data

stream = BytesIO(LEFT_THUMB)

image = Image.open(stream).convert("RGBA")
stream.close()
image.save('out.png')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.