def export_img(visio_filename, image_filename, pagenum=None, pagename=None):
<EOL>image_pathname = os.path.abspath(image_filename)<EOL>if not os.path.isdir(os.path.dirname(image_pathname)):<EOL><INDENT>msg = '<STR_LIT>' % image_filename<EOL>raise IOError(msg)<EOL><DEDENT>with VisioFile.Open(visio_filename) as visio:<EOL><INDENT>pages = filter_pages(visio.pages, pagenum, pagename)<EOL>try:<EOL><INDENT>if len(pages) == <NUM_LIT:1>:<EOL><INDENT>pages[<NUM_LIT:0>].Export(image_pathname)<EOL><DEDENT>else:<EOL><INDENT>digits = int(log(len(pages), <NUM_LIT:10>)) + <NUM_LIT:1><EOL>basename, ext = os.path.splitext(image_pathname)<EOL>filename_format = "<STR_LIT>" % (basename, digits, ext)<EOL>for i, page in enumerate(pages):<EOL><INDENT>filename = filename_format % (i + <NUM_LIT:1>)<EOL>page.Export(filename)<EOL><DEDENT><DEDENT><DEDENT>except Exception:<EOL><INDENT>raise IOError('<STR_LIT>' % image_pathname)<EOL><DEDENT><DEDENT>
Exports images from visio file