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.

JTTI-Defl
JTTI-Eom
JTTI-COCO
JTTI-Ellis
JTTI-Selina
Title
Email Address
Type
Sales Issues
Sales Issues
System Problems
After-sales problems
Complaints and Suggestions
Marketing Cooperation
Information
Code
Submit