1. Tasks
  2. Dynamic Image Generator

Tasks

Dynamic Image Generator

Generate an image based on a Fabric.js object

This task allows you to use Fabric.js to generate an image based on a Fabric.js object. This is useful for creating images dynamically based on user input or other data.
You can use substitution to inject data from the stub into the image.

TIP

You can use Fabric Studio to build your Fabric.js canvas visually.
Use the Export JSON button to get the canvas JSON object, then save it into the task's canvas property.

TIP

To build the initial Fabric.js object you can use Claude Try a prompt similar to this : Please can you generate a fabric.js object that... [your description], please respond with the JSON object only.

Basic usage

loading...

Parameters

width
number

The width of the image to generate in pixels.


height
number

The height of the image to generate in pixels.


canvas
object

The Fabric.js canvas object to use for generating the image. This should be a valid Fabric.js object.


file
object

The details of the file to create such as the filename and content_type.


Result

loading...

Properties

file

object

The details of the file that was created.


Examples

Generate two red rectangles on an 800 X 600 image

loading...

Image generated :

Inject Stubref into image

loading...

Image generated :

Fabric Studio

You can use Fabric Studio to build your Fabric.js canvas visually. The studio lets you create and edit Fabric.js objects, preview the canvas in real time, and export the canvas JSON for use in the dynamic image generator task.

To use a canvas from Fabric Studio:

  1. Open Fabric Studio.
  2. Create or edit your canvas.
  3. Use Export JSON to copy the Fabric.js canvas object.
  4. Paste the exported JSON into the dynamic image generator task's canvas property.

Fabric Studio can also load an existing Fabric.js canvas from the URL. Encode the canvas JSON as base64, then pass it in the load_json query parameter:

URL
        https://fabric-studio-workspace-615427407646.us-west1.run.app/?load_json=[base64 json canvas]

      

For example, if your canvas JSON is:

        {"objects":[{"type":"rect","left":100,"top":100,"width":50,"height":50,"fill":"red"}]}

      

Base64 encode the JSON and add it to the URL:

URL
        https://fabric-studio-workspace-615427407646.us-west1.run.app/?load_json=eyJvYmplY3RzIjpbeyJ0eXBlIjoicmVjdCIsImxlZnQiOjEwMCwidG9wIjoxMDAsIndpZHRoIjo1MCwiaGVpZ2h0Ijo1MCwiZmlsbCI6InJlZCJ9XX0=

      

If the encoded value contains URL-sensitive characters, URL encode the base64 string before adding it to load_json.