0

I am developing some simple app with Kivy/Python. I have some problem with displaying images which earlier were saved in android storage via Camera. Below I published a take_shot method which take a picture and save it in /storage/emulated/0/Kalkulator/ dir in android. After that the path to picture will be store in sqlite database.

def take_shot(self,name,when):
    if kiedy == 'before':
        self.before='/storage/emulated/0/Kalkulator/'+name+when+'.jpg'
        camera.take_picture(self.before,self.done(when))  
    elif kiedy == 'after':
        self.after = '/storage/emulated/0/Kalkulator/' + name + when+'.jpg'
        camera.take_picture(self.after, self.done(when))

Code below present method used to reading file where data is getting from database. When I try to display file from android storage, kivy displays only black square. When I try to display images from app directory './files/photos/irina.jpg' everything works fine.

    if str(data[5])=='Empty':
        before=Image(source='./files/photos/irina.jpg', 
              keep_ratio=True,size_hint= (1,None),height=dp(400))
    else:
        before = Image(source=str(dane[5]), keep_ratio=True,size_hint= 
                     (1,None),height=dp(400))
    if str(data[6]) == 'Empty':
        after = Image(source='./files/photos/irina.jpg', 
                   keep_ratio=True,size_hint= (1,None),height=dp(400))
    else:
        after = Image(source=str(dane[6]), keep_ratio=True,size_hint= 
                   (1,None),height=dp(400))
    photos.add_widget(before)
    photos.add_widget(after)
    self.ids.box.add_widget(photos)

Where is the problem? I don't have any errors in logs.

I saw that kivy don't display any Image with higher resolution.

Przemek
  • 27
  • 4
  • `When I try to display file from android storage, kivy displays only black square` Did you log a path to picture you're trying to load? Did you check if picture actually present by path? – Mikhail Gerasimov Jan 06 '18 at 15:59
  • @MikhailGerasimov Yes, picture is actually present by path. Probably problem is in size of the pictures. – Przemek Jan 07 '18 at 20:27
  • you're checking `data[5]` but then you're using `dane[5]` according to that code. If `dane` didn't exist you'd crash with an Exception. Are `dane` and `data` the things you think they are? Can you print the contents of both to be sure? Is the image path you're checking relative to your run path like your fallback image? – James Moore Jun 19 '18 at 01:18

1 Answers1

0

If you sure it's about picture size, things I guess you can do:

  • Try to use kivy master branch (use kivy==master in buildozer's requirements) to build apk: bug may be fixed there

  • Try to use another image provider (set KIVY_IMAGE to pil).

  • Try to reduce image size using Pillow.

  • Report issue on project's github

  • Ask for help in kivy users support google group

Mikhail Gerasimov
  • 36,989
  • 16
  • 116
  • 159