This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This code adapted from https://github.com/python-pillow/Pillow/issues/4644 to resolve an issue | |
# described in https://github.com/python-pillow/Pillow/issues/4640 | |
# | |
# There is a known issue with the Pillow library that messes up GIF transparency by replacing the | |
# transparent pixels with black pixels (among other issues) when the GIF is saved using PIL.Image.save(). | |
# This code works around the issue and allows us to properly generate transparent GIFs. | |
from typing import Tuple, List, Union | |
from collections import defaultdict | |
from random import randrange |