Edit Image
Edits images using Google's Gemini API based on a text prompt and mask image.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Connection Id - The connection ID obtained from the Connect node.
- Edit Prompt - Describe what changes you want to make to the image.
- Base Image Path - Path to the image you want to edit.
- Mask Image Path - Path to mask image (white areas will be edited).
Options
- Model - The model to use for image editing. Options include:
- Imagen 3.0 Edit
- Custom Model
- Custom Model - Custom model name when "Custom Model" is selected for Model.
- Number of Images - Number of variations to generate (1-4). Default is 1.
- Negative Prompt - Describe what you don't want in the edited areas.
- Output Format - Format for the output images. Options are:
- PNG
- JPEG
- WebP
- Output Quality - JPEG quality (1-100, only for JPEG format).
- Timeout (seconds) - Request timeout in seconds (default: 120).
Output
- Edited Images - The generated edited images with file paths and metadata.
How It Works
The Edit Image node modifies images using Google's Gemini API based on a text prompt and mask. When executed, the node:
- Validates the provided connection ID, edit prompt, and image file paths
- Ensures the base and mask image files exist
- Configures the image editing parameters including model, number of images, and output format
- Reads the base and mask images from the file system
- Sends an image editing request to the Gemini API
- Saves the edited images to a temporary directory
- Returns structured information about the edited images including file paths and metadata
Requirements
- A valid Google Gemini API key
- Connection ID from a successful Connect node execution
- Valid base image file path
- Valid mask image file path
- Edit prompt describing the desired changes
Error Handling
The node will return specific errors in the following cases:
- Empty or invalid Connection ID
- Empty or invalid Edit Prompt
- Empty or invalid Base Image Path
- Empty or invalid Mask Image Path
- Base image file not found
- Mask image file not found
- Edit prompt too long (maximum 1000 characters)
- Negative prompt too long (maximum 1000 characters)
- Invalid number of images value
- Invalid output quality value (must be between 1 and 100 for JPEG)
- Invalid custom model name
- API errors from Google's Gemini service
Usage Notes
- The edit prompt should clearly describe the changes you want to make
- The mask image should have white areas where you want edits to occur
- Edited images are saved to a temporary directory with unique names
- The maximum length for edit prompts and negative prompts is 1000 characters
- For JPEG output, quality can be adjusted between 1-100
- The default timeout is 120 seconds, which can be adjusted for complex edits
- The node returns file paths to the edited images, which can be used by other nodes