- Admin "Híres emberek": birth data, one photo (S3: DigitalOcean Spaces in production, RustFS in development), a face point that every crop keeps in view, publishing, and a detailed portrait written with its own `celebrity` prompt (third person, by name, from the chart alone). - The photo is stored once (upright JPEG, at most 2000 px, no metadata); next/image makes the sizes from it, so Cloudflare can cache those. - Public list and pages (/hires-emberek), in the sitemap, with a share image showing the face and the chart. - Share images: the wheel's glyphs and numbers are drawn with the card's fonts (inside the SVG image they came out as boxes, on every card). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
37 lines
1.6 KiB
TypeScript
37 lines
1.6 KiB
TypeScript
// A famous person's photo: one stored version, served by the backend through
|
||
// the /api/v1 proxy; next/image makes the sized versions from it (and
|
||
// Cloudflare caches those), so no sizes are stored.
|
||
import type { CelebrityPhoto } from "./types";
|
||
|
||
/** The stored photo's address on this site (also the source of next/image). */
|
||
export function photoSrc(photo: Pick<CelebrityPhoto, "key">): string {
|
||
return `/api/v1/public/photos/${photo.key.split("/").map(encodeURIComponent).join("/")}`;
|
||
}
|
||
|
||
/** CSS `object-position` that keeps the face point in view when the photo is cropped. */
|
||
export function objectPosition(photo: Pick<CelebrityPhoto, "focus_x" | "focus_y">): string {
|
||
return `${(photo.focus_x * 100).toFixed(1)}% ${(photo.focus_y * 100).toFixed(1)}%`;
|
||
}
|
||
|
||
/**
|
||
* Where a `width`×`height` photo goes in a `boxW`×`boxH` frame so that it
|
||
* covers it with the face point as near the middle as the edges allow (for
|
||
* the preview image, whose renderer has no object-position).
|
||
*/
|
||
export function coverBox(
|
||
photo: Pick<CelebrityPhoto, "width" | "height" | "focus_x" | "focus_y">,
|
||
boxW: number,
|
||
boxH: number,
|
||
): { width: number; height: number; left: number; top: number } {
|
||
const scale = Math.max(boxW / photo.width, boxH / photo.height);
|
||
const width = Math.ceil(photo.width * scale);
|
||
const height = Math.ceil(photo.height * scale);
|
||
const clamp = (v: number, min: number) => Math.round(Math.min(0, Math.max(min, v)));
|
||
return {
|
||
width,
|
||
height,
|
||
left: clamp(boxW / 2 - photo.focus_x * width, boxW - width),
|
||
top: clamp(boxH / 2 - photo.focus_y * height, boxH - height),
|
||
};
|
||
}
|