Does anyone have any ideas how to do it? I tried using a PIL, apng, and imageio, but it didn't work.
1 Answer
You can also use 'apnggif' library to read the Animated PNG (APNG) and convert into GIF files.
#Sample Python Code#
from apnggif import apnggif
# Here it reads files in the folder input and sorts
imgs = glob.glob("input/*.png")
imgs.sort(key=lambda f: int(re.sub('\D', '', f)))
# Folder Creation for the output
# Gets current working directory
path = os.getcwd()
# Joins the folder that we wanted to create
path = os.path.join(path, 'output')
# creates the folder, and checks if it is created or not.
os.makedirs(path, exist_ok=True)
# Iterates over the input images and saves them into output folder
for idx, img in enumerate(imgs):
filenamePath = "output\\" + str(idx+1) + ".gif"
apnggif(img, filenamePath)
To use that you should install the library as follows "pip install apnggif"
. Running console in Administrator mode might be needed in some cases.