Image Expander

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

NameTypeRequiredDescription
imagestringyesBase64 encoded image
expandobjectyesAn object that controls how much to expand the image in each direction. It has four properties:
  • left: Number of pixels to add to the left side (e.g., 100)
  • right: Number of pixels to add to the right side (e.g., 100)
  • top: Number of pixels to add to the top (e.g., 50)
  • bottom: Number of pixels to add to the bottom (e.g., 50)
Example: { "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

NameTypeRequiredDescription
x-api-keystringyesYour 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 implementation
interface 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

NameTypeRequiredDescription
x-api-keystringyesYour 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 implementation
async 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

StatusDescription
creatingJob is being initialized
pendingJob is in processing queue
runningJob is actively processing
completedProcessing finished successfully
failedProcessing encountered an error
not-foundInvalid 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'
}