Created
February 9, 2025 14:01
-
-
Save tluyben/7eff63a240b889394007e1cc920c7015 to your computer and use it in GitHub Desktop.
Convert script for svg -> png
This file contains 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
const sharp = require("sharp"); | |
const fs = require("fs/promises"); | |
const sizes = [16, 48, 128]; | |
async function convertIcons() { | |
try { | |
await fs.mkdir("dist/assets", { recursive: true }); | |
for (const size of sizes) { | |
await sharp("assets/icon.svg") | |
.resize(size, size) | |
.png() | |
.toFile(`dist/assets/icon${size}.png`); | |
} | |
console.log("Icons converted successfully"); | |
} catch (error) { | |
console.error("Error converting icons:", error); | |
process.exit(1); | |
} | |
} | |
convertIcons(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment