AI Modify Image
Controlled node
Overview
The AI Modify Image node transforms an existing image using a text prompt and AI image generation models. This is commonly known as "img2img" or image-to-image generation, where the AI uses the input image as a base and applies the modifications described in the prompt.
The node takes a Jimp image object as input, converts it to base64, and sends it to an AI model along with generation parameters. The model then returns a modified version of the image that reflects the prompt while maintaining the structural elements of the original.
This node is ideal for tasks like:
- Style transfer (e.g., "convert this photo to oil painting style")
- Image editing (e.g., "add a sunset background")
- Content modification (e.g., "change the color of the car to red")
- Image variation generation
Inputs
| Input | Type | Description | Default |
|---|---|---|---|
| Run | Event | Triggers the image modification process | - |
| Image | Data | The source image to modify (must be a Jimp image object) | - |
| Prompt | Text | Description of how to modify the image | - |
| Width | Number | Target width of the output image in pixels | 1024 |
| Height | Number | Target height of the output image in pixels | 768 |
| Guidance | Number | Controls how closely the AI follows the prompt (0-10 scale) | 7 |
| Steps | Number | Number of inference steps (higher = more detail but slower) | 28 |
Outputs
| Output | Type | Description |
|---|---|---|
| Output | Data | The modified image as a Jimp object |
| Done | Event | Fires when the image generation is complete |
Runtime Behavior and Defaults
Parameter Constraints
The node automatically validates and clamps input values to ensure valid image generation:
- Width/Height: Clamped between 32 and 1024 pixels. If invalid, defaults to 256.
- Guidance: Clamped between 0 and 10. If invalid, defaults to 1.
- Steps: Minimum value of 1. If invalid, defaults to 1.
- Seed: Although not exposed in the UI, the node uses a default seed of
1for reproducibility.
Image Processing
- The input image is cloned to avoid modifying the original
- Converted to base64 JPEG format for transmission to the AI service
- Sent to the image modification service with all parameters
- The returned base64 image is converted back to a Jimp object
Error Handling
- If the input image is not a valid Jimp object, the node outputs an empty string
- If image conversion to base64 fails, the node outputs an empty string
- All errors are logged to the console for debugging
Example Usage
Basic Style Transfer
Transform a photograph into an oil painting:
- Connect a Read Image node to the
Imageinput - Set the Prompt to:
"oil painting style, artistic, textured brush strokes" - Set Width to
1024and Height to1024for square output - Keep Guidance at
7for balanced prompt adherence - Trigger the Run event to generate the modified image
Workflow Integration
[Read Image] → [AI Modify Image] → [Write To Library]
↓ ↓ ↓
Image Output File
In this workflow:
- Read Image loads an image from the library
- AI Modify Image transforms it based on the prompt
- Write To Library saves the result back to the project library as a JPEG
Dynamic Resizing
To maintain aspect ratio while resizing, calculate dimensions before the node:
- Use the Image Size node to get original dimensions
- Use Formula nodes to calculate new width/height while preserving aspect ratio
- Feed these calculated values into the Width and Height inputs