Skip to content

Commit b43e91d

Browse files
bigcat88lrivera
authored andcommitted
[V3] converted nodes_images.py to V3 schema (Comfy-Org#11206)
* converted nodes_images.py to V3 schema * fix test
1 parent aeec93e commit b43e91d

File tree

5 files changed

+354
-362
lines changed

5 files changed

+354
-362
lines changed

comfy_api/latest/_io.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@
2828
prune_dict, shallow_clone_class)
2929
from ._resources import Resources, ResourcesLocal
3030
from comfy_execution.graph_utils import ExecutionBlocker
31-
from ._util import MESH, VOXEL
31+
from ._util import MESH, VOXEL, SVG as _SVG
3232

33-
# from comfy_extras.nodes_images import SVG as SVG_ # NOTE: needs to be moved before can be imported due to circular reference
3433

3534
class FolderType(str, Enum):
3635
input = "input"
@@ -656,7 +655,7 @@ class Video(ComfyTypeIO):
656655

657656
@comfytype(io_type="SVG")
658657
class SVG(ComfyTypeIO):
659-
Type = Any # TODO: SVG class is defined in comfy_extras/nodes_images.py, causing circular reference; should be moved to somewhere else before referenced directly in v3
658+
Type = _SVG
660659

661660
@comfytype(io_type="LORA_MODEL")
662661
class LoraModel(ComfyTypeIO):

comfy_api/latest/_util/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from .video_types import VideoContainer, VideoCodec, VideoComponents
22
from .geometry_types import VOXEL, MESH
3+
from .image_types import SVG
34

45
__all__ = [
56
# Utility Types
@@ -8,4 +9,5 @@
89
"VideoComponents",
910
"VOXEL",
1011
"MESH",
12+
"SVG",
1113
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from io import BytesIO
2+
3+
4+
class SVG:
5+
"""Stores SVG representations via a list of BytesIO objects."""
6+
7+
def __init__(self, data: list[BytesIO]):
8+
self.data = data
9+
10+
def combine(self, other: 'SVG') -> 'SVG':
11+
return SVG(self.data + other.data)
12+
13+
@staticmethod
14+
def combine_all(svgs: list['SVG']) -> 'SVG':
15+
all_svgs_list: list[BytesIO] = []
16+
for svg_item in svgs:
17+
all_svgs_list.extend(svg_item.data)
18+
return SVG(all_svgs_list)

0 commit comments

Comments
 (0)