mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 10:46:16 +03:00
ensure files are closed
This commit is contained in:
parent
85693d60d0
commit
a422a4ff4e
|
@ -209,14 +209,15 @@ class MorphOp:
|
|||
|
||||
def get_on_pixels(self, image):
|
||||
"""Get a list of all turned on pixels in a binary image
|
||||
|
||||
Returns a list of tuples of (x,y) coordinates of all matching pixels."""
|
||||
|
||||
return _imagingmorph.get_on_pixels(image.im.id)
|
||||
|
||||
def load_lut(self, filename):
|
||||
"""Load an operator from an mrl file"""
|
||||
self.lut = bytearray(open(filename,'rb').read())
|
||||
with open(filename,'rb') as f:
|
||||
self.lut = bytearray(f.read())
|
||||
|
||||
if len(self.lut)!= 8192:
|
||||
self.lut = None
|
||||
raise Exception('Wrong size operator file!')
|
||||
|
@ -225,7 +226,8 @@ class MorphOp:
|
|||
"""Load an operator save mrl file"""
|
||||
if self.lut is None:
|
||||
raise Exception('No operator loaded')
|
||||
open(filename,'wb').write(self.lut)
|
||||
with open(filename,'wb') as f:
|
||||
f.write(self.lut)
|
||||
|
||||
def set_lut(self, lut):
|
||||
"""Set the lut from an external source"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user