Repository: kivy/kivy

Issue:
Forcing img_pil causes an error when trying to load PNGs
When I force PIL provider using `export KIVY_IMAGE=img_pil` Kivy exits with this error log:
I have installed Pillow library from PyPI.

```
[INFO   ] [Logger      ] Record log in /mnt/data/logs/kivy_69-12-31_5.txt
[INFO   ] Kivy v1.9.0-dev
[INFO   ] [Python      ] v2.7.8 (default, Sep 24 2014, 05:50:30) 
[GCC 4.8.2 20131219 (prerelease)]
[INFO   ] [Factory     ] 172 symbols loaded
[INFO   ] [Image       ] Providers: img_pil (img_tex, img_dds, img_sdl2, img_pygame, img_ffpyplayer, img_gif ignored)
[INFO   ] [Window      ] Provider: egl_rpi
[INFO   ] [GL          ] OpenGL version <OpenGL ES 2.0>
[INFO   ] [GL          ] OpenGL vendor <Broadcom>
[INFO   ] [GL          ] OpenGL renderer <VideoCore IV HW>
[INFO   ] [GL          ] OpenGL parsed version: 2, 0
[INFO   ] [GL          ] Shading version <OpenGL ES GLSL ES 1.00>
[INFO   ] [GL          ] Texture max size <2048>
[INFO   ] [GL          ] Texture max units <8>
[INFO   ] [Shader      ] fragment shader: <Compiled>
[INFO   ] [Shader      ] vertex shader: <Compiled>
[CRITICAL] [Window      ] Unable to find any valuable Window provider at all!
egl_rpi - AttributeError: dispose
  File "/opt/vendor/lib/python2.7/site-packages/kivy/core/__init__.py", line 65, in core_select_lib
    cls = cls()
  File "/opt/vendor/lib/python2.7/site-packages/kivy/core/window/__init__.py", line 594, in __init__
    self.create_window()
  File "/opt/vendor/lib/python2.7/site-packages/kivy/core/window/window_egl_rpi.py", line 26, in create_window
    super(WindowEglRpi, self).create_window()
  File "/opt/vendor/lib/python2.7/site-packages/kivy/core/window/__init__.py", line 731, in create_window
    self.render_context = RenderContext()
  File "kivy/graphics/instructions.pyx", line 751, in kivy.graphics.instructions.RenderContext.__init__ (kivy/graphics/instructions.c:10225)
  File "/opt/vendor/lib/python2.7/site-packages/kivy/core/image/__init__.py", line 461, in __init__
    self.filename = arg
  File "/opt/vendor/lib/python2.7/site-packages/kivy/core/image/__init__.py", line 650, in _set_filename
    mipmap=self._mipmap, nocache=self._nocache)
  File "/opt/vendor/lib/python2.7/site-packages/kivy/core/image/__init__.py", line 388, in load
    im = loader(filename, **kwargs)
  File "/opt/vendor/lib/python2.7/site-packages/kivy/core/image/__init__.py", line 164, in __init__
    self._data = self.load(filename)
  File "/opt/vendor/lib/python2.7/site-packages/kivy/core/image/img_pil.py", line 96, in load
    return list(self._img_read(im))
  File "/opt/vendor/lib/python2.7/site-packages/kivy/core/image/img_pil.py", line 75, in _img_read
    if not im.dispose and img_ol:
  File "/opt/vendor/lib/python2.7/site-packages/PIL/Image.py", line 608, in __getattr__
    raise AttributeError(name)

[INFO   ] [Text        ] Provider: pil(['text_sdl2', 'text_pygame', 'text_sdlttf'] ignored)
[CRITICAL] [App         ] Unable to get a Window, abort.
 Exception SystemExit: 1 in 'kivy.properties.dpi2px' ignored
[INFO   ] [Audio       ] Providers:  (audio_pygst, audio_ffpyplayer, audio_sdl, audio_pygame ignored)
[CRITICAL] [App         ] Unable to get a Window, abort.
```



Discussion:

Resolving patch:
diff --git a/kivy/core/image/img_pil.py b/kivy/core/image/img_pil.py
--- a/kivy/core/image/img_pil.py
+++ b/kivy/core/image/img_pil.py
@@ -72,7 +72,7 @@ def _img_read(self, im):
             while True:
                 img_tmp = im
                 img_tmp = self._img_correct(img_tmp)
-                if not im.dispose and img_ol:
+                if img_ol and (hasattr(im, 'dispose') and not im.dispose):
                     # paste new frame over old so as to handle
                     # transparency properly
                     img_ol.paste(img_tmp, (0, 0), img_tmp)


Test patch: