Merge branch 'comfyanonymous:master' into master

This commit is contained in:
patientx 2025-06-03 16:34:28 +03:00 committed by GitHub
commit 19173c4a28
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 38 additions and 2 deletions

View File

@ -16,7 +16,8 @@ from inspect import cleandoc
import torch import torch
import comfy.utils import comfy.utils
from comfy.comfy_types import FileLocator from comfy.comfy_types import FileLocator, IO
from server import PromptServer
MAX_RESOLUTION = nodes.MAX_RESOLUTION MAX_RESOLUTION = nodes.MAX_RESOLUTION
@ -491,6 +492,36 @@ class SaveSVGNode:
counter += 1 counter += 1
return { "ui": { "images": results } } return { "ui": { "images": results } }
class GetImageSize:
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"image": (IO.IMAGE,),
},
"hidden": {
"unique_id": "UNIQUE_ID",
}
}
RETURN_TYPES = (IO.INT, IO.INT)
RETURN_NAMES = ("width", "height")
FUNCTION = "get_size"
CATEGORY = "image"
DESCRIPTION = """Returns width and height of the image, and passes it through unchanged."""
def get_size(self, image, unique_id=None) -> tuple[int, int]:
height = image.shape[1]
width = image.shape[2]
# Send progress text to display size on the node
if unique_id:
PromptServer.instance.send_progress_text(f"width: {width}, height: {height}", unique_id)
return width, height
NODE_CLASS_MAPPINGS = { NODE_CLASS_MAPPINGS = {
"ImageCrop": ImageCrop, "ImageCrop": ImageCrop,
"RepeatImageBatch": RepeatImageBatch, "RepeatImageBatch": RepeatImageBatch,
@ -500,4 +531,5 @@ NODE_CLASS_MAPPINGS = {
"SaveAnimatedPNG": SaveAnimatedPNG, "SaveAnimatedPNG": SaveAnimatedPNG,
"SaveSVGNode": SaveSVGNode, "SaveSVGNode": SaveSVGNode,
"ImageStitch": ImageStitch, "ImageStitch": ImageStitch,
"GetImageSize": GetImageSize,
} }

View File

@ -2067,6 +2067,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"ImageQuantize": "Image Quantize", "ImageQuantize": "Image Quantize",
"ImageSharpen": "Image Sharpen", "ImageSharpen": "Image Sharpen",
"ImageScaleToTotalPixels": "Scale Image to Total Pixels", "ImageScaleToTotalPixels": "Scale Image to Total Pixels",
"GetImageSize": "Get Image Size",
# _for_testing # _for_testing
"VAEDecodeTiled": "VAE Decode (Tiled)", "VAEDecodeTiled": "VAE Decode (Tiled)",
"VAEEncodeTiled": "VAE Encode (Tiled)", "VAEEncodeTiled": "VAE Encode (Tiled)",

View File

@ -5,7 +5,10 @@ from unittest.mock import patch, MagicMock
mock_nodes = MagicMock() mock_nodes = MagicMock()
mock_nodes.MAX_RESOLUTION = 16384 mock_nodes.MAX_RESOLUTION = 16384
with patch.dict('sys.modules', {'nodes': mock_nodes}): # Mock server module for PromptServer
mock_server = MagicMock()
with patch.dict('sys.modules', {'nodes': mock_nodes, 'server': mock_server}):
from comfy_extras.nodes_images import ImageStitch from comfy_extras.nodes_images import ImageStitch