added svg export node with trigger

This commit is contained in:
Aaron Burton
2026-03-18 20:13:22 -07:00
parent 79af116ef5
commit 1f6b5d7c4d
4 changed files with 93 additions and 9 deletions
+9
View File
@@ -32,6 +32,15 @@ except Exception as e:
_failed.append(("AugmentPNGToSVGPro", e))
print(f"[augment-vectorize] ⚠ AugmentPNGToSVGPro unavailable: {e}")
# ── Export SVG ──
try:
from .export_svg import AugmentExportSVG
NODE_CLASS_MAPPINGS["AugmentExportSVG"] = AugmentExportSVG
NODE_DISPLAY_NAME_MAPPINGS["AugmentExportSVG"] = "Export SVG"
except Exception as e:
_failed.append(("AugmentExportSVG", e))
print(f"[augment-vectorize] ⚠ AugmentExportSVG unavailable: {e}")
# ── Summary ──
WEB_DIRECTORY = "./web/js"
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]
+75
View File
@@ -0,0 +1,75 @@
# "Design-focused node suite for ComfyUI."
# Copyright 2026 Augment Studio
# Augmentstudio.app
import os
import json
import folder_paths
class AugmentExportSVG:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"svg": ("AUGMENT_SVG",),
"filename_prefix": ("STRING", {"default": "svg/augment"}),
},
"optional": {
"trigger": ("TRIGGER",),
},
}
RETURN_TYPES = ("TRIGGER")
RETURN_NAMES = ("trigger")
FUNCTION = "execute"
CATEGORY = "Augment/Enhance"
OUTPUT_NODE = True
@classmethod
def VALIDATE_INPUTS(cls, **kwargs):
return True
def execute(self, svg, filename_prefix="svg/export/asset", trigger=None):
output_dir = folder_paths.get_output_directory()
full_output_folder, filename, counter, subfolder, _ = (
folder_paths.get_save_image_path(filename_prefix, output_dir)
)
os.makedirs(full_output_folder, exist_ok=True)
file = f"{filename}_{counter:05}_.svg"
filepath = os.path.join(full_output_folder, file)
if isinstance(svg, bytes):
svg_data = svg
elif isinstance(svg, str):
svg_data = svg.encode("utf-8")
else:
svg_data = bytes(svg)
with open(filepath, "wb") as f:
f.write(svg_data)
size = len(svg_data)
print(f"[Augment] Exported SVG ({size} bytes) to {filepath}")
json_result = json.dumps({
"node": "AugmentExportSVG",
"file": file,
"subfolder": subfolder,
"size_bytes": size,
})
return {
"ui": {"images": [{"filename": file, "subfolder": subfolder, "type": "output"}]},
"result": (json_result, "done"),
}
NODE_CLASS_MAPPINGS = {
"AugmentExportSVG": AugmentExportSVG,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"AugmentExportSVG": "Export SVG",
}
+4 -5
View File
@@ -28,7 +28,7 @@ class AugmentPNGToSVGPro:
},
}
RETURN_TYPES = ("SVG", "AUGMENT_JSON", "TRIGGER")
RETURN_TYPES = ("AUGMENT_SVG", "AUGMENT_JSON", "TRIGGER")
RETURN_NAMES = ("svg", "json_result", "trigger")
FUNCTION = "execute"
CATEGORY = "Augment/Enhance"
@@ -106,13 +106,12 @@ class AugmentPNGToSVGPro:
if svg_r.status_code != 200:
raise RuntimeError(f"SVG fetch error: {svg_r.status_code}")
from comfy_api.latest._util.image_types import SVG
svg_bytes = io.BytesIO(svg_r.content)
size = svg_bytes.getbuffer().nbytes
svg_content = svg_r.content
size = len(svg_content)
print(f"[Augment API] Done! Received SVG ({size} bytes)")
json_result = json.dumps({"node": "PNGToSVGPro", "size_bytes": size})
return {"ui": {"text": [svg_r.text[:500]]}, "result": (SVG([svg_bytes]), json_result, "done")}
return {"ui": {"text": [svg_r.text[:500]]}, "result": (svg_content, json_result, "done")}
NODE_CLASS_MAPPINGS = {
+5 -4
View File
@@ -31,10 +31,11 @@ app.registerExtension({
window.open("https://augmentstudio.app/pricing", "_blank");
});
const jsonIdx = this.outputs?.findIndex(o => o.name === "json_result");
if (jsonIdx >= 0) {
this.outputs.splice(jsonIdx, 1);
}
this.outputs?.forEach(o => {
if (o.name === "json_result") {
o.hidden = true;
}
});
};
const origDraw = nodeType.prototype.onDrawForeground;