Please bookmark this page to avoid losing your image tool!

Photo Data Extractor From Identity Card Images

(Free & Supports Bulk Upload)

Drag & drop your images here or

The result will appear here...
You can edit the below JavaScript code to customize the image tool.
async function processImage(originalImg, language = 'eng') {
  // Create a container for the result
  const container = document.createElement('div');
  container.style.fontFamily = 'Arial, sans-serif';
  container.style.padding = '20px';
  container.style.background = '#f9f9f9';
  container.style.border = '1px solid #dcdcdc';
  container.style.borderRadius = '8px';
  container.style.color = '#333';
  container.style.lineHeight = '1.6';
  container.style.boxSizing = 'border-box';
  container.style.width = '100%';
  
  // Create a loading state with progress bar
  const loadingContainer = document.createElement('div');
  
  const loadingText = document.createElement('div');
  loadingText.innerText = 'Extracting data from Identity Card...';
  loadingText.style.fontWeight = 'bold';
  loadingText.style.marginBottom = '10px';
  
  const progressBar = document.createElement('div');
  progressBar.style.width = '100%';
  progressBar.style.height = '12px';
  progressBar.style.background = '#e0e0e0';
  progressBar.style.borderRadius = '6px';
  progressBar.style.overflow = 'hidden';
  
  const progressFill = document.createElement('div');
  progressFill.style.width = '0%';
  progressFill.style.height = '100%';
  progressFill.style.background = '#4caf50';
  progressFill.style.transition = 'width 0.2s';
  
  progressBar.appendChild(progressFill);
  loadingContainer.appendChild(loadingText);
  loadingContainer.appendChild(progressBar);
  container.appendChild(loadingContainer);
  
  // Draw the image to a canvas to safely extract pixel data and avoid certain CORS issues
  const canvas = document.createElement('canvas');
  canvas.width = originalImg.width;
  canvas.height = originalImg.height;
  const ctx = canvas.getContext('2d');
  ctx.drawImage(originalImg, 0, 0);

  try {
    // Dynamically load Tesseract.js if not already available
    if (!window.Tesseract) {
      await new Promise((resolve, reject) => {
        const script = document.createElement('script');
        script.src = 'https://cdn.jsdelivr.net/npm/tesseract.js@4/dist/tesseract.min.js';
        script.onload = resolve;
        script.onerror = reject;
        document.head.appendChild(script);
      });
    }

    // Pass the canvas to Tesseract for OCR text extraction
    window.Tesseract.recognize(
      canvas,
      language,
      {
        logger: m => {
          if (m.status === 'recognizing text') {
            const percentage = Math.round(m.progress * 100);
            progressFill.style.width = `${percentage}%`;
            loadingText.innerText = `Extracting Identity Card Data... ${percentage}%`;
          } else {
            loadingText.innerText = `Loading OCR Engine: ${m.status}...`;
          }
        }
      }
    ).then(({ data: { text } }) => {
      // Clean and sanitize the extracted text output
      const escapedText = text.replace(/&/g, '&')
                              .replace(/</g, '&lt;')
                              .replace(/>/g, '&gt;');
                              
      container.innerHTML = `
        <h3 style="margin-top: 0; margin-bottom: 15px; color: #1976d2;">Extracted Identity Card Data</h3>
        <p style="margin-top: 0; font-size: 13px; color: #666;">Note: OCR results may contain inaccuracies depending on the image quality.</p>
        <div style="
          white-space: pre-wrap; 
          word-break: break-all; 
          background: #fff; 
          padding: 15px; 
          border: 1px solid #ddd; 
          border-radius: 4px; 
          max-height: 400px; 
          overflow-y: auto; 
          font-family: monospace; 
          font-size: 14px;
          color: #2c3e50;">${escapedText.trim() || 'No legible text found on the image.'}</div>
      `;
    }).catch(err => {
      container.innerHTML = `
        <h3 style="margin-top: 0; margin-bottom: 15px; color: #d32f2f;">Extraction Failed</h3>
        <div style="color: #c62828; background: #ffebee; padding: 15px; border: 1px solid #ffcdd2; border-radius: 4px;">
          <strong>Error extracting data:</strong> ${err.message}
        </div>
      `;
    });
    
  } catch (err) {
    container.innerHTML = `
      <h3 style="margin-top: 0; margin-bottom: 15px; color: #d32f2f;">Initialization Failed</h3>
      <div style="color: #c62828; background: #ffebee; padding: 15px; border: 1px solid #ffcdd2; border-radius: 4px;">
        <strong>Error Loading OCR library.</strong> Please check your internet connection and try again.
      </div>
    `;
  }

  // Returns immediately while Tesseract processes the image asynchronously in the background
  return container;
}

Free Image Tool Creator

Can't find the image tool you're looking for?
Create one based on your own needs now!

Description

This tool uses Optical Character Recognition (OCR) technology to extract text information from images of identity cards. It processes the visual data from an uploaded image and converts the written text into a digital, readable format. This utility is useful for automating data entry, digitizing personal identification details, and streamlining administrative workflows that require verifying or recording information from physical ID documents.

Leave a Reply

Your email address will not be published. Required fields are marked *