From 07c3cbd526033efb827c1918ea3ee8d4922688fa Mon Sep 17 00:00:00 2001 From: mohamed ali rashad Date: Tue, 25 Dec 2018 00:57:28 +0200 Subject: [PATCH] Changing rsvg to cairosvg rsvg is outdated (i think) i couldn't make it run in my machine but cairosvg worked as a charm ... so i updated this repo with it --- racovimge/racovimge.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/racovimge/racovimge.py b/racovimge/racovimge.py index 52b559c..1660f48 100644 --- a/racovimge/racovimge.py +++ b/racovimge/racovimge.py @@ -13,6 +13,7 @@ import subprocess import tempfile import textwrap +import os ############################################################################### # Helper Functins @@ -42,18 +43,19 @@ def copy_fonts(*fonts): def to_png(image): - _, path = tempfile.mkstemp(suffix='.svg') + fd, path = tempfile.mkstemp(suffix='.svg') with open(path, 'w') as file: file.write(image) outpath = path.replace('.svg', '.png') - subprocess.call(['rsvg', path, outpath]) + subprocess.call(['cairosvg', path, '-o', outpath]) with open(outpath, 'rb') as file: data = file.read() pathlib.Path(path).unlink() pathlib.Path(outpath).unlink() + os.close(fd) + os.remove(path) return data - def wrap(text, width): if not isinstance(text, str): return text