From 7e427830963f4a516f38ea4aad5ea53d2787abe2 Mon Sep 17 00:00:00 2001 From: lex Date: Wed, 27 May 2026 10:37:26 +0900 Subject: [PATCH 1/2] fix: add JPEG preview fallback when raw.imageData() returns empty result When LibRaw's dcraw_make_mem_image() returns NULL (e.g., for unsupported compression variants on recognized cameras like Nikon Z f), the result object is empty/undefined. Previously this fell through to a destructure TypeError and a generic "Error loading file". Now it triggers the embedded JPEG preview fallback, allowing the image to load at 8-bit precision. Co-Authored-By: Claude Opus 4.7 --- negative2positive/src/app/rawFileLoader.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/negative2positive/src/app/rawFileLoader.js b/negative2positive/src/app/rawFileLoader.js index 05256f7..9d3990b 100644 --- a/negative2positive/src/app/rawFileLoader.js +++ b/negative2positive/src/app/rawFileLoader.js @@ -237,6 +237,10 @@ export async function loadRawFile(buffer, fileName, options = {}) { } throw err; } + if (!result || !result.data) { + console.error('[RAW] imageData returned empty result', result); + return await handleTimeoutFallback(); + } const { width, height, data: rgbData } = result; const pixelCount = width * height; From 7446a3c4f9dad0640715bcd728da9ac7b5578dbf Mon Sep 17 00:00:00 2001 From: lex Date: Wed, 27 May 2026 10:47:08 +0900 Subject: [PATCH 2/2] fix: use forked libraw-wasm for Nikon Z f and newer camera support Switch from npm registry package to GitHub fork. Why: The npm package libraw-wasm@1.1.2 bundles a WASM binary compiled from an older LibRaw version that does not support cameras released after ~2022, including Nikon Z f, Z8, Z6-III, and others. This causes NEF files from these cameras to fail with a generic error. Our fork (lexluthor0304/LibRaw-Wasm) rebuilds with LibRaw 0.22.1 which recognizes these cameras. A PR has been submitted upstream: https://github.com/ybouane/LibRaw-Wasm/pull/15 How to switch back: When the upstream PR is merged and a new npm version is released, revert this commit and run: npm install libraw-wasm@latest See also: fix in rawFileLoader.js that adds JPEG preview fallback when raw.imageData() returns empty, providing a graceful degradation path. Co-Authored-By: Claude Opus 4.7 --- package-lock.json | 7 +++---- package.json | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index bdece8c..2a92917 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "@techstark/opencv-js": "4.12.0-release.1", "@vercel/analytics": "^2.0.1", "jszip": "3.10.1", - "libraw-wasm": "^1.1.2", + "libraw-wasm": "github:lexluthor0304/LibRaw-Wasm", "pako": "2.1.0", "three": "^0.183.2", "upng-js": "2.1.0", @@ -1533,9 +1533,8 @@ "license": "(MIT AND Zlib)" }, "node_modules/libraw-wasm": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/libraw-wasm/-/libraw-wasm-1.1.2.tgz", - "integrity": "sha512-lOVdqbzCkvsLtMoTz41Pc3alQptWHCyD71jGBTnQmoNK5CTVayXGqtTSBntLil7YaO3h/yESx7e9jMskMtnOEQ==", + "version": "1.2.0", + "resolved": "git+ssh://git@github.com/lexluthor0304/LibRaw-Wasm.git#c17e6ffa83f176497f07a90e740fca495ce0eca3", "license": "ISC" }, "node_modules/lie": { diff --git a/package.json b/package.json index 56f638f..cb9d5a4 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "@techstark/opencv-js": "4.12.0-release.1", "@vercel/analytics": "^2.0.1", "jszip": "3.10.1", - "libraw-wasm": "^1.1.2", + "libraw-wasm": "github:lexluthor0304/LibRaw-Wasm", "pako": "2.1.0", "three": "^0.183.2", "upng-js": "2.1.0",