Actions9
Overview
The "Replace Background" operation of the Recraft v3 node allows users to replace the background of an input image using AI-driven transformation based on a text prompt. This is useful for creative editing where you want to change the scene or environment behind the main subject without manually masking or editing the image in graphic software.
Common scenarios include:
- Changing a photo's background to a different setting (e.g., from indoors to a beach).
- Transforming the background style to match a theme (e.g., winter snow, futuristic cityscape).
- Quickly generating multiple variations of an image with different backgrounds.
Practical example: You have a portrait photo and want to replace its background with a snowy winter landscape by providing a prompt like "Transform the scene to winter with snow." The node processes the input image and outputs new images with the replaced background accordingly.
Properties
| Name | Meaning |
|---|---|
| Input Image | Name of the binary property containing the original image file to be processed. |
| Prompt | Text description guiding how the background should be transformed or replaced. |
| Number of Images | Number of variations of the output images to generate (1 to 6). |
| Style | Style of the transformation applied to the background. Options: Any, Realistic Image, Digital Illustration, Vector Illustration. |
| Negative Prompt | Description of elements or qualities to avoid in the transformed image (e.g., blurry, artifacts). |
| Response Format | Format of the returned image data: either a URL pointing to the image or base64 encoded JSON. |
Output
The node outputs JSON data containing the generated images according to the selected response format:
- If "URL" is chosen, the output contains URLs linking to the generated images.
- If "Base64 JSON" is chosen, the output contains base64-encoded image data embedded directly in the JSON.
The output includes one or more images depending on the "Number of Images" parameter.
Dependencies
- Requires an API key credential for the Recraft AI service.
- The node sends HTTP POST requests to the Recraft API endpoint
/images/replaceBackground. - Input images must be provided as binary data accessible by the node.
- No additional external dependencies beyond the configured API credential and internet access.
Troubleshooting
- Invalid or missing input image: Ensure the binary property name specified in "Input Image" exists and contains valid image data.
- Prompt too long: Prompts longer than 1000 bytes will cause errors; keep prompts concise.
- Invalid JSON in properties: Although not specific to this operation, other operations use JSON fields that must be correctly formatted.
- API errors: Network issues or invalid API credentials will cause request failures. Verify API key validity and network connectivity.
- Too many images requested: The number of images must be between 1 and 6; exceeding this range will cause errors.
Links and References
- Recraft AI Official Website (for general info about the AI model)
- n8n Documentation on Creating Custom Nodes
- Recraft API documentation (not publicly linked here, but available to users with API access)