Shashank3736 / captcha-canvas

A captcha generator by using skia-canvas.
https://captcha-canvas.js.org
Apache License 2.0
61 stars 11 forks source link

repl.it issue #31

Closed abdlmutii closed 3 years ago

abdlmutii commented 3 years ago

Captcha dosen't appears. https://media.discordapp.net/attachments/883652933579866132/901548736625401876/file.jpg

Shashank3736 commented 3 years ago

Please mention the version you are using and also show the code you used to generate captcha.

abdlmutii commented 3 years ago
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

abdlmutii commented 3 years ago

Yea. I use latest version.

Shashank3736 commented 3 years ago

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. captcha

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.

abdlmutii commented 3 years ago

I will try it. But i use repl.it. may its problem from it?

abdlmutii commented 3 years ago

Ok thx bro.. problem from skia canvas