CAIROSVG¶
Convert SVG files with cairosvg.
Example¶
This wrapper can be used in the following way:
rule:
input:
"{prefix}.svg"
output:
"{prefix}.{fmt,(pdf|png)}"
wrapper:
"v2.6.0-35-g755343f/utils/cairosvg"
Note that input, output and log file paths can be chosen freely.
When running with
snakemake --use-conda
the software dependencies will be automatically deployed into an isolated environment before execution.
Software dependencies¶
cairosvg=2.7.1
Authors¶
- Johannes Köster
Code¶
__author__ = "Johannes Köster"
__copyright__ = "Copyright 2017, Johannes Köster"
__email__ = "johannes.koester@protonmail.com"
__license__ = "MIT"
import os
from snakemake.shell import shell
extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=True, stderr=True)
_, ext = os.path.splitext(snakemake.output[0])
if ext not in (".png", ".pdf", ".ps", ".svg"):
raise ValueError("invalid file extension: '{}'".format(ext))
fmt = ext[1:]
shell("cairosvg -f {fmt} {snakemake.input[0]} -o {snakemake.output[0]}")