You can trace the PNG with the trace bitmap option in Inkscape. Then choose to break apart. Both these options are under the PATH menu. This will give you a black SVG which you can then set the colours for on each of the objects. Then save as an SVG in inkscape.
If you have problems with detecting the elements of the PNG you may need to trace twice with different brigtness or edge detection and then reassemble.
@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
Finaly got the issue sorted myself... :) It was my bad, as i didn't see "-layers merge" getting adding to my paperclip command from initializers...
Paperclip::Attachment.default_options[:convert_options] = { :all => '-layers merge' }
Finally got it worked with paperclip(IM) itself... Hope it will help someone..... :)
I have read that convert options have to be before the input file. Try with
MiniMagick::Tool::Convert.new do |convert|
convert << "-density" << "72"
convert << "-transparent" << "white"
convert << "input.svg"
convert << "output.png"
end