Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b08c2b609a | ||
|
|
a897eacbe8 |
+3
-2
@@ -1,10 +1,11 @@
|
||||
from .nodes import YARS, YARSAdv
|
||||
from .nodes import YARS, YARSAdv, YARSAdvFrack
|
||||
|
||||
|
||||
NODE_CLASS_MAPPINGS = {"YARS": YARS, "YARSAdv": YARSAdv}
|
||||
NODE_CLASS_MAPPINGS = {"YARS": YARS, "YARSAdv": YARSAdv, "YARSAdvFrack": YARSAdvFrack}
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"YARS": "yaResolution Selector",
|
||||
"YARSAdv": "yaResolution Selector (Advanced)",
|
||||
"YARSAdvFrack": "yaResolution Selector (Fractional)",
|
||||
}
|
||||
|
||||
|
||||
|
||||
+6
-1
@@ -141,7 +141,11 @@ app.registerExtension({
|
||||
name: "trop.YARS",
|
||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||
// add resolution printout
|
||||
if (nodeData.name === "YARSAdv" || nodeData.name === "YARS") {
|
||||
if (
|
||||
nodeData.name === "YARSAdvFrack" ||
|
||||
nodeData.name === "YARSAdv" ||
|
||||
nodeData.name === "YARS"
|
||||
) {
|
||||
const onExecuted = nodeType.prototype.onExecuted;
|
||||
nodeType.prototype.onExecuted = function (message) {
|
||||
const r = onExecuted?.apply?.(this, arguments);
|
||||
@@ -181,6 +185,7 @@ app.registerExtension({
|
||||
const entries = [
|
||||
{ name: "yaResolution Selector", value: "YARS" },
|
||||
{ name: "Advanced yaResolution Selector", value: "YARSAdv" },
|
||||
{ name: "Fractional yaResolution Selector", value: "YARSAdvFrack" },
|
||||
];
|
||||
for (const entry of entries) {
|
||||
options.unshift({
|
||||
|
||||
BIN
Binary file not shown.
@@ -212,6 +212,84 @@ class YARSAdv:
|
||||
}
|
||||
|
||||
|
||||
class YARSAdvFrack:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(self):
|
||||
return {
|
||||
"required": {
|
||||
"base_resolution": (
|
||||
"INT",
|
||||
{
|
||||
"default": 512,
|
||||
"min": 512,
|
||||
"max": 8192,
|
||||
"step": 128,
|
||||
},
|
||||
),
|
||||
"width_ratio": (
|
||||
"FLOAT",
|
||||
{
|
||||
"default": 1,
|
||||
"min": 0.1,
|
||||
"max": 24,
|
||||
"step": 0.01,
|
||||
},
|
||||
),
|
||||
"height_ratio": (
|
||||
"FLOAT",
|
||||
{
|
||||
"default": 1,
|
||||
"min": 0.1,
|
||||
"max": 24,
|
||||
"step": 0.01,
|
||||
},
|
||||
),
|
||||
"overextend": (
|
||||
"BOOLEAN",
|
||||
{"default": False, "label_on": "yes ", "label_off": "no "},
|
||||
),
|
||||
"constant_resolution": (
|
||||
"BOOLEAN",
|
||||
{"default": False, "label_on": "yes ", "label_off": "no "},
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("INT", "INT")
|
||||
RETURN_NAMES = ("width", "height")
|
||||
FUNCTION = "calculate"
|
||||
OUTPUT_NODE = False
|
||||
CATEGORY = "utils"
|
||||
|
||||
def calculate(
|
||||
self,
|
||||
base_resolution: int,
|
||||
width_ratio: float,
|
||||
height_ratio: float,
|
||||
overextend: bool,
|
||||
constant_resolution: bool,
|
||||
):
|
||||
ratio: float = height_ratio / width_ratio
|
||||
|
||||
if constant_resolution:
|
||||
d = calculate_constant_constant_resolution(base_resolution, ratio)
|
||||
else:
|
||||
d = calculate_aspect_ratio(base_resolution, ratio, overextend)
|
||||
|
||||
# return as dict with `ui` key to trigger onExecuted
|
||||
return {
|
||||
"ui": {
|
||||
"width": [d.width],
|
||||
"height": [d.height],
|
||||
"ratio": [width_ratio / height_ratio],
|
||||
},
|
||||
"result": (d.width, d.height),
|
||||
}
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import unittest
|
||||
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
[project]
|
||||
name = "ComfyUI-yaResolutionSelector"
|
||||
name = "comfyui-yaresolutionselector"
|
||||
description = "Freely adjust resolution and aspect ratio, maintain pixel count of StableDiffusion model, or hook it up to upscaling nodes to get that 5k 16:10 wallpaper in just few clicks."
|
||||
version = "1.2.0"
|
||||
license = "LICENSE"
|
||||
version = "1.3.0"
|
||||
license = {text = "GPL License"}
|
||||
|
||||
[project.urls]
|
||||
Repository = "https://github.com/Tropfchen/ComfyUI-yaResolutionSelector"
|
||||
|
||||
Reference in New Issue
Block a user