Picture Word Counter

Picture Word Counter

Picture Word Counter

Drag & drop an image here or click to select

Supported file types: JPG, PNG, WebP, GIF, BMP, TIFF

Processing image...

"; // Use Tesseract.js for OCR try { const { data: { text } } = await Tesseract.recognize( file, 'eng', { logger: m => console.log(m) } ); if (!text) { errorMessage.textContent = 'No text found in the image.'; return; }// Count words in the extracted text const wordCount = countWords(text); displayResults(wordCount); } catch (error) { console.error('Error during OCR:', error); errorMessage.textContent = 'Error processing image. Please try again.'; } }function countWords(text) { // Split text into words by spaces and count them const words = text.trim().split(/\s+/); return words.length; }function displayResults(wordCount) { const html = `

Word Count

${wordCount}

`; results.innerHTML = html; } });