ComfyUI Extension: Comfyui-Resolution-Master
Precise resolution and aspect ratio control for ComfyUI
Custom Nodes (0)
README
https://github.com/user-attachments/assets/f9b51c0f-677c-410e-8980-3f75bb4f8032
https://github.com/user-attachments/assets/f15ea0c2-0a65-4578-b2c7-db812bf4020c
Features
๐ฏ Core Functionality
- Interactive 2D Canvas Control: Visually select resolution with real-time preview
- Normal Drag: Standard behavior with snap to canvas grid (controlled by
canvas_step_x/y) - Shift + Drag: Preserves aspect ratio while dragging (with snap enabled)
- Ctrl + Drag: Disables snap for fine-tuning without grid constraints
- Ctrl + Shift + Drag: Preserves aspect ratio with 1px precision (no snap)
- Normal Drag: Standard behavior with snap to canvas grid (controlled by
- Smart Rescaling: Automatic calculation of rescale factors for upscaling workflows
- Snap Button: Round current dimensions to the snap value (NOT related to 2D canvas grid)
- Real-time Info Display: Shows current resolution, megapixels, p-value and aspect ratio
- Visual Output Values: Color-coded clickable values at output slots (blue/pink/green)
๐ Advanced Scaling Options
- Manual Scale: Direct multiplier control (ex. 2.0x)
- Resolution Targeting: Scale to standard resolutions (ex. 480p, 720p, 1080p, 2160p)
- Megapixel Targeting: Scale to specific megapixel counts (ex. 5 MP)
- Live Preview: See resulting dimensions before applying changes
๐จ Preset Categories
Extensive preset library organized by use case:
- Standard: Common aspect ratios (1:1, 4:3, 16:9, 21:9, etc.)
- SDXL: Optimized resolutions for Stable Diffusion XL
- Flux: Flux model optimized presets with smart constraints
- WAN: Video model presets with resolution recommendations
- HiDream Dev: HiDream model optimized presets
- Qwen-Image: Qwen-Image model optimized presets
- Social Media: Instagram, Twitter, Facebook, YouTube optimized sizes
- Print: Standard print formats (A4, Letter, photo sizes)
- Cinema: Professional film aspect ratios (2.39:1, 1.85:1, etc.)
- Display Resolutions: Standard screen/video resolutions (720p, 1080p, 4K, 8K, etc.)
๐ค Model-Specific Optimizations
SDXL Mode
- Enforces officially supported resolutions
- Fixed dimensions for optimal generation quality
Flux Mode
- 32px increment enforcement
- Resolution range: 320px to 2560px
- Maximum 4.0 megapixels constraint
- Sweet spot recommendation: 1920ร1080
WAN Mode
- Flexible 320p to 820p range
- 16px increments for video encoding compatibility
- Automatic model recommendation (480p vs 720p)
- Maintains proper aspect ratios for video generation
HiDream Dev Mode
- Preset-based optimization system
- Uses closest matching preset from HiDream Dev category
- Automatically selects best preset based on input dimensions and aspect ratio
- Supports both original and flipped orientations for optimal matching
Qwen-Image Mode
- Resolution range: ~0.6MP to 4.2MP (589,824 to 4,194,304 pixels)
- Smart scaling: If input is already within range, dimensions remain unchanged
- Automatic scaling: Input outside range is scaled to fit while maintaining aspect ratio
- Preserves original dimensions when already optimized
๐ Installation
Install via ComfyUI-Manager
- Search
Comfyui-Resolution-Masterin ComfyUI-Manager and clickInstallbutton.
Manual Install
- Install ComfyUi.
- Clone this repo into
custom_modules:cd ComfyUI/custom_nodes/ git clone https://github.com/Azornes/Comfyui-Resolution-Master.git - Start up ComfyUI.
- Restart ComfyUI or reload custom nodes
Usage
Basic Operation
- Add the "Resolution Master" node to your workflow
- Connect the outputs to your image generation nodes:
width: Current width value (click the blue number to set custom width)height: Current height value (click the pink number to set custom height)rescale_factor: Calculated scale factor for upscaling (green number)
Workflow Examples
Example 1: Image Resizing Workflow
If you want to resize an input image using Resolution Master:
- Load Image: Add a "Load Image" node and connect your image.
- Connect to Resolution Master: Link the image output to the input of Resolution Master (enables Auto-Detect).
- Configure Resolution Master:
- Enable Auto-Detect toggle to read input image dimensions.
- Select a preset or set target resolution/aspect ratio.
- Use Auto-Fit or Auto-Resize for automatic adaptation.
- Resize Image: Connect Resolution Master's
widthandheightoutputs to a "Resize Image" node's width/height inputs. - Connect Image: Link the original image from "Load Image" to the "Resize Image" node's image input.
- Output: The resized image will match your target specifications.
Note: Resolution Master doesn't process images directlyโit calculates dimensions. Always connect it to a resizing node (like "Resize Image") for actual image transformation.
Example 2: Generation Workflow
For new image generation:
- Connect Resolution Master's
width/heightto your sampler/checkpoint nodes. - Use
rescale_factorwith upscaling nodes if needed. - Enable Auto-Detect if using an input image as reference.
๐ฎ Understanding the Controls
Actions Section
- โ Swap Button: Swaps width and height values
- โ Snap Button: Rounds the current width/height to the nearest snap value (e.g., if snap=64 and width=520, clicking Snap makes it 512)
- Snap Value Slider: Sets the value used by the Snap button (16-256px). Important: This does NOT change the 2D canvas grid behavior!
2D Canvas
- White Dot: Drag to set resolution visually
- Grid Dots: Visual guides controlled by
canvas_step_x/yproperties (NOT by the snap slider) - Blue Rectangle: Shows current resolution selection
Scaling Section
- โฌ Manual Scale Button: Applies the manual scale factor to current dimensions
- ๐บ Resolution Button: Scales to target resolution (e.g., 1080p)
- ๐ท Megapixels Button: Scales to target megapixel count
- Radio Buttons: Select which scaling mode affects the
rescale_factoroutput
Auto-Detect Section
- Auto-detect Toggle: ON/OFF switch for automatic dimension detection from connected images
- Monitors input connection every second
- Updates dimensions when new image is detected
- Shows detected resolution in green text
- ๐ฏ Auto-fit Button: Finds best matching preset for current dimensions
- Analyzes both aspect ratio and total pixels
- Checks both normal and flipped orientations
- Applies category-specific scaling when Custom Calc is enabled
- Auto Checkbox: Enable automatic fitting when dimensions change
- Located next to Auto-Fit button
- Only active when category is selected and image detected
- ๐ Auto-Resize Button: Applies scaling based on selected mode (Manual/Resolution/Megapixels)
- Integrates with active scaling mode from Scaling section
- Maintains manual scale value without reset to 1.0x
- Auto Checkbox: Automatically apply scaling when new image is detected
- Works in sequence after Auto-fit (if enabled)
- Applies chosen scaling mode to detected dimensions
- Detected Text (green): Click to apply the detected image's original dimensions
- โก Auto-calc Button: Applies model-specific calculations to current dimensions
- Calc Checkbox: Enables automatic model-specific optimizations
Presets Section
- Category Dropdown: Select preset category (Standard, SDXL, Flux, etc.)
- Preset Dropdown: Choose specific preset from selected category
๐ง Node Properties Configuration
You can customize various parameters by accessing the node's Properties panel in ComfyUI. Here's a complete list of all configurable properties:
Canvas Properties
canvas_min_x/canvas_min_y: Minimum values for X and Y axes (default: 0)canvas_max_x/canvas_max_y: Maximum values for X and Y axes (default: 2048, max: 32768)- Increase these for working with higher resolutions (e.g., 8192 for 8K)
canvas_step_x/canvas_step_y: Grid snap increments for the 2D canvas (default: 64)- This controls the grid dots and snap behavior when dragging on the 2D canvas
- NOT controlled by the snap slider in the Actions section
canvas_decimals_x/canvas_decimals_y: Decimal precision for X/Y values (default: 0)canvas_snap: Enable/disable grid snapping on 2D canvas (default: true)canvas_dots: Show/hide grid dots on 2D canvas (default: true)canvas_frame: Show/hide the blue selection frame (default: true)
Action Sliders Range
action_slider_snap_min: Minimum value for snap slider (default: 16)action_slider_snap_max: Maximum value for snap slider (default: 256)action_slider_snap_step: Step increment for snap slider (default: 16)
Scaling Sliders Range
scaling_slider_min: Minimum manual scale factor (default: 0.1)scaling_slider_max: Maximum manual scale factor (default: 4.0)scaling_slider_step: Step increment for scale slider (default: 0.1)megapixels_slider_min: Minimum megapixels target (default: 0.5)megapixels_slider_max: Maximum megapixels target (default: 6.0)megapixels_slider_step: Step increment for megapixels slider (default: 0.1)
Section Collapse States
section_actions_collapsed: Actions section collapsed state (default: false)section_scaling_collapsed: Scaling section collapsed state (default: false)section_autoDetect_collapsed: Auto-Detect section collapsed state (default: false)section_presets_collapsed: Presets section collapsed state (default: false)
Example: Customizing for 8K Workflow
- Right-click on the ResolutionMaster node
- Select "Properties"
- Set
canvas_max_xandcanvas_max_yto 8192 - Set
canvas_step_xandcanvas_step_yto 128 for larger grid increments - Set
manual_slider_max_wandmanual_slider_max_hto 8192
Working with Presets
- Select a Category: Choose from the dropdown (e.g., "SDXL", "Social Media")
- Choose a Preset: Select specific aspect ratio or resolution
- Enable Custom Calc (optional): Checkbox appears next to preset dropdown
- Activates model-specific constraints
- Automatically adjusts dimensions to model requirements
- Apply: Dimensions are automatically updated
๐ฏ Advanced Preset Management
ResolutionMaster includes a powerful Preset Manager system for creating, organizing, and managing custom presets. Access it by clicking the "โ๏ธ Manage Presets" button in the Presets section.
Preset Manager Features
๐ List View
The main view shows all your custom presets organized by category:
- Statistics Header: Displays total categories and preset count
- Category Sections: Each category shows its presets with dimensions
- Bulk Operations: Select multiple presets for batch deletion (Shift+Click for range selection)
- Empty State: Helpful message when no custom presets exist
โ Add/Edit Preset View
Create or modify presets with an intuitive interface:
- Category Selection: Choose target category from dropdown
- Rename Category: Click the โ๏ธ button next to category name to rename
- Quick Add Form:
- Name field with real-time validation
- Width and Height inputs (minimum 64px)
- Live preview showing aspect ratio and shape visualization
- Visual feedback for edit mode (green accents) vs add mode (blue accents)
- Preset Preview: Grid view of all presets in selected category
- Click any preset to load its values into the form for editing
- Delete custom presets or hide/unhide built-in presets
- Visual indicators for custom (โ๏ธ icon) and hidden presets
๐ Drag & Drop Operations
The Preset Manager supports advanced drag & drop with visual feedback:
Preset Reordering & Moving
- Drag Handle (left side): Drag presets to reorder within category or move between categories
- Visual Indicators:
- Blue line: Reordering within same category
- Orange line: Moving to different category
- Red line: Invalid drop (name conflict)
- Green line: Duplicate/clone operation
- Modifier Keys:
- Normal Drag: Move preset to new position
- Drag by Clone Handle (โ): Duplicate preset to new location
Category Reordering
- Drag Category Headers: Reorder entire categories by dragging their headers
- Drop Zones:
- Above any category header
- Below last category (in category section body)
- At top (drop on statistics header)
๐ Clone/Duplicate Presets
- Clone Handle (โ icon): Drag this handle to duplicate a preset
- Auto-naming: Automatically generates unique names (e.g., "Preset (1)", "Preset (2)")
- Cross-category Cloning: Duplicate presets between different categories
- Smart Positioning: Dropped preset appears at the exact position where you drop it
โ๏ธ Rename Functionality
Inline Renaming
- Double-click on any preset or category name to rename in-place
- Enter: Save changes
- Escape: Cancel editing
- Auto-validation: Prevents duplicate names, empty names
- Auto-unique naming (categories): Adds suffix "(1)", "(2)" if name exists
Rename Dialog (Categories)
- Click โ๏ธ button next to category name in Add view
- Real-time validation with error messages
- Shows current name for reference
- Enter to apply, Escape to cancel
๐ JSON Editor
Advanced users can directly edit the preset configuration as JSON:
- Multiple Editor Modes: Code, Tree, Form, Text, View, Preview
- Syntax Highlighting: VS Code-style dark theme (Twilight)
- Real-time Validation: Instant feedback on JSON syntax errors
- Drag & Drop: Drop .json files directly into the editor to load them
- Full Editing: Add, remove, or modify categories and presets
- Import/Export:
- Apply changes to replace current configuration
- Export current configuration as JSON file
- All Features Available: Sort, transform, search, and more
Access: Click "{ } JSON Editor" button in Preset Manager footer
Use Cases:
- Bulk editing multiple presets
- Importing preset collections from files
- Creating complex preset structures
- Backup and restore configurations
- Sharing preset collections with others
๐๏ธ Deletion Options
- Individual Delete: Click ๐๏ธ button on any custom preset
- Hide Built-in Presets: Click ๐๏ธ on built-in presets to hide them (they remain in system)
- Unhide: Click ๐๏ธ again on hidden presets to restore visibility
- Bulk Delete:
- Select multiple presets using checkboxes
- Click "Delete Selected" button
- Shift+Click for range selection
- Delete Empty Categories: Option in footer to clean up categories with no presets
๐จ Visual Feedback & Tooltips
- Color-coded Indicators: Different colors for different drag operations
- Interactive Tooltips: Hover over buttons for helpful descriptions
- Mode Indicators: Visual distinction between add and edit modes
- Real-time Validation: Instant feedback on errors and conflicts
- Shape Preview: Visual representation of aspect ratio in add/edit form
โจ๏ธ Keyboard Shortcuts & Interactions
- Double-click: Rename preset or category name
- Enter: Apply rename or save changes
- Escape: Cancel current operation or close dialog
- Shift+Click: Select range of presets (bulk operations)
- Ctrl/Cmd+Drag: Fine control for drag operations
Import/Export Presets
Export
- Open Preset Manager
- Click "๐ฅ Export JSON" button
- JSON file downloads with current preset configuration
- Share or backup your custom presets
Import
- Open Preset Manager
- Click "๐ค Import JSON" button
- Choose merge or replace mode:
- Merge: Add new presets, keep existing ones
- Replace: Completely replace current configuration
- Select your .json file
- Presets are loaded instantly
Alternative: Use the JSON Editor's drag & drop feature to load preset files directly
Preset Manager Tips
- Organize by Category: Keep related presets together for easier management
- Use Descriptive Names: Clear names make presets easier to find and use
- Clone for Variations: Duplicate similar presets and adjust slightly
- Regular Backups: Export your presets periodically
- Hide Unused Built-ins: Declutter your preset list by hiding unused built-in presets
- Keyboard Navigation: Use double-click rename for quick adjustments
- Visual Validation: Watch the preview shape when creating presets to verify aspect ratio
- Drag to Organize: Quickly reorder presets and categories with drag & drop
Scaling Workflow
The node provides three scaling methods that work together:
- Set Base Resolution: Use presets or manual input
- Choose Scaling Method:
- Manual: Direct multiplier
- Resolution: Target specific output resolution
- Megapixels: Target specific pixel count
- Apply Scale: Updates dimensions while maintaining aspect ratio
- Use Rescale Factor: Connect to upscaling nodes in your workflow
Snap Functionality
- Snap Button: Rounds dimensions to nearest grid value
- Adjustable Grid: 16px to 256px increments (adjustable via slider)
- Smart Snapping: Respects model constraints when Custom Calc is enabled
- Canvas Drag Modifiers:
- Normal Drag: Standard behavior with snap to grid
- Shift + Drag: Preserves aspect ratio while dragging (with snap enabled)
- Ctrl + Drag: Disables snap for fine-tuning without grid constraints
- Ctrl + Shift + Drag: Preserves aspect ratio with 1px precision (no snap)
Auto-Detect & Auto-Fit
- Auto-Detect Toggle: Automatically detects dimensions from connected images
- Monitors input connection every second
- Updates dimensions when new image is detected
- Shows detected resolution in green text
- Auto-Fit Button: Intelligently matches detected dimensions to closest preset
- Analyzes both aspect ratio and total pixels
- Checks both normal and flipped orientations
- Applies category-specific scaling when Custom Calc is enabled
- Auto Checkbox: Enable automatic fitting when dimensions change
- Located next to Auto-Fit button
- Only active when category is selected and image detected
Output Values
- width (INT): Selected width in pixels
- height (INT): Selected height in pixels
- rescale_factor (FLOAT): Calculated scaling factor for external upscaling nodes
- This value is used when you want to upscale/downscale your image using external nodes
- Changes based on selected scaling mode (manual scale, resolution target, or megapixels target)
- Connect this output to upscaling nodes in your workflow for resolution-independent scaling
Values are shown directly at output slots for quick reference.
Rescale Factor Modes
The rescale factor adapts based on your selection (choose via radio buttons):
- Manual Mode: Uses the manual scale slider value (adjustable 0.1x to 4.0x)
- Resolution Mode: Calculates factor to reach target resolution (p-value based)
- Megapixels Mode: Calculates factor to reach target pixel count (0.5 to 6.0 MP)
Each scaling row shows:
- Control button for immediate application (โฌ, ๐บ, ๐ท)
- Adjustment method (slider/dropdown)
- Calculated scale factor
- Preview of resulting dimensions
- Radio button to set as active rescale mode
๐ง Understanding rescale_factor Behavior
Important: The rescale_factor output is not a simple "scale from input" value. It's a workflow control parameter designed for professional ComfyUI pipelines.
How rescale_factor Actually Works
The rescale_factor represents your scaling intent for downstream nodes (like upscalers), not the relationship between input and current resolution.
Key Concepts:
- Base Resolution: The current width/height values (set manually, via presets, or auto-detected)
- Scaling Intent: What you want to achieve (manual scale, target resolution, or target megapixels)
- rescale_factor: The calculated multiplier to achieve your scaling intent
Three Scaling Modes Control rescale_factor:
- Manual Mode: Uses the manual scale slider value (0.1x to 4.0x)
- Resolution Mode: Calculates factor to reach target resolution (p-value based)
- Megapixels Mode: Calculates factor to reach target pixel count (0.5 to 6.0 MP)
Common Misconceptions
โ Wrong: "rescale_factor should reset to 1.0 when I connect a new image" โ Correct: rescale_factor maintains your scaling intent regardless of input changes
โ Wrong: "rescale_factor should show the ratio between input and current resolution" โ Correct: rescale_factor shows the multiplier needed to achieve your target scaling
Practical Example
Workflow Setup:
1. Connect 512ร512 image โ auto-detect sets base resolution to 512ร512
2. Set resolution target to 1080p โ rescale_factor calculates ~2.81x
3. Connect different 1024ร1024 image โ base resolution updates to 1024ร1024
4. rescale_factor recalculates to ~1.41x (to still reach 1080p target)
Why this happens: Your scaling intent (reach 1080p) remains constant, but the required multiplier changes based on the new input resolution.
Auto-Detect + Scaling Workflow
When using auto-detect with scaling:
- Auto-detect updates base resolution from connected images
- Your scaling mode remains active (manual/resolution/megapixel)
- rescale_factor recalculates to maintain your scaling intent
- Canvas drag operations update base resolution but preserve scaling intent
This design allows resolution-independent workflows where you can swap input images without breaking your scaling logic.
Canvas Drag Behavior
When dragging the canvas with different modifiers:
- Normal Drag: Updates base resolution, rescale_factor adjusts to maintain scaling intent
- Shift + Drag: Preserves aspect ratio, rescale_factor adjusts accordingly
- Ctrl + Drag: Fine-tuning without snap, rescale_factor adjusts
- Ctrl + Shift + Drag: Precise aspect ratio control, rescale_factor adjusts
The rescale_factor always reflects your active scaling mode, not the drag operation itself.
Examples
Example 1: Understanding Snap Button vs Canvas Grid
Snap Button (Actions Section):
- Current resolution: 520ร380
- Snap value slider: 64
- Click Snap button โ Resolution becomes 512ร384 (rounded to nearest 64)
2D Canvas Grid (controlled by properties):
canvas_step_x= 32,canvas_step_y= 32- When dragging on canvas, resolution snaps to 32px increments
- The snap slider does NOT affect this - only
canvas_step_x/yproperties do!
Example 2: SDXL Portrait Generation
- Select "SDXL" category
- Choose "3:4 Portrait (768ร1024)"
- Enable "Custom Calc" for SDXL optimization
- Connect to your SDXL workflow
Example 3: Social Media Content
- Select "Social Media" category
- Choose "Instagram Square (1080ร1080)"
- Use resolution scaling to target 2160p for high quality
- Apply rescale factor in upscaling node
Example 4: Flux Model Generation
- Select "Flux" category
- Enable "Custom Calc" for automatic constraints
- Choose any preset - dimensions auto-adjust to Flux requirements
- Node enforces 32px increments and 4MP limit
Tips & Best Practices
- Start with Presets: Use category presets as starting points, then fine-tune
- Enable Custom Calc: For SDXL, Flux, and WAN models to ensure compatibility
- Use Snap for Clean Values: Helps avoid odd dimensions that may cause issues
- Monitor Info Messages: Pay attention to mode-specific recommendations
- Leverage Rescale Factor: Connect to upscaling nodes for resolution-independent workflows
Working with High Resolutions (Above 2K)
The node now supports outputs up to 32K resolution. When working with very high resolutions:
- Visual Representation: The 2D canvas may appear distorted at extreme resolutions as it's optimized for the default 2048x2048 range
- Actual Outputs: The width/height outputs maintain correct aspect ratios regardless of canvas appearance
- Solution: Use the Properties panel to adjust
canvas_max_xandcanvas_max_yvalues to match your working resolution range- Example: For 8K work, set both to 8192
- Example: For 32K work, set both to 32768
- This adjustment fixes the visual representation while maintaining accurate output values
Internal Properties
- canvas_min_x/y: Minimum values for X and Y axes (default: 0)
- canvas_max_x/y: Maximum values for X and Y axes (default: 2048, adjustable up to 32768)
- canvas_step_x/y: Step values for grid snapping
- canvas_decimals_x/y: Decimal precision settings
- Visual options: dots, frame, snap toggles
โ ๏ธ Known Issues / Compatibility
-
Conflict with comfyui-mixlab-nodes
Some users have reported that the Resolution Master node appears completely blank when added to the canvas.
This issue is caused by a conflict with comfyui-mixlab-nodes.โ Temporary Fix: Disable or uninstall
comfyui-mixlab-nodesโ the node will then display and work correctly.
โ Unfortunately, I cannot reproduce this bug on my end, since with my setup both node packs work fine together.
๐ Until a proper fix is implemented incomfyui-mixlab-nodes, the only workaround is disablingcomfyui-mixlab-nodesor manual patch (see below).
If you really want or need to use comfyui-mixlab-nodes despite this, hereโs the deal:
The problem occurs because mixlab overrides the onDrawForeground method of other nodes, which breaks their display. This behavior is, frankly, unacceptable since it hijacks a method other nodes legitimately rely on. The good news is that mixlab only uses this override if the method is defined in the prototype, which means we can adjust it safely.
โ Patch
In ui_mixlab.js (see source line here), replace this part:
const orig = node.__proto__.onDrawForeground;
with this safer version:
const orig = node.onDrawForeground ?? node.__proto__.onDrawForeground;
With this modification, the Resolution Master node (and potentially other affected nodes) will render correctly again.
You can either apply this tweak manually or report it to the mixlab authors so it can be properly integrated upstream.
๐ Full discussion and context are available here:
github.com/Smirnov75/ComfyUI-mxToolkit/issues/28#issuecomment-2603091317
- Incompatibility with Modern Node Design (Vue Nodes)
This node is not compatible with the new Vue Nodes display system.
To use this node, you must revert the settings: Settings โ (search) Vue Nodes โ Disable "Modern Node Design (Vue Nodes)".
Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
๐ Support / Sponsorship
If youโd like to support my work:
๐ GitHub Sponsors