Skip to content

Files

Latest commit

d2cc3fd · Jun 25, 2023

History

History

tutorials

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jun 25, 2023

Tutorial

See below for a step-by-step tutorial on how to use svgtrace

Using the trace function

  1. Create the following files (logo-bw.png and logo.png)

    Screenshot 1 Screenshot 2
  2. Import svgtrace and convert a file on disk (with trace) to an svg, andsave this back to disk (with Path().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")
  3. Output

    logo-wb.svg logo.svg

Using the asyncTrace function

  1. Import svgtrace and convert a file on disk (with asyncTrace) to an svg, andsave this back to disk (with Path().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")
  2. Output is identical to above

Using the skimageTrace function

  1. Import svgtrace and convert a pillow image (with skimageTrace) to an svg, andsave this back to disk (with Path().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")
  2. Output

    logo-skimageBw.svg logo-skimage.svg