Quick and easy captcha resolver.
npm i --save catcha
catcha
use tesseract-ocr and ImageMagick. Please make sure to have them installed.
import catcha from "catcha";
const settings = {
transforms: [
{key: 'resize', value: '240x100'},
{key: 'colorspace', value: 'gray'},
{key: 'negate'},
{key: 'threshold', value: '12%'},
{key: 'blur', value: '10 '},
{key: 'threshold', value: '43%'},
{key: 'negate'},
],
digitOnly: true,
deleteTemporaryImage: false,
};
const kitten = catcha(settings);
kitten('/tmp/path/to/image/.{tiff,png,jpg}')
.then((text) => {
console.log(text); // 314400
});
- transforms: array of key and value for transforms. Will be passed verbatim to ImageMagick parameter.
- deleteTemporaryImage: default to true. Delete converted image via transforms settings.
- deleteSourceImage: default to false. Delete source image.
- resolveBeforeCleaning: default to true. Resolve immediately after OCR ran, without waiting cleaning finished.
- digitOnly: will pass '-digits' parameter for tesseract so it will only recognized digits.
- Accept more image processing libraries. OpenCV, etc.
- Accept option to specify .tmp directory
- Add skewed image detection and auto-deskewing.
- Add training method where user input images and expected output then kitten will find the best tranforms settings.
- Add .gitkeep to .tmp directory / use mkdirp to make sure it exists.
MIT © Raabb Ajam