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
{{ message }}
Repository navigation
UnboundLocalError: local variable 'err_code' referenced before assignment #2383
No problem, I might wanna also include that the gif was processed before (loaded into PIL, frames extracted, Wand/Imagemagick effects applied and then stitched together with ffmpeg) using the same function.
Which bounces out, and then we hit the err_code not defined.
I know that in other image types (e.g., TIFF) when we have multiple frames, we allow for the new image to be a different size than the old one. TIFFs don't have disposal options that GIFs have, so there's a little more complication in the GIF case.
I'd propose that if the extents are outside the existing image, we should increase the canvas size to cover the union of the existing and next frame. (as long as the extents aren't negative. I think that we should bounce that error).
Additionally, we should not bury errors of this sort. They should probably be raised and allowed to stop the processing.
Activity
wiredfool commentedon Jan 29, 2017
Thanks, a couple of people have reported this, but your report is the first to include a triggering image.
NotSoSuper commentedon Jan 29, 2017
No problem, I might wanna also include that the gif was processed before (loaded into PIL, frames extracted, Wand/Imagemagick effects applied and then stitched together with ffmpeg) using the same function.
hugovk commentedon Jan 29, 2017
This URL gives me:
Please could you attach the image to this issue?
NotSoSuper commentedon Jan 29, 2017
That's weird, still loading for me after cache reset but Discord CDN tends to be weird, here:

wiredfool commentedon Feb 7, 2017
The basic problem is that the second frame has an extent of 256x249, while the first frame is 256x248.
This is in a try/except, which simply swallows the error.
Which bounces out, and then we hit the
err_codenot defined.I know that in other image types (e.g., TIFF) when we have multiple frames, we allow for the new image to be a different size than the old one. TIFFs don't have disposal options that GIFs have, so there's a little more complication in the GIF case.
I'd propose that if the extents are outside the existing image, we should increase the canvas size to cover the union of the existing and next frame. (as long as the extents aren't negative. I think that we should bounce that error).
Additionally, we should not bury errors of this sort. They should probably be raised and allowed to stop the processing.
NotSoSuper commentedon Feb 10, 2017
Ah, well that makes more sense now.
Increasing canvas size does sound like a good way to go unless there are other complications, thanks again!
radarhere commentedon May 2, 2019
Negative extents aren't actually possible, as the offsets are unsigned integers.
Pillow/src/PIL/GifImagePlugin.py
Line 234 in c47792c
Pillow/src/PIL/_binary.py
Lines 32 to 34 in c47792c
I've created PR #3822 to resolve this.