mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 17:24:31 +03:00
Moved SgiImagePlugin save error to before the start of write operations
This commit is contained in:
parent
bbe07d4f49
commit
11399b18ce
|
@ -104,6 +104,11 @@ def _save(im, fp, filename):
|
|||
z = len(im.mode)
|
||||
if dim == 1 or dim == 2:
|
||||
z = 1
|
||||
# assert we've got the right number of bands.
|
||||
if len(im.getbands()) != z:
|
||||
raise ValueError("incorrect number of bands in SGI write: %s vs %s" %
|
||||
(z, len(im.getbands())))
|
||||
|
||||
# Minimum Byte value
|
||||
pinmin = 0
|
||||
# Maximum Byte value (255 = 8bits per pixel)
|
||||
|
@ -131,11 +136,6 @@ def _save(im, fp, filename):
|
|||
|
||||
fp.write(struct.pack('404s', b'')) # dummy
|
||||
|
||||
# assert we've got the right number of bands.
|
||||
if len(im.getbands()) != z:
|
||||
raise ValueError("incorrect number of bands in SGI write: %s vs %s" %
|
||||
(z, len(im.getbands())))
|
||||
|
||||
for channel in im.split():
|
||||
fp.write(channel.tobytes())
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user