2

Is there a way to convert svg files to png using ffmpeg on Windows 10 64bit?

I obviously tried ffmpeg -i "file.svg" "file.png" and it doesn't work by default.

Perhaps there is something to do that would make it work? Couldn't find anything for win10.

Something users can do using --enable-librsvg perhaps? Is there a command? Or do you have to download something?

EDIT:

If not ffmpeg, anything that works on win10 is welcomed, as long as I can convert lots of svg files at once.

6
  • 1
    Can you edit your question and explain why this conversion must be done with ffmpeg, or, if not, what tools would be acceptable (e.g. anything FLOSS that runs in Windows 10).
    – bitinerant
    Jan 30, 2021 at 1:05
  • @bitinerant done
    – goldnick7
    Jan 30, 2021 at 1:55
  • Have you tried IrfanView? It's as close a thing as there is to a universal image viewer/editor for Windows, and should be able to open SVG files and save them as PNG. Jan 30, 2021 at 2:23
  • ffmpeg requires to be compiled with --enable-librsvg. Unfortunately I do not see this included in the pre-compiled ffmpeg executables for Windows provided by Gyan or BtbN. So you would have to compile it yourself or ask one of them to include it. (Looks like someone already asked Gyan).
    – llogan
    Jan 30, 2021 at 18:20
  • Refer to this answer may it will help you. superuser.com/a/260071/1073152
    – HarshShah
    Feb 2, 2021 at 6:08

1 Answer 1

4

You best bet is to use Inkscape's command-line mode:

"C:\Program Files\Inkscape\bin\inkscape.exe" -o compass.png -w 1440 compass.svg

Full manpage here:

https://inkscape.org/doc/inkscape-man.html

From what I can tell, to do many images at once will require wrapping it in a loop in a batch file. Maybe something like:

FOR %%I in (*.svg) DO "C:\Program Files\Inkscape\bin\inkscape.exe" -o %%~nI.png -w 1440 %%I
4
  • Works! 1. Downloaded & Installed Inkscape 2. Tested both commands and both worked at first try. Thanks!
    – goldnick7
    May 5, 2021 at 15:48
  • FWIW, I've since found a much faster way using Inkscape's shell mode. You create a text file with one line per SVG, where each line is "file-open:filename01.svg;export-filename:filename01.png;export-do;file-close;". You then pipe the text file into "inkscape.exe --shell" with something like "type svg_commands.txt | inkscape.exe --shell". I converted a couple of million fairly complex SVGs with a Python version of this, in batches of a few hundred at a time, at a rate of about 1 per second. Dec 23, 2021 at 22:25
  • could you add all the batch files and the instructions.txt in a ZIP .. then upload it and share link? Otherwise maybe share a video showing the steps? Or make a post somewhere (google docs, reddit, pastebin) ... if it's easy... otherwise nvm... I rarely need to deal with svg files... your original solution is good enough for me.
    – goldnick7
    Dec 24, 2021 at 0:03
  • I'm in the middle of other projects right now, but I'll keep that in the back of my mind as something I could do when I get the time. Thanks for the suggestion. Dec 24, 2021 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.