Add support for EXR and HDR image formats

This commit is contained in:
2026-03-31 23:03:50 +02:00
parent 6c27ed9ecf
commit d061aa3021

View File

@@ -51,8 +51,12 @@ function inferImageMimeType(sourceName: string, fallbackMimeType: string): strin
switch (getFileExtension(sourceName)) {
case "avif":
return "image/avif";
case "exr":
return "image/x-exr";
case "gif":
return "image/gif";
case "hdr":
return "image/vnd.radiance";
case "jpg":
case "jpeg":
return "image/jpeg";
@@ -63,10 +67,15 @@ function inferImageMimeType(sourceName: string, fallbackMimeType: string): strin
case "webp":
return "image/webp";
default:
throw new Error(`Unsupported image asset format for ${sourceName}. Use a browser-supported image file.`);
throw new Error(`Unsupported image asset format for ${sourceName}. Use a browser-supported image file or .exr/.hdr.`);
}
}
function isHdrFormat(sourceName: string): boolean {
const ext = getFileExtension(sourceName);
return ext === "exr" || ext === "hdr";
}
function getImportedFilePath(file: File): string {
const relativePath = typeof file.webkitRelativePath === "string" ? file.webkitRelativePath.trim() : "";
const sourcePath = relativePath.length > 0 ? relativePath : file.name.trim();