1.0.3 • Published 10 months ago

textifyimage v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

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)

  1. Import the extractTextFromImage function from the package:

  2. 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");
  1. Handle the promise using then and catch 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)

  1. Call the convertTextToImage function, passing desired parameters. The function returns a promise:
import { convertTextToImage } from "textifyimage";
  1. Handle the promise using then and catch 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.

1.0.3

10 months ago

1.0.2

10 months ago

1.0.0

10 months ago