All Rounder Tools Blogger-Best blog for blogger: Image to Text Converter Tool with colorful styling and all its features use any free library...

Wednesday, September 25, 2024

Image to Text Converter Tool with colorful styling and all its features use any free library...

 

Image to Text Converter

Image to Text Converter

Converted Text:

* { box-sizing: border-box; } body { font-family: Arial, sans-serif; background-color: #f0f4f8; color: #333; margin: 0; padding: 20px; } .container { max-width: 600px; margin: 0 auto; padding: 20px; border-radius: 8px; background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); } h1 { text-align: center; color: #4CAF50; } input[type="file"] { display: block; margin: 20px auto; } button { display: block; width: 100%; padding: 10px; background-color: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer; } button:hover { background-color: #45a049; } .output { margin-top: 20px; } textarea { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 5px; font-family: monospace; resize: none; } #status { text-align: center; margin-top: 10px; font-weight: bold; } document.getElementById('convert-btn').addEventListener('click', function() { const fileInput = document.getElementById('file-input'); const outputText = document.getElementById('output-text'); const status = document.getElementById('status'); if (fileInput.files.length === 0) { status.innerText = "Please upload an image."; return; } const file = fileInput.files[0]; const reader = new FileReader(); reader.onload = function(event) { const img = new Image(); img.src = event.target.result; img.onload = function() { status.innerText = "Converting..."; Tesseract.recognize( img, 'eng', { logger: info => console.log(info) // Optional: Log progress } ).then(({ data: { text } }) => { outputText.value = text; status.innerText = "Conversion complete!"; }).catch(err => { console.error(err); status.innerText = "Error during conversion."; }); }; }; reader.readAsDataURL(file); });

No comments:

Post a Comment