SFML community forums

Help => Graphics => Topic started by: degski on August 02, 2019, 12:08:31 pm

Title: Commandline tool to convert svg files to png with optional scaling
Post by: degski on August 02, 2019, 12:08:31 pm
I'm posting a simple,and stupid command-line utility https://github.com/degski/svg2png (https://github.com/degski/svg2png) to convert svg to png (as SFML does not support that format out of the box and there seem to be few on the ground).

It is based on sf-svg, all the credits go to Kamil Koczurek (github.com/kamirr).

I've released a 64-bit statically linked windows executable [in the releases section of the github repository], virustotal.com report linked.

If you have a folder of svg-files to convert (I had 222 of them), this saves you loads of time, and the results are altogether satisfying.
Title: Re: Commandline tool to convert svg files to png with optional scaling
Post by: FRex on August 02, 2019, 07:20:36 pm
ImageMagick can do it too if you have it installed or are willing to install it.

I once had a bunch of bmp files and wrote a similar tool to go from bmp, jpg, etc. to png ( https://github.com/FRex/topng/ ) because I didn't have ImageMagick and didn't want to install it just for this, but I later also found out ffmpeg also can do such conversions (and ffmpeg I do have installed) but mine is at least simple to invoke in find command or something.
Title: Re: Commandline tool to convert svg files to png with optional scaling
Post by: degski on August 03, 2019, 06:18:44 am
> ... but I later also found out ffmpeg also can do such conversions (and ffmpeg I do have installed) ...

Same here, I have that installed as well (and did not know about it!).
Title: Re: Commandline tool to convert svg files to png with optional scaling
Post by: FRex on August 03, 2019, 06:44:19 am
To be clear: ffmpeg can do jpeg and others to png. It can't do svg to png. ImageMagick can.
Title: Re: Commandline tool to convert svg files to png with optional scaling
Post by: degski on August 03, 2019, 10:52:55 am
I was just gonna ask you what the magic incantations were, because I did not find them in the help screens.

So, one cannot convert svg to png using ffmpeg.
Title: Re: Commandline tool to convert svg files to png with optional scaling
Post by: eXpl0it3r on August 03, 2019, 11:30:42 am
Wouldn't be surprised if ffmpeg could somehow also convert SVG. Seems like Inkscape is also a good alternative: https://stackoverflow.com/questions/9853325/how-to-convert-a-svg-to-a-png-with-image-magick