Repository: kivy/kivy

Issue:
Atlas: UnicodeDecodeError (Python 3.4)
I executed `python3 -m kivy.atlas myatlas.atlas 256 *.png` in a directory full of `.png` files on `Ubuntu 14.04 / 64bit`

``` Python
[INFO   ] Kivy v1.9.0-dev
[INFO   ] [Python      ] v3.4.0 (default, Apr 11 2014, 13:05:11) 
[GCC 4.8.2]
 Traceback (most recent call last):
   File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
     "__main__", mod_spec)
   File "/usr/lib/python3.4/runpy.py", line 85, in _run_code
     exec(code, run_globals)
   File "/usr/lib/python3/dist-packages/kivy/atlas.py", line 415, in <module>
     ret = Atlas.create(outname, filenames, size, **options)
   File "/usr/lib/python3/dist-packages/kivy/atlas.py", line 260, in create
     im = Image.open(fp)
   File "/usr/lib/python3/dist-packages/PIL/Image.py", line 2000, in open
     prefix = fp.read(16)
   File "/usr/lib/python3.4/codecs.py", line 313, in decode
     (result, consumed) = self._buffer_decode(data, self.errors, final)
 UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte
```

Atlas: UnicodeDecodeError (Python 3.4)
I executed `python3 -m kivy.atlas myatlas.atlas 256 *.png` in a directory full of `.png` files on `Ubuntu 14.04 / 64bit`

``` Python
[INFO   ] Kivy v1.9.0-dev
[INFO   ] [Python      ] v3.4.0 (default, Apr 11 2014, 13:05:11) 
[GCC 4.8.2]
 Traceback (most recent call last):
   File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
     "__main__", mod_spec)
   File "/usr/lib/python3.4/runpy.py", line 85, in _run_code
     exec(code, run_globals)
   File "/usr/lib/python3/dist-packages/kivy/atlas.py", line 415, in <module>
     ret = Atlas.create(outname, filenames, size, **options)
   File "/usr/lib/python3/dist-packages/kivy/atlas.py", line 260, in create
     im = Image.open(fp)
   File "/usr/lib/python3/dist-packages/PIL/Image.py", line 2000, in open
     prefix = fp.read(16)
   File "/usr/lib/python3.4/codecs.py", line 313, in decode
     (result, consumed) = self._buffer_decode(data, self.errors, final)
 UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte
```



Discussion:

Resolving patch:
diff --git a/kivy/atlas.py b/kivy/atlas.py
--- a/kivy/atlas.py
+++ b/kivy/atlas.py
@@ -266,7 +266,7 @@ def create(outname, filenames, size, padding=2, use_path=False):
         # open all of the images
         ims = list()
         for f in filenames:
-            fp = open(f)
+            fp = open(f, 'rb')
             im = Image.open(fp)
             im.load()
             fp.close()
@@ -393,6 +393,7 @@ def create(outname, filenames, size, padding=2, use_path=False):
     to make a new atlas. """
 
     import sys
+    from glob import glob
     argv = sys.argv[1:]
     # earlier import of kivy has already called getopt to remove kivy system
     # arguments from this line. That is all arguments up to the first '--'
@@ -426,7 +427,7 @@ def create(outname, filenames, size, padding=2, use_path=False):
         print('Error: size must be an integer or <integer>x<integer>')
         sys.exit(1)
 
-    filenames = argv[2:]
+    filenames = [fname for fnames in argv[2:] for fname in glob(fnames)]
     ret = Atlas.create(outname, filenames, size, **options)
     if not ret:
         print('Error while creating atlas!')


Test patch: