@Lolo. I don't think a pipeline with alone can do what you want. From the manpage:potrace
The potrace algorithm expects a bitmap, thus all pixels of the input images are converted to black or white before processing begins.
@philippe_b. I ran into the same problem as you, i.e.
convert foo.png foo.pbm && potrace foo.pbm -s -o foo.svg
gave me an all black output image. Incidentally, this was actually happening at the PNG->PBM stage. My images had transparent alpha. This is my working solution
pngtopnm -mix assign.png > a.pnm && potrace a.pnm -s -o a.svg
Here's a script to do it in batches
#!/bin/bash
for src in *.png; do
name=`basename $src .png`
pnm="$name.pnm"
svg="$name.svg"
pngtopnm -mix $src > $pnm && potrace $pnm -s -o $svg && rm $pnm
# set colour
# sed -i "s/#000000/#016b8f/g" *.svg
# same for PNG
# mogrify -fill '#016b8f' -opaque black *.png
done
Use like this:ImageMagick
mogrify -background none -format png *.svg
that says... "take all the files and render them as SVG files with a transparent background."PNG
ImageMagick is available from here. It is installed on most Linux distros and is available for OSX (ideally via ) and also for Windows.homebrew
It's possible that will not work, if your SVG files are defined using, say, a rectangle of white as the background rather than defining a background properly in SVG terms. If there are files that don't work, please post them, so they can be checked.
If you are on Linux, you can use to speed this up for thousands of files, but you didn't say.GNU Parallel
Oh, I already found out by this article. It uses GIMP.
Open the image you want to edit and use the select tools to remove parts of the image until you get the shape that you want to produce with your SVG path:
Next use the magic wand to select all the areas that you just cut out.
Now go to the Invert item from the Select menu.
This will make the selection tool take the shape of the painted area, as opposed to the transparent area. Now choose To Path from the Select menu.
In the Paths window, you will see a path has been created (it should be called Selection. Right click on the path and choose Export Path
Save the path on the filesystem.