Skip to main content

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.

Use Case

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

InputTypeDescriptionDefault
RunEventTriggers the image modification process-
ImageDataThe source image to modify (must be a Jimp image object)-
PromptTextDescription of how to modify the image-
WidthNumberTarget width of the output image in pixels1024
HeightNumberTarget height of the output image in pixels768
GuidanceNumberControls how closely the AI follows the prompt (0-10 scale)7
StepsNumberNumber of inference steps (higher = more detail but slower)28

Outputs

OutputTypeDescription
OutputDataThe modified image as a Jimp object
DoneEventFires 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 1 for reproducibility.

Image Processing

  1. The input image is cloned to avoid modifying the original
  2. Converted to base64 JPEG format for transmission to the AI service
  3. Sent to the image modification service with all parameters
  4. 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:

  1. Connect a Read Image node to the Image input
  2. Set the Prompt to: "oil painting style, artistic, textured brush strokes"
  3. Set Width to 1024 and Height to 1024 for square output
  4. Keep Guidance at 7 for balanced prompt adherence
  5. 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