Created
December 27, 2020 06:39
-
-
Save fxp/285c17a242f9bc4d07a396d14b0561b3 to your computer and use it in GitHub Desktop.
generate bar code
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 bwipjs = require('bwip-js'); | |
const fs = require('fs'); | |
async function genImgs() { | |
for (let i = 1; i < 500 ; i++) { | |
const stream = fs.createWriteStream("./" + i + ".png"); | |
let buf = await bwipjs.toBuffer({ | |
bcid: 'code128', | |
text: '' + i, | |
scale: 3, | |
height: 10, | |
includetext: true, | |
textxalign: 'center', | |
dpi:300 | |
}); | |
await stream.write(buf); | |
} | |
} | |
genImgs(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment