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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>OCR Text Extractor</title>
|
| 7 |
+
<style>
|
| 8 |
+
* {
|
| 9 |
+
margin: 0;
|
| 10 |
+
padding: 0;
|
| 11 |
+
box-sizing: border-box;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
body {
|
| 15 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 16 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 17 |
+
min-height: 100vh;
|
| 18 |
+
display: flex;
|
| 19 |
+
justify-content: center;
|
| 20 |
+
align-items: center;
|
| 21 |
+
padding: 20px;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
.container {
|
| 25 |
+
background: white;
|
| 26 |
+
border-radius: 20px;
|
| 27 |
+
padding: 50px;
|
| 28 |
+
max-width: 600px;
|
| 29 |
+
width: 100%;
|
| 30 |
+
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
|
| 31 |
+
text-align: center;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
h1 {
|
| 35 |
+
color: #333;
|
| 36 |
+
margin-bottom: 10px;
|
| 37 |
+
font-size: 2.5em;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
.subtitle {
|
| 41 |
+
color: #666;
|
| 42 |
+
margin-bottom: 30px;
|
| 43 |
+
font-size: 1em;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
.upload-area {
|
| 47 |
+
border: 3px dashed #ddd;
|
| 48 |
+
border-radius: 15px;
|
| 49 |
+
padding: 40px 20px;
|
| 50 |
+
transition: all 0.3s ease;
|
| 51 |
+
cursor: pointer;
|
| 52 |
+
background: #fafafa;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
.upload-area:hover {
|
| 56 |
+
border-color: #667eea;
|
| 57 |
+
background: #f0f2ff;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
.upload-area.dragover {
|
| 61 |
+
border-color: #667eea;
|
| 62 |
+
background: #e8ebff;
|
| 63 |
+
transform: scale(1.02);
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
.upload-icon {
|
| 67 |
+
font-size: 3em;
|
| 68 |
+
margin-bottom: 15px;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
.upload-text {
|
| 72 |
+
color: #666;
|
| 73 |
+
font-size: 1.1em;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
.upload-text strong {
|
| 77 |
+
color: #667eea;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
#fileInput {
|
| 81 |
+
display: none;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
#previewContainer {
|
| 85 |
+
margin-top: 20px;
|
| 86 |
+
display: none;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
#imagePreview {
|
| 90 |
+
max-width: 100%;
|
| 91 |
+
max-height: 300px;
|
| 92 |
+
border-radius: 10px;
|
| 93 |
+
box-shadow: 0 4px 10px rgba(0,0,0,0.1);
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
.file-info {
|
| 97 |
+
margin-top: 10px;
|
| 98 |
+
color: #666;
|
| 99 |
+
font-size: 0.9em;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
.upload-btn {
|
| 103 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 104 |
+
color: white;
|
| 105 |
+
border: none;
|
| 106 |
+
padding: 15px 50px;
|
| 107 |
+
font-size: 1.1em;
|
| 108 |
+
border-radius: 50px;
|
| 109 |
+
cursor: pointer;
|
| 110 |
+
transition: all 0.3s ease;
|
| 111 |
+
margin-top: 20px;
|
| 112 |
+
font-weight: 600;
|
| 113 |
+
letter-spacing: 0.5px;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
.upload-btn:hover {
|
| 117 |
+
transform: translateY(-2px);
|
| 118 |
+
box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
.upload-btn:disabled {
|
| 122 |
+
opacity: 0.6;
|
| 123 |
+
cursor: not-allowed;
|
| 124 |
+
transform: none;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
.loading {
|
| 128 |
+
display: none;
|
| 129 |
+
margin-top: 20px;
|
| 130 |
+
padding: 15px;
|
| 131 |
+
background: #f0f2ff;
|
| 132 |
+
border-radius: 10px;
|
| 133 |
+
color: #667eea;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
.loading.active {
|
| 137 |
+
display: block;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
.spinner {
|
| 141 |
+
display: inline-block;
|
| 142 |
+
width: 20px;
|
| 143 |
+
height: 20px;
|
| 144 |
+
border: 3px solid #ddd;
|
| 145 |
+
border-radius: 50%;
|
| 146 |
+
border-top-color: #667eea;
|
| 147 |
+
animation: spin 1s ease-in-out infinite;
|
| 148 |
+
margin-right: 10px;
|
| 149 |
+
vertical-align: middle;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
@keyframes spin {
|
| 153 |
+
to { transform: rotate(360deg); }
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
@media (max-width: 600px) {
|
| 157 |
+
.container {
|
| 158 |
+
padding: 30px 20px;
|
| 159 |
+
}
|
| 160 |
+
h1 {
|
| 161 |
+
font-size: 2em;
|
| 162 |
+
}
|
| 163 |
+
}
|
| 164 |
+
</style>
|
| 165 |
+
</head>
|
| 166 |
+
<body>
|
| 167 |
+
<div class="container">
|
| 168 |
+
<h1>๐ OCR Text Extractor</h1>
|
| 169 |
+
<p class="subtitle">Upload an image and extract text from it instantly</p>
|
| 170 |
+
|
| 171 |
+
<form action="/upload" method="POST" enctype="multipart/form-data" id="uploadForm">
|
| 172 |
+
<div class="upload-area" id="dropZone">
|
| 173 |
+
<div class="upload-icon">๐ผ๏ธ</div>
|
| 174 |
+
<div class="upload-text">
|
| 175 |
+
<strong>Click to browse</strong> or drag & drop your image here
|
| 176 |
+
</div>
|
| 177 |
+
<div class="file-info">Supports: JPG, PNG, GIF, BMP</div>
|
| 178 |
+
<input type="file" name="image" id="fileInput" accept="image/*">
|
| 179 |
+
</div>
|
| 180 |
+
|
| 181 |
+
<div id="previewContainer">
|
| 182 |
+
<img id="imagePreview" src="#" alt="Preview">
|
| 183 |
+
<div class="file-info" id="fileName"></div>
|
| 184 |
+
</div>
|
| 185 |
+
|
| 186 |
+
<button type="submit" class="upload-btn" id="submitBtn">Extract Text โจ</button>
|
| 187 |
+
</form>
|
| 188 |
+
|
| 189 |
+
<div class="loading" id="loadingIndicator">
|
| 190 |
+
<span class="spinner"></span>
|
| 191 |
+
Processing your image...
|
| 192 |
+
</div>
|
| 193 |
+
</div>
|
| 194 |
+
|
| 195 |
+
<script>
|
| 196 |
+
const dropZone = document.getElementById('dropZone');
|
| 197 |
+
const fileInput = document.getElementById('fileInput');
|
| 198 |
+
const previewContainer = document.getElementById('previewContainer');
|
| 199 |
+
const imagePreview = document.getElementById('imagePreview');
|
| 200 |
+
const fileName = document.getElementById('fileName');
|
| 201 |
+
const submitBtn = document.getElementById('submitBtn');
|
| 202 |
+
const loadingIndicator = document.getElementById('loadingIndicator');
|
| 203 |
+
const form = document.getElementById('uploadForm');
|
| 204 |
+
|
| 205 |
+
// Click to upload
|
| 206 |
+
dropZone.addEventListener('click', () => {
|
| 207 |
+
fileInput.click();
|
| 208 |
+
});
|
| 209 |
+
|
| 210 |
+
// File selected
|
| 211 |
+
fileInput.addEventListener('change', (e) => {
|
| 212 |
+
handleFile(e.target.files[0]);
|
| 213 |
+
});
|
| 214 |
+
|
| 215 |
+
// Drag and drop
|
| 216 |
+
dropZone.addEventListener('dragover', (e) => {
|
| 217 |
+
e.preventDefault();
|
| 218 |
+
dropZone.classList.add('dragover');
|
| 219 |
+
});
|
| 220 |
+
|
| 221 |
+
dropZone.addEventListener('dragleave', () => {
|
| 222 |
+
dropZone.classList.remove('dragover');
|
| 223 |
+
});
|
| 224 |
+
|
| 225 |
+
dropZone.addEventListener('drop', (e) => {
|
| 226 |
+
e.preventDefault();
|
| 227 |
+
dropZone.classList.remove('dragover');
|
| 228 |
+
const file = e.dataTransfer.files[0];
|
| 229 |
+
handleFile(file);
|
| 230 |
+
fileInput.files = e.dataTransfer.files;
|
| 231 |
+
});
|
| 232 |
+
|
| 233 |
+
function handleFile(file) {
|
| 234 |
+
if (file && file.type.startsWith('image/')) {
|
| 235 |
+
const reader = new FileReader();
|
| 236 |
+
reader.onload = (e) => {
|
| 237 |
+
imagePreview.src = e.target.result;
|
| 238 |
+
previewContainer.style.display = 'block';
|
| 239 |
+
fileName.textContent = `๐ ${file.name} (${(file.size / 1024 / 1024).toFixed(2)} MB)`;
|
| 240 |
+
dropZone.style.display = 'none';
|
| 241 |
+
};
|
| 242 |
+
reader.readAsDataURL(file);
|
| 243 |
+
} else {
|
| 244 |
+
alert('Please upload a valid image file.');
|
| 245 |
+
fileInput.value = '';
|
| 246 |
+
}
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
// Show loading on submit
|
| 250 |
+
form.addEventListener('submit', () => {
|
| 251 |
+
if (fileInput.files.length > 0) {
|
| 252 |
+
submitBtn.disabled = true;
|
| 253 |
+
loadingIndicator.classList.add('active');
|
| 254 |
+
submitBtn.textContent = 'Processing...';
|
| 255 |
+
}
|
| 256 |
+
});
|
| 257 |
+
</script>
|
| 258 |
+
</body>
|
| 259 |
+
</html>
|