Python:将 svg 转换为 png 而不压缩

问题描述 投票:0回答:0

我正在尝试在 python 中将 svg 转换为 png,但我不想要任何压缩和抗锯齿。 我试图将 inkscape 与子进程一起使用,但我找不到告诉 inkscape 我不想要任何压缩和抗锯齿的参数。

inkscape_path = "D:/Programmes/bin/inkscape.exe"
dpi_value = 300

result = subprocess.run([inkscape_path, "cleaned.svg", "--export-id=layer1", "--export-ignore-filters", "--export-type=png", "--export-filename=" + "cleaned.png", "--export-dpi=" + str(dpi_value)], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

if result.returncode != 0:
    print("Error: " + result.stderr.decode("utf-8"))
else:
    print("PNG file exported successfully.")

在 inkscape 的 UI 中导出过程中我们可以指定这个,你知道我们是否可以对子过程做同样的事情吗?

screen shot of the export ui in inkscape

python svg inkscape
© www.soinside.com 2019 - 2024. All rights reserved.