Created
March 14, 2022 05:21
-
-
Save XanderCodes/5a3b7484471107455b4f55fbbbedecd0 to your computer and use it in GitHub Desktop.
Super basic image formatter for Unturned Icons (Node.JS)
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
// This takes the svg's from the other script and converts them to a font using 'svgtofont' | |
const svgtofont = require('svgtofont'); | |
const path = require('path'); | |
svgtofont({ | |
src: path.resolve(process.cwd(), 'svgs'), // svg path | |
dist: path.resolve(process.cwd(), 'fonts'), // output path | |
fontName: 'killfeed-font', // font name | |
startUnicode: 0x0021, // unicode start number | |
}).then(() => { | |
console.log('done!'); | |
}); |
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
// this isn't much to be desired for. uses sharp and potrace for image manip. | |
const sharp = require("sharp"); | |
var potrace = require('potrace'), | |
fs = require('fs'); | |
var params = { | |
//color: 'blue' | |
}; | |
async function resizeImage(fileName) { | |
try { | |
await sharp("./images/" + fileName) | |
.trim() | |
.toFile("./cropped/" + fileName); | |
await potrace.trace('./cropped/' + fileName, params, function(err, svg) { | |
if (err) throw err; | |
fs.writeFileSync('./svgs/' + fileName + ".svg", svg); | |
}); | |
} catch (error) { | |
console.log(error); | |
} | |
} | |
const images = fs.readdirSync("./images"); | |
images.forEach(function (fileName) { | |
if (fileName.endsWith('.png')) { | |
resizeImage(fileName); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment