Skip to content

Smart Resolution Calculator v0.5.4 - Better Defaults & Performance

Choose a tag to compare

@djdarcy djdarcy released this 07 Nov 12:03
· 96 commits to main since this release

Smart Resolution Calculator v0.5.4 - IMAGE Output with Better Defaults

Major Feature: IMAGE Output (v0.4.x)

The node now provides dual output capability - both IMAGE and LATENT outputs for maximum flexibility:

IMAGE Output Nub:

  • Transform input images: 4 transformation modes
    • Distort: Scale to exact dimensions (stretch/squash to fit)
    • Crop/Pad: Pure crop/pad at 1:1 scale (no scaling)
    • Scale/Crop: Scale to cover target, crop excess (maintains aspect ratio)
    • Scale/Pad: Scale to fit inside target, pad remainder (maintains aspect ratio)
  • Generate empty images: 5 fill patterns
    • Black, white, custom color, noise, random
    • Perfect for creating canvases at precise calculated dimensions
  • Dual pipeline workflows: Send output through image OR latent path to KSampler

What This Enables:

  • Generate images at precise calculated dimensions
  • Transform reference images before latent conversion
  • Create custom-sized canvases for painting/inpainting
  • Process through either image or latent pipeline
  • Fine control over aspect ratios and dimension constraints

v0.5.4 Updates - Better Defaults & Documentation

Changed - Default Widget Values

Updated to showcase IMAGE output and optimize for modern SD models:

Dimension Defaults:

  • WIDTH: 1920 → 1024 (standard SD resolution)
  • HEIGHT: 1080 → 1024 (square format default)
  • divisible_by: Kept at 16 (safe for SD1.5/SDXL/Flux/Illustrious)

Aspect Ratio & Fill:

  • custom_aspect_ratio: 16:9 → 5.2:2.5 (wider cinematic landscape ~2.08:1)
  • fill_color: #808080 → #522525 (dark red for better visual contrast)
  • IMAGE MODE: ON → OFF (disabled by default, manual-first workflow)

Why These Defaults?

  • 1024×1024 is universally compatible with SD1.5, SDXL, Flux, and Illustrious
  • divisible_by=16 ensures compatibility across all modern models
  • Manual workflow (IMAGE MODE off) encourages intentional dimension control
  • Wider landscape ratio provides cinematic/presentation format option
  • Dark red fill improves visual debugging vs medium gray

Improved - Documentation

  • NEW Screenshot: Showcases IMAGE output feature with dual output capability
  • Shows node outputting through both 'image' and 'latent' paths
  • Caption explicitly mentions both output options
  • Uses new default values (5.2:2.5 AR, 1024×1024, dark red fill)

Technical

  • Defaults synchronized across three layers:
    • Backend: py/smart_resolution_calc.py INPUT_TYPES
    • Frontend: web/smart_resolution_calc.js widget creation
    • Validation: WIDGET_SCHEMAS for corruption healing
  • Applied to new nodes and corrupted workflow healing
  • No breaking changes to existing workflows

v0.5.3 - Zero-Cost Logging Performance

Fixed - Performance Overhead

Eliminated performance impact of debug logging for normal users:

Performance Results (200K operations, 20 widgets):

  • Before (unguarded): +112.31% overhead (13.80ms)
  • After (guarded): -6.15% overhead (6.10ms) ← essentially zero cost
  • Saved: 7.70ms per 200K operations

Technical Solution:

  • Applied if (logger.debugEnabled) guards around expensive logging
  • Protected JSON.stringify calls in restore loops (4 locations)
  • Protected large object logging (8 locations)
  • Protected template literal evaluations (15+ locations)

Root Cause:
JavaScript evaluates function arguments before calling functions, so even with early return in logger.debug(), expensive operations (JSON.stringify, template literals) execute. Guards prevent argument evaluation entirely.

Added - Performance Test Infrastructure

Cross-platform testing framework:

  • tests/one-offs/performance/test_logging_performance.html - Synthetic benchmark
  • tests/one-offs/run_performance_tests.py - Test runner (Windows/Linux/macOS)
  • tests/one-offs/clean_performance_tests.py - Cleanup utility
  • Tests copy to web/tests/ temporarily (gitignored)

Fixed - Pre-commit Hook

  • Changed pattern from ^.*.log to ^.*\.log$ (escaped dot + end anchor)
  • Previously matched substring .log in filenames like test_logging_performance.html
  • Now correctly matches only files ending in .log extension

Installation

Install via ComfyUI Manager or:

cd ComfyUI/custom_nodes
git clone https://github.com/djdarcy/ComfyUI-Smart-Resolution-Calc.git

Registry

  • ComfyUI Registry: v0.5.4 published
  • Node ID: comfyui-smart-resolution-calc
  • Publisher: djdarcy