(cls, image, enable=True)
| 29 | |
| 30 | @classmethod |
| 31 | def execute(cls, image, enable=True) -> io.NodeOutput: |
| 32 | ui_images = [] |
| 33 | if enable and image is not None and getattr(image, "ndim", 0) == 4 and image.shape[0] > 0: |
| 34 | try: |
| 35 | import os |
| 36 | import time |
| 37 | import random |
| 38 | import numpy as np |
| 39 | import folder_paths |
| 40 | from PIL import Image as PILImage |
| 41 | from server import PromptServer |
| 42 | |
| 43 | out_dir = folder_paths.get_temp_directory() |
| 44 | os.makedirs(out_dir, exist_ok=True) |
| 45 | arr = (image[0].cpu().numpy() * 255.0).clip(0, 255).astype(np.uint8) |
| 46 | fn = f"ideogram_ref_{int(time.time() * 1000)}_{random.randint(0, 9999)}.png" |
| 47 | PILImage.fromarray(arr).save(os.path.join(out_dir, fn)) |
| 48 | payload = {"filename": fn, "subfolder": "", "type": "temp"} |
| 49 | PromptServer.instance.send_sync("ideogram-studio.ref-sync", payload) |
| 50 | ui_images = [payload] |
| 51 | except Exception as e: |
| 52 | print(f"[IdeogramRefSync] sync failed: {e}") |
| 53 | |
| 54 | return io.NodeOutput(image, ui={"images": ui_images}) |
nothing calls this directly
no outgoing calls
no test coverage detected