Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions scripts/validate_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ def validate_cross_chain_metadata(
def get_svg_dimensions(svg_path: Path) -> tuple[int | None, int | None]:
"""Extract width and height from an SVG file.

Falls back to the viewBox attribute when width/height are absent, since
SVGs exported without explicit pixel dimensions are common and valid.

Args:
svg_path: Path to the SVG file.

Expand All @@ -370,6 +373,14 @@ def get_svg_dimensions(svg_path: Path) -> tuple[int | None, int | None]:
height = int(re.sub(r"[^0-9.]", "", height_str).split(".")[0])
return width, height

view_box = root.get("viewBox")
if view_box:
parts = view_box.replace(",", " ").split()
if len(parts) == 4:
width = int(float(parts[2]))
height = int(float(parts[3]))
return width, height

return None, None
except Exception:
return None, None
Expand Down
Loading