Need to batch convert svg to png? I have a few thousand .svg files that I need to convert to raster, namely .png. I ended up using ImageMagick. Apparently it is the standard tool to use. However, Inkscape and Apache Batik are also capable of converting svg to a raster format.
ImageMagick has a convert tool and a mogrify tool which can convert svg to png.
What I want to do is covert my few thousand .svg files to .png files using the same file name as the .svg files, only with the .png extension.
For some reason, I couln’t do that with the convert command. All of the output files needed to have part of the file name given, so that numbers could be appended to it, or a full file name given, in which case only one output file was created.
I poked around a bit and discovered the mogrify command would use the input file names to create the output file names, only with the .png extension instead of the .svg extension. I also needed the .png files to be a certain size, which mogrify also allows.
Here is the command I used:
mogrify -resize widthxheight -format png *.svg
where width is the desired width of the .png, ex: 100, and height is the desired height of the .png, ex: 100.
Worked great and I now have my batch of .svg files converted to .png files in the size I need.