diff --git a/docs/Luminary-User-Guide.pdf b/docs/Luminary-User-Guide.pdf index 56bea09..4e379c6 100644 Binary files a/docs/Luminary-User-Guide.pdf and b/docs/Luminary-User-Guide.pdf differ diff --git a/docs/user-guide/guide.html b/docs/user-guide/guide.html index 6a15b48..5930aa3 100644 --- a/docs/user-guide/guide.html +++ b/docs/user-guide/guide.html @@ -224,7 +224,7 @@
@@ -306,7 +306,7 @@ BrowserA current Chromium (Chrome, Edge), Firefox or Safari with WebGL 2. Hardware acceleration is strongly recommended: previews, thumbnails and exports all render on the GPU. Display1280 × 800 minimum. The layout is built for a laptop and expands to fill a desktop screen. - Server (optional)Node 22.5+ or Docker, for raw decoding, shared storage, accounts and proofing links. JPEG/PNG/TIFF work without it. + Server (optional)Node 22.5+ or Docker, for raw and TIFF decoding, shared storage, accounts and proofing links. JPEG, PNG, WebP and AVIF work without it. Windows app (optional)Windows 10 or 11, 64-bit. Nothing else: Node, .NET and the VC++ runtime are bundled or not needed. @@ -452,7 +452,8 @@ - + +
TypeBehaviour
JPEG, PNG, WebP, AVIF, TIFFDecoded in the browser. EXIF camera, lens, ISO, aperture, shutter and focal length are read when present.
JPEG, PNG, WebP, AVIFDecoded in the browser. EXIF camera, lens, ISO, aperture, shutter and focal length are read when present.
TIFF (.tif, .tiff)Decoded on the server into an editable JPEG proxy, because browsers have no TIFF decoder. The original TIFF is stored untouched and the full-resolution proxy drives the editor and export.
Camera raw — CR2, CR3, NEF, ARW, ORF, RW2, RAF, DNG, PEF, SRW, 3FR and 20 moreSent to the server, demosaiced with LibRaw, stored as the original plus an editable JPEG proxy and a 16-bit sidecar.
@@ -1176,6 +1177,7 @@
  • No plugin ecosystem. Edits live in the catalogue record and XMP sidecars, not in third-party plugins.
  • Colour management is per export. Choose sRGB, Display P3 or Adobe RGB in the export dialog; the soft-proof panel handles printer gamut.
  • Browser storage is finite. Large raw catalogues belong on the server; the browser copy is a working cache.
  • +
  • TIFF is edited through a proxy. TIFF has no browser decoder, so the server writes a JPEG proxy capped at RAW_EDGE (6000 px by default); the original TIFF is stored unchanged for fidelity and re-proxying.
  • Unsigned Windows build. SmartScreen warns on first run; sign the executable if you distribute it widely.
  • @@ -1199,7 +1201,7 @@ PNG (.png)Browser WebP (.webp)Browser AVIF (.avif)Browser - TIFF (.tif, .tiff)Browser + TIFF (.tif, .tiff)Server (sharp JPEG proxy; browsers cannot decode TIFF) Camera raw: CR2, CR3, CRW, NEF, NRW, ARW, SRF, SR2, ORF, RW2, RWL, RAF, PEF, DNG, SRW, 3FR, FFF, IIQ, X3F, ERF, K25, KDC, DCR, MOS, MRW, MEFServer (LibRaw) diff --git a/public/luminary-user-guide.pdf b/public/luminary-user-guide.pdf index 56bea09..4e379c6 100644 Binary files a/public/luminary-user-guide.pdf and b/public/luminary-user-guide.pdf differ diff --git a/server/index.mjs b/server/index.mjs index 135ba97..5ff7a26 100644 --- a/server/index.mjs +++ b/server/index.mjs @@ -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, diff --git a/server/raw.mjs b/server/raw.mjs index 9da351f..dc338e7 100644 --- a/server/raw.mjs +++ b/server/raw.mjs @@ -28,6 +28,26 @@ export function isRawName(name = '') { return RAW_EXTENSIONS.has(ext); } +/** + * Standard images that browsers cannot decode. TIFF takes the raw upload path + * (store the original, serve a JPEG proxy) but is decoded by sharp, not LibRaw. + */ +export const SERVER_IMAGE_EXTENSIONS = new Set(['tif', 'tiff']); + +export function isStillName(name = '') { + const ext = name.split('.').pop()?.toLowerCase() ?? ''; + return SERVER_IMAGE_EXTENSIONS.has(ext); +} + +/** Rejects instead of waiting forever when a decoder wedges on one file. */ +function withTimeout(promise, ms, message) { + let timer; + const guard = new Promise((_, reject) => { + timer = setTimeout(() => reject(new Error(message)), ms); + }); + return Promise.race([promise, guard]).finally(() => clearTimeout(timer)); +} + /** True when the buffer starts with a container signature LibRaw can open. */ export function looksLikeRaw(buffer) { if (!buffer || buffer.length < 64) return false; @@ -45,6 +65,19 @@ export function looksLikeRaw(buffer) { let engineState = 'unloaded'; +export async function decodeStill(buffer) { + const proxy = await toJpegProxy(buffer, RAW_PREVIEW_EDGE); + if (!proxy) throw new Error('Could not decode this image'); + const size = await jpegInfo(proxy.data); + return { + jpeg: proxy.data, + width: size?.width || proxy.width, + height: size?.height || proxy.height, + engine: 'sharp', + ext: proxy.ext, + }; +} + export async function rawEngine() { if (engineState === 'unloaded') { try { @@ -187,10 +220,14 @@ export function extractEmbeddedJpeg(buffer) { async function embeddedPreview(buffer) { if ((await rawEngine()) === 'ready') { try { - const thumb = await rawPool.use(async (lib) => { - await lib.open(Buffer.from(buffer), { useCameraWb: true }); - return lib.thumbnailData(); - }); + const thumb = await withTimeout( + rawPool.use(async (lib) => { + await lib.open(Buffer.from(buffer), { useCameraWb: true }); + return lib.thumbnailData(); + }), + 12000, + 'LibRaw preview timed out', + ); if (thumb?.data && thumb.format === 'jpeg' && thumb.data.length > 4096) { return Buffer.from(thumb.data); } @@ -209,10 +246,10 @@ export async function decodeRaw(buffer) { let librawError = null; if (looksLikeRaw(buffer)) { try { - let frame = await demosaic(buffer, true); + let frame = await withTimeout(demosaic(buffer, true), 45000, 'LibRaw timed out on this file'); // No usable matrix (an odd body or older engine): decode the familiar sRGB // way instead of shipping camera samples nobody can convert. - if (!frame.rgbCam || !frame.rgb16) frame = await demosaic(buffer, false); + if (!frame.rgbCam || !frame.rgb16) frame = await withTimeout(demosaic(buffer, false), 45000, 'LibRaw timed out on this file'); const { width, height, rgbCam } = frame; // Both buffers are rewritten in place: `rgb` becomes the sRGB proxy and // `rgb16` the camera-native sidecar, sharing one white point. diff --git a/src/components/Panels.tsx b/src/components/Panels.tsx index 0504aa7..f061fed 100644 --- a/src/components/Panels.tsx +++ b/src/components/Panels.tsx @@ -1481,7 +1481,13 @@ export function NavigatorPanel({ {photo.name}
    - {photo.raw ? (photo.decode === 'embedded' ? 'Raw · camera preview' : 'Raw · demosaiced') : 'JPEG/PNG'}{' '} + {photo.raw + ? photo.decode === 'embedded' + ? 'Raw · camera preview' + : 'Raw · demosaiced' + : photo.decode === 'sharp' + ? 'TIFF · server JPEG' + : 'JPEG/PNG'}{' '} · {photo.width}×{photo.height}
    diff --git a/src/lib/api.ts b/src/lib/api.ts index 62bef57..bc99958 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -23,7 +23,7 @@ export interface SessionUser { export interface UploadResult { raw: boolean; - engine?: 'libraw' | 'embedded'; + engine?: 'libraw' | 'embedded' | 'sharp'; width?: number; height?: number; mime?: string; @@ -153,7 +153,7 @@ export function reprocessRawPhoto( ): Promise<{ width: number; height: number; - engine?: 'libraw' | 'embedded'; + engine?: 'libraw' | 'embedded' | 'sharp'; note?: string | null; previewVersion?: number; previewUrl?: string; diff --git a/src/lib/images.ts b/src/lib/images.ts index 78c59f0..8692600 100644 --- a/src/lib/images.ts +++ b/src/lib/images.ts @@ -7,7 +7,11 @@ const cache = new Map(); /** Where to fetch the original (or raw proxy) when it is not cached on this device. */ export function remoteAssetUrl(photo: PhotoRecord): string { - if (photo.raw) return photo.previewUrl || `/api/photos/${encodeURIComponent(photo.id)}/preview`; + // Server-decoded formats (TIFF today) keep a browser-readable JPEG proxy just + // like raws; their original cannot be decoded by createImageBitmap. + if (photo.raw || photo.decode === 'sharp') { + return photo.previewUrl || `/api/photos/${encodeURIComponent(photo.id)}/preview`; + } return `/api/photos/${encodeURIComponent(photo.id)}/original`; } diff --git a/src/lib/import.ts b/src/lib/import.ts index 7348b16..5a874f0 100644 --- a/src/lib/import.ts +++ b/src/lib/import.ts @@ -4,7 +4,7 @@ import type { PhotoMeta, PhotoRecord } from '../types'; import { putAsset, putPhoto } from './db'; import { defaultEdits, normalizePhoto } from './edits'; import { defaultForMeta, loadCameraLensDefaults, type CameraLensDefault } from './lensDefaults'; -import { isRawFile, RAW_EXTENSIONS } from './raw'; +import { isRawFile, isTiffFile, RAW_EXTENSIONS } from './raw'; export interface ImportProgress { done: number; @@ -125,6 +125,8 @@ async function importRaw( keywords: string[], cloud: CloudImport, defaults: CameraLensDefault[], + /** TIFF goes through the same proxy path but is not a raw container. */ + raw = true, ): Promise { const id = uid(); const upload = await cloud.uploadOriginal(id, file, file.name); @@ -158,7 +160,7 @@ async function importRaw( keywords, edits, history: [{ label: 'Import', ts: Date.now(), edits }], - raw: true, + raw, decode: upload.engine, previewUrl, }); @@ -242,9 +244,10 @@ export async function importFiles( await mapLimit(images, cloud ? IMPORT_CONCURRENCY : 2, async (file, index) => { if (signal?.aborted) return; try { - const photo = isRawFile(file) + const viaServer = isRawFile(file) || isTiffFile(file); + const photo = viaServer ? cloud - ? await importRaw(file, eventId, keywords, cloud, defaults) + ? await importRaw(file, eventId, keywords, cloud, defaults, isRawFile(file)) : (() => { throw new Error('Raw files need the Luminary server. Sign in, then import again.'); })() diff --git a/src/lib/raw.ts b/src/lib/raw.ts index 1722622..7db90dd 100644 --- a/src/lib/raw.ts +++ b/src/lib/raw.ts @@ -7,12 +7,27 @@ export const RAW_EXTENSIONS = new Set([ 'rw2', 'raw', 'rwl', 'raf', 'pef', 'dng', - 'srw', '3fr', 'fff', 'iiq', 'x3f', 'erf', 'k25', 'kdc', 'dcr', 'mos', 'mrw', 'mef', + 'srw', '3fr', 'fff', 'iiq', 'x3f', 'erf', 'k25', 'kdc', 'dcr', 'mos', 'mrw', 'mef', 'sraw', ]); +/** + * Standard images the browser cannot decode itself. They take the same server + * path as raws: the original is stored and the server writes a JPEG proxy. + * Chrome and Firefox have no TIFF decoder, so a TIFF left to the browser is a + * silent import failure. + */ +export const SERVER_IMAGE_EXTENSIONS = new Set(['tif', 'tiff']); + +export function isTiffFile(file: File): boolean { + const ext = file.name.split('.').pop()?.toLowerCase() ?? ''; + return SERVER_IMAGE_EXTENSIONS.has(ext); +} + export function isRawFile(file: File): boolean { const ext = file.name.split('.').pop()?.toLowerCase() ?? ''; return RAW_EXTENSIONS.has(ext); } -export const RAW_ACCEPT = [...RAW_EXTENSIONS].map((e) => `.${e}`).join(','); +export const RAW_ACCEPT = [...RAW_EXTENSIONS, ...SERVER_IMAGE_EXTENSIONS] + .map((e) => `.${e}`) + .join(','); diff --git a/src/types.ts b/src/types.ts index 7d2c1e1..227f15d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -320,7 +320,7 @@ export interface PhotoRecord { /** true when the original is a camera raw decoded by the server */ raw?: boolean; /** how the editable proxy was produced */ - decode?: 'libraw' | 'embedded'; + decode?: 'libraw' | 'embedded' | 'sharp'; /** server URL for the editable proxy (raw only) */ previewUrl?: string; /** server URL for the grid thumbnail */