- os module imported properly instead of __import__("os")
- browse_folder distinguishes a real COM/dialog failure from a user cancel
- fix Marshal.PtrToStringUni + leak-safe cleanup in the folder-picker COM call
- lock browse_folder so two concurrent clicks can't open two dialogs
- drop redundant int(round()) in SmartResolutionMultiplier
- unify "CraftKit —" docstring prefix across nodes
- comment OUTPUT_NODE=True on the status-label nodes so it isn't "cleaned up" later
- add .jfif/.avif/.heic to SmartBatchResize's supported extensions, document non-recursive scanning
- add a progress bar to SmartBatchResize (degrades gracefully outside a live ComfyUI)
- add readme/requires-python and a dependency-rationale comment to pyproject.toml
55 lines
2.0 KiB
Python
55 lines
2.0 KiB
Python
class SmartResolutionMultiplier:
|
|
"""
|
|
Multiplies image dimensions by a factor.
|
|
Outputs width, height, and resolution (longest side) as INT.
|
|
Use resolution output directly with SeedVR2's resolution input.
|
|
"""
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"image": ("IMAGE", {
|
|
"tooltip": "Source image. Its current width/height are read directly, no separate Get Image Size node needed."
|
|
}),
|
|
"multiplier": ("FLOAT", {
|
|
"default": 2.0,
|
|
"min": 0.1,
|
|
"max": 16.0,
|
|
"step": 0.1,
|
|
"round": 0.01,
|
|
"tooltip": "Multiply width and height by this factor. E.g. 2.0 = double resolution."
|
|
}),
|
|
"multiple_of": ("INT", {
|
|
"default": 8,
|
|
"min": 1,
|
|
"max": 64,
|
|
"step": 1,
|
|
"tooltip": "Snap output dimensions to a multiple of this value."
|
|
}),
|
|
}
|
|
}
|
|
|
|
RETURN_TYPES = ("INT", "INT", "INT")
|
|
RETURN_NAMES = ("width", "height", "resolution")
|
|
FUNCTION = "run"
|
|
CATEGORY = "CraftKit"
|
|
|
|
def run(self, image, multiplier, multiple_of):
|
|
h, w = image.shape[1], image.shape[2]
|
|
|
|
new_w = round(w * multiplier)
|
|
new_h = round(h * multiplier)
|
|
|
|
if multiple_of > 1:
|
|
new_w = max(multiple_of, round(new_w / multiple_of) * multiple_of)
|
|
new_h = max(multiple_of, round(new_h / multiple_of) * multiple_of)
|
|
|
|
resolution = max(new_w, new_h)
|
|
print(f"[SmartResolutionMultiplier] {w}x{h} x {multiplier} -> {new_w}x{new_h} (resolution: {resolution})")
|
|
return (new_w, new_h, resolution)
|
|
|
|
|
|
NODE_CLASS_MAPPINGS = {"SmartResolutionMultiplier": SmartResolutionMultiplier}
|
|
NODE_DISPLAY_NAME_MAPPINGS = {"SmartResolutionMultiplier": "Smart Resolution Multiplier 📏"}
|