Skip to content

Commit

Permalink
Use sharp instead of svg-to-png to convert images
Browse files Browse the repository at this point in the history
  • Loading branch information
EliverLara committed Oct 7, 2021
1 parent cac8ca3 commit f9c3c05
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"execa": "^1.0.0",
"minimist": "^1.2.5",
"replaceall": "^0.1.6",
"string-capitalize": "^1.0.1",
"svg-to-png": "^4.0.0"
"sharp": "^0.29.1",
"string-capitalize": "^1.0.1"
}
}
12 changes: 8 additions & 4 deletions utils/themes-extras.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { readFile, writeFile, __dirname, unlink } from './utils.mjs'
import svg_to_png from 'svg-to-png'
import replaceall from 'replaceall'
import capitalize from 'string-capitalize'
import sharp from 'sharp'
import setColors from './svg-template.mjs'


Expand All @@ -19,11 +20,14 @@ export const createNewThemesImgs = async newThemes => {
}

const makeImg = async (xml, fileName) => {
fileName = `${changeSpaces(fileName)}.svg`
fileName = changeSpaces(fileName);
let svg = `${fileName}.svg`
try {
await writeFile(fileName, xml)
await svg_to_png.convert(`${__dirname}/${fileName}`, "../images")
await unlink(fileName)
await writeFile(svg, xml)
await sharp(`${__dirname}/${svg}`)
.png()
.toFile(`../images/${fileName}.png`)
await unlink(svg)
}catch(err) {
console.log(err)
}
Expand Down

0 comments on commit f9c3c05

Please sign in to comment.