// Eigenschaften des gewählten Bilds auf dem Layout-Blatt ([208]): Lage, Breite (Höhe folgt dem Seitenverhältnis), // Zuschnitt in Prozent je Kante, Auflösung (dpi) und Löschen. Gestaltung wie die übrigen Blatt-HUDs. import type { LayoutImage } from "../model/types"; import { cropImage, imageGeometry, resizeImageWidth } from "../model/layoutImages"; import { t } from "../i18n"; /** dpi, ab denen ein Bild für den Druck knapp wird (Plakate werden aus Distanz betrachtet). */ export const LOW_DPI = 100; type Edge = "left" | "right" | "top" | "bottom"; /** Zuschnitt-Anteile (0..1) → Randabstände je Kante in Prozent. */ function edges(img: LayoutImage): Record { const c = img.crop ?? { x: 0, y: 0, w: 1, h: 1 }; return { left: Math.round(c.x * 1000) / 10, top: Math.round(c.y * 1000) / 10, right: Math.round((1 - c.x - c.w) * 1000) / 10, bottom: Math.round((1 - c.y - c.h) * 1000) / 10, }; } function cropFromEdges(e: Record): LayoutImage["crop"] { const l = Math.min(98, Math.max(0, e.left)) / 100; const t0 = Math.min(98, Math.max(0, e.top)) / 100; const r = Math.min(98 - l * 100, Math.max(0, e.right)) / 100; const b = Math.min(98 - t0 * 100, Math.max(0, e.bottom)) / 100; if (l === 0 && t0 === 0 && r === 0 && b === 0) return undefined; return { x: l, y: t0, w: 1 - l - r, h: 1 - t0 - b }; } export function SheetImageHud({ image, onPatch, onRemove, }: { image: LayoutImage; onPatch: (patch: Partial>) => void; onRemove: () => void; }) { const e = edges(image); const dpi = Math.round(imageGeometry(image).dpi); const num = (v: number, set: (n: number) => void, testId?: string) => ( { const n = parseFloat(ev.target.value); if (Number.isFinite(n)) set(n); }} /> ); return (
{image.name || t("sheetImage.title")}
X / Y mm {num(image.xMm, (xMm) => onPatch({ xMm }), "image-x")} {num(image.yMm, (yMm) => onPatch({ yMm }), "image-y")}
{t("sheetImage.width")} {num(image.widthMm, (w) => onPatch(resizeImageWidth(image, w)), "image-width")}
{Math.round(image.widthMm)} × {Math.round(image.heightMm)} mm · {image.pixelWidth} × {image.pixelHeight} px
0 && dpi < LOW_DPI ? { color: "#b45309" } : undefined}> {dpi > 0 ? t("sheetImage.dpi", { dpi }) : ""} {dpi > 0 && dpi < LOW_DPI ? ` · ${t("sheetImage.lowDpi")}` : ""}
{t("sheetImage.crop")}
{(["left", "right", "top", "bottom"] as Edge[]).map((k) => (
{t(`sheetImage.crop.${k}`)} {num(e[k], (v) => onPatch(cropImage(image, cropFromEdges({ ...e, [k]: v }))), `image-crop-${k}`)}%
))}
{image.crop && ( )}
); }