Files
Reactive-Resume/apps/web/src/routes/dashboard/resumes/-components/cards/resume-thumbnail.shared.ts
T
Amruth Pillai 50ba37a27f v5.1.0 (#2970)
* chore(release): v5.1.0

* feat: implement resume thumbnails

* fix: remove unused mcp tools

* docs: fix formatting of docs
2026-05-07 15:12:33 +02:00

27 lines
710 B
TypeScript

type PageSize = {
height: number;
width: number;
};
export const RESUME_THUMBNAIL_TARGET_WIDTH = 420;
const MAX_THUMBNAIL_PIXEL_RATIO = 2;
export const getResumeThumbnailCacheKey = (resumeId: string, updatedAt: Date) => {
return `${resumeId}:${updatedAt.getTime()}`;
};
export const getResumeThumbnailRenderSize = (
pageSize: PageSize,
targetWidth = RESUME_THUMBNAIL_TARGET_WIDTH,
pixelRatio = 1,
) => {
const outputScale = Math.min(Math.max(pixelRatio, 1), MAX_THUMBNAIL_PIXEL_RATIO);
const pageScale = targetWidth / pageSize.width;
return {
height: Math.round(pageSize.height * pageScale * outputScale),
scale: pageScale * outputScale,
width: Math.round(targetWidth * outputScale),
};
};