def optimize_svg(svgfile_in): """ Use python scour to optimise svg gain roughtly 50% in size options (default): {'strip_ids': False, 'shorten_ids': False, 'simple_colors': True, 'strip_comments': False, 'remove_metadata': False, 'outfilename': None, 'group_create': False, 'protect_ids_noninkscape': False, 'indent_type': 'space', 'keep_editor_data': False, 'shorten_ids_prefix': '', 'keep_defs': False, 'renderer_workaround': True, 'style_to_xml': True, 'protect_ids_prefix': None, 'enable_viewboxing': False, 'digits': 5, 'embed_rasters': True, 'infilename': 'none', 'strip_xml_prolog': False, 'group_collapse': True, 'quiet': False, 'protect_ids_list': None} """ #get default option opts = scour.generateDefaultOptions() options = opts.__dict__ #custom options for beampy #TODO: add this option to a configuration file options['indent_type'] = None options['strip_comments'] = True #options['group_create'] = True #create group with identical element defs #run scour #print('optimize svg...') t = time.time() #svgout = scour.scourString(svgfile_in, opts).encode("UTF-8") svgout = scour.scourString(svgfile_in, opts) print('optimize svg run in %f' % (time.time() - t)) #print('done') return svgout
def optimize_svg(svgfile_in): """ Use python scour to optimise svg gain roughtly 50% in size options (default): {'strip_ids': False, 'shorten_ids': False, 'simple_colors': True, 'strip_comments': False, 'remove_metadata': False, 'outfilename': None, 'group_create': False, 'protect_ids_noninkscape': False, 'indent_type': 'space', 'keep_editor_data': False, 'shorten_ids_prefix': '', 'keep_defs': False, 'renderer_workaround': True, 'style_to_xml': True, 'protect_ids_prefix': None, 'enable_viewboxing': False, 'digits': 5, 'embed_rasters': True, 'infilename': 'none', 'strip_xml_prolog': False, 'group_collapse': True, 'quiet': False, 'protect_ids_list': None} """ #get default option opts = scour.generateDefaultOptions() options = opts.__dict__ #custom options for beampy #TODO: add this option to a configuration file options['indent_type'] = None options['strip_comments'] = True #options['group_create'] = True #create group with identical element defs #run scour #print('optimize svg...') svgout = scour.scourString(svgfile_in, opts).encode("UTF-8") #print('done') return svgout