When using context manager, Image does not close file pointer, as expected. It checks getattr(self, "_exclusive_fp", False) and closes the file pointer only if it's True.
with open("file.png", "rb") as fp:
assert fp.closed is False
with Image.open(fp) as im:
...
assert fp.closed is False # OK
But the Image.close() method misses _exclusive_fp check and closes the file pointer unexpectedly:
with open("test.png", "rb") as fp:
assert fp.closed is False
im = Image.open(fp)
...
im.close()
assert fp.closed is False # AssertionError