Oyyi

Merge Images Side by Side

Combine multiple images into a single image by placing them side by side horizontally or vertically.

POST /api/image/merge-side-by-side

Request Parameters

ParameterTypeRequiredDescription
filesFile ArrayYesList of image files to merge. At least 2 images are required. Supported formats: JPEG, PNG, WebP, BMP, TIFF.
alignStringNoHow to align images of different sizes. For horizontal merging: top, center, bottom. For vertical merging: left, center, right. Default: center.
resize_methodStringNoHow to handle images of different sizes. Options: none (keep original sizes), max (resize to match largest dimension), min (resize to match smallest dimension), stretch (stretch to match). Default: none.
paddingIntegerNoPadding around the entire merged image in pixels. Range: 0-100. Default: 0.
output_formatStringNoThe format of the output image. Options: jpeg, png, webp. Default: jpeg.

Response

Returns a single image containing all input images merged side by side in the specified direction.

Example Request

    // example.sh
curl -X POST "https://oyyi.xyz/api/image/merge-side-by-side"   -H "accept: application/json" \
  -H "Content-Type: multipart/form-data" \
  -F "files=@image1.jpg" \
  -F "files=@image2.jpg" \
  -F "files=@image3.jpg" \
  --output merged.jpg
  

Example with Python

    // merge_images.py
import requests

url = "https://oyyi.xyz/api/image/merge-side-by-side"

files = [
    ('files', open('image1.jpg', 'rb')),
    ('files', open('image2.jpg', 'rb')),
    ('files', open('image3.jpg', 'rb'))
]

data = {}

response = requests.post(url, files=files, data=data)

# Save the merged image
with open('merged.jpg', 'wb') as f:
    f.write(response.content)
  

Example with JavaScript

    // merge_images.js
// Using fetch API
const formData = new FormData();

// Add multiple images
for (const file of imageFilesInput.files) {
  formData.append('files', file);
}

fetch('https://oyyi.xyz/api/image/merge-side-by-side', {
  method: 'POST',
  body: formData
})
.then(response => response.blob())
.then(blob => {
  // Create a URL for the blob
  const url = URL.createObjectURL(blob);

  // Create a link to download the image
  const a = document.createElement('a');
  a.href = url;
  a.download = 'merged.jpg';
  a.click();

  // Clean up by revoking the URL
  URL.revokeObjectURL(url);
})
.catch(error => console.error('Error:', error));
  

Merge Directions

Horizontal

Images are placed side by side from left to right. Good for before/after comparisons or creating panoramas.

Vertical

Images are stacked on top of each other from top to bottom. Good for creating sequences or timelines.

Resize Methods

None

Keep all images at their original sizes. May result in uneven edges if images have different dimensions.

Max

Resize all images to match the largest width (for vertical merging) or height (for horizontal merging) while maintaining aspect ratios.

Min

Resize all images to match the smallest width (for vertical merging) or height (for horizontal merging) while maintaining aspect ratios.

Stretch

Stretch all images to have the same width (for vertical merging) or height (for horizontal merging), which may distort aspect ratios.

How It Works

The merge-side-by-side endpoint combines multiple images into a single composite image:

  1. Image Loading: All uploaded images are loaded and processed.
  2. Resizing (Optional): If a resize method is specified, images are resized according to the selected method.
  3. Canvas Creation: A new canvas is created with dimensions large enough to hold all images plus spacing and padding.
  4. Image Placement: Each image is placed on the canvas in the specified direction with the specified spacing.
  5. Alignment: Images are aligned according to the specified alignment option.
  6. Background Filling: Any spacing or padding areas are filled with the specified background color.
  7. Output Generation: The final composite image is generated in the specified output format.

The result is a single image containing all input images arranged side by side or stacked vertically.

Error Responses

Status CodeDescription
400Bad request. Missing required parameters, fewer than 2 images provided, invalid direction, invalid spacing value, invalid background color, invalid align value, invalid resize method, invalid padding value, invalid output format, or invalid file format.
413Payload too large. The combined file size exceeds the maximum allowed limit.
500Internal server error. Something went wrong on the server.

Notes

  • You can upload up to 10 images in a single request.
  • The order of the images in the merged result will match the order they were uploaded.
  • For best results with images of different sizes, use the resize_method parameter to ensure consistent dimensions.
  • The spacing parameter is useful for creating visual separation between images.
  • When using transparent PNG images, the background color will be visible through transparent areas.
  • The maximum file size allowed for each image is 10MB, with a total limit of 50MB for all images combined.
  • For creating complex layouts with multiple rows and columns, you may need to make multiple API calls and combine the results.

Use Cases

  • Creating before/after comparison images
  • Combining multiple screenshots into a single image
  • Creating photo collages or galleries
  • Generating product comparison images
  • Creating timeline or sequence visualizations
  • Combining charts or graphs for reports
  • Creating panoramic images by stitching photos horizontally
  • Generating social media content with multiple images