Match mask size to pasted image size in GifImagePlugin by radarhere · Pull Request #7779 · python-pillow/Pillow

Resolves #7777

When looping through images to create a GIF image, the frames may be different sizes.

At the moment, this means that

diff_frame.paste(fill, mask=ImageOps.invert(mask))

fill comes from the size of the new frame, whereas mask comes from ImageChops.subtract_modulo() between the new and the old frame.

This may cause a mismatch in size between the image being pasted and the mask, which can lead to an error.