Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Error loading gif image in kivy Image

447 views
Skip to first unread message

Abdu Moez

unread,
Sep 8, 2023, 7:02:21 AM9/8/23
to Kivy users support
Issue Description:
I'm encountering a problem when trying to load GIF images in my code. Strangely, some GIF images work perfectly fine, but others do not. Here's what happened:

1. I initially added a GIF image to my code, and it worked without any issues. I simply changed the path to a different GIF image, and it also worked as expected.

2. However, when I attempted to add a new GIF image, which I intended to use for my splash screen, it didn't load up correctly.

CODE & LOGS:
1. kivy logs

Note: I attempted to extract the splash screen code from my app's code and rewrote it for clarity. However, there mightbe errors, and I apologize for any potential issues. I suspect the problem lies in the .kv file.


The gif image i want to insert is attach directly to this message.

smokingSkull.gif

elli...@cox.net

unread,
Sep 8, 2023, 7:37:20 PM9/8/23
to kivy-...@googlegroups.com

Interesting apparently not all gif formats are supported by the underlying libraries that provide gif support.  It is possible to convert the gif file to a zip file of images and use that instead. 

I used this site to convert the .gif to a zip of images.  https://ezgif.com/split

I have attached the resulting file.

 

I tested with this code, it works and looks good.  Note I needed to set the anim_delay to get 15fps.

 

from kivy.app import App
from kivy.lang import Builder


kv =
"""
BoxLayout:
    orientation: 'vertical'
    Image:
        source: 'ezgif-2-3826eb7bb9-gif-im.zip'
        anim_delay: .0667  # 15 fps
    Label:
        text: 'Smoking Skull'
        size_hint_y: None
        height: dp(48)
"""


class TestSmokingSkullGifApp(App):
   
def build(self):
       
return Builder.load_string(kv)


TestSmokingSkullGifApp().run()

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/415f4a0c-d802-4ab4-82a7-b61dfe686630n%40googlegroups.com.

ezgif-2-3826eb7bb9-gif-im.zip

elli...@cox.net

unread,
Sep 8, 2023, 7:58:45 PM9/8/23
to kivy-...@googlegroups.com

I wondered about turning the gif into a video.  This resulted in a significantly smaller file. 

The mp4 file is 146 KB.

The original gif file is 355KB.

The zip file is 878KB.

 

 

from kivy.app import App
from kivy.lang import Builder


kv =

"""
BoxLayout:
    orientation: 'vertical'
    Video:
        id: video
        source: 'ezgif.com-gif-to-mp4.mp4'
        options: {'eos': 'loop'}
        on_kv_post: self.state = 'play'
    # Image:
    #     source: 'ezgif-2-3826eb7bb9-gif-im.zip'
    #     anim_delay: .0667  # 15 fps

ezgif.com-gif-to-mp4.mp4

Abdu Moez

unread,
Sep 9, 2023, 4:00:04 AM9/9/23
to Kivy users support
Thanks for the replay. And now it seems to be working well.
Reply all
Reply to author
Forward
0 new messages