{ "kind": "open-flow-workflow", "version": 1, "name": "Generate a Custom Placeholder Image", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_c914c2eff22ff02f": { "name": "Run the example", "kind": "start", "inputDefs": [] }, "n_c677a0c264c4844b": { "inputs": { "size": { "kind": "value", "value": "600x400" }, "backgroundColor": { "kind": "value", "value": "cc22e3" }, "textColor": { "kind": "value", "value": "ffffff" }, "text": { "kind": "value", "value": "Generated!" }, "fontSize": { "kind": "value", "value": "100" }, "type": { "kind": "value", "value": "png" }, "fontFamily": { "kind": "value", "value": "pacifico" } }, "name": "Generate the image", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "size" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "backgroundColor" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "textColor" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "text" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "fontSize" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "type" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "fontFamily" } ], "outputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "file" } ], "name": "Generate the image", "moduleId": "n_9efc6db5f3a3e61f", "capabilities": [ { "kind": "http", "hosts": [ "dummyjson.com" ] } ] } }, "n_059714c98a48bab5": { "name": "Generated image", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "file" } ], "outputMappings": { "file": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_c677a0c264c4844b", "output": "file" } ] } } } }, "edges": [ { "source": "n_c914c2eff22ff02f", "target": "n_c677a0c264c4844b" }, { "source": "n_c677a0c264c4844b", "target": "n_059714c98a48bab5" } ] } }, "modules": { "n_9efc6db5f3a3e61f": { "name": "Generate the image", "imports": [], "source": "import {Buffer} from 'node:buffer';\nexport default async function generate({size,backgroundColor,textColor,text,fontSize,type,fontFamily},context){\n const q=new URLSearchParams({text,fontSize,type,fontFamily});const url=`https://dummyjson.com/image/${encodeURIComponent(size)}/${encodeURIComponent(backgroundColor)}/${encodeURIComponent(textColor)}?${q}`;\n const r=await context.fetch(url,{method:'GET'});if(!r.ok)throw Error('Image request failed');const bytes=Buffer.from(await r.arrayBuffer());if(!bytes.length)throw Error('Empty image response');return{file:{name:'placeholder.'+type,mimeType:r.headers.get('content-type'),contentBase64:bytes.toString('base64')}};\n}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }