BoxBox
BoxBox is a lightweight ComfyUI extension for drawing, cropping, resizing, and reinserting specific regions of an image.
Nodes (4)
Crop exactly the box you drew, with the coordinates intact
Stitch your edited region back so the rest of the image never moves
Resize to a generation-friendly resolution, and hand the recipe to BoxReinsert
Draw a box on any image, get coordinates that actually land where you drew
BoxBox - Enhanced Version
ComfyUI custom node for interactive box/region selection with advanced features.
🎉 What's New in This Enhanced Version
This is an improved fork of the original BoxBox with several bug fixes and new features:
✅ Bug Fixes
-
Fixed Image Loading After ComfyUI Update
- Updated image URL construction to use ComfyUI's API helper
- Added proper filename encoding for special characters
- Improved error handling with fallback mechanisms
-
Fixed Backend Issues
- Corrected temp directory usage to use ComfyUI's proper temp folder
- Fixed HTTP response format (now returns proper
web.json_response) - Sanitized filenames to prevent path separator issues
-
Fixed Coordinate Scaling
- Removed duplicate coordinate division (was happening in both frontend and backend)
- Coordinates now correctly convert from display space to original image space
-
Fixed Intermediate Node Support
- Added recursive node chain traversal to find source images
- Now works with processing nodes (Brightness, Blur, etc.) between LoadImage and BoxSelector
- Searches up to 20 levels deep in the node graph
-
NumPy 2.0 Compatibility
- Updated backend logic with explicit casting (
np.uint8,np.float32) - Fixed binary incompatibility issues in coordinate processing
- Updated backend logic with explicit casting (
-
ComfyUI v0.12.2+ (Modern API) Support
- Re-engineered frontend to use the modern
window.comfyAPIsystem - Eliminated "Legacy API" deprecation warnings
- Improved dialog instantiation with robust fallback mechanisms
- Re-engineered frontend to use the modern
-
Adaptive Window Scaling
- Fixed coordinate misalignment when the browser window is resized
- System now dynamically calculates total scale (Server Scale * Browser CSS Scale)
🆕 New Features
-
Aspect Ratio Memory
- Remembers your last selected aspect ratio using localStorage
- Persists across browser sessions and system restarts
- Keeps aspect ratio locked when drawing new selections
-
Selection Restoration
- Automatically restores your previous selection when reopening the selector
- Shows the blue selection box from your last session
- Allows you to adjust or modify existing selections
-
Improved User Experience
- Removed annoying popup alerts for small images
- Better console logging for debugging
- Image error handler with helpful messages
📦 Installation
Method 1: ComfyUI Manager (Recommended)
- Open ComfyUI Manager
- Search for "BoxBox Enhanced"
- Click Install
Method 2: Manual Installation
cd ComfyUI/custom_nodes
git clone https://github.com/Latentnaut/BoxBox.git
Then restart ComfyUI.
🎯 Usage
- Add a LoadImage node to your workflow
- Add a BoxSelector node
- Connect the image output to BoxSelector
- Click 📦 Select Box button
- Draw a rectangular selection on your image
- Choose an aspect ratio (optional)
- Click ✅ Confirm
- Use BoxCrop to crop the selected region
- Use BoxResize to resize the cropped image
Supported Workflows
✅ Direct: LoadImage → BoxSelector → BoxCrop
✅ With Processing: LoadImage → Brightness → BoxSelector → BoxCrop
✅ Complex Chains: LoadImage → Node1 → Node2 → ... → BoxSelector
🔧 Nodes Included
- 📦 BoxSelector: Interactive region selection with aspect ratio locking
- ✂️ BoxCrop: Crops image based on selected coordinates
- 📐 BoxResize: Resizes images with aspect ratio preservation
🐛 Known Issues
- Preview shows original image (not processed) when using intermediate nodes
- This is intentional for performance reasons
- Coordinates are still applied correctly to the processed image
🙏 Credits
- Original Author: mercu-lore
- Enhanced Version: Latentnaut
- Improvements: AI-assisted development with Claude
📄 License
Same license as the original BoxBox project.
🤝 Contributing
Issues and pull requests are welcome! If you find bugs or have feature requests, please open an issue on GitHub.