Overview
The Edit Image+ node in n8n allows you to programmatically create a new image with custom dimensions and background color. This is particularly useful for generating placeholder images, backgrounds, or base canvases for further image processing within your workflow. For example, you might use this node to create a blank image before overlaying text, drawing shapes, or compositing other images.
Practical Examples
- Generate a blank canvas: Create a transparent or colored image of specific size to serve as a background for further editing.
- Automated graphics generation: Dynamically generate images for reports, dashboards, or social media posts.
- Workflow automation: Prepare an image base for subsequent steps like adding watermarks, logos, or annotations.
Properties
Below are the input properties relevant to the Default Resource and Create Operation:
Display Name | Type | Description |
---|---|---|
Property Name | String | Name of the binary property in which the image data can be found. |
Background Color | Color | The background color of the image to create (supports alpha channel). |
Image Width | Number | The width of the image to create (minimum: 1). |
Image Height | Number | The height of the image to create (minimum: 1). |
Options | Collection | Additional options for output formatting and metadata. Contains: |
File Name | String | File name to set in binary data. |
Format | Options | Set the output image format (bmp , gif , jpeg , png , tiff , webp ). |
Quality | Number | Sets the compression level for jpeg , png , or tiff formats (0–100, best at 100). |
Font Name or ID | Options | (Not used in Create operation) |
Output
The node outputs an item with the following structure:
- json:
- Contains the original input JSON data (if any).
- binary:
- A property (default:
"data"
, or as specified by Property Name) containing:data
: The generated image file as binary data.mimeType
: MIME type corresponding to the selected format (e.g.,image/png
).fileExtension
: File extension matching the format (e.g.,png
).fileName
: (Optional) File name if specified in options.
- A property (default:
Example Output Structure:
{
"json": { /* original input */ },
"binary": {
"data": {
"data": "<binary image data>",
"mimeType": "image/png",
"fileExtension": "png",
"fileName": "example.png"
}
}
}
Note: The node outputs only binary data representing the created image. No additional metadata is included unless present in the input.
Dependencies
External Libraries:
- gm (GraphicsMagick/ImageMagick): Used for image creation and manipulation.
- tmp-promise: Handles temporary files during processing.
- get-system-fonts: (Not used in Create operation)
n8n Requirements:
- The host environment must have GraphicsMagick or ImageMagick installed and accessible.
No API keys or external services required for the Create operation.
Troubleshooting
Common Issues:
Missing GraphicsMagick/ImageMagick:
- Error:
Command failed: gm ... not found
- Solution: Ensure that either GraphicsMagick or ImageMagick is installed on your server and available in the system PATH.
- Error:
Invalid Dimensions:
- Error:
width/height must be >= 1
- Solution: Make sure both Image Width and Image Height are set to values greater than or equal to 1.
- Error:
Unsupported Format:
- Error:
Unknown image format
- Solution: Choose a supported format from the Format option.
- Error:
Permission Issues Writing Temporary Files:
- Error:
EACCES: permission denied
- Solution: Ensure the n8n process has write access to the system's temporary directory.
- Error:
Links and References
- n8n Documentation: Binary Data
- GraphicsMagick Documentation
- ImageMagick Documentation
- gm npm package
- tmp-promise npm package
Summary:
The Edit Image+ node's Create operation is ideal for generating new images with customizable size and background color, outputting them as binary data for further use in your n8n workflows.