mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user