Inkscape.org
Beyond the Basics how to trace a bitmap on the command line ?
  1. #1
    phil123456789101112 phil123456789101112 @phil123456789101112
    Hi,
    
    is there a way to convert a png to svg from the command line ?
    
    selection-trace is only embedding the original png inside an svg file
    
    thanks
    
  2. #2
    alexgrey alexgrey @alexgrey

    Yes, there is a way to do so in the Inkscape. Surprisingly, I was also looking for the same thing a few weeks back and I found the solution after many hours of researching. You can follow the below steps:

    Inkscape has got an awesome auto-tracing tool.

    Install Inkscape using sudo apt-get install inkscape
    Import your image
    Select your image
    From the menu bar, select Path > Trace Bitmap Item
    Adjust the tracing parameters as needed

  3. #3
    Tyler Durden Tyler Durden @TylerDurden

    @alexgrey, the question was use of command-line. Please read carefully before posting.

  4. #4
    phil123456789101112 phil123456789101112 @phil123456789101112
    alexgrey

    Yes, there is a way to do so in the Inkscape. Surprisingly, I was also looking for the same thing a few weeks back and I found the solution after many hours of researching. You can follow the below steps: Inkscape has got an awesome auto-tracing tool. Install Inkscape using sudo apt-get install inkscape Import your image Select your image From the menu bar, select Path > Trace Bitmap Item Adjust the tracing parameters as needed

    thanks for ruining any chance for this post to get one day a proper answer

    as for me - so far - I use potrace to automate this process from the command line

  5. #5
    inklinea inklinea @inklinea⛰️

    I've tried it myself with 

    inkscape --batch-process --actions="select-by-id:image1380;SelectionTrace;export-filename:traced.svg;export-do;" drawing.svg

    and you are correct, it simply reformats the base64 string of the <image> but does not produce a trace.

    A developer very kindly checked my findings - confirmed this is the case.

    If you want to use an external tracing utility, there are a couple of ways you can do it.

    1. just run potrace in the command script ( such as bash or powershell )

    2. You could call either the potrace executable from a custom extension.

    3. Install https://pypi.org/project/pypotrace/ and use that in a custom extensions.

    It's not actually possible to pass parameters to any extensions from the command line, however if you are working your way through a list of svgs with embedded images it probably does not matter since you are probably using the same parameters each time.

     

  6. #6
    alexgrey alexgrey @alexgrey

    I am sorry! I didn't understand what you were really looking for. Sorry, I hope to come up with a better solution next time.

Inkscape Inkscape.org Inkscape Forum Beyond the Basics how to trace a bitmap on the command line ?