textifyimage
v1.0.3
Published
textifyimage is a lightweight npm package that allows you to extract text from images effortlessly.
Downloads
22
Maintainers
Readme
TextifyImage
TextifyImage is a JavaScript package that allows you to extract text from images using OCR (Optical Character Recognition) technology.
Installation
You can install the package using npm:
npm install textifyimage
Usage
To use the TextifyImage package, follow these steps:
Image to Text (Extract text from image)
Import the
extractTextFromImage
function from the package:Call the
extractTextFromImage
function, passing the file path or URL of the image as a parameter. The function returns a promise:
import { extractTextFromImage } from "textifyimage";
var text = extractTextFromImage("test.jpg");
- Handle the promise using
then
andcatch
to access the extracted text or handle any errors:
text
.then((data) => {
console.log(data); // Output the extracted text
})
.catch((error) => {
console.log(error); // Handle any errors
});
Please note that the extractTextFromImage
function returns a promise, which allows you to handle the result asynchronously.
Image to Text (Extract text from image)
- Call the
convertTextToImage
function, passing desired parameters. The function returns a promise:
import { convertTextToImage } from "textifyimage";
- Handle the promise using
then
andcatch
to access the extracted text or handle any errors:
const text = "Hello, World Text!";
const outputPath = "output.png";
// returns a callback. handle it with then and catch
convertTextToImage({
text,
outputPath,
fontSize: "30px",
fontName: "Arial",
textColor: "rgb(0,0,0)",
backgroundColor: "orange",
width: 200,
height: 200,
lineHeight: 30,
textAlignment: "start",
x: 0,
y: 30,
})
.then(() => {
console.log(`Image saved to ${outputPath}`);
})
.catch((error) => {
console.error("Error:", error);
});
Output
Please note that the convertTextToImage
function returns a promise, which allows you to handle the result asynchronously.
License
This package is licensed under the ISC License.