diff --git a/comfy_api_nodes/apis/recraft_api.py b/comfy_api_nodes/apis/recraft_api.py
index c0ec9d0c8..c36d95f24 100644
--- a/comfy_api_nodes/apis/recraft_api.py
+++ b/comfy_api_nodes/apis/recraft_api.py
@@ -81,7 +81,6 @@ class RecraftStyle:
class RecraftIO:
STYLEV3 = "RECRAFT_V3_STYLE"
- SVG = "SVG" # TODO: if acceptable, move into ComfyUI's typing class
COLOR = "RECRAFT_COLOR"
CONTROLS = "RECRAFT_CONTROLS"
diff --git a/comfy_api_nodes/nodes_recraft.py b/comfy_api_nodes/nodes_recraft.py
index 994f377d1..5c89d21e9 100644
--- a/comfy_api_nodes/nodes_recraft.py
+++ b/comfy_api_nodes/nodes_recraft.py
@@ -1,6 +1,7 @@
from __future__ import annotations
from inspect import cleandoc
from comfy.utils import ProgressBar
+from comfy_extras.nodes_images import SVG # Added
from comfy.comfy_types.node_typing import IO
from comfy_api_nodes.apis.recraft_api import (
RecraftImageGenerationRequest,
@@ -28,9 +29,6 @@ from comfy_api_nodes.apinode_utils import (
resize_mask_to_image,
validate_string,
)
-import folder_paths
-import json
-import os
import torch
from io import BytesIO
from PIL import UnidentifiedImageError
@@ -162,102 +160,6 @@ class handle_recraft_image_output:
raise Exception("Received output data was not an image; likely an SVG. If you used style_id, make sure it is not a Vector art style.")
-class SVG:
- """
- Stores SVG representations via a list of BytesIO objects.
- """
- def __init__(self, data: list[BytesIO]):
- self.data = data
-
- def combine(self, other: SVG):
- return SVG(self.data + other.data)
-
- @staticmethod
- def combine_all(svgs: list[SVG]):
- all_svgs = []
- for svg in svgs:
- all_svgs.extend(svg.data)
- return SVG(all_svgs)
-
-
-class SaveSVGNode:
- """
- Save SVG files on disk.
- """
-
- def __init__(self):
- self.output_dir = folder_paths.get_output_directory()
- self.type = "output"
- self.prefix_append = ""
-
- RETURN_TYPES = ()
- DESCRIPTION = cleandoc(__doc__ or "") # Handle potential None value
- FUNCTION = "save_svg"
- CATEGORY = "api node/image/Recraft"
- OUTPUT_NODE = True
-
- @classmethod
- def INPUT_TYPES(s):
- return {
- "required": {
- "svg": (RecraftIO.SVG,),
- "filename_prefix": ("STRING", {"default": "svg/ComfyUI", "tooltip": "The prefix for the file to save. This may include formatting information such as %date:yyyy-MM-dd% or %Empty Latent Image.width% to include values from nodes."})
- },
- "hidden": {
- "prompt": "PROMPT",
- "extra_pnginfo": "EXTRA_PNGINFO"
- }
- }
-
- def save_svg(self, svg: SVG, filename_prefix="svg/ComfyUI", prompt=None, extra_pnginfo=None):
- filename_prefix += self.prefix_append
- full_output_folder, filename, counter, subfolder, filename_prefix = folder_paths.get_save_image_path(filename_prefix, self.output_dir)
- results = list()
-
- # Prepare metadata JSON
- metadata_dict = {}
- if prompt is not None:
- metadata_dict["prompt"] = prompt
- if extra_pnginfo is not None:
- metadata_dict.update(extra_pnginfo)
-
- # Convert metadata to JSON string
- metadata_json = json.dumps(metadata_dict, indent=2) if metadata_dict else None
-
- for batch_number, svg_bytes in enumerate(svg.data):
- filename_with_batch_num = filename.replace("%batch_num%", str(batch_number))
- file = f"{filename_with_batch_num}_{counter:05}_.svg"
-
- # Read SVG content
- svg_bytes.seek(0)
- svg_content = svg_bytes.read().decode('utf-8')
-
- # Inject metadata if available
- if metadata_json:
- # Create metadata element with CDATA section
- metadata_element = f"""
-
-
-"""
- # Insert metadata after opening svg tag using regex
- import re
- svg_content = re.sub(r'(