From 586fd61781f4016a54a7d062798576c9069c19cd Mon Sep 17 00:00:00 2001 From: Bauke Date: Mon, 15 Jan 2024 13:04:47 +0100 Subject: [PATCH] Switch the resolution to be an optional tuple. --- render.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/render.py b/render.py index a1a9eec..8789f18 100755 --- a/render.py +++ b/render.py @@ -2,7 +2,7 @@ from pathlib import Path from subprocess import run -from typing import List, Optional +from typing import List, Optional, Tuple def main() -> None: @@ -14,8 +14,7 @@ def main() -> None: convert_to_image( source=svg, destination=svg.with_name(f"{svg.stem}-{resolution}.png"), - width=resolution, - height=resolution, + resolution=(resolution, resolution), ) else: convert_to_image(source=svg, destination=svg.with_suffix(".png")) @@ -24,14 +23,13 @@ def main() -> None: def convert_to_image( source: Path, destination: Path, - width: Optional[int] = None, - height: Optional[int] = None, + resolution: Optional[Tuple[int, int]] = None, ) -> None: """Convert an SVG to an image with `inkscape`.""" inkscape_args: List[str] = ["inkscape", str(source), "-o", str(destination)] - if width is not None and height is not None: - inkscape_args.extend(["-w", str(width), "-h", str(height)]) + if resolution is not None: + inkscape_args.extend(["-w", str(resolution[0]), "-h", str(resolution[1])]) run(args=inkscape_args) mat2_image(destination)