The File or Blob to convert to an image
Promise that resolves to an HTMLImageElement
When image loading fails (invalid format, corrupted data, etc.)
// Convert file input to image
const fileInput = document.getElementById('file') as HTMLInputElement;
const file = fileInput.files[0];
const image = await fileToImage(file);
// Convert blob to image
const response = await fetch('image.jpg');
const blob = await response.blob();
const image = await fileToImage(blob);
Convert File or Blob to HTMLImageElement.
Creates an object URL from the file/blob and loads it as an image. The object URL is automatically cleaned up after loading.