LinuxCommandLibrary

ksvgtopng5

Convert SVG images to PNG images

TLDR

Convert an SVG file (should be an absolute path) to PNG

$ ksvgtopng5 [width] [height] [path/to/file.svg] [output_filename.png]
copy

SYNOPSIS

ksvgtopng5 [options] <input.svg> <output.png>

PARAMETERS

<input.svg>
    The path to the input SVG file that needs to be converted.

<output.png>
    The path where the resulting PNG image will be saved.

--width <pixels>
    Sets the desired output image width in pixels. If only width or height is specified, the aspect ratio of the SVG will be maintained.

--height <pixels>
    Sets the desired output image height in pixels. If only width or height is specified, the aspect ratio of the SVG will be maintained.

--scale <factor>
    Applies a scaling factor to the SVG rendering. For example, --scale 2 will render the SVG at double its original size or the size specified by --width/--height.

--background-color <color>
    Specifies a background color for the PNG image. This can be a color name (e.g., white) or a hexadecimal RGB value (e.g., #RRGGBB).

--dark-mode
    Renders the SVG using a dark color scheme, if the SVG content supports it and has defined styles for different color modes.

--color-scheme <scheme>
    Specifies a particular color scheme for rendering the SVG, such as light or dark. This allows for more granular control over thematic rendering than just --dark-mode.

--no-cache
    Prevents the command from using or writing to any SVG rendering cache, ensuring a fresh render each time.

--help
    Displays a brief help message detailing the command's usage and available options.

--version
    Shows the version information of the ksvgtopng5 utility.

DESCRIPTION

ksvgtopng5 is a command-line utility within the KDE Frameworks designed to convert Scalable Vector Graphics (SVG) files into Portable Network Graphics (PNG) raster images. Leveraging Qt's SVG rendering capabilities, it's primarily used by KDE applications and developers to dynamically render SVG assets, such as icons and UI elements, into pixel-based formats for display. This tool is instrumental in ensuring that KDE applications can efficiently display high-quality, resolution-independent vector graphics, adapting them to various screen resolutions and HiDPI displays without pixelation. While it does not offer advanced editing features, it provides essential options for controlling output dimensions, scaling, and background color, making it an efficient utility for its specific role within the KDE ecosystem.

CAVEATS

ksvgtopng5 is primarily designed for use within the KDE/Qt environment and relies on Qt's SVG module for rendering. While efficient for its intended purpose, it may not support every advanced or esoteric SVG feature that dedicated full-fledged SVG editors or robust renderers (like librsvg) might. Its usage is typically by applications rather than direct end-user interaction for general image conversion.

KDE/QT INTEGRATION

As a core component of KDE Frameworks, ksvgtopng5 is deeply integrated into the KDE desktop environment. It is often invoked internally by KDE applications to dynamically render scalable vector icons and other graphics into pixel-based images suitable for display on various screen resolutions, including HiDPI displays. This ensures a consistent and crisp visual experience across all KDE applications by adapting vector assets on-the-fly.

PERFORMANCE CONSIDERATIONS

While not a comprehensive SVG editing tool, ksvgtopng5 is optimized for rapid, batch conversion of SVG assets. Its lightweight nature and direct reliance on Qt's rendering engine make it highly efficient for its intended purpose within the KDE ecosystem. This efficiency is particularly valuable for generating user interface elements and icons dynamically, contributing to the overall responsiveness of KDE applications.

HISTORY

ksvgtopng5 is an integral part of the KDE Frameworks 5, building upon Qt5's powerful SVG rendering capabilities. Its development was driven by the need for KDE applications to efficiently and natively convert SVG assets, such as icons and graphical elements, into raster formats for display across diverse resolutions. The '5' in its name specifically signifies its integration with Qt 5 and KDE Frameworks 5, differentiating it from potential older versions built for Qt 4 or earlier KDE releases, and highlighting its role in the modern KDE desktop environment.

SEE ALSO

rsvg-convert(1), convert(1), inkscape(1)

Copied to clipboard