Skip to main content

Replacing Image Background with Solid Colors

This documentation outlines how to utilize the background replacement feature to swap an image's background with a solid color using our API.

How it works:

  1. Provide Image URL: Submit the URL of the image whose background you want to replace.
  2. Prompt: Fill with hex code color and always prefix the hex code with #

API Call Example:

curl --location 'https://api.katalis.ai/service/v1/generate-image' \
--data '{
"image_url": "https://image.url.com",
"background": {
"prompt": "#FEFCE8",
"negative_prompt": ""
},
}'

Explanation:

  • "image_url": The URL of the image you want to modify.
  • "background": An object containing the following:
  • "prompt": a hex code color, always prefix the hex code with #.
  • "negative_prompt": parameter is not applicable for solid color backgrounds.

API Response:

{
"message": "Success",
"data": {
"img_url": "https://storage.googleapis.com/katalis-ai/image/generated/1/1713944425-2290.png"
}
}

Response Fields:

  • "message": Indicates the status of the request (e.g., "Success").
  • "data": Contains the generated image URL:
  • "img_url": A URL pointing to the newly generated image with the replaced background.

Before & After Example:

Original Image:

original

Prompt: "#FEFCE8"

Generated Image:

generated