Simple failover to RGB mode (#13)
This commit is contained in:
11
generator
11
generator
@@ -63,9 +63,14 @@ def generate_sprite_from_frames(framesPath, columns, size, output):
|
|||||||
masterWidth = size[0] * columns
|
masterWidth = size[0] * columns
|
||||||
masterHeight = size[1] * int(math.ceil(float(len(framesMap)) / columns))
|
masterHeight = size[1] * int(math.ceil(float(len(framesMap)) / columns))
|
||||||
|
|
||||||
line, column = 0, 0
|
line, column, mode = 0, 0, 'RGBA'
|
||||||
|
|
||||||
finalImage = Image.new(mode='RGBA', size=(masterWidth, masterHeight), color=(0,0,0,0))
|
try:
|
||||||
|
finalImage = Image.new(mode=mode, size=(masterWidth, masterHeight), color=(0,0,0,0))
|
||||||
|
finalImage.save(output)
|
||||||
|
except IOError:
|
||||||
|
mode = 'RGB'
|
||||||
|
finalImage = Image.new(mode=mode, size=(masterWidth, masterHeight))
|
||||||
|
|
||||||
for filename in framesMap:
|
for filename in framesMap:
|
||||||
with Image.open(filename) as image:
|
with Image.open(filename) as image:
|
||||||
@@ -81,7 +86,7 @@ def generate_sprite_from_frames(framesPath, columns, size, output):
|
|||||||
line += 1
|
line += 1
|
||||||
column = 0
|
column = 0
|
||||||
|
|
||||||
finalImage.save(output, transparency=0)
|
finalImage.save(output)
|
||||||
shutil.rmtree(TMP_FRAMES_PATH, ignore_errors=True)
|
shutil.rmtree(TMP_FRAMES_PATH, ignore_errors=True)
|
||||||
print "Saved!"
|
print "Saved!"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user