SVG (Scalable Vector Graphics) recordsdata are generally used for logos, icons, and illustrations as a result of they are often resized with out dropping high quality.
Nonetheless, typically you must convert SVG recordsdata to a PNG (Moveable Community Graphics) format for higher compatibility with web sites or purposes.
In Linux, there are a number of methods to do that conversion simply, utilizing each command-line instruments and graphical purposes.
1. Utilizing Inkscape
Inkscape is a robust, open-source vector graphics editor that helps the SVG format and might simply be used to transform SVG recordsdata to PNG format.
If Inkscape shouldn’t be put in in your system, you’ll be able to set up it utilizing the next instructions primarily based in your Linux distribution:
sudo apt set up inkscape [On Debian, Ubuntu and Mint]
sudo yum set up inkscape [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
sudo emerge -a sys-apps/inkscape [On Gentoo Linux]
sudo apk add inkscape [On Alpine Linux]
sudo pacman -S inkscape [On Arch Linux]
sudo zypper set up inkscape [On OpenSUSE]
sudo pkg set up inkscape [On FreeBSD]
As soon as put in, you should utilize the next command to transform the SVG file to PNG.
inkscape enter.svg –export-type=png –export-filename=output.png –export-dpi=300
2. Utilizing ImageMagick
ImageMagick is a flexible instrument that may convert photographs between completely different codecs, together with SVG to PNG from the command line.
If ImageMagick shouldn’t be put in in your system, you’ll be able to set up it utilizing the next instructions primarily based in your Linux distribution:
sudo apt set up imagemagick [On Debian, Ubuntu and Mint]
sudo yum set up ImageMagick [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
sudo emerge -a sys-apps/imagemagick [On Gentoo Linux]
sudo apk add imagemagick [On Alpine Linux]
sudo pacman -S imagemagick [On Arch Linux]
sudo zypper set up imagemagick [On OpenSUSE]
sudo pkg set up imagemagick [On FreeBSD]
As soon as ImageMagick is put in, you’ll be able to convert SVG recordsdata to PNG by working:
convert enter.svg output.png
If you wish to set a customized decision for the output PNG file, use the -density possibility.
convert -density 300 enter.svg output.png
3. Utilizing rsvg-convert (A part of librsvg)
rsvg-convert is a command-line instrument that’s a part of the librsvg bundle, which is light-weight and particularly designed for changing SVG recordsdata.
If rsvg-convert: shouldn’t be put in in your system, you’ll be able to set up it utilizing the next instructions primarily based in your Linux distribution:
sudo apt set up librsvg2-bin [On Debian, Ubuntu and Mint]
sudo yum set up librsvg2-tools [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
sudo emerge -a gnome-base/librsvg [On Gentoo Linux]
sudo apk add librsvg [On Alpine Linux]
sudo pacman -S librsvg [On Arch Linux]
sudo zypper set up librsvg2-tools [On OpenSUSE]
sudo pkg set up librsvg2 [On FreeBSD]
As soon as rsvg-convert is put in, you’ll be able to convert an SVG file to PNG by working the next command:
rsvg-convert -o output.png enter.svg
You possibly can specify the width or peak of the output picture utilizing -w (width) or -h (peak):
rsvg-convert -w 800 -h 600 -o output.png enter.svg
4. Batch Conversion of SVG to PNG
You probably have a number of SVG recordsdata and need to convert all of them to PNG directly, you should utilize a easy shell loop.
Utilizing Inkscape:
for file in *.svg; do
inkscape “$file” –export-type=png –export-filename=”${file%.svg}.png”
completed
Utilizing ImageMagick:
for file in *.svg; do
convert “$file” “${file%.svg}.png”
completed
This loop will convert all .svg recordsdata within the present listing to .png.
Conclusion
Changing SVG to PNG in Linux is an easy process that may be completed utilizing varied instruments. Whether or not you like a graphical instrument like Inkscape, the flexibleness of ImageMagick, or a fast command-line instrument like rsvg-convert, Linux supplies a number of straightforward strategies for this conversion.