Tuesday, 24 September 2019

Cannot view tiff images in Kivy

problem
I am able to load pictures with the Image() module in kivy. But for some reason, I can't load .tif files into kivy. When the image source is '..\pics\lugia.png', the image loads perfectly fine. But if the source is '..\pics\snorlax.tif', I just get that white box and the error:

[WARNING] [Image       ] Unable to load image <C:\Users\path\pics\snorlax.tif>
[ERROR  ] [Image       ] Error loading texture ..\pics\snorlax.tif

code

    from kivy.app import App
    from kivy.uix.boxlayout import BoxLayout
    from kivy.clock import Clock
    from kivy.uix.image import Image

    class ContainerBox(BoxLayout):
        def __init__(self, **kwargs):
            super(ContainerBox, self).__init__(**kwargs)
            self.orientation = 'vertical'
            #self.picture = Image(allow_stretch=True, source='..\pics\lugia.png')
            self.picture = Image(allow_stretch=True, source='..\pics\snorlax.tif')
            Clock.schedule_once(lambda dt: self.add_widget(self.picture), timeout=0.1)


    class SimpleImage(App):
        def build(self):
            return ContainerBox()

    if __name__ == '__main__':
        SimpleImage().run()

technical details

  • The images are from veekun.com (property of nintendo etc).
  • All the images are 64 x 64. I just exported some of them into TIFF format. So image size shouldn't be the problem.
  • I am using Kivy version 1.11.0rc1
  • According to Anaconda, the virtual environment is running Python 3.5.6
  • I am running this via PyCharm on Windows 7
  • I have sdl2_image version 2.0.2 build 0. According to the sdl2_image page, sdl2_image has supported tiff since version 1.2.5.
  • I have libtiff version 4.0.9
  • changing the file extension from '.tif' to '.tiff'

my question to you
Am I doing something wrong, or does Kivy just not support TIFF format?



from Cannot view tiff images in Kivy

No comments:

Post a Comment