Merge pull request #1 from radarhere/patch-2

Added test and flush file pointer
This commit is contained in:
Fariz Rahman 2021-07-31 01:05:42 +04:00 committed by GitHub
commit c42e6bab1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -73,6 +73,13 @@ def test_write(tmp_path):
img.save(out, format="sgi")
assert_image_equal_tofile(img, out)
out = str(tmp_path / "fp.sgi")
with open(out, "wb") as fp:
img.save(fp)
assert_image_equal_tofile(img, out)
assert not fp.closed
for mode in ("L", "RGB", "RGBA"):
roundtrip(hopper(mode))

View File

@ -193,6 +193,9 @@ def _save(im, fp, filename):
for channel in im.split():
fp.write(channel.tobytes("raw", rawmode, 0, orientation))
if hasattr(fp, "flush"):
fp.flush()
class SGI16Decoder(ImageFile.PyDecoder):
_pulls_fd = True