mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
* feat(find-duplicates): upgrade to 128-bit dHash with metadata and thumbnails * feat(find-duplicates): add custom-results display mode and duplicate store * feat(find-duplicates): add results overview grid and detail comparison view * feat(find-duplicates): overhaul settings with sensitivity presets and download actions * feat(find-duplicates): update i18n description * chore: replace jsqr with zxing-wasm for barcode reading * feat(barcode-read): rewrite backend with zxing-wasm for all barcode types * feat(barcode-read): rewrite frontend with multi-file, results table, progress, export - Multi-file sequential processing with per-file progress - Structured results table with type badges and copy per-result - Copy All and Export CSV functionality - Thorough scan toggle (maps to tryHarder in zxing-wasm) - Before/after view shows annotated image with bounding boxes - Updated tool description in constants and i18n * feat(stitch): update tool name and description for redesign * feat(stitch): add grid layout, alignment, border, radius, quality, and new resize modes * feat(stitch): redesign settings UI with grid, alignment, border, radius, quality * test(stitch): add stitch to e2e tool navigation suite * feat(vectorize): redesign with dual-engine backend and preset-driven UI - Backend: potrace for B&W, VTracer (@neplex/vectorizer) for full-color vectorization - Frontend: 5 presets (logo, illustration, photo, sketch, custom) - Settings: color precision, gradient step, detail, smoothing, corner threshold, invert - Updated OpenAPI spec and i18n description * feat(border): redesign with presets, shadow, padding color, swatches - Add 8 one-click presets (Clean White, Gallery Black, Shadow, Rounded, Polaroid, Vintage, Minimal, Cinematic) - Implement proper shadow rendering with blur, offset X/Y, color, opacity - Add padding color control (was hardcoded white) - Add color swatches for quick color selection - Wrap in form for Enter key submission - Add smart validation (requires at least one effect active) - Align frontend/backend slider ranges - Organize UI with sections and collapsible shadow toggle * feat(split): overhaul image splitting with live grid overlay and tile preview - Add interactive-split display mode with SplitCanvas component - Live SVG grid overlay on uploaded image showing split boundaries - Two split modes: Grid (NxM) and Tile Size (px dimensions) - 9 grid presets (2x1, 1x2, 2x2, 3x1, 1x3, 3x3, 2x3, 3x2, 4x4) - Output format selection (original/PNG/JPG/WebP) with quality slider - Post-split tile preview thumbnails with individual download - Download All as ZIP button - HEIC/HEIF preview with loading spinner - Backend: tile-size mode, output format conversion, quality control - Zustand store for split state management * feat(split): rewrite backend and frontend settings Backend: tile-size mode, output format conversion, quality control. Frontend: split modes, presets, format selector, tile preview grid. * feat(border): add live CSS preview and remove before/after slider - Add imageWrapperStyle prop to ImageViewer for live border preview - Add onImageStyle callback through tool-page to settings components - Change border displayMode to no-comparison (no slider) - BorderControls sends live CSS styles (border, padding, radius, shadow) - Preview updates instantly as user adjusts sliders or clicks presets * fix: repair i18n file corrupted by formatter during merge conflict resolution * feat(border): enable live CSS preview in right pane as settings change * fix(border): keep CSS preview visible after processing for WYSIWYG consistency * chore(gif-tools): scaffold for SOTA upgrade - Add animated GIF test fixture (3 frames, 100x100) - Update tool description to reflect new capabilities - Add fflate dependency to API for ZIP creation * feat(gif-tools): rewrite backend with 6 processing modes Modes: resize (with percentage), optimize (colors/dither/effort), speed (delay manipulation), reverse (frame reorder), extract (single/range/all with ZIP), rotate (90/180/270 + flip). Adds /api/v1/tools/gif-tools/info metadata endpoint. * test(gif-tools): add integration tests for all 6 modes Tests metadata endpoint, resize (pixel + percentage), optimize, speed, reverse, extract (single/range/all), and rotate (angle + flip). Fix animated.gif fixture to be a real 3-frame animation (was a single 100x300 frame). Fix reverse and rotate modes to process frames individually and reassemble via GIF binary concatenation, since Sharp 0.33.x loses page-height metadata when reconstructing from raw pixel data. * feat(gif-tools): rewrite frontend with tabbed 6-mode UI - useGifInfo hook for metadata (frame count, dimensions, duration) - Info bar showing GIF properties - 3x2 mode grid: Resize, Optimize, Speed, Reverse, Extract, Rotate - Animation modes disabled for static images - Loop control (infinite/once/custom) - Batch processing support * test(gif-tools): add to representative tools in e2e suite --------- Co-authored-by: Siddharth Kumar Sah <siddharth123sk@gmail.com>
362 lines
10 KiB
TypeScript
362 lines
10 KiB
TypeScript
export interface CollageCell {
|
|
gridColumn: string;
|
|
gridRow: string;
|
|
}
|
|
|
|
export interface CollageTemplate {
|
|
id: string;
|
|
imageCount: number;
|
|
label: string;
|
|
gridTemplateColumns: string;
|
|
gridTemplateRows: string;
|
|
cells: CollageCell[];
|
|
}
|
|
|
|
export const COLLAGE_TEMPLATES: CollageTemplate[] = [
|
|
// ── 2 images ──────────────────────────────────────────────────────
|
|
{
|
|
id: "2-h-equal",
|
|
imageCount: 2,
|
|
label: "Side by side",
|
|
gridTemplateColumns: "1fr 1fr",
|
|
gridTemplateRows: "1fr",
|
|
cells: [
|
|
{ gridColumn: "1", gridRow: "1" },
|
|
{ gridColumn: "2", gridRow: "1" },
|
|
],
|
|
},
|
|
{
|
|
id: "2-v-equal",
|
|
imageCount: 2,
|
|
label: "Stacked",
|
|
gridTemplateColumns: "1fr",
|
|
gridTemplateRows: "1fr 1fr",
|
|
cells: [
|
|
{ gridColumn: "1", gridRow: "1" },
|
|
{ gridColumn: "1", gridRow: "2" },
|
|
],
|
|
},
|
|
{
|
|
id: "2-h-left-large",
|
|
imageCount: 2,
|
|
label: "Left large",
|
|
gridTemplateColumns: "2fr 1fr",
|
|
gridTemplateRows: "1fr",
|
|
cells: [
|
|
{ gridColumn: "1", gridRow: "1" },
|
|
{ gridColumn: "2", gridRow: "1" },
|
|
],
|
|
},
|
|
{
|
|
id: "2-h-right-large",
|
|
imageCount: 2,
|
|
label: "Right large",
|
|
gridTemplateColumns: "1fr 2fr",
|
|
gridTemplateRows: "1fr",
|
|
cells: [
|
|
{ gridColumn: "1", gridRow: "1" },
|
|
{ gridColumn: "2", gridRow: "1" },
|
|
],
|
|
},
|
|
|
|
// ── 3 images ──────────────────────────────────────────────────────
|
|
{
|
|
id: "3-left-large",
|
|
imageCount: 3,
|
|
label: "Left large",
|
|
gridTemplateColumns: "2fr 1fr",
|
|
gridTemplateRows: "1fr 1fr",
|
|
cells: [
|
|
{ gridColumn: "1", gridRow: "1 / 3" },
|
|
{ gridColumn: "2", gridRow: "1" },
|
|
{ gridColumn: "2", gridRow: "2" },
|
|
],
|
|
},
|
|
{
|
|
id: "3-right-large",
|
|
imageCount: 3,
|
|
label: "Right large",
|
|
gridTemplateColumns: "1fr 2fr",
|
|
gridTemplateRows: "1fr 1fr",
|
|
cells: [
|
|
{ gridColumn: "1", gridRow: "1" },
|
|
{ gridColumn: "1", gridRow: "2" },
|
|
{ gridColumn: "2", gridRow: "1 / 3" },
|
|
],
|
|
},
|
|
{
|
|
id: "3-top-large",
|
|
imageCount: 3,
|
|
label: "Top large",
|
|
gridTemplateColumns: "1fr 1fr",
|
|
gridTemplateRows: "2fr 1fr",
|
|
cells: [
|
|
{ gridColumn: "1 / 3", gridRow: "1" },
|
|
{ gridColumn: "1", gridRow: "2" },
|
|
{ gridColumn: "2", gridRow: "2" },
|
|
],
|
|
},
|
|
{
|
|
id: "3-h-equal",
|
|
imageCount: 3,
|
|
label: "Three columns",
|
|
gridTemplateColumns: "1fr 1fr 1fr",
|
|
gridTemplateRows: "1fr",
|
|
cells: [
|
|
{ gridColumn: "1", gridRow: "1" },
|
|
{ gridColumn: "2", gridRow: "1" },
|
|
{ gridColumn: "3", gridRow: "1" },
|
|
],
|
|
},
|
|
{
|
|
id: "3-v-equal",
|
|
imageCount: 3,
|
|
label: "Three rows",
|
|
gridTemplateColumns: "1fr",
|
|
gridTemplateRows: "1fr 1fr 1fr",
|
|
cells: [
|
|
{ gridColumn: "1", gridRow: "1" },
|
|
{ gridColumn: "1", gridRow: "2" },
|
|
{ gridColumn: "1", gridRow: "3" },
|
|
],
|
|
},
|
|
|
|
// ── 4 images ──────────────────────────────────────────────────────
|
|
{
|
|
id: "4-grid",
|
|
imageCount: 4,
|
|
label: "2x2 grid",
|
|
gridTemplateColumns: "1fr 1fr",
|
|
gridTemplateRows: "1fr 1fr",
|
|
cells: [
|
|
{ gridColumn: "1", gridRow: "1" },
|
|
{ gridColumn: "2", gridRow: "1" },
|
|
{ gridColumn: "1", gridRow: "2" },
|
|
{ gridColumn: "2", gridRow: "2" },
|
|
],
|
|
},
|
|
{
|
|
id: "4-left-large",
|
|
imageCount: 4,
|
|
label: "Left large",
|
|
gridTemplateColumns: "2fr 1fr",
|
|
gridTemplateRows: "1fr 1fr 1fr",
|
|
cells: [
|
|
{ gridColumn: "1", gridRow: "1 / 4" },
|
|
{ gridColumn: "2", gridRow: "1" },
|
|
{ gridColumn: "2", gridRow: "2" },
|
|
{ gridColumn: "2", gridRow: "3" },
|
|
],
|
|
},
|
|
{
|
|
id: "4-top-large",
|
|
imageCount: 4,
|
|
label: "Top large",
|
|
gridTemplateColumns: "1fr 1fr 1fr",
|
|
gridTemplateRows: "2fr 1fr",
|
|
cells: [
|
|
{ gridColumn: "1 / 4", gridRow: "1" },
|
|
{ gridColumn: "1", gridRow: "2" },
|
|
{ gridColumn: "2", gridRow: "2" },
|
|
{ gridColumn: "3", gridRow: "2" },
|
|
],
|
|
},
|
|
{
|
|
id: "4-bottom-large",
|
|
imageCount: 4,
|
|
label: "Bottom large",
|
|
gridTemplateColumns: "1fr 1fr 1fr",
|
|
gridTemplateRows: "1fr 2fr",
|
|
cells: [
|
|
{ gridColumn: "1", gridRow: "1" },
|
|
{ gridColumn: "2", gridRow: "1" },
|
|
{ gridColumn: "3", gridRow: "1" },
|
|
{ gridColumn: "1 / 4", gridRow: "2" },
|
|
],
|
|
},
|
|
|
|
// ── 5 images ──────────────────────────────────────────────────────
|
|
{
|
|
id: "5-top2-bottom3",
|
|
imageCount: 5,
|
|
label: "2 + 3",
|
|
gridTemplateColumns: "1fr 1fr 1fr 1fr 1fr 1fr",
|
|
gridTemplateRows: "1fr 1fr",
|
|
cells: [
|
|
{ gridColumn: "1 / 4", gridRow: "1" },
|
|
{ gridColumn: "4 / 7", gridRow: "1" },
|
|
{ gridColumn: "1 / 3", gridRow: "2" },
|
|
{ gridColumn: "3 / 5", gridRow: "2" },
|
|
{ gridColumn: "5 / 7", gridRow: "2" },
|
|
],
|
|
},
|
|
{
|
|
id: "5-top3-bottom2",
|
|
imageCount: 5,
|
|
label: "3 + 2",
|
|
gridTemplateColumns: "1fr 1fr 1fr 1fr 1fr 1fr",
|
|
gridTemplateRows: "1fr 1fr",
|
|
cells: [
|
|
{ gridColumn: "1 / 3", gridRow: "1" },
|
|
{ gridColumn: "3 / 5", gridRow: "1" },
|
|
{ gridColumn: "5 / 7", gridRow: "1" },
|
|
{ gridColumn: "1 / 4", gridRow: "2" },
|
|
{ gridColumn: "4 / 7", gridRow: "2" },
|
|
],
|
|
},
|
|
{
|
|
id: "5-left-large",
|
|
imageCount: 5,
|
|
label: "Left large",
|
|
gridTemplateColumns: "2fr 1fr",
|
|
gridTemplateRows: "1fr 1fr 1fr 1fr",
|
|
cells: [
|
|
{ gridColumn: "1", gridRow: "1 / 5" },
|
|
{ gridColumn: "2", gridRow: "1" },
|
|
{ gridColumn: "2", gridRow: "2" },
|
|
{ gridColumn: "2", gridRow: "3" },
|
|
{ gridColumn: "2", gridRow: "4" },
|
|
],
|
|
},
|
|
{
|
|
id: "5-center-large",
|
|
imageCount: 5,
|
|
label: "Center large",
|
|
gridTemplateColumns: "1fr 2fr 1fr",
|
|
gridTemplateRows: "1fr 1fr",
|
|
cells: [
|
|
{ gridColumn: "1", gridRow: "1" },
|
|
{ gridColumn: "2", gridRow: "1 / 3" },
|
|
{ gridColumn: "3", gridRow: "1" },
|
|
{ gridColumn: "1", gridRow: "2" },
|
|
{ gridColumn: "3", gridRow: "2" },
|
|
],
|
|
},
|
|
|
|
// ── 6 images ──────────────────────────────────────────────────────
|
|
{
|
|
id: "6-grid-2x3",
|
|
imageCount: 6,
|
|
label: "2x3 grid",
|
|
gridTemplateColumns: "1fr 1fr",
|
|
gridTemplateRows: "1fr 1fr 1fr",
|
|
cells: [
|
|
{ gridColumn: "1", gridRow: "1" },
|
|
{ gridColumn: "2", gridRow: "1" },
|
|
{ gridColumn: "1", gridRow: "2" },
|
|
{ gridColumn: "2", gridRow: "2" },
|
|
{ gridColumn: "1", gridRow: "3" },
|
|
{ gridColumn: "2", gridRow: "3" },
|
|
],
|
|
},
|
|
{
|
|
id: "6-grid-3x2",
|
|
imageCount: 6,
|
|
label: "3x2 grid",
|
|
gridTemplateColumns: "1fr 1fr 1fr",
|
|
gridTemplateRows: "1fr 1fr",
|
|
cells: [
|
|
{ gridColumn: "1", gridRow: "1" },
|
|
{ gridColumn: "2", gridRow: "1" },
|
|
{ gridColumn: "3", gridRow: "1" },
|
|
{ gridColumn: "1", gridRow: "2" },
|
|
{ gridColumn: "2", gridRow: "2" },
|
|
{ gridColumn: "3", gridRow: "2" },
|
|
],
|
|
},
|
|
{
|
|
id: "6-top-large",
|
|
imageCount: 6,
|
|
label: "Top large",
|
|
gridTemplateColumns: "1fr 1fr 1fr 1fr 1fr",
|
|
gridTemplateRows: "2fr 1fr",
|
|
cells: [
|
|
{ gridColumn: "1 / 6", gridRow: "1" },
|
|
{ gridColumn: "1", gridRow: "2" },
|
|
{ gridColumn: "2", gridRow: "2" },
|
|
{ gridColumn: "3", gridRow: "2" },
|
|
{ gridColumn: "4", gridRow: "2" },
|
|
{ gridColumn: "5", gridRow: "2" },
|
|
],
|
|
},
|
|
|
|
// ── 7 images ──────────────────────────────────────────────────────
|
|
{
|
|
id: "7-mosaic",
|
|
imageCount: 7,
|
|
label: "Mosaic",
|
|
gridTemplateColumns: "1fr 1fr 1fr",
|
|
gridTemplateRows: "1fr 1fr 1fr",
|
|
cells: [
|
|
{ gridColumn: "1 / 3", gridRow: "1" },
|
|
{ gridColumn: "3", gridRow: "1" },
|
|
{ gridColumn: "1", gridRow: "2" },
|
|
{ gridColumn: "2", gridRow: "2" },
|
|
{ gridColumn: "3", gridRow: "2" },
|
|
{ gridColumn: "1", gridRow: "3" },
|
|
{ gridColumn: "2 / 4", gridRow: "3" },
|
|
],
|
|
},
|
|
|
|
// ── 8 images ──────────────────────────────────────────────────────
|
|
{
|
|
id: "8-mosaic",
|
|
imageCount: 8,
|
|
label: "Mosaic",
|
|
gridTemplateColumns: "1fr 1fr 1fr 1fr",
|
|
gridTemplateRows: "1fr 1fr 1fr",
|
|
cells: [
|
|
{ gridColumn: "1 / 3", gridRow: "1" },
|
|
{ gridColumn: "3", gridRow: "1" },
|
|
{ gridColumn: "4", gridRow: "1" },
|
|
{ gridColumn: "1", gridRow: "2" },
|
|
{ gridColumn: "2", gridRow: "2" },
|
|
{ gridColumn: "3 / 5", gridRow: "2" },
|
|
{ gridColumn: "1 / 3", gridRow: "3" },
|
|
{ gridColumn: "3 / 5", gridRow: "3" },
|
|
],
|
|
},
|
|
|
|
// ── 9 images ──────────────────────────────────────────────────────
|
|
{
|
|
id: "9-grid",
|
|
imageCount: 9,
|
|
label: "3x3 grid",
|
|
gridTemplateColumns: "1fr 1fr 1fr",
|
|
gridTemplateRows: "1fr 1fr 1fr",
|
|
cells: [
|
|
{ gridColumn: "1", gridRow: "1" },
|
|
{ gridColumn: "2", gridRow: "1" },
|
|
{ gridColumn: "3", gridRow: "1" },
|
|
{ gridColumn: "1", gridRow: "2" },
|
|
{ gridColumn: "2", gridRow: "2" },
|
|
{ gridColumn: "3", gridRow: "2" },
|
|
{ gridColumn: "1", gridRow: "3" },
|
|
{ gridColumn: "2", gridRow: "3" },
|
|
{ gridColumn: "3", gridRow: "3" },
|
|
],
|
|
},
|
|
];
|
|
|
|
/** Find all templates matching a specific image count. */
|
|
export function getTemplatesForCount(count: number): CollageTemplate[] {
|
|
return COLLAGE_TEMPLATES.filter((t) => t.imageCount === count);
|
|
}
|
|
|
|
/** Pick the best default template for a given image count. */
|
|
export function getDefaultTemplate(count: number): CollageTemplate {
|
|
const exact = getTemplatesForCount(count);
|
|
if (exact.length > 0) return exact[0];
|
|
|
|
// Fall back: find the nearest template with >= count cells
|
|
const sorted = [...COLLAGE_TEMPLATES].sort(
|
|
(a, b) => Math.abs(a.imageCount - count) - Math.abs(b.imageCount - count),
|
|
);
|
|
return sorted[0];
|
|
}
|
|
|
|
/** Get a template by ID. */
|
|
export function getTemplateById(id: string): CollageTemplate | undefined {
|
|
return COLLAGE_TEMPLATES.find((t) => t.id === id);
|
|
}
|