Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved SgiImagePlugin save error to before the start of write operations #2646

Merged
merged 1 commit into from
Aug 16, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions PIL/SgiImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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())

Expand Down