mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-14 03:21:44 +03:00
Don't requantize 'P' images
This commit is contained in:
parent
26e145c8a3
commit
b315b6ecf3
|
@ -295,6 +295,7 @@ RAWMODE = {
|
||||||
|
|
||||||
def _normalize_mode(im, initial_call=False):
|
def _normalize_mode(im, initial_call=False):
|
||||||
if im.mode in RAWMODE:
|
if im.mode in RAWMODE:
|
||||||
|
im.load()
|
||||||
return im
|
return im
|
||||||
if Image.getmodebase(im.mode) == "RGB":
|
if Image.getmodebase(im.mode) == "RGB":
|
||||||
if initial_call:
|
if initial_call:
|
||||||
|
@ -326,16 +327,15 @@ def _write_single_frame(im, fp, palette):
|
||||||
fp.write(b"\0") # end of image data
|
fp.write(b"\0") # end of image data
|
||||||
|
|
||||||
def _write_multiple_frames(im, fp, palette):
|
def _write_multiple_frames(im, fp, palette):
|
||||||
if "duration" in im.encoderinfo:
|
|
||||||
duration = im.encoderinfo["duration"]
|
duration = im.encoderinfo.get("duration", None)
|
||||||
else:
|
|
||||||
duration = None
|
|
||||||
|
|
||||||
im_frames = []
|
im_frames = []
|
||||||
frame_count = 0
|
frame_count = 0
|
||||||
for imSequence in [im]+im.encoderinfo.get("append_images", []):
|
for imSequence in [im]+im.encoderinfo.get("append_images", []):
|
||||||
for im_frame in ImageSequence.Iterator(imSequence):
|
for im_frame in ImageSequence.Iterator(imSequence):
|
||||||
im_frame = _normalize_mode(im_frame)
|
# a copy is required here since seek can still mutate the image
|
||||||
|
im_frame = _normalize_mode(im_frame.copy())
|
||||||
im_frame = _normalize_palette(im_frame, palette, im.encoderinfo)
|
im_frame = _normalize_palette(im_frame, palette, im.encoderinfo)
|
||||||
|
|
||||||
encoderinfo = im.encoderinfo.copy()
|
encoderinfo = im.encoderinfo.copy()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user