I'm using potrace to convert a png file to svg. The png is black on transparent background with alpha-transparency levels. I would like to report them in the svg output. Is it possible ? Potrace skips the alpha-transparency and turns it to black.
Here is my command:
convert -alpha Remove file.png pgm: | potrace --svg -o file.svg
PNG : http://i.imgur.com/d2ZYrf6.png
SVG output (.svg in reality but you can see directly the result in png) : http://i.imgur.com/n1NsNYQ.png
Thanks !
@Lolo. I don't think a pipeline with potrace
alone can do what you want. From the manpage:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With