Skip to content

Add Image Stitcher web application#217

Open
simonw wants to merge 2 commits intomainfrom
claude/image-stitching-tool-Z8pxq
Open

Add Image Stitcher web application#217
simonw wants to merge 2 commits intomainfrom
claude/image-stitching-tool-Z8pxq

Conversation

@simonw
Copy link
Owner

@simonw simonw commented Feb 5, 2026

Summary

Add a complete web-based image stitching tool that allows users to horizontally stitch multiple images together with precise vertical alignment control.

Key Features

  • Image Loading: Drag-and-drop or click-to-select multiple images (PNG, JPEG, WebP, GIF)
  • Visual Alignment:
    • Drag images vertically to adjust alignment
    • Arrow keys for fine-tuning (1px or 10px increments)
    • Auto-align using edge luminance cross-correlation
  • Interactive Editor:
    • Reorder images with left/right buttons
    • Real-time overlap previews showing seam areas (3x zoom)
    • Live stitched result canvas
    • Selection and nudge controls
  • Export Options: Download as PNG or JPEG with adjustable quality
  • Responsive Design: Works on desktop and mobile devices

Implementation Details

  • Auto-alignment algorithm: Analyzes right edge of one image and left edge of the next using luminance-based cross-correlation to find optimal vertical offset
  • Overlap previews: Shows 60px from each side of adjacent images at 3x zoom with a red seam line indicator
  • Drag interaction: Uses Pointer Events API with capture for smooth dragging and visual feedback
  • Performance: Throttled rendering during drag operations using requestAnimationFrame
  • Accessibility: Keyboard shortcuts (arrow keys, Delete), semantic HTML, visually hidden file input

Technical Stack

  • Vanilla JavaScript (no dependencies)
  • HTML5 Canvas for image processing and rendering
  • CSS Grid/Flexbox for responsive layout
  • FileReader API for image loading

https://claude.ai/code/session_01Cf9UUauF9ZfjvFwnZMLs4F

Single-page tool that lets users load multiple images and stitch them
horizontally with adjustable vertical alignment. Features include:
- Auto-align using edge luminance cross-correlation
- Drag to adjust vertical offset (pointer events for desktop + mobile)
- Pixel-precise nudge buttons (1px and 10px) and arrow key support
- Zoomed overlap preview showing seam areas between adjacent images
- Image reordering with left/right buttons
- Live stitched result preview at full resolution
- Export as PNG or JPEG with adjustable quality

https://claude.ai/code/session_01Cf9UUauF9ZfjvFwnZMLs4F
@claude
Copy link
Contributor

claude bot commented Feb 5, 2026

Claude finished @simonw's task —— View job


PR Review: Image Stitcher Web Application

I've completed a comprehensive review of the image stitcher web application. This is a well-implemented tool with impressive functionality for horizontal image stitching. Here's my detailed feedback:

Review Progress

  • Read and analyze the image-stitcher.html file
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Evaluate performance considerations
  • Assess security concerns
  • Review test coverage
  • Provide comprehensive review feedback

Strengths

Code Quality & Architecture

  • Well-structured vanilla JS: Clean separation of concerns with state management, event handling, and rendering functions
  • Modern web APIs: Excellent use of Pointer Events, FileReader, Canvas APIs, and CSS Grid/Flexbox
  • Accessibility: Good practices with semantic HTML, visually hidden file input, keyboard shortcuts (arrow keys, Delete)
  • Responsive design: Mobile-friendly with media queries and touch-action CSS

Advanced Features

  • Auto-alignment algorithm: Sophisticated luminance-based cross-correlation for edge matching (image-stitcher.html:366-444)
  • Real-time overlap previews: Innovative 3x zoom view showing seam areas between images (image-stitcher.html:574-653)
  • Smooth interactions: Proper pointer capture, throttled rendering during drag operations
  • Export flexibility: PNG/JPEG with quality control

⚠️ Issues & Recommendations

Performance Considerations

  1. Memory usage for large images (image-stitcher.html:673-674):

    resultCanvas.width = totalW;
    resultCanvas.height = totalH;
    • Issue: No limits on canvas size - could exceed browser memory limits
    • Recommendation: Add max canvas size validation (e.g., 32K x 32K pixels) and offer to downscale
  2. Auto-align computation (image-stitcher.html:385-443):

    • Issue: Creates temporary canvases for each image pair without cleanup
    • Recommendation: Reuse canvas elements or add explicit cleanup
  3. Image loading (image-stitcher.html:332-364):

    • Issue: All images loaded into memory simultaneously
    • Recommendation: Consider progressive loading for many/large images

Potential Bugs

  1. Division by zero risk (image-stitcher.html:439):

    const mse = sse / count;
    • Issue: If count is 0, this creates NaN
    • Recommendation: Add if (count === 0) continue; before the division
  2. Canvas context loss (image-stitcher.html:675):

    • Issue: No handling of WebGL context loss events
    • Recommendation: Add context loss detection and recovery
  3. File input state (image-stitcher.html:263):

    • Issue: Input value cleared immediately, preventing same file re-selection
    • Current implementation: Actually handles this correctly with e.target.value = '';

Security Considerations

  1. File type validation (image-stitcher.html:339):

    if (!file.type.startsWith('image/')) return;
    • Good: Basic MIME type checking
    • Enhancement: Consider magic number validation for additional security
  2. Memory exhaustion (image-stitcher.html:695-705):

    • Issue: No limits on blob size or canvas dimensions
    • Recommendation: Add size limits to prevent DoS-style memory exhaustion
  3. URL cleanup (image-stitcher.html:704):

    setTimeout(() => URL.revokeObjectURL(url), 3000);
    • Good: Proper cleanup of object URLs

Code Quality Improvements

  1. Magic numbers (image-stitcher.html:244-245):

    const OVERLAP_PX = 60;
    const ZOOM_FACTOR = 3;
    • Good: Constants are properly defined
    • Enhancement: Consider making these user-configurable
  2. Error handling:

    • Missing: No try-catch blocks around image operations
    • Recommendation: Add error handling for canvas operations and file reading

Test Coverage

  • Current state: No automated tests present
  • Recommendations:
    • Unit tests for auto-alignment algorithm
    • Integration tests for drag-and-drop functionality
    • Visual regression tests for rendering accuracy
    • Performance tests for large image handling

🔧 Suggested Improvements

  1. Add canvas size limits:

    const MAX_CANVAS_AREA = 268435456; // 16K x 16K
    if (totalW * totalH > MAX_CANVAS_AREA) {
      // Offer to downscale or show warning
    }
  2. Improve error handling:

    try {
      ctx.drawImage(im.img, x, im.offsetY - minY);
    } catch (e) {
      console.error('Canvas operation failed:', e);
      // Handle gracefully
    }
  3. Add progress indicators for large operations (auto-align, rendering)

  4. Memory optimization: Add option to work with downscaled previews and only render full resolution on export


📋 Overall Assessment

This is high-quality, production-ready code with impressive functionality. The auto-alignment algorithm is particularly sophisticated and the UI/UX is well-designed. The main concerns are around handling edge cases with very large images and adding comprehensive error handling.

Recommendation: ✅ Approve with minor enhancements

The code demonstrates excellent understanding of web APIs and image processing. The suggested improvements are mostly about robustness and edge case handling rather than fundamental issues.

…litch

- Add Horizontal/Vertical toggle buttons in the toolbar to switch
  stitching orientation
- In vertical mode: images stack top-to-bottom, cross-axis adjustment
  is left/right, auto-align uses bottom/top edge correlation
- Nudge button labels and keyboard shortcuts adapt to current mode
- Fix visual glitch where drop zone dashed border leaked outside its
  bounds by adding position:relative and overflow:hidden to contain
  the absolutely-positioned hidden file input

https://claude.ai/code/session_01Cf9UUauF9ZfjvFwnZMLs4F
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 5, 2026

Deploying tools with  Cloudflare Pages  Cloudflare Pages

Latest commit: 908ae3d
Status: ✅  Deploy successful!
Preview URL: https://4f0e78f6.tools-b1q.pages.dev
Branch Preview URL: https://claude-image-stitching-tool.tools-b1q.pages.dev

View logs

@claude
Copy link
Contributor

claude bot commented Feb 5, 2026

Claude finished @simonw's task —— View job


PR Review: Image Stitcher Web Application

I've completed a comprehensive review of the image stitcher web application. This is a well-implemented tool with impressive functionality for horizontal image stitching. Here's my detailed feedback:

Review Progress

  • Read and analyze the image-stitcher.html file
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Evaluate performance considerations
  • Assess security concerns
  • Review test coverage
  • Provide comprehensive review feedback

Strengths

Code Quality & Architecture

  • Well-structured vanilla JS: Clean separation of concerns with state management, event handling, and rendering functions
  • Modern web APIs: Excellent use of Pointer Events, FileReader, Canvas APIs, and CSS Grid/Flexbox
  • Accessibility: Good practices with semantic HTML, visually hidden file input, keyboard shortcuts (arrow keys, Delete)
  • Responsive design: Mobile-friendly with media queries and touch-action CSS

Advanced Features

  • Auto-alignment algorithm: Sophisticated luminance-based cross-correlation for edge matching (image-stitcher.html:366-444)
  • Real-time overlap previews: Innovative 3x zoom view showing seam areas between images (image-stitcher.html:574-653)
  • Smooth interactions: Proper pointer capture, throttled rendering during drag operations
  • Export flexibility: PNG/JPEG with quality control

⚠️ Issues & Recommendations

Performance Considerations

  1. Memory usage for large images (image-stitcher.html:673-674):

    resultCanvas.width = totalW;
    resultCanvas.height = totalH;
    • Issue: No limits on canvas size - could exceed browser memory limits
    • Recommendation: Add max canvas size validation (e.g., 32K x 32K pixels) and offer to downscale
  2. Auto-align computation (image-stitcher.html:385-443):

    • Issue: Creates temporary canvases for each image pair without cleanup
    • Recommendation: Reuse canvas elements or add explicit cleanup
  3. Image loading (image-stitcher.html:332-364):

    • Issue: All images loaded into memory simultaneously
    • Recommendation: Consider progressive loading for many/large images

Potential Bugs

  1. Division by zero risk (image-stitcher.html:439):

    const mse = sse / count;
    • Issue: If count is 0, this creates NaN
    • Recommendation: Add if (count === 0) continue; before the division
  2. Canvas context loss (image-stitcher.html:675):

    • Issue: No handling of WebGL context loss events
    • Recommendation: Add context loss detection and recovery
  3. File input state (image-stitcher.html:263):

    • Issue: Input value cleared immediately, preventing same file re-selection
    • Current implementation: Actually handles this correctly with e.target.value = '';

Security Considerations

  1. File type validation (image-stitcher.html:339):

    if (!file.type.startsWith('image/')) return;
    • Good: Basic MIME type checking
    • Enhancement: Consider magic number validation for additional security
  2. Memory exhaustion (image-stitcher.html:695-705):

    • Issue: No limits on blob size or canvas dimensions
    • Recommendation: Add size limits to prevent DoS-style memory exhaustion
  3. URL cleanup (image-stitcher.html:704):

    setTimeout(() => URL.revokeObjectURL(url), 3000);
    • Good: Proper cleanup of object URLs

Code Quality Improvements

  1. Magic numbers (image-stitcher.html:244-245):

    const OVERLAP_PX = 60;
    const ZOOM_FACTOR = 3;
    • Good: Constants are properly defined
    • Enhancement: Consider making these user-configurable
  2. Error handling:

    • Missing: No try-catch blocks around image operations
    • Recommendation: Add error handling for canvas operations and file reading

Test Coverage

  • Current state: No automated tests present
  • Recommendations:
    • Unit tests for auto-alignment algorithm
    • Integration tests for drag-and-drop functionality
    • Visual regression tests for rendering accuracy
    • Performance tests for large image handling

🔧 Suggested Improvements

  1. Add canvas size limits:

    const MAX_CANVAS_AREA = 268435456; // 16K x 16K
    if (totalW * totalH > MAX_CANVAS_AREA) {
      // Offer to downscale or show warning
    }
  2. Improve error handling:

    try {
      ctx.drawImage(im.img, x, im.offsetY - minY);
    } catch (e) {
      console.error('Canvas operation failed:', e);
      // Handle gracefully
    }
  3. Add progress indicators for large operations (auto-align, rendering)

  4. Memory optimization: Add option to work with downscaled previews and only render full resolution on export


📋 Overall Assessment

This is high-quality, production-ready code with impressive functionality. The auto-alignment algorithm is particularly sophisticated and the UI/UX is well-designed. The main concerns are around handling edge cases with very large images and adding comprehensive error handling.

Recommendation: ✅ Approve with minor enhancements

The code demonstrates excellent understanding of web APIs and image processing. The suggested improvements are mostly about robustness and edge case handling rather than fundamental issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants