Warn about floating height/width and round them

Closes #8
This commit is contained in:
caribaud 2023-05-27 16:08:58 +02:00
parent 81be7d477b
commit a0d2a8c470
1 changed files with 6 additions and 2 deletions

View File

@ -40,8 +40,12 @@ def extract_zooms(src_folder):
tree = ET.parse(svg_path)
root = tree.getroot()
zooms[idx]["width"] = int(root.get("width"))
zooms[idx]["height"] = int(root.get("height"))
if "." in root.get("width"):
print(f"WARNING: file {svg_path} has a floating width, it will be rounded", file=sys.stderr)
zooms[idx]["width"] = round(float(root.get("width")))
if "." in root.get("height"):
print(f"WARNING: file {svg_path} has a floating height, it will be rounded", file=sys.stderr)
zooms[idx]["height"] = round(float(root.get("height")))
for area in root.findall('.//{*}rect'):
zooms[idx]["zooms"].append([