Skip to content

Errors while preprocessing svg files  #24

@athenas-lab

Description

@athenas-lab

Hi,

I used preprocess.py to process icons from the iconfinder dataset, which is a public site for icons. I am getting the following errors. The svg file for one of the icons from the iconfinder dataset is provided below, as an example. Does preprocess.py only work for the icons8 dataset? I would appreciate some guidance for how it can be adapted to process the svg format provided below, which does not include the "viewbox" attribute.

Thanks

svg = SVG.load_svg(svg_file)
File "../deepsvg/svglib/svg.py", line 74, in load_svg
    return SVG.from_str(f.read())
File "../deepsvg/svglib/svg.py", line 124, in from_str
    viewbox_list = list(map(float, svg_root.getAttribute("viewBox").split(" ")))
ValueError: could not convert string to float: 

<?xml version="1.0" ?><svg height="100" id="svg6584" version="1.1" width="100" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg"><defs id="defs6586"/><g id="layer1" transform="translate(0,-952.362)"><path d="m 45.833336,973.19536 -39.583305,22.91663 8.333327,0 0,4.16661 0,25.0001 0,4.1666 c 0,2.0834 1.858332,4.1667 4.166664,4.1667 l 12.499991,0 0,-20.8333 c 0,-2.3084 1.858291,-4.1667 4.166664,-4.1667 l 29.166646,0 c 2.308373,0 4.09458,1.8595 4.166663,4.1667 l 0,20.8333 12.499992,0 c 2.308331,0 4.166663,-1.8583 4.166663,-4.1667 l 0,-4.1666 0,-25.0001 0,-4.16661 8.333328,0 -39.583305,-22.91663 C 52.38554,972.16411 50.632666,971.11412 50,971.11203 c -0.63275,-0.002 -2.358248,1.03625 -4.166664,2.08333 z m -10.416659,39.58334 0,4.1666 29.166646,0 0,-4.1666 z m 0,8.3333 0,4.1667 29.166646,0 0,-4.1667 z m 0,8.3333 0,4.1667 29.166646,0 0,-4.1667 z" id="path4181" style="color:#000000;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"/></g></svg>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions