📜  svg to png (1)

📅  最后修改于: 2023-12-03 15:20:23.805000             🧑  作者: Mango

SVG to PNG Converter

Do you need to convert an SVG image to PNG format? Look no further than our SVG to PNG converter tool! This simple program allows you to quickly and easily convert your SVG files to PNG images that you can use in your projects.

Installation

Our SVG to PNG converter tool is available as a module on npm, so you can easily install it using:

npm install svg-to-png-converter
Usage

The SVG to PNG converter tool is easy to use. Simply require the module and call the convert function with the path to your SVG file and the desired output PNG file name.

const { convert } = require('svg-to-png-converter');

convert('path/to/my/image.svg', 'output.png')
  .then(() => console.log('Conversion complete!'))
  .catch((err) => console.error(`Conversion failed: ${err}`));
Options

You can also specify additional options when calling the convert function. These include:

  • width - The width of the output PNG image.
  • height - The height of the output PNG image.
  • quality - The quality of the PNG image, between 0 and 1.
  • backgroundColor - The background color of the PNG image.
convert('path/to/my/image.svg', 'output.png', {
  width: 800,
  height: 600,
  quality: 0.8,
  backgroundColor: '#fff'
});
Conclusion

Our SVG to PNG converter tool is an easy and reliable way to convert your SVG images to PNG format. With simple installation and usage, it's the perfect solution for all your image conversion needs.