Related blog post: Convert SVG to PNG using Node.js
Created
December 31, 2024 04:57
-
-
Save GroupDocsGists/118598481c4e31b705b8c8aaf763615d to your computer and use it in GitHub Desktop.
Convert SVG to PNG using Node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Convert SVG file into PNG format using Node.js Conversion API with default options | |
| const converter = new groupdocs.conversion.Converter("path/vector-graphic.svg") | |
| const convertOptions = new groupdocs.conversion.ImageConvertOptions() | |
| convertOptions.setFormat(groupdocs.conversion.ImageFileType.Png) | |
| converter.convert("path/converted-svg-to-png.png", convertOptions) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Convert SVG vector into PNG format with Node.js using various customizations | |
| const converter = new groupdocs.conversion.Converter("path/vector-graphic.svg") | |
| const convertOptions = new groupdocs.conversion.ImageConvertOptions(); | |
| convertOptions.setFormat(groupdocs.conversion.ImageFileType.Png); | |
| convertOptions.setFlipMode(groupdocs.conversion.ImageFlipModes.FlipY); | |
| convertOptions.setBrightness(50); | |
| convertOptions.setContrast(50); | |
| convertOptions.setGamma(0.5); | |
| convertOptions.setGrayscale(true); | |
| convertOptions.setHorizontalResolution(300); | |
| convertOptions.setVerticalResolution(100); | |
| convertOptions.setPageNumber(1); | |
| convertOptions.setPagesCount(2); | |
| converter.convert("path/converted-svg-to-png.png", convertOptions) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment