1.0.0 • Published 6 months ago

iran-bank-cards-ocr v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Iranian Bank Cards OCR

License: MIT npm version GitHub stars

A TypeScript library to detect Iranian bank names, logos, and validate card numbers using OCR (Tesseract.js) and the Luhn algorithm.

Features

  • Bank Detection: Detect Iranian bank names (in English and Persian) and logos based on card numbers.
  • Card Validation: Validate card numbers using the Luhn algorithm.
  • OCR Integration: Extract card numbers from images using Tesseract.js.
  • Easy to Use: Simple and intuitive API for quick integration.

Installation

You can install the package via npm:

npm install iran-bank-cards-ocr

Or using yarn:

yarn add iran-bank-cards-ocr

Usage

Here's a quick example to get you started:

import readBankCard from 'iran-bank-card-reader';

async function main() {
  const { cardNumber, bankInfo } = await readBankCard();

  if (cardNumber && bankInfo) {
    console.log(`Card Number: ${cardNumber}`);
    console.log(`Bank Name (English): ${bankInfo.en}`);
    console.log(`Bank Name (Persian): ${bankInfo.fa}`);
    console.log(`Bank Logo URL: ${bankInfo.logo}`);
  } else {
    console.log('No valid card number found in the image.');
  }
}

main();

API

readBankCard()

Captures an image from the camera, processes it to extract the card number, and detects the bank information.

Returns: A promise that resolves to an object with the following properties:

  • cardNumber: The extracted card number (string | null).
  • bankInfo: An object containing the bank name (in English and Persian) and logo URL (object | null).

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/YourFeatureName).
  3. Commit your changes (git commit -m 'Add some feature').
  4. Push to the branch (git push origin feature/YourFeatureName).
  5. Open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments


Made with ❤️ by Peyman Pirzadeh