add workflows, etc

This commit is contained in:
Sirshendu Ganguly
2026-02-25 22:35:30 -05:00
parent dee0949f78
commit bc7b906bbd
12 changed files with 445 additions and 48 deletions
+20 -4
View File
@@ -8,13 +8,25 @@ from PIL import Image
from datetime import datetime
def _is_svg_url(url: str) -> bool:
"""True if URL points to SVG (e.g. from Runware Vectorize)."""
u = (url or "").split("?")[0].lower()
return u.endswith(".svg")
def _bytes_to_image_tensor(img_data: bytes):
"""Decode image bytes to ComfyUI IMAGE tensor [1, H, W, C] float32 0-1."""
"""Decode image bytes to ComfyUI IMAGE tensor [1, H, W, C] float32 0-1. Fails on SVG (use placeholder for SVG)."""
pil = Image.open(io.BytesIO(img_data)).convert("RGB")
arr = np.array(pil).astype(np.float32) / 255.0
return torch.from_numpy(arr).unsqueeze(0)
def _placeholder_image_tensor():
"""Return a 1x1 RGB placeholder tensor [1, 1, 1, 3] for non-raster outputs (e.g. SVG from Vectorize)."""
arr = np.ones((1, 1, 3), dtype=np.float32) * 0.5 # grey
return torch.from_numpy(arr).unsqueeze(0)
class RunwareSaveImage:
"""Runware Save Image: download from URL(s), save/preview to disk, and forward as IMAGE for chaining."""
@@ -23,7 +35,7 @@ class RunwareSaveImage:
return {
"required": {
"Images": ("STRING", {
"tooltip": "Image URL(s) from Runware Image Inference node. For multiple images, URLs should be comma-separated."
"tooltip": "Image URL(s) from Runware Image Inference or Runware Vectorize node. For multiple images, URLs should be comma-separated. SVG URLs (e.g. from Vectorize) are saved as .svg files; a placeholder tensor is passed for the IMAGE output."
}),
"filenamePrefix": ("STRING", {
"default": "ComfyUI",
@@ -69,10 +81,14 @@ class RunwareSaveImage:
response.raise_for_status()
img_data = response.content
tensors.append(_bytes_to_image_tensor(img_data))
# SVG (e.g. from Runware Vectorize) cannot be opened by PIL; save as file and use placeholder tensor
if _is_svg_url(image_url):
tensors.append(_placeholder_image_tensor())
else:
tensors.append(_bytes_to_image_tensor(img_data))
url_without_params = image_url.split("?")[0]
ext = url_without_params.split(".")[-1].lstrip(".") or "png"
ext = url_without_params.split(".")[-1].lstrip(".").lower() or "png"
extension = "." + ext
if len(image_urls) > 1:
filename = f"{filenamePrefix}_{timestamp}_{i+1:03}{extension}"