(image: File)
| 34 | * This validates the image can be read and prepares it for display |
| 35 | */ |
| 36 | const processImage = async (image: File): Promise<void> => |
| 37 | new Promise((resolve, reject) => { |
| 38 | const reader = new FileReader(); |
| 39 | |
| 40 | reader.onload = () => { |
| 41 | // Image has been read and is ready for display |
| 42 | resolve(); |
| 43 | }; |
| 44 | |
| 45 | reader.onerror = () => { |
| 46 | reject(new Error(`Failed to read image: ${image.name}`)); |
| 47 | }; |
| 48 | |
| 49 | reader.onabort = () => { |
| 50 | reject(new Error(`Image reading was aborted: ${image.name}`)); |
| 51 | }; |
| 52 | |
| 53 | // Read the image as data URL - this takes time for large images |
| 54 | reader.readAsDataURL(image); |
| 55 | }); |
| 56 | |
| 57 | /** |
| 58 | * Process multiple files concurrently with individual error handling |
no test coverage detected