diff --git a/nodes/workflow_generator.py b/nodes/workflow_generator.py index 82d3762..ba67155 100644 --- a/nodes/workflow_generator.py +++ b/nodes/workflow_generator.py @@ -1058,6 +1058,22 @@ class WorkflowGenerator: return int(default) width = _to_int(overrides.get('width', res['width']), 512) height = _to_int(overrides.get('height', res['height']), 512) + # Last-resort fallback: if the template wires width/height to a + # runtime node-ref (e.g. ImageResizeKJv2 output in i2v), the static + # JSON value is just the resize target, not the actual output size. + # In that case — and when no UI override was set — read the real + # dimensions directly from the source_image tensor instead. + if source_image is not None and hasattr(source_image, 'shape'): + src_h = source_image.shape[1] # [B, H, W, C] + src_w = source_image.shape[2] + w_is_ref = res.get('_width_from_node_ref', False) + h_is_ref = res.get('_height_from_node_ref', False) + # Only override when the template used a node-ref (runtime value) + # AND the user hasn't explicitly set width/height via the UI. + if w_is_ref and 'width' not in overrides: + width = src_w + if h_is_ref and 'height' not in overrides: + height = src_h length = overrides.get('length', res.get('length')) batch = ( _to_int(length, 1) if length is not None diff --git a/py/workflow_extraction_utils.py b/py/workflow_extraction_utils.py index 88763b1..cd26b13 100644 --- a/py/workflow_extraction_utils.py +++ b/py/workflow_extraction_utils.py @@ -359,6 +359,10 @@ def extract_resolution(prompt_data, workflow_data): w = inp.get('width', resolution['width']) h = inp.get('height', resolution['height']) b = inp.get('batch_size', resolution['batch_size']) + # Track whether width/height came from node-refs (runtime values) + # so execute() knows it can use source_image dims as a better fallback. + resolution['_width_from_node_ref'] = isinstance(w, list) + resolution['_height_from_node_ref'] = isinstance(h, list) resolution['width'] = _scalar(w, resolution['width'], 'width') resolution['height'] = _scalar(h, resolution['height'], 'height') # batch_size in WanImageToVideo can equal 'length' — clamp to 1 if > 64