Closed abdlmutii closed 3 years ago
Please mention the version you are using and also show the code you used to generate captcha.
const { CaptchaGenerator } = require("captcha-canvas");
const captcha = new CaptchaGenerator()
.setDimension(150, 450)
.setCaptcha({color: '#1DAEEF'})
.setDecoy({opacity: 0.5})
.setTrace({color: '#1DAEEF'});
I use latest version..lemme do quick check
Yea. I use latest version.
the variable captcha
here will not provide you Buffer
. To get Buffer
you have to use generateSync
method.
I used your code in my PC and it works
Code:
const { CaptchaGenerator } = require("captcha-canvas");
const { writeFileSync } = require("fs");
const captcha = new CaptchaGenerator()
.setDimension(150, 450)
.setCaptcha({color: '#1DAEEF'})
.setDecoy({opacity: 0.5})
.setTrace({color: '#1DAEEF'});
const captchaImageData = captcha.generateSync();
writeFileSync('captcha.png', captchaImageData);
This code creates a file captcha.png which have the image.
skia-canvas
make sure skia-canvas
works on your system.If your system do not support skia-canvas
then you can try v2.3.1
of captcha-canvas
. As v2 uses node-canvas
for image manipulation. The above code will also work on v2 too.
npm i captcha-canvas@2.3.1
BTW skia-canvas
is fast compare to node-canvas
.
I will try it. But i use repl.it. may its problem from it?
Ok thx bro.. problem from skia canvas
Captcha dosen't appears. https://media.discordapp.net/attachments/883652933579866132/901548736625401876/file.jpg