mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 17:54:32 +03:00
Added _mutable method for common code
This commit is contained in:
parent
23a51a35e9
commit
411765a69c
21
PIL/Image.py
21
PIL/Image.py
|
@ -592,6 +592,12 @@ class Image(object):
|
|||
self.pyaccess = None
|
||||
self.readonly = 0
|
||||
|
||||
def _mutable(self):
|
||||
if self.readonly:
|
||||
self._copy()
|
||||
else:
|
||||
self.load()
|
||||
|
||||
def _dump(self, file=None, format=None, **options):
|
||||
import tempfile
|
||||
|
||||
|
@ -1390,10 +1396,7 @@ class Image(object):
|
|||
im = im.convert(self.mode)
|
||||
im = im.im
|
||||
|
||||
if self.readonly:
|
||||
self._copy()
|
||||
else:
|
||||
self.load()
|
||||
self._mutable()
|
||||
|
||||
if mask:
|
||||
mask.load()
|
||||
|
@ -1499,10 +1502,7 @@ class Image(object):
|
|||
other color value.
|
||||
"""
|
||||
|
||||
if self.readonly:
|
||||
self._copy()
|
||||
else:
|
||||
self.load()
|
||||
self._mutable()
|
||||
|
||||
if self.mode not in ("LA", "RGBA"):
|
||||
# attempt to promote self to a matching alpha mode
|
||||
|
@ -1558,10 +1558,7 @@ class Image(object):
|
|||
:param offset: An optional offset value. The default is 0.0.
|
||||
"""
|
||||
|
||||
if self.readonly:
|
||||
self._copy()
|
||||
else:
|
||||
self.load()
|
||||
self._mutable()
|
||||
|
||||
self.im.putdata(data, scale, offset)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user