See below for a step-by-step tutorial on how to use svgtrace
-
Create the following files (
logo-bw.png
andlogo.png
) -
Import
svgtrace
and convert a file on disk (withtrace
) to an svg, andsave this back to disk (withPath().write_text
)from pathlib import Path from svgtrace import trace Path("logo-bw.svg").write_text(trace("logo-bw.png", True), encoding="utf-8") Path("logo.svg").write_text(trace("logo.png"), encoding="utf-8")
-
Output
-
Import
svgtrace
and convert a file on disk (withasyncTrace
) to an svg, andsave this back to disk (withPath().write_text
)from pathlib import Path from svgtrace import trace Path("logo-asyncBw.svg").write_text(asyncio.run(asyncTrace("logo-bw.png", True)), encoding="utf-8") Path("logo-async.svg").write_text(asyncio.run(asyncTrace("logo.png")), encoding="utf-8")
-
Output is identical to above
-
Import
svgtrace
and convert a pillow image (withskimageTrace
) to an svg, andsave this back to disk (withPath().write_text
)from pathlib import Path from PIL import Image from svgtrace import trace Path("logo-skimageBw.svg").write_text(skimageTrace(Image.open("logo-bw.png")), encoding="utf-8") Path("logo-skimage.svg").write_text(skimageTrace(Image.open("logo.png")), encoding="utf-8")
-
Output