const tesseract = require("node-tesseract-ocr");
const Jimp = require("jimp");

const config = {
    lang: "eng",
    oem: 1,
    psm: 3,
}

async function convertImageToWhiteBlack(image_path) {
    const image = await Jimp.read(image_path);
    image.().write(image_path + ".wb");
    return image_path + ".wb";
}

// let filePath = "/Users/panlei/Desktop/blocked_000c3af9-711e-4b7e-b8ac-5c0a5a2122e7.png"
let filePath = "/Users/panlei/Desktop/01c2456c-blocked_0423a70a-171d-4cb2-9d7d-06ca0dcf6169.png"
convertImageToWhiteBlack(filePath).then(newFilePath => {
    tesseract
        .recognize(newFilePath, config).then(result => {
        console.log(result)
    })
})

