# comfyui自定义节点开发 **Repository Path**: bfanfanfan/comfyui_custom_node ## Basic Information - **Project Name**: comfyui自定义节点开发 - **Description**: 基于comfyui实现自定义节点 - **Primary Language**: Python - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2024-05-26 - **Last Updated**: 2024-11-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 节点列表 | 节点 | 功能 | python文件 | |-----------------------------------------|---------------|------------------------| | [AddTextToImage](#addtexttoimage) | 给生成的图片添加自定义文案 | [add_text_2_img.py](/add_text_2_img.py) | | [ChineseCLIPEncode](#chineseclipencode) | 支持输入中文prompt | [chinese_clip_encode.py](/chinese_clip_encode.py) | # AddTextToImage ## 功能 基于comfyui开发的一个自定义节点,用于给生成的图片添加自定义文案(如作者信息、时间信息、图片描述等) ## 依赖库 ```shell pillow==10.4.0 numpy==1.22.3 torch(作者这里使用的版本是 2.0.1+cu118) ``` ## 使用方式 克隆该仓库,然后将文件 `add_text_2_img.py` 复制到 `comfyui/custom_nodes` 目录下,重启 `comfyui`。 - 节点位置:Add Node / AI_Boy / AddTextToImage ![img_2.png](img/img_2.png) ![img_1.png](img/img_1.png) ## 字体 其中,fonts文件夹(如果需要指定自定义字体,则需要手动创建该文件夹,位置为 comfyui/custom_nodes/fonts)中存放的是本地字体文件,即文案展示时的字体样式,该字体文件非必须,可以在节点中直接指定字体的路径。支持的字体格式后缀为`.ttf/.TTF/.ttc/.TTC` ## 节点属性 | 属性 | 描述 | 必须 | |------------------|------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------| | image | 节点的输入类型必须为image | 是 | | IMAGE | 节点的输出类型为IMAGE | 是 | | x | 文案展示在图片x轴坐标的位置 | 否。默认位于图片正下方 | | y | 文案展示在图片y轴坐标的位置 | 否。默认位于图片正下方 | | font_size | 字体大小 | 是 | | font_family | 字体样式 | 是。
如果 fonts 文件夹下有字体,则可以选择 fonts 文件夹(comfyui/custom_nodes/fonts)中的字体。当该属性的值为 "Custom" 时,需要指定 "custom_font_path" 属性的值 | | custom_font_path | 字体路径,如指定windows中自带的字体路径 "C:\Windows\Fonts\SIMLI.TTF" | 否。
当 "font_family"="Custom" 时,需要指定 "custom_font_path" 属性的值 | | font_color | 字体颜色,支持RGB格式(255,255,255)、十六进制格式(#000000) | 是。默认为 "#ffffff",即白色 | | font_shadow_x | 字体阴影x轴偏移量 | 否。默认为0 | | font_shadow_y | 字体阴影y轴偏移量 | 否。默认为0 | | shadow_color | 字体阴影颜色 | 否。
当属性 "font_shadow_x"=0 并且属性 "font_shadow_y"=0 时,该属性不生效。
当属性 "font_shadow_x" 与 属性 "font_shadow_y" 有一个不为0时,该属性生效,且需要指定该属性的值。默认为 "#000000",即黑色 | # ChineseCLIPEncode ## 功能 基于comfyui开发的一个自定义节点,可以直接输入中文prompt,最终会将中文翻译成英文进行CLIP编码 ## 依赖库 ```shell translate==3.6.1 ``` ## 使用方式 克隆该仓库,然后将文件 `chinese_clip_encode.py` 复制到 `comfyui/custom_nodes` 目录下,重启 `comfyui`。 - 节点位置:Add Node / AI_Boy / ChineseCLIPEncode ![img.png](img.png)