mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 10:46:16 +03:00
Merge pull request #5645 from farizrahman4u/patch-2
Do not close file pointer in SGI save handler
This commit is contained in:
commit
61419b54d6
|
@ -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))
|
||||
|
||||
|
|
|
@ -193,7 +193,8 @@ def _save(im, fp, filename):
|
|||
for channel in im.split():
|
||||
fp.write(channel.tobytes("raw", rawmode, 0, orientation))
|
||||
|
||||
fp.close()
|
||||
if hasattr(fp, "flush"):
|
||||
fp.flush()
|
||||
|
||||
|
||||
class SGI16Decoder(ImageFile.PyDecoder):
|
||||
|
|
Loading…
Reference in New Issue
Block a user