# $Id$ # render powerpoint slides for use with s5maker (work in progress) # to run this, you need PIL and the pilwmf extension; you can get # both from http://effbot.org/downloads # usage: # # first (but optional), make a copy of your powerpoint presentation, # and remove headers and footers, etc. # # then save the presentation as "windows meta files..." to a suitable # directory # # finally, run this script on that directory to get a bunch of image # files, and a TXT file that you can use with s5maker.py. # # you'll probably want to add proper tiles to the TXT file, before you # show it to anyone else. import glob, os, re, sys import traceback import Image import WmfImagePlugin import WmfPlugin force = 0 width = 800 height = 600 presentation = os.path.basename(sys.argv[1]) files = [] for file in glob.glob(os.path.join(sys.argv[1], "*.wmf")): page = re.search("(\d+).wmf$", file).group(1) files.append((int(page), file)) # files.sort() for page, file in files: outfile = "%s-%d.png" % (presentation, page) if not force and os.path.isfile(outfile): continue try: image = Image.open(file) # poor mans antialiasing: render slightly larger than requested # size, and downsize using linear interpolation image.size = int(width * 1.2), int(height * 1.2) image.load() # force load to work around bug in 1.1.5a1 image = image.resize((width, height), Image.BILINEAR) image.save(outfile) print outfile, "ok" except: print outfile, "failed" print "-" * 68 traceback.print_exc() print "-" * 68 # generate files.sort() out = open(presentation + ".txt", "w") for page, file in files: outfile = "%s-%d.png" % (presentation, page) # FIXME: s5maker should copy the image files, or fix the links, # so we don't have to resort to this kind of silliness imfile = os.path.abspath(outfile) imfile = imfile.replace(os.sep, "/") imfile = "file:///" + imfile print >>out, "#", outfile print >>out print >>out, "![%s](%s)" % (outfile, imfile) print >>out print out.name, "ok"