Import TIFF through the server and survive a wedged raw decoder

Browsers have no TIFF decoder, so TIFF import failed at createImageBitmap
and the develop canvas asked for the undecodable original. TIFF now takes
the raw proxy path (original stored, sharp writes the JPEG proxy) and the
editor reads that proxy. LibRaw demosaic and preview calls are bounded so
one bad file falls back to the embedded preview instead of hanging.
This commit is contained in:
2026-11-28 20:49:25 +00:00
parent 8aafdcfb16
commit 27360ffae7
11 changed files with 96 additions and 25 deletions
+8 -4
View File
@@ -80,7 +80,7 @@ import {
writeThumb16,
} from './storage.mjs';
import { previewRebuildTargets, startPreviewRebuild } from './previewRebuild.mjs';
import { decodeRaw, isRawName, rawSupport } from './raw.mjs';
import { decodeRaw, decodeStill, isRawName, isStillName, rawSupport } from './raw.mjs';
import {
bridgeConfigured,
bridgeForEvent,
@@ -2080,7 +2080,10 @@ route('POST', '/api/photos/:id/original', async ({ req, res, params }) => {
const drop = url.searchParams.get('drop') === '1';
const mime = normalizePhotoMime(url.searchParams.get('mime') || '', name);
const ext = (name.split('.').pop() || 'bin').toLowerCase();
const raw = isRawName(name) || drop;
// TIFF is not a raw container, but browsers cannot decode it either. It takes
// the same upload path and is turned into a JPEG proxy here with sharp.
const still = isStillName(name);
const raw = isRawName(name) || drop || still;
// New ids are part of the normal import flow: the client uploads bytes first
// and PUTs the record afterwards. Until that row exists the bytes are charged
@@ -2148,7 +2151,7 @@ route('POST', '/api/photos/:id/original', async ({ req, res, params }) => {
if (raw) {
try {
const data = await fsp.readFile(target);
const decoded = await decodeRaw(data);
const decoded = still ? await decodeStill(data) : await decodeRaw(data);
await writePreview(params.id, decoded.jpeg, decoded.ext);
if (decoded.preview16) {
await writePreview16(params.id, decoded.preview16.data);
@@ -2161,7 +2164,8 @@ route('POST', '/api/photos/:id/original', async ({ req, res, params }) => {
}
const info = await jpegInfo(decoded.jpeg);
return json(res, 201, {
raw: true,
raw: isRawName(name) || drop,
serverDecoded: still,
engine: decoded.engine,
width: info?.width || decoded.width,
height: info?.height || decoded.height,