Outpainting
With outpainting, you can extend the borfder of the image in any directions. The AI examines the colors, shapes, and overall style of the image. Then, it starts generating new pixels in the direction you choose (up, down, left, right).
Tip
- Leave the prompt blank to let the AI automatically design the extended areas
- The strength, overlap, stretch_area, stretch_scale, horizontal_tile, vertical_tile params have been optimized for you and doesn't need to be changed but offers fine-tuning to those who need it.
- Python
- JavaScript
- php
import requests
import json
url = "https://api.imagepipeline.io/outpainting/v1"
headers = {
"API-Key": "Your API Key"
}
data = {
"init_image": "https://f005.backblazeb2.com/b2api/v2/b2_download_file_by_id?fileId=4_zfdf0a8ed59e8666b89b10713_f1009f7bd8006edff_d20240216_m085518_c005_v0501017_t0017_u01708073718621",
"prompt": "",
"direction": ["right", "left", "down", "up"],
"expansion": [64, 64, 64, 64],
"num_inference_steps": 30,
"guidance_scale": 7.5,
"resolution": 1024,
"samples": 2,
"strength": 0.7,
"overlap": 0.02,
"stretch_area": 0.3,
"stretch_scale": 2,
"horizontal_tile": 3,
"vertical_tile": 24,
"server_id": ""
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
const url = "https://api.imagepipeline.io/sd/text2image/v1";
const headers = {
"API-Key": "Your API Key",
"Content-Type": "application/json"
};
const data = {
"init_image": "https://f005.backblazeb2.com/b2api/v2/b2_download_file_by_id?fileId=4_zfdf0a8ed59e8666b89b10713_f1009f7bd8006edff_d20240216_m085518_c005_v0501017_t0017_u01708073718621",
"prompt": "",
"direction": ["right", "left", "down", "up"],
"expansion": [64, 64, 64, 64],
"num_inference_steps": 30,
"guidance_scale": 7.5,
"resolution": 1024,
"samples": 2,
"strength": 0.7,
"overlap": 0.02,
"stretch_area": 0.3,
"stretch_scale": 2,
"horizontal_tile": 3,
"vertical_tile": 24,
"server_id": ""
};
fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => console.log(data))
.catch((error) => console.error('Error:', error));
<?php
$url = "https://api.imagepipeline.io/sd/text2image/v1";
$headers = array(
"API-Key: Your-API-Key",
"Content-Type: application/json"
);
$data = array(
"init_image"=> "https://f005.backblazeb2.com/b2api/v2/b2_download_file_by_id?fileId=4_zfdf0a8ed59e8666b89b10713_f1009f7bd8006edff_d20240216_m085518_c005_v0501017_t0017_u01708073718621",
"prompt"=> "",
"direction"=> ["right", "left", "down", "up"],
"expansion"=> [64, 64, 64, 64],
"num_inference_steps"=> 30,
"guidance_scale"=> 7.5,
"resolution"=> 1024,
"samples"=> 2,
"strength"=> 0.7,
"overlap"=> 0.02,
"stretch_area"=> 0.3,
"stretch_scale"=> 2,
"horizontal_tile"=> 3,
"vertical_tile"=> 24,
"server_id"=> ""
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
if($response === FALSE){
die(curl_error($ch));
}
$responseData = json_decode($response, TRUE);
curl_close($ch);
var_dump($responseData);
?>
JSON Parameters
Parameter | Permissible values | Notes |
---|---|---|
init_image | str | Public URL for init image |
num_inference_steps | int, [0-51] | Number of inference steps. Noise is reduced with each step, improving image quality. Recommended: 30-50 |
strength | float, [0-1] | Strength of controlnet. Higher values prioritize preserving input features. Recommended: 0.5-1.0 |
guidance_scale | float, [0, 20] | Scale for guidance. Higher values prioritize relevance to text prompts over image quality. Recommended: 7.5-12.5 |
direction | str, array | Array of directions for expansion: left, right, up, down |
samples | int, [0-2] | Number of samples to generate. Maximum 2 per API call. Recommended: 2 |
expansion | int, array | Array of height/width to extend by. Needs to be a multiple of 8 |
overlap | float, [0, 0.05] | Smoothening of outpainted edges. Recommended: 0.01 |
horizontal_tile | int | Number of horizontal tiles when expanding horizontally. Recommended: 3 |
vertical_tile | int | Number of vertical tiles when expanding vertically. Recommended: 24 |
stretch_area | number | Area to stretch |
stretch_scale | integer | Scale for stretching |
resolution | int, [0-1024] | Resolution for outpainted image. Recommended: 1024 |
server_id | string | Server_id for enterprise subscription. Provide any for load-balancing, specific id for routing |
webhook | string | Webhook to send generated image to |
Status
Your response will include a status
.
- If the
status
=SUCCESS
, you will also havedownload_urls
that will have the links to your generated image based on the number of samples you have entered. The maximum number of samples that can be generated is 2. - If the
status
=PENDING
, you will receive aid
. You can use the status endpoint to fetch your image using theid
. - If the
status
=FAILURE
, you will receive only an error message.
Endpoint: [GET]
https://api.imagepipeline.io/outpainting/v1/status/{{id}}
Pass the API-Key as the authorization in the header.
- Input
- Output
{
"init_image": "https://f005.backblazeb2.com/b2api/v2/b2_download_file_by_id?fileId=4_zfdf0a8ed59e8666b89b10713_f1009f7bd8006edff_d20240216_m085518_c005_v0501017_t0017_u01708073718621",
"prompt": "",
"direction": ["right", "left", "down", "up"],
"expansion": [64, 64, 64, 64],
"num_inference_steps": 30,
"guidance_scale": 7.5,
"resolution": 1024,
"samples": 2,
"strength": 0.7,
"overlap": 0.02,
"stretch_area": 0.3,
"stretch_scale": 2,
"horizontal_tile": 3,
"vertical_tile": 24
}
{
"download_urls": [
"https://f005.backblazeb2.com/b2api/v2/b...",
]
}