Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Convert png to svg using imagemagick and potrace
#!/bin/bash
if [ "$1" == "" ]; then
echo Usage: $0 pngfile
exit 0;
fi
FILE=`basename $1 .png`
if [ ! -e $FILE.png ]; then
echo $FILE.png does not exist
exit 1;
fi
convert $FILE.png $FILE.pnm
potrace -s -o $FILE.svg $FILE.pnm
rm $FILE.pnm
@RahulSDeshpande

This comment has been minimized.

Show comment Hide comment
@RahulSDeshpande

RahulSDeshpande Aug 12, 2014

Can you please reply me with the code (.bat file) for Windows version??

Can you please reply me with the code (.bat file) for Windows version??

@ghost

This comment has been minimized.

Show comment Hide comment
@ghost

ghost Apr 30, 2015

Wow thanks for this! Really useful <3

ghost commented Apr 30, 2015

Wow thanks for this! Really useful <3

@gonzafirewall

This comment has been minimized.

Show comment Hide comment
@gonzafirewall

gonzafirewall Aug 5, 2015

@diadzine

This comment has been minimized.

Show comment Hide comment
@diadzine

diadzine Oct 13, 2015

Nice script! I love it ;)

Nice script! I love it ;)

@eriksape

This comment has been minimized.

Show comment Hide comment
@eriksape

eriksape Dec 10, 2015

with alpha channel to white

convert $FILE.png -fx 'a==0 ? white : u' $FILE.pnm

with alpha channel to white

convert $FILE.png -fx 'a==0 ? white : u' $FILE.pnm

@rjpeart

This comment has been minimized.

Show comment Hide comment
@rjpeart

rjpeart Mar 8, 2017

Keeping alpha channel as white with the above didn't work for me. Instead I used

convert $FILE.png -background White -alpha Background $FILE.pnm

rjpeart commented Mar 8, 2017

Keeping alpha channel as white with the above didn't work for me. Instead I used

convert $FILE.png -background White -alpha Background $FILE.pnm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment