|
|
|
@ -32,3 +32,20 @@ def mip_sizes(dimensions: Tuple[int, int], mip_count: Optional[int] = None) -> L
|
|
|
|
|
dimensions = tuple([max(dim // 2, 1) for dim in dimensions])
|
|
|
|
|
|
|
|
|
|
return chain
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def resize_no_premultiply(image: Image.Image, size: Tuple[int, int]) -> Image.Image:
|
|
|
|
|
"""
|
|
|
|
|
Resize an image without premulitplying the alpha. Required due to a quick in Pillow
|
|
|
|
|
|
|
|
|
|
:param image: Image to resize
|
|
|
|
|
:param size: Size to resize to
|
|
|
|
|
:return: The resized image
|
|
|
|
|
"""
|
|
|
|
|
if image.mode == 'RGBA':
|
|
|
|
|
rgb = image.convert('RGB').resize(size, Image.BILINEAR)
|
|
|
|
|
a = image.getchannel('A').resize(size, Image.BILINEAR)
|
|
|
|
|
rgb.putalpha(a)
|
|
|
|
|
return rgb
|
|
|
|
|
else:
|
|
|
|
|
return image.resize(size, Image.BILINEAR)
|
|
|
|
|