How to Convert SVG to PNG in Linux

Take Your Linux Skills to the Next Level All courses, certifications, ad-free articles & community — from $8/mo
Join Root →
Ad-free access to all premium articles
Access to all courses: Learn Linux, AI for Linux, Bash Scripting, Ubuntu Handbook, Golang and more.
Access to Linux certifications (RHCSA, RHCE, LFCS and LFCA)
Access new courses on release
Get access to weekly newsletter
Priority help in comments
Private Telegram community
Connect with the Linux community
From $8/mo · or $59/yr billed annually · Cancel anytime

SVG (Scalable Vector Graphics) files are commonly used for logos, icons, and illustrations because they can be resized without losing quality.

However, sometimes you need to convert SVG files to a PNG (Portable Network Graphics) format for better compatibility with websites or applications.

In Linux, there are several ways to do this conversion easily, using both command-line tools and graphical applications.

1. Using Inkscape

Inkscape is a powerful, open-source vector graphics editor that supports the SVG format and can easily be used to convert SVG files to PNG format.

If Inkscape is not installed on your system, you can install it using the following commands based on your Linux distribution:

sudo apt install inkscape         [On Debian, Ubuntu and Mint]
sudo yum install 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 install inkscape      [On OpenSUSE]    
sudo pkg install inkscape         [On FreeBSD]

Once installed, you can use the following command to convert the SVG file to PNG.

inkscape input.svg --export-type=png --export-filename=output.png --export-dpi=300

2. Using ImageMagick

ImageMagick is a versatile tool that can convert images between different formats, including SVG to PNG from the command line.

If ImageMagick is not installed on your system, you can install it using the following commands based on your Linux distribution:

sudo apt install imagemagick         [On Debian, Ubuntu and Mint]
sudo yum install 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 install imagemagick      [On OpenSUSE]    
sudo pkg install imagemagick         [On FreeBSD]

Once ImageMagick is installed, you can convert SVG files to PNG by running:

convert input.svg output.png

If you want to set a custom resolution for the output PNG file, use the -density option.

convert -density 300 input.svg output.png

3. Using rsvg-convert (Part of librsvg)

rsvg-convert is a command-line tool that is part of the librsvg package, which is lightweight and specifically designed for converting SVG files.

If rsvg-convert: is not installed on your system, you can install it using the following commands based on your Linux distribution:

sudo apt install librsvg2-bin         [On Debian, Ubuntu and Mint]
sudo yum install 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 install librsvg2-tools    [On OpenSUSE]    
sudo pkg install librsvg2             [On FreeBSD]

Once rsvg-convert is installed, you can convert an SVG file to PNG by running the following command:

rsvg-convert -o output.png input.svg

You can specify the width or height of the output image using -w (width) or -h (height):

rsvg-convert -w 800 -h 600 -o output.png input.svg

4. Batch Conversion of SVG to PNG

If you have multiple SVG files and want to convert them all to PNG at once, you can use a simple shell loop.

Using Inkscape:

for file in *.svg; do
  inkscape "$file" --export-type=png --export-filename="${file%.svg}.png"
done

Using ImageMagick:

for file in *.svg; do
  convert "$file" "${file%.svg}.png"
done

This loop will convert all .svg files in the current directory to .png.

Conclusion

Converting SVG to PNG in Linux is a simple task that can be done using various tools. Whether you prefer a graphical tool like Inkscape, the flexibility of ImageMagick, or a quick command-line tool like rsvg-convert, Linux provides several easy methods for this conversion.

Root Plan
Premium Linux Education for Serious Learners

Take Your Linux Skills to the Next Level

Root members get full access to every course, certification prep track, and a growing library of hands-on Linux content — with new courses added every month.

What You Get
Ad-free access to all premium articles
Access to all courses: Learn Linux, AI for Linux, Bash Scripting, Ubuntu Handbook, Golang and more.
Access to Linux certifications (RHCSA, RHCE, LFCS and LFCA)
Access new courses on release
Get access to weekly newsletter
Priority help in comments
Private Telegram community
Connect with the Linux community
Ravi Saive
I'm Ravi Saive, an award-winning entrepreneur and founder of several successful 5-figure online businesses, including TecMint.com, GeeksMint.com, UbuntuMint.com, and the premium learning hub Pro.Tecmint.com.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.