cassiobotaro/certificates

Support SVG to PNG conversion without Inkscape

Closed this issue · 2 comments

E.g with something like Kozea/CairoSVG, by including it in the dependencies and replacing lines

output_filename = output_directory / f'{name}.svg'
output_svg = Path(output_filename)
output_svg.write_text(new_svg)
png_filename = str(output_filename).replace("svg", "png")
os.system(f'inkscape -z -e "{png_filename}" "{output_filename}"')

with something like:

import cairosvg  # put me in the top

new_svg = base_svg.read_text(encoding='utf-8').format(**locals())
png_filename = str(output_filename).replace("svg", "png")
cairosvg.svg2pdf(file_obj=new_svg, write_to=png_filename)

I install cairosvg, and test with examples, but the results aren't good.
joe doe

Unfortunately, I know little to nothing about SVG format or Cairo .. could you file a bug in https://github.com/Kozea/CairoSVG/issues with any additional details you have?