Files
hyperframes/packages/studio-server/src/helpers/thumbnailOutput.ts
T
Miguel ÁngelandCodex 96861cbafc perf(studio-server): coordinate cancelable thumbnail generation (#2720)
* perf(studio): schedule adaptive timeline thumbnails

* perf(studio): bound thumbnail decoding resources

* perf(studio): virtualize timeline thumbnail media

* perf(studio): prioritize timeline thumbnail work

* perf(studio-server): coordinate cancelable thumbnail generation

---------

Co-authored-by: Codex <codex@local>
2026-08-05 20:41:35 -07:00

21 lines
646 B
TypeScript

export interface ThumbnailOutputDimensions {
width: number;
height: number;
outputWidth: number;
outputHeight: number;
}
/** Sole adapter rule for capturing authored layout at bounded physical dimensions. */
export function thumbnailDeviceScaleFactor({
width,
height,
outputWidth,
outputHeight,
}: ThumbnailOutputDimensions): number {
const dimensions = [width, height, outputWidth, outputHeight];
if (dimensions.some((value) => !Number.isFinite(value) || value <= 0)) {
throw new RangeError("Thumbnail dimensions must be positive finite numbers");
}
return Math.min(1, outputWidth / width, outputHeight / height);
}