Please bookmark this page to avoid losing your image tool!

Image Name Date Of Birth And Address Remover

(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, maskColor = "#000000", padding = 4) {
    // Create a canvas to draw and modify the image
    const canvas = document.createElement('canvas');
    canvas.width = originalImg.width;
    canvas.height = originalImg.height;
    const ctx = canvas.getContext('2d');
    ctx.drawImage(originalImg, 0, 0);

    // Dynamically load Tesseract.js for Optical Character Recognition (OCR) if not already loaded
    if (typeof Tesseract === 'undefined') {
        await new Promise((resolve, reject) => {
            const script = document.createElement('script');
            script.src = 'https://cdn.jsdelivr.net/npm/tesseract.js@5/dist/tesseract.min.js';
            script.onload = resolve;
            script.onerror = reject;
            document.head.appendChild(script);
        });
    }

    // Process the image with Tesseract to extract text and their coordinates (bounding boxes)
    const { data } = await Tesseract.recognize(canvas, 'eng');
    const lines = data.lines;

    // Regular Expressions to identify Name, Date of Birth, and Address patterns/keywords
    const dateRegex = /\b(\d{1,4}[/\-.]\d{1,2}[/\-.]\d{1,4})\b|(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]*[\s.,]+\d{1,2}[\s.,]+\d{2,4}/i;
    const dobKeywordRegex = /\b(dob|birth|birthdate|born|date of birth)\b/i;
    const nameKeywordRegex = /\b(name|first name|last name|surname|given name)\b/i;
    const addressKeywordRegex = /\b(address|street|ave|avenue|blvd|rd|road|lane|ln|apt|zip|state|city)\b/i;
    // Common address patterns (e.g. "123 Main St" or "City, ST 12345")
    const addressPattern1 = /\b\d{1,5}\s+[a-z]+\s+(st|ave|blvd|rd|road|lane|ln|drive|drv|dr|court|ct)\b/i;
    const addressPattern2 = /\b[a-z\s]+,\s*[a-z]{2}\s*\d{5}\b/i; 

    ctx.fillStyle = maskColor;
    let linesToRedact = 0;

    for (let i = 0; i < lines.length; i++) {
        const line = lines[i];
        const text = line.text.trim();
        let redactThis = false;

        // Check if the current line contains sensitive information based on RegExp heuristics
        if (dateRegex.test(text) || dobKeywordRegex.test(text)) redactThis = true;
        if (nameKeywordRegex.test(text)) redactThis = true;
        if (addressKeywordRegex.test(text) || addressPattern1.test(text) || addressPattern2.test(text)) redactThis = true;

        if (redactThis) {
            const bbox = line.bbox;
            // Draw a rectangle over the sensitive text
            ctx.fillRect(
                bbox.x0 - padding, 
                bbox.y0 - padding, 
                (bbox.x1 - bbox.x0) + padding * 2, 
                (bbox.y1 - bbox.y0) + padding * 2
            );
            
            // In cases like ID cards, often the label ("Name:") is on one line 
            // and the actual value ("John Doe") is on the very next line.
            // If the triggered line is short or ends with a colon, flag the next line for redaction as well.
            if (text.length < 15 || text.endsWith(':')) {
                linesToRedact = 1;
            }
        } else if (linesToRedact > 0) {
            // Mask the follow-up line that contains the value for the previously found label
            const bbox = line.bbox;
            ctx.fillRect(
                bbox.x0 - padding, 
                bbox.y0 - padding, 
                (bbox.x1 - bbox.x0) + padding * 2, 
                (bbox.y1 - bbox.y0) + padding * 2
            );
            linesToRedact--;
        }
    }

    // Return the updated canvas holding the redacted image
    return canvas;
}

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) to automatically detect and redact sensitive personal information from images. It specifically identifies and masks text related to names, dates of birth, and physical addresses by analyzing patterns and keywords. This utility is useful for protecting privacy when sharing scans of identification documents, forms, or other paperwork that contains personally identifiable information (PII).

Leave a Reply

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