Skip to content

Rework cropping system with dual-image interface for better UX#6

Merged
Patras3 merged 4 commits intomasterfrom
claude/improve-image-cropping-011CULhxMkPWNfYVawGJEHQe
Oct 22, 2025
Merged

Rework cropping system with dual-image interface for better UX#6
Patras3 merged 4 commits intomasterfrom
claude/improve-image-cropping-011CULhxMkPWNfYVawGJEHQe

Conversation

@Patras3
Copy link
Owner

@Patras3 Patras3 commented Oct 21, 2025

Summary

This PR improves the image cropping user experience with a new dual-image interface that makes it easier to adjust crop settings interactively.


New Dual-Image Cropping System

Problems Fixed:

  • Users were confused when the preview showed a cropped image but overlays referenced the original dimensions
  • Cropping was blocked after first crop, requiring reset to adjust
  • Users could only crop from one position without resetting
  • Input fields were disabled after cropping, preventing further adjustments

New Features:

  • Top image: Source/original image with interactive crop overlay box
  • Bottom image: Live preview of cropped result (auto-updates with 100ms debounce)
  • Users can now adjust cropping multiple times without resetting
  • All crop input fields remain enabled for continuous fine-tuning
  • Reset button always visible when crop is enabled
  • Interactive drag-and-resize handles on the crop overlay
  • Real-time canvas preview shows exact crop region

Technical Implementation:

  • Added sourceImageData to store original image for canvas rendering
  • Created updateCropPreview() and drawCropPreview() for live crop preview using HTML5 canvas
  • Updated updateCropVisibility() to toggle between dual-image (crop tab) and single-image (other tabs) modes
  • All crop interaction functions now use source-image instead of preview-image
  • Auto-update triggers in drag/resize mousemove handlers provide instant visual feedback
  • Added CSS for crop section titles and canvas preview styling

Background Opacity Controls

Added opacity controls for background colors to allow semi-transparent overlays:

  • Overlay background opacity: Control transparency of text overlay backgrounds (datetime/text)
  • State icon background opacity: Control transparency of state icon backgrounds
  • Opacity sliders range from 0.0 (fully transparent) to 1.0 (fully opaque)
  • Backend properly converts RGB colors + opacity to RGBA for rendering
  • Text and icon colors are always rendered at full opacity for maximum readability

Files Modified

Frontend:

  • panel.html: New dual-image crop layout structure and opacity controls
  • panel.js: Crop preview logic, interaction handlers, and opacity handling
  • state-icon-manager.js: Updated for new crop system
  • styles.css: Crop section and canvas preview styling

Backend:

  • image_processor.py: Background opacity support with RGBA conversion
  • const.py: Added background opacity configuration constants

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

This commit completely reworks the image cropping functionality to address
several UX issues:

**Problems Fixed:**
- Users were confused when the preview showed a cropped image but the overlay
  referenced the original dimensions
- Cropping was blocked after first crop, requiring reset to adjust
- Users could only crop from one position without resetting
- Input fields were disabled after cropping, preventing adjustments

**New Dual-Image Cropping System:**
- Top image: Source/original image with interactive crop overlay
- Bottom image: Live preview of cropped result (auto-updating with 100ms debounce)
- Users can now adjust cropping multiple times without resetting
- All crop inputs remain enabled for continuous adjustments
- Reset button always visible when crop is enabled for easy reset
- No separate "Preview" button needed - updates happen automatically

**Technical Changes:**
- Added sourceImageData variable to store original image for canvas rendering
- Created updateCropPreview() and drawCropPreview() for live crop preview
- Updated updateCropVisibility() to toggle between dual-image and single-image modes
- Removed blocking logic from updateCropInteractionState()
- Updated all crop interaction functions to use source-image instead of preview-image
- Added auto-update triggers in drag/resize mousemove handlers
- Added CSS for crop section titles and canvas preview styling

Files modified:
- panel.html: New dual-image layout structure
- panel.js: Crop preview logic and interaction updates
- styles.css: Styling for new crop sections

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Patras3 and others added 3 commits October 22, 2025 00:51
Changes:
Frontend (UI):
- Add opacity sliders (0.0-1.0, step 0.1) to Overlays tab for text color and background color
- Add opacity slider to State Icons tab for global background color
- Add opacity sliders to state-icon-manager.js for individual state rule icon and text colors
- Update panel.js to save/load opacity values in getFormData() and populateForm()
- Add event listeners for opacity sliders to update value displays
- Style opacity sliders to match existing UI

Backend (Python):
- Add opacity constants: CONF_OVERLAY_COLOR_OPACITY, CONF_OVERLAY_BACKGROUND_OPACITY, CONF_STATE_ICON_BACKGROUND_OPACITY
- Update _hex_to_rgba() to accept optional opacity parameter that multiplies with alpha channel
- Update _draw_text() to apply overlay color and background opacity values
- Update _draw_multicolor_text() to apply state icon background opacity
- Update _draw_state_icon() to extract icon_opacity and text_opacity from state rules
- Pass opacity values through parts list to _draw_multicolor_text() for rendering

This allows users to configure transparency for:
- Overlay text color (datetime, custom text)
- Overlay background
- State icon global background
- State icon rule-specific icon color
- State icon rule-specific text color

All opacity values default to 1.0 (fully opaque) for backward compatibility.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Changes:
- Remove overlay_color_opacity slider from Overlays tab in panel.html
- Remove icon_opacity and text_opacity sliders from State Icons modal
- Remove text opacity event listeners and form handling from panel.js
- Remove CONF_OVERLAY_COLOR_OPACITY constant from const.py
- Remove text/icon opacity handling from image_processor.py
- Text and icon colors are now always fully opaque (opacity = 1.0)
- Background opacity controls remain fully functional

This simplifies the UI by removing non-functional text opacity controls
while preserving the working background opacity feature for both overlay
backgrounds and state icon backgrounds.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@Patras3 Patras3 merged commit 7a5fbb4 into master Oct 22, 2025
5 checks passed
@Patras3 Patras3 deleted the claude/improve-image-cropping-011CULhxMkPWNfYVawGJEHQe branch October 22, 2025 19:35
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