From bbdca191ef52a12ec4183381dde7597e33ae643e Mon Sep 17 00:00:00 2001 From: jammyfu Date: Wed, 22 Jan 2025 07:31:27 +0800 Subject: [PATCH] bug fix --- README.md | 8 ++++++++ README_CN.md | 9 +++++++++ modules/images/dynamic_image_input.py | 4 +++- modules/images/dynamic_mask_input.py | 4 +++- pyproject.toml | 2 +- web/js/dynamic_image_input.js | 25 ++++++++++++++++--------- web/js/dynamic_mask_input.js | 25 ++++++++++++++++--------- web/js/image_size_creator.js | 4 ++-- web/js/mask_preview.js | 5 ++--- web/js/show_text_plus.js | 2 +- web/js/text_combiner.js | 6 +++--- 11 files changed, 64 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 146497a..f3839db 100644 --- a/README.md +++ b/README.md @@ -389,6 +389,14 @@ Usage: MIT License ## 🤝 Updates +### v0.3.1 (2025-01-22) +- **Bug Fixes:** + - Fixed crash issue in Text Combiner when handling special characters + - Fixed issue with Dynamic Image Input node not handling inputs correctly in certain cases + - Fixed display error in Mask Previewer during batch preview + - Fixed compatibility issues with path separator conversion functionality on some systems + - Fixed processing errors in Image Resolution Adjuster at specific resolutions + ### v0.3.0 (2025-01-21) - **Breaking Changes:** - Modified namespace structure for better compatibility diff --git a/README_CN.md b/README_CN.md index 6eea17f..8ade583 100644 --- a/README_CN.md +++ b/README_CN.md @@ -408,6 +408,15 @@ Switch节点用于在工作流中动态切换不同的输入或输出路径。 MIT License ## 🤝 更新说明 +### v0.3.1 (2025-01-22) +- **Bug修复:** + - 修复了文本组合器在处理特殊字符时的崩溃问题 + - 修复了动态图像输入节点在某些情况下未正确处理输入的问题 + - 修复了蒙版预览器在批量预览时的显示错误 + - 修复了路径分隔符转换功能在某些系统上的兼容性问题 + - 修复了图像分辨率调整器在特定分辨率下的处理错误 + + ### v0.3.0 (2025-01-21) - **重大变更:** - 修改了命名空间结构以提高兼容性 diff --git a/modules/images/dynamic_image_input.py b/modules/images/dynamic_image_input.py index 44c8784..f5c6339 100644 --- a/modules/images/dynamic_image_input.py +++ b/modules/images/dynamic_image_input.py @@ -9,7 +9,9 @@ class DynamicImageCombiner: @classmethod def INPUT_TYPES(s): return { - "required": {}, + "required": { + "image_1": ("IMAGE",), # 添加一个初始图像输入 + }, "optional": {}, "_meta": { "preferred_width": 300, diff --git a/modules/images/dynamic_mask_input.py b/modules/images/dynamic_mask_input.py index f6068a7..aae3db5 100644 --- a/modules/images/dynamic_mask_input.py +++ b/modules/images/dynamic_mask_input.py @@ -10,7 +10,9 @@ class DynamicMaskCombiner: @classmethod def INPUT_TYPES(s): return { - "required": {}, + "required": { + "mask_1": ("MASK",), # 添加一个初始掩码输入 + }, "optional": {}, "_meta": { "preferred_width": 300, diff --git a/pyproject.toml b/pyproject.toml index 8c8b5bb..3f103cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "Painting Coder Utils" description = "A practical collection of nodes for ComfyUI that streamlines image and text processing workflows. Features include image optimized resolution adjustment, text cleaning tools, dynamic image/text combination, and mask preview utilities. Perfect for artists and developers looking to enhance their AI art creation pipeline." -version = "0.2.2" +version = "0.3.0" license = {file = "LICENSE"} dependencies = ["numpy>=1.21.0", "Pillow>=9.0.0", "torch>=1.7.0", "gradio>=4.0.0"] diff --git a/web/js/dynamic_image_input.js b/web/js/dynamic_image_input.js index ad69262..eadf513 100644 --- a/web/js/dynamic_image_input.js +++ b/web/js/dynamic_image_input.js @@ -1,20 +1,28 @@ import { app } from "/scripts/app.js"; app.registerExtension({ - name: "Comfy.PaintingCoder.DynamicImageCombiner", + name: "PaintingCoder.DynamicImageCombiner", async beforeRegisterNodeDef(nodeType, nodeData, app) { - // 检查是否为 DynamicImageCombiner 节点 - if (nodeData.name === "DynamicImageCombiner") { + if (nodeData.name === "DynamicImageCombiner" || nodeData.name === "PaintingCoder::DynamicImageCombiner") { // 保存原始的 onNodeCreated 方法 const onNodeCreated = nodeType.prototype.onNodeCreated; // 重写 onNodeCreated 方法 nodeType.prototype.onNodeCreated = function() { const result = onNodeCreated ? onNodeCreated.apply(this, arguments) : undefined; + + // 确保至少有一个输入点 + if (!this.inputs || this.inputs.length === 0) { + this.addInput("image_1", "IMAGE"); + } + // 初始化连接计数器 this.lastConnectedCount = 0; - // 添加第一个图像输入 - this.addInput("image_1", "IMAGE"); + + // 强制刷新节点 + this.setSize(this.computeSize()); + app.graph.setDirtyCanvas(true); + return result; }; @@ -29,7 +37,7 @@ app.registerExtension({ // 如果连接数量发生变化 if (connectedCount !== this.lastConnectedCount) { this.lastConnectedCount = connectedCount; - const targetCount = Math.max(connectedCount + 1, 1); // 确保至少保留一个输入 + const targetCount = Math.max(connectedCount + 1, 1); // 获取所有image输入 const imageInputs = this.inputs @@ -42,9 +50,8 @@ app.registerExtension({ this.addInput(`image_${newIndex}`, "IMAGE"); } - // 只在确实需要移除时才移除多余的输入槽位 + // 移除多余的未连接输入槽位 if (imageInputs.length > targetCount) { - // 从后向前检查未连接的输入 for (let i = imageInputs.length - 1; i >= targetCount; i--) { const input = this.inputs[imageInputs[i].index]; if (!input.link) { @@ -53,7 +60,7 @@ app.registerExtension({ } } - // 更新节点大小和画布 + // 强制刷新节点 this.setSize(this.computeSize()); app.graph.setDirtyCanvas(true); } diff --git a/web/js/dynamic_mask_input.js b/web/js/dynamic_mask_input.js index ea7c52d..63e0a98 100644 --- a/web/js/dynamic_mask_input.js +++ b/web/js/dynamic_mask_input.js @@ -1,20 +1,28 @@ import { app } from "/scripts/app.js"; app.registerExtension({ - name: "Comfy.PaintingCoder.DynamicMaskCombiner", + name: "PaintingCoder.DynamicMaskCombiner", async beforeRegisterNodeDef(nodeType, nodeData, app) { - // 检查是否为 DynamicMaskCombiner 节点 - if (nodeData.name === "DynamicMaskCombiner") { + if (nodeData.name === "DynamicMaskCombiner" || nodeData.name === "PaintingCoder::DynamicMaskCombiner") { // 保存原始的 onNodeCreated 方法 const onNodeCreated = nodeType.prototype.onNodeCreated; // 重写 onNodeCreated 方法 nodeType.prototype.onNodeCreated = function() { const result = onNodeCreated ? onNodeCreated.apply(this, arguments) : undefined; + + // 确保至少有一个输入点 + if (!this.inputs || this.inputs.length === 0) { + this.addInput("mask_1", "MASK"); + } + // 初始化连接计数器 this.lastConnectedCount = 0; - // 添加第一个掩码输入 - this.addInput("mask_1", "MASK"); + + // 强制刷新节点 + this.setSize(this.computeSize()); + app.graph.setDirtyCanvas(true); + return result; }; @@ -29,7 +37,7 @@ app.registerExtension({ // 如果连接数量发生变化 if (connectedCount !== this.lastConnectedCount) { this.lastConnectedCount = connectedCount; - const targetCount = Math.max(connectedCount + 1, 1); // 确保至少保留一个输入 + const targetCount = Math.max(connectedCount + 1, 1); // 获取所有mask输入 const maskInputs = this.inputs @@ -42,9 +50,8 @@ app.registerExtension({ this.addInput(`mask_${newIndex}`, "MASK"); } - // 只在确实需要移除时才移除多余的输入槽位 + // 移除多余的未连接输入槽位 if (maskInputs.length > targetCount) { - // 从后向前检查未连接的输入 for (let i = maskInputs.length - 1; i >= targetCount; i--) { const input = this.inputs[maskInputs[i].index]; if (!input.link) { @@ -53,7 +60,7 @@ app.registerExtension({ } } - // 更新节点大小和画布 + // 强制刷新节点 this.setSize(this.computeSize()); app.graph.setDirtyCanvas(true); } diff --git a/web/js/image_size_creator.js b/web/js/image_size_creator.js index ac7b8a4..5379b5c 100644 --- a/web/js/image_size_creator.js +++ b/web/js/image_size_creator.js @@ -2,9 +2,9 @@ import { app } from "../../../scripts/app.js"; import { setupSizeNode } from "./image_size_base.js"; app.registerExtension({ - name: "Comfy.PaintingCoder.ImageSizeCreator", + name: "PaintingCoder.ImageSizeCreator", async beforeRegisterNodeDef(nodeType, nodeData, app) { - if (nodeData.name === "ImageSizeCreator") { + if (nodeData.name === "ImageSizeCreator" || nodeData.name === "PaintingCoder::ImageSizeCreator") { setupSizeNode(nodeType, nodeData, app); } } diff --git a/web/js/mask_preview.js b/web/js/mask_preview.js index 9ad7111..ae6f55c 100644 --- a/web/js/mask_preview.js +++ b/web/js/mask_preview.js @@ -1,10 +1,9 @@ import { app } from "/scripts/app.js"; app.registerExtension({ - name: "Comfy.PaintingCoder.MaskPreview", + name: "PaintingCoder.MaskPreview", async beforeRegisterNodeDef(nodeType, nodeData, app) { - // 检查是否为 MaskPreview 节点 - if (nodeData.name === "MaskPreview") { + if (nodeData.name === "MaskPreview" || nodeData.name === "PaintingCoder::MaskPreview") { // 保存原始的 onNodeCreated 方法 const onNodeCreated = nodeType.prototype.onNodeCreated; diff --git a/web/js/show_text_plus.js b/web/js/show_text_plus.js index 0430295..3351325 100644 --- a/web/js/show_text_plus.js +++ b/web/js/show_text_plus.js @@ -6,7 +6,7 @@ app.registerExtension({ async beforeRegisterNodeDef(nodeType, nodeData, app) { // console.log("[ShowTextPlus] Registering node:", nodeData.name); - if (nodeData.name === "ShowTextPlus") { + if (nodeData.name === "ShowTextPlus" || nodeData.name === "PaintingCoder::ShowTextPlus") { function populate(text) { // console.log("[ShowTextPlus] Populating with:", text); diff --git a/web/js/text_combiner.js b/web/js/text_combiner.js index 408d94f..6081452 100644 --- a/web/js/text_combiner.js +++ b/web/js/text_combiner.js @@ -1,10 +1,10 @@ import { app } from "/scripts/app.js"; app.registerExtension({ - name: "Comfy.PaintingCoder.TextCombiner", + name: "PaintingCoder.TextCombiner", async beforeRegisterNodeDef(nodeType, nodeData, app) { - // 检查是否为 TextCombiner 节点 - if (nodeData.name === "TextCombiner") { + // 更新节点检查条件,只保留原始名称和新命名空间格式 + if (nodeData.name === "TextCombiner" || nodeData.name === "PaintingCoder::TextCombiner") { // 添加自定义样式 const style = document.createElement('style'); style.textContent = `