I have these SVGS and I'd like to export them to PNG images, I could export them with Inkscape but that would mean open each file and export that file to PNG which is not efficient (I have hundreds of them).
How can I do this?
I have these SVGS and I'd like to export them to PNG images, I could export them with Inkscape but that would mean open each file and export that file to PNG which is not efficient (I have hundreds of them).
How can I do this?
It appears you can use Inkscape from command line:
more details
I imagine you can write a simple bash script to process all SVG files:
the example above converts all .svg files in the current directory, adding .png extension to the output files.
Inspired by the previously accepted answer I came up with this one-liner:
For Inkscape version 0.92.4 and earlier:
This way you don't need to call a script. If you wanted to, you could create an alias for converting all svgs in the current directory to pngs:
For Inkscape version 1.0 Beta and later:
This way you don't need to call a script. If you wanted to, you could create an alias for converting all svgs in the current directory to pngs:
Graphical Nautilus Script
Overview
The command line is great for batch conversions but sometimes you just don't want to leave the comfort of your GUI. That's why I coded a GUI-based Nautilus script to batch convert SVG files to PNG images. Other file managers with custom actions (e.g. Thunar) should be supported, too.
Screenshot
Script
I will try to keep this answer updated but please check out my Github repository for the latest version of the script.
Installation
Generic installation instructions for all Nautilus scripts may be found here. The following commands should cover all the necessary dependencies:
For further information please consult the script header above.
Usage
After installing the script you should be able to invoke it from your file manager's context menu. Simply select one or more SVG files and click on the appropriate entry in your context menu. A GUI dialog should come up with several options concering the conversion.
You can either convert the SVG based on DPI or width. The aspect ratio will be conserved in both cases. Make sure to supply your DPI or width of choice before clicking on the conversion buttons.
You can also choose between exporting the full SVG file or only the cropped drawing. If your SVG canvas has a lot of empty space it's advisable to choose "Drawing" as the export option.
Here's a slightly different alternative solution in a more readable scripting language - python. It can batch export all your svgs. Particularly ideal if you're doing Android dev and have to make multiple pngs from a single svg.
Disclaimer: I wrote the lib. Hope it helps someone.
Click here.
For a simple use, download the library into a folder, put the svgs in the same folder, then run
in the command line/terminal after you
cd
to the folder. For more advanced options, do check out the README.If not all files, but only certain SVG files need to be converted to PNG, one might use
sed
to automatically generate the file names: