(file_path: str)
| 14 | |
| 15 | |
| 16 | def infer_size_from_path(file_path: str) -> tuple[int, int] | None: |
| 17 | raw = file_path.replace("\\", "/") |
| 18 | for part in raw.split("/"): |
| 19 | m = re.match(r"^(\d+)x(\d+)$", part, re.I) |
| 20 | if m: |
| 21 | w, h = int(m.group(1)), int(m.group(2)) |
| 22 | if w > 0 and h > 0: |
| 23 | return w, h |
| 24 | return None |
| 25 | |
| 26 | |
| 27 | def safe_symbol_from_path(path: str) -> str: |