Image Expander
Overview
Image Expander is a powerful AI tool that lets you extend or enlarge your images in any direction (left, right, top, or bottom). It intelligently generates new content to fill the expanded areas while maintaining a natural and seamless look. This is perfect when you need to:
- Add more background space to your photos
- Adjust image composition without cropping
- Create wider or taller versions of your images
- Fix images that are too tightly cropped
Simply upload your image and specify how much you want to expand each side - our AI will do the rest!
API Reference
- URL: https://api.maxstudio.ai/image-expander
- Method: POST
API Parameters
Name | Type | Required | Description |
---|---|---|---|
image | string | yes | Base64 encoded image |
expand | object | yes | An object that controls how much to expand the image in each direction. It has four properties:
{
"left": 100,
"right": 100,
"top": 50,
"bottom": 50
} will add 100 pixels on each side and 50 pixels on top and bottom. Set any value to 0 if you don't want to expand in that direction. |
⚠️ Important: When sending the base64 image, do not include the prefix (e.g., 'data:image/jpeg;base64,'). Send only the raw base64 string.
Header
Name | Type | Required | Description |
---|---|---|---|
x-api-key | string | yes | Your API key obtained from the MaxStudio APIs Dashboard (opens in a new tab). Generate this key by logging into your account and navigating to the API Keys section. |
Code Examples
// TypeScript implementationinterface Params { image: string; expand: { left: number; right: number; top: number; bottom: number; };}async function ImageExpander(params: Params): Promise<any> { try { const response = await fetch('https://api.maxstudio.ai/image-expander', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ image: params.image, expand: { left: 0, right: 0, top: 0, bottom: 0 } }) }); const jobId = await response.json(); return jobId; } catch (error) { console.error('Error:', error); throw error; }}
Success Response
{
"jobId": "<job_id>"
}
Error Response Examples
// Rate Limit Error
{
"status": 429,
"error": "Rate limit exceeded. Please try again later."
}
// Insufficient Credits
{
"status": 402,
"error": "Insufficient credits. Please Buy credits."
}
// Invalid Input
{
"status": 400,
"error": "Image size must be less than 5MB"
}
Get Job Status
Header
Name | Type | Required | Description |
---|---|---|---|
x-api-key | string | yes | Your API key obtained from the MaxStudio APIs Dashboard (opens in a new tab). Generate this key by logging into your account and navigating to the API Keys section. |
To check the status of your job, use the following examples:
// TypeScript implementationasync function getJobStatus(jobId: string): Promise<any> { const url = `https://api.maxstudio.ai/image-expander/${jobId}`; try { const response = await fetch(url); const jobId = await response.json(); return jobId; } catch (error) { console.error('Error:', error); throw error; }}
Job Status Reference
Status | Description |
---|---|
creating | Job is being initialized |
pending | Job is in processing queue |
running | Job is actively processing |
completed | Processing finished successfully |
failed | Processing encountered an error |
not-found | Invalid or expired job ID |
Output
{
"status": "<status>", // One of the status values from the table above
"result": "<result>" // Base64 encoded image data when status is 'completed'
}