rebuild for 10.11+
This commit is contained in:
parent
d989eff547
commit
901b731582
234 changed files with 1522 additions and 927 deletions
|
|
@ -2,7 +2,7 @@ from . import Image, ImageFile
|
|||
try:
|
||||
from . import _webp
|
||||
SUPPORTED = True
|
||||
except ImportError as e:
|
||||
except ImportError:
|
||||
SUPPORTED = False
|
||||
from io import BytesIO
|
||||
|
||||
|
|
@ -32,7 +32,8 @@ def _accept(prefix):
|
|||
|
||||
if is_riff_file_format and is_webp_file and is_valid_vp8_mode:
|
||||
if not SUPPORTED:
|
||||
return "image file could not be identified because WEBP support not installed"
|
||||
return "image file could not be identified " \
|
||||
"because WEBP support not installed"
|
||||
return True
|
||||
|
||||
|
||||
|
|
@ -163,7 +164,7 @@ class WebPImageFile(ImageFile.ImageFile):
|
|||
self.__loaded = self.__logical_frame
|
||||
|
||||
# Set tile
|
||||
if self.fp:
|
||||
if self.fp and self._exclusive_fp:
|
||||
self.fp.close()
|
||||
self.fp = BytesIO(data)
|
||||
self.tile = [("raw", (0, 0) + self.size, 0, self.rawmode)]
|
||||
|
|
@ -190,7 +191,19 @@ def _save_all(im, fp, filename):
|
|||
_save(im, fp, filename)
|
||||
return
|
||||
|
||||
background = encoderinfo.get("background", (0, 0, 0, 0))
|
||||
background = (0, 0, 0, 0)
|
||||
if "background" in encoderinfo:
|
||||
background = encoderinfo["background"]
|
||||
elif "background" in im.info:
|
||||
background = im.info["background"]
|
||||
if isinstance(background, int):
|
||||
# GifImagePlugin stores a global color table index in
|
||||
# info["background"]. So it must be converted to an RGBA value
|
||||
palette = im.getpalette()
|
||||
if palette:
|
||||
r, g, b = palette[background*3:(background+1)*3]
|
||||
background = (r, g, b, 0)
|
||||
|
||||
duration = im.encoderinfo.get("duration", 0)
|
||||
loop = im.encoderinfo.get("loop", 0)
|
||||
minimize_size = im.encoderinfo.get("minimize_size", False)
|
||||
|
|
@ -255,7 +268,8 @@ def _save_all(im, fp, filename):
|
|||
rawmode = ims.mode
|
||||
if ims.mode not in _VALID_WEBP_MODES:
|
||||
alpha = 'A' in ims.mode or 'a' in ims.mode \
|
||||
or (ims.mode == 'P' and 'A' in ims.im.getpalettemode())
|
||||
or (ims.mode == 'P' and
|
||||
'A' in ims.im.getpalettemode())
|
||||
rawmode = 'RGBA' if alpha else 'RGB'
|
||||
frame = ims.convert(rawmode)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue