mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-02 02:41:57 +02:00
24 lines
598 B
Python
24 lines
598 B
Python
import os
|
|
import subprocess
|
|
from pathlib import Path
|
|
from typing import List
|
|
|
|
|
|
def rasterize(
|
|
from_: Path, to_: Path, area: str = "", dpi: float = 90
|
|
) -> None:
|
|
"""
|
|
Make PNG image out of SVG using Inkscape.
|
|
"""
|
|
inkscape: str = "inkscape"
|
|
if "INKSCAPE_BIN" in os.environ:
|
|
inkscape: str = os.environ["INKSCAPE_BIN"]
|
|
|
|
commands: List[str] = [inkscape]
|
|
commands += ["--export-png", to_.absolute()]
|
|
commands += ["--export-dpi", str(dpi)]
|
|
if area:
|
|
commands += ["--export-area", area]
|
|
commands += [from_.absolute()]
|
|
|
|
subprocess.run(commands)
|