/** * GTImageCrop — Renders a cropped region of an image based on a bounding box. * * Used in the Ground Truth labeling UI to show row and column crops * of the current entry being reviewed. */ import type { BBox } from './ground-truth-types' interface GTImageCropProps { imageUrl: string bbox: BBox naturalWidth: number naturalHeight: number maxWidth?: number label?: string } export function GTImageCrop({ imageUrl, bbox, naturalWidth, naturalHeight, maxWidth = 380, label }: GTImageCropProps) { if (!bbox || bbox.w === 0 || bbox.h === 0) return null const cropWPx = (bbox.w / 100) * naturalWidth const cropHPx = (bbox.h / 100) * naturalHeight if (cropWPx < 1 || cropHPx < 1) return null const scale = maxWidth / cropWPx const displayH = cropHPx * scale return (
{label &&
{label}
}
) }