Generate animated .gifs, .pdfs similar to generateMP4()?
-
@justvanrossum , @frederik , anyone else: At Robothon this spring, Just showed me how to save animations frame by frame as .pngs with newDrawing() and saveImage(), and then generate the MP4 from them in a separate step with generateMP4.
Is there a similar undocumented function for generating animated .gifs from individual .gif frames, or generating multipage .pdf documents?
I'm asking because the structure of the Crouwel code I'm working on generates lots of variations from a single base glyph. I'll want to use newDrawing() to keep from running out of system memory, and I'm hoping for some options to combine the frames in the end besides making an .mp4.
-
that is possible you can use:
from drawBot.context.tools.gifTools import generateGif generateGif(gifPaths, destinationPath, frameRates) # gifPaths: a list of paths to gif files # destinationPath: a path where to save the animated gif # frameRates: a list with the same length as the gifPaths of ints in 1/100sec
see https://github.com/typemytype/drawbot/blob/master/drawBot/context/tools/gifTools.py#L11
hope this works!
-
Thanks, Frederik!
-
@frederik Is there a similar tool for .pdfs, or would I be better generating one-off .pdf pages and combining them with Acrobat?
-
not really...
but this is not so hard with a PDFDocument