svg2png
Convert Scalable Vector Graphics to PNG
TLDR
Convert an SVG file to PNG
Convert an SVG file to PNG with a specific width (preserving aspect ratio)
Convert an SVG file to PNG with a specific height (preserving aspect ratio)
Convert an SVG file to PNG with both width and height (image centered in space)
Convert an SVG file to PNG scaled by a factor
Convert an SVG from stdin to PNG on stdout
Flip the output image horizontally or vertically
SYNOPSIS
svg2png [OPTIONS]
PARAMETERS
-w, --width
Sets the width of the output PNG image in pixels.
-h, --height
Sets the height of the output PNG image in pixels.
--scale
Scales the SVG content by a given factor before rendering.
-q, --quality <0-100>
Sets the PNG compression quality (lower means smaller file size but potentially lower quality).
--id
Renders only the SVG element with the specified ID.
--background
Sets the background color of the output PNG (e.g., 'transparent', '#RRGGBB').
-f, --force
Overwrites the output file if it already exists.
-h, --help
Displays a help message and exits.
-v, --version
Outputs version information and exits.
DESCRIPTION
The svg2png command is a utility designed for converting Scalable Vector Graphics (SVG) files into Portable Network Graphics (PNG) images. This is particularly useful when you need to use vector-based graphics in contexts that do not support SVG directly, such as web pages where high performance or broader browser compatibility is required, or in applications that primarily handle raster image formats. svg2png leverages underlying libraries to interpret the SVG code and render it into a pixel-based PNG output. It offers control over output dimensions and other rendering aspects, making it a versatile tool for image format conversion in the Linux environment. The command-line interface allows for easy integration into scripts and automated workflows.
CAVEATS
The accuracy of the rendering can depend on the complexity of the SVG and the capabilities of the underlying rendering engine used by svg2png. Some advanced SVG features might not be perfectly supported. Ensure that the required rendering libraries are installed on your system.
DEPENDENCIES
svg2png typically relies on libraries like librsvg for SVG rendering. Ensure these are installed for proper functionality.
HISTORY
svg2png emerged as a need for developers and designers to bridge the gap between the flexibility of SVG and the ubiquitous support for PNG. Its development is often tied to the evolution of SVG rendering libraries in the open-source community, aiming to provide a simple, command-line interface for a common conversion task. Usage spans from web development for fallback images to generating static assets for various platforms.


