Switch the resolution to be an optional tuple.
This commit is contained in:
parent
8ac998ef7d
commit
586fd61781
12
render.py
12
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)
|
||||
|
|
Loading…
Reference in New Issue