Commits

Mikhail Korobov committed 5f85a1e

stupid mistakes with previous commit are fixed

  • Participants
  • Parent commits 4343dc3

Comments (0)

Files changed (1)

psd_tools/decoder/layers.py

 def channels_to_PIL(layer, channels_data):
     from PIL import Image
     size = layer.width(), layer.height()
+    if size == (0, 0):
+        return
 
     bands = {}
 
             continue
 
         if channel.compression == Compression.RAW:
-            bands[pil_band] = Image.fromstring("L", size, channel.data, 'L')
+            bands[pil_band] = Image.fromstring("L", size, channel.data, "raw", 'L')
         elif channel.compression == Compression.PACK_BITS:
             bands[pil_band] = Image.fromstring("L", size, channel.data, "packbits", 'L')
         elif Compression.is_known(channel.compression):
             warnings.warn("Unknown compression method (%s)" % channel.compression)
 
     def as_bands(mode):
-        if set(bands.keys()) == set(list(mode)):
-            return [bands[band] for band in ['R', 'G', 'B', 'A']]
+        mode_list = list(mode)
+        if set(bands.keys()) == set(mode_list):
+            return [bands[band] for band in mode_list]
 
 
     for mode in ['RGBA', 'RGB']: