Support > About cybersecurity > SVG to PNG conversion method in Linux environment
SVG to PNG conversion method in Linux environment
Time : 2025-01-21 16:06:45
Edit : Jtti

SVG is a scalable vector graphics file, commonly used for logos, ICONS, and illustrations, that guarantees resize without loss of quality. However, in some cases, it is also necessary to convert SVG files to PNG format for better compatibility with websites/applications. Common conversion methods in Linux are through command-line tools, or by using graphical applications.

Inkscape is a powerful open source vector graphics editor that supports SVG conversion to PNG format. Inkscape installation:

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]

After installation, conversion method:

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

ImageMagick is a versatile tool that can convert SVG to PNG, install:

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]

Conversion method:

convert input.svg output.png

If you need to output PNG files to set a custom resolution:

convert -density 300 input.svg output.png

rsvg-convert is a lightweight tool designed for SVG files. Installation:

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]

Use:

rsvg-convert -o output.png input.svg

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

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

If you have multiple SVG files and want to convert them 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

The above command converts all files in the current.svg directory to.png.

Relevant contents

Key differences and detailed comparisons between 32-bit and 64-bit systems What to do if the temporary file on the server has no permission How to add a new disk to an existing Linux server File copy/move method with progress bar in Linux Hong Kong Server hardware network topology and bandwidth management Discard weak Hash algorithm to ensure SSL/TLS certificate security Method to ensure SSL/TLS certificate security This section describes how to manage the /etc/shadow password file in Linux How to configure network interfaces in Linux using ifconfig Impact and defense strategy of DNS pollution Common methods for changing the MySQL password
Go back

24/7/365 support.We work when you work

Support