2

I need to process all images in folder from png to svg. My usual workflow is using Inkscape and doing it manually for each file. Since this is repetitive operation and I usually have image with 2 or 3 colors task is simple but time consuming nonetheless. When I found out that inkscape can be controlled from bash I went out to try and create batch script.

I have this script which opens image in Inkscape selects it and attempts to trace it to vector.

inkscape --verb "EditSelectAll; SelectionTrace" image.png

"image.png" is input image, --verb argument passes command to select all and to trace selection

You can get list of verbs with:

inkscape --verb-list

And that is fine except that verb SelectionTrace simply opens up dialog box for that and I don't know way of controlling that window with bash or verbs.

Inkscape trace bitmap window

Somewhere I've read that you need to create custom verb(extension I guess) which does what you need to do and then use that in verb argument. Issue with that is that there is no example of similar extension already done.

5
  • 2
    This isn't going to work with any current or near-future Inkscape version. The dialog fields need input. For that, the verb needs to be converted into an action (which can take (multiple) arguments), and a way needs to be found to make that easy to use. However, you can use the libraries that do the tracing directly, if you want to. Potrace and Autotrace are being used.
    – Moini
    Feb 4, 2020 at 2:38
  • Alright that's good to know. At least I won't try to do imposible. Ok, so I know about potrace and autotrace. I tried them but failed to get colored and same result as Inkscape. Inkscape does layering good and saves a bit data by making one color as background. I will take better look at libraries and see if I can come up with something. Feb 4, 2020 at 14:17
  • 1
    As far as I know, the color separation is done in Inkscape already (maybe with imagemagick?), and the tracers only get the different color layers.
    – Moini
    Feb 4, 2020 at 20:14
  • Found this tool github.com/migvel/color_trace and it works like charm. Which is based on potrace and imagemagick so almost same as in inkscape. It was missing that neat feature of removing one layer at back so I went and added it. Ill update when and if pull request is approved. Feb 9, 2020 at 13:36
  • The SIOX option is for selecting the foreground (but I think it's currently broken)
    – Moini
    Feb 9, 2020 at 14:30

1 Answer 1

2

It is unfortunately not possible directly with the current version of Inkscape.

As a workaround you can try https://github.com/fablabnbg/inkscape-centerline-trace as suggested here: https://stackoverflow.com/questions/62042051/howto-vectorize-a-bitmap-file-with-the-inkscape-1-0-cli-interface

1
  • Thanks. I think I have came across that github page on my search later on. It didn't helped. Instead I used potrace as few suggested. May 3, 2021 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.