We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a0b44f9 commit 7d081c1Copy full SHA for 7d081c1
openslide/__init__.py
@@ -267,8 +267,10 @@ def __init__(self, file):
267
file can be a filename or a PIL.Image."""
268
AbstractSlide.__init__(self)
269
if isinstance(file, Image.Image):
270
+ self._close = False
271
self._image = file
272
else:
273
+ self._close = True
274
self._image = Image.open(file)
275
276
@classmethod
@@ -288,6 +290,11 @@ def detect_format(cls, filename):
288
290
289
291
def close(self):
292
"""Close the slide object."""
293
+ if self._close:
294
+ if hasattr(self._image, 'close'):
295
+ # Pillow >= 2.5.0
296
+ self._image.close()
297
298
self._image = None
299
300
@property
0 commit comments