mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
Premultiply RGBA images prior to transform and resize and undo after
This commit is contained in:
parent
b9f94b7632
commit
10214bc6c4
|
@ -1309,6 +1309,9 @@ class Image:
|
||||||
if self.mode in ("1", "P"):
|
if self.mode in ("1", "P"):
|
||||||
resample = NEAREST
|
resample = NEAREST
|
||||||
|
|
||||||
|
if self.mode == 'RGBA':
|
||||||
|
return self.convert('RGBa').resize(size, resample).convert('RGBA')
|
||||||
|
|
||||||
if resample == ANTIALIAS:
|
if resample == ANTIALIAS:
|
||||||
# requires stretch support (imToolkit & PIL 1.1.3)
|
# requires stretch support (imToolkit & PIL 1.1.3)
|
||||||
try:
|
try:
|
||||||
|
@ -1606,6 +1609,9 @@ class Image:
|
||||||
:returns: An Image object.
|
:returns: An Image object.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if self.mode == 'RGBA':
|
||||||
|
return self.convert('RGBa').transform(size, method, data, resample, fill).convert('RGBA')
|
||||||
|
|
||||||
if isinstance(method, ImageTransformHandler):
|
if isinstance(method, ImageTransformHandler):
|
||||||
return method.transform(size, self, resample=resample, fill=fill)
|
return method.transform(size, self, resample=resample, fill=fill)
|
||||||
if hasattr(method, "getdata"):
|
if hasattr(method, "getdata"):
|
||||||
|
@ -1613,6 +1619,7 @@ class Image:
|
||||||
method, data = method.getdata()
|
method, data = method.getdata()
|
||||||
if data is None:
|
if data is None:
|
||||||
raise ValueError("missing method data")
|
raise ValueError("missing method data")
|
||||||
|
|
||||||
im = new(self.mode, size, None)
|
im = new(self.mode, size, None)
|
||||||
if method == MESH:
|
if method == MESH:
|
||||||
# list of quads
|
# list of quads
|
||||||
|
|
Loading…
Reference in New Issue
Block a user