fix: show real image dimensions in right pane for DNG/RAW files

The preview endpoint now returns X-Original-Width/Height headers with
dimensions read from Sharp metadata (or ExifTool for RAW files). The
frontend stores these in FileEntry and the ImageViewer prefers them over
the browser's naturalWidth/naturalHeight, which reflects the resized
preview rather than the original sensor dimensions.
This commit is contained in:
SnapOtter
2026-05-12 22:13:58 +08:00
parent 8c1526559b
commit 2d17fd4903
7 changed files with 105 additions and 14 deletions
+16 -2
View File
@@ -65,7 +65,13 @@ export function needsServerPreview(file: File): boolean {
return SERVER_PREVIEW_EXTENSIONS.has(ext);
}
export async function fetchDecodedPreview(file: File): Promise<string | null> {
export interface DecodedPreview {
url: string;
originalWidth: number | null;
originalHeight: number | null;
}
export async function fetchDecodedPreview(file: File): Promise<DecodedPreview | null> {
try {
const formData = new FormData();
formData.append("file", file);
@@ -75,8 +81,16 @@ export async function fetchDecodedPreview(file: File): Promise<string | null> {
body: formData,
});
if (!res.ok) return null;
const w = Number(res.headers.get("X-Original-Width"));
const h = Number(res.headers.get("X-Original-Height"));
const blob = await res.blob();
return URL.createObjectURL(blob);
return {
url: URL.createObjectURL(blob),
originalWidth: w > 0 ? w : null,
originalHeight: h > 0 ? h : null,
};
} catch {
return null;
}