You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ran single colour frames through GifImagePlugin _normalize_palette
What did you expect to happen?
Image object palette changes, nothing else
What actually happened?
Image.getbbox() went from 100x100 to None
What are your OS, Python and Pillow versions?
OS: Archlinux
Python: 3.4.9 (in venv)
Pillow: 5.4.1
To reproduce:
(This is a modification of the test_save_dispose test from the test suite - I think it's preventing a valid fix for something else but unsure)
Also, modify _write_multiple_frames in GifImagePlugin.py to contain a log of the image bounding box before and after the '_normalize_palette` call (around line 407):
forimSequenceinitertools.chain([im],
im.encoderinfo.get("append_images", [])):
forim_frameinImageSequence.Iterator(imSequence):
# a copy is required here since seek can still mutate the imageprint("NEWFRAME")
print(im_frame.getbbox())
im_frame=_normalize_mode(im_frame.copy())
print("MODE")
print(im_frame.getbbox())
im_frame=_normalize_palette(im_frame, palette, im.encoderinfo)
print("PALETTE")
print(im_frame.getbbox())
encoderinfo=im.encoderinfo.copy()
ifisinstance(duration, (list, tuple)):
encoderinfo['duration'] =duration[frame_count]
ifisinstance(disposal, (list, tuple)):
encoderinfo["disposal"] =disposal[frame_count]
frame_count+=1
Is it possible that the Image.remap_palette being done by _normalize_palette is putting the only colour as colour 0, which causes the Image.getbbox to see the whole image as colour 0 and therefore not at all filled?
The frame having no bounding box results in the gif optimisation essentially ignoring the frame and extending the previous one.
radarhere
changed the title
Flaw in GifImagePlugin normalize_palette destroys bounding box of frame
GifImagePlugin normalize_palette destroys bounding box of frame
Mar 23, 2019
This is an unusual issue, because it's not really a discussion about Pillow's API, or an issue with an example of a broken handling of an image, but about Pillow's internal operations.
I don't think it matters that im_frame.getbbox() is empty - delta.getbbox() is what is used to determine whether or not this frame is different to the previous one.
What did you do?
Ran single colour frames through GifImagePlugin _normalize_palette
What did you expect to happen?
Image object palette changes, nothing else
What actually happened?
Image.getbbox() went from 100x100 to None
What are your OS, Python and Pillow versions?
To reproduce:
(This is a modification of the test_save_dispose test from the test suite - I think it's preventing a valid fix for something else but unsure)
Also, modify
_write_multiple_frames
inGifImagePlugin.py
to contain a log of the image bounding box before and after the '_normalize_palette` call (around line 407):Each time I see:
Is it possible that the
Image.remap_palette
being done by_normalize_palette
is putting the only colour as colour 0, which causes theImage.getbbox
to see the whole image as colour 0 and therefore not at all filled?The frame having no bounding box results in the gif optimisation essentially ignoring the frame and extending the previous one.
I ran into this while trying to work on #3665
The text was updated successfully, but these errors were encountered: